2 Replies - 4507 Views - Last Post: 19 December 2012 - 10:17 PM Rate Topic: -----

#1 pythonuser  Icon User is offline

  • New D.I.C Head

Reputation: -2
  • View blog
  • Posts: 15
  • Joined: 21-February 12

How To Pass one Parameter to both functions

Posted 15 March 2012 - 03:59 AM

hi everyone ,
how can i pass the same parameter 'id' to both functions and python taking this parameter as input from xml file.

def load_chr_values():
	result = common.db_results("select * from table1 WHERE custdetailid="+id)
	db = []
	for row in result_set:
		db += [(row['custname'] , str(row['custdeailid']),False),]
		
def __main__():
	ad = sys.argv[1]
	cd = sys.argv[2]
	id = sys.argv[3]
	dev = sys.argv[6]
	output_name = sys.argv[7]
	out = open( output_name, 'w' )


	if dev == 'cust2':
		
		result = common.db_results( "select * from custmor (" + id + "," + ad + ",'" + cd + ")" )


how

Is This A Good Question/Topic? 0
  • +

Replies To: How To Pass one Parameter to both functions

#2 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6062
  • View blog
  • Posts: 23,513
  • Joined: 23-August 08

Re: How To Pass one Parameter to both functions

Posted 15 March 2012 - 04:24 AM

First result in a Google search of "python passing arguments to functions".
Was This Post Helpful? 0
  • +
  • -

#3 eGrove Systems  Icon User is offline

  • New D.I.C Head

Reputation: -5
  • View blog
  • Posts: 10
  • Joined: 09-December 12

Re: How To Pass one Parameter to both functions

Posted 19 December 2012 - 10:17 PM

def load_chr_values(id):
result = common.db_results("select * from table1 WHERE custdetailid="+id)
db = []
for row in result_set:
db += [(row['custname'] , str(row['custdeailid']),False),]

def __main__():
ad = sys.argv[1]
cd = sys.argv[2]
id = sys.argv[3]
dev = sys.argv[6]
output_name = sys.argv[7]
out = open( output_name, 'w' )

load_chr_values(id) # you can simply pass a arg from main function

if dev == 'cust2':

result = common.db_results( "select * from custmor (" + id + "," + ad + ",'" + cd + ")" )
Was This Post Helpful? -1
  • +
  • -

Page 1 of 1