[NEWBIE] access return values

paul kölle paul at subsignal.org
Thu Sep 18 12:22:40 CEST 2003


hi folks,

during the last couple of days I wrote my first small app with wxPython 
and it all works pretty well, but now I'm somewhat lost. I'd like to 
access the return value from a function inside an imported module (a 
method of a class of that module eh?)

---gui.py----

from wxPython.wx import *
from app.py import *

user=UserObject(config)  # class instance from app.py

the class UserObject has a function set_pwd() which returns a var, say 
"ch_success" indicating success/failure wich I'd like to pass to a 
Dialog to give some feedback to the user.

but:
--in gui.py----

d=wxMessageDialog(self, user.ch_success,"Info:", wxICON_INFORMATION | wxOK)

gives:

AttributeError: UserObject instance has no attribute 'ch_success'

That makes sense, since ch_success is a local variable of set_pwd(), so 
I tried to make it global but with very little success so far. I tried:

--in app.py----

	def set_pwd(someargs, moreargs)
	  do stuff //
	  ...
	  global ch_success
or:
	  return ch_success
or:
	  self.ch_success

Nothing worked (but frankly, I don't really know what I'm doing here).

Any ideas? Thanks

Paul










More information about the Python-list mailing list