Joe: See below:
> -----Original Message----- > Date: Tue, 2 Jan 2007 19:16:33 +0000 (UTC) > From: Joe M <[EMAIL PROTECTED]> > Subject: [Tutor] basic python question/getting values > To: tutor@python.org > Message-ID: <[EMAIL PROTECTED]> > Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed > > I apologize in advanced as I know this is basic information, but I cannot > seem to figure it. > > I have a few scripts that will return a value ie here I am testing to see > if a database is alive (script is called dbping.py): > > def db_alive(): > dbRunning = '0' > try: > con = pg.connect(dbname='xxx', host='localhost', user > ='xxx',port = xxx) > pass > except pg.InternalError: > dbRunning = '1' > return dbRunning > <<snip>> > > import dbping > l = dbping.db_run(db_run.dbRunning) # > print l > > NameError: name 'db_run' is not defined You are not calling the function you defined. The name and number of parameters are both wrong. To match your function definition, your assignment should be: >>> l = dbping.db_alive() Note, also, that the "pass" statement in dbping.db_alive will cause a syntax error. "pass" is only used when a code block is required but has no executable statements. For example: >>> intval = 0 . . . try: intval = int(strval) except ValueError: pass # strval is not a valid string representation of an integer. # intval remains 0. # Suppress the error and continue the program. > > Thanks for any pointers > > [EMAIL PROTECTED] > SDF Public Access UNIX System - http://sdf.lonestar.org > HTH. Regards, Barry [EMAIL PROTECTED] 541-302-1107 ________________________ We who cut mere stones must always be envisioning cathedrals. -Quarry worker's creed _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor