S
Sarcastic Zombie
Good morning,
If I have a class
class A:
__init__(id)
self.id = id
is there any way to overload the 'if' unary usage to detect if a
variable has a value?
For example, in the code:
a = A(56)
if a:
print "Hoo hah!"
how can I insure that the if will come back true and fire off the print
if and only if self.id is defined? I want to do this in an overloaded,
generic way, if possible; I know that I could test for a.id.
Thanks so much!
-Jason Ledbetter
If I have a class
class A:
__init__(id)
self.id = id
is there any way to overload the 'if' unary usage to detect if a
variable has a value?
For example, in the code:
a = A(56)
if a:
print "Hoo hah!"
how can I insure that the if will come back true and fire off the print
if and only if self.id is defined? I want to do this in an overloaded,
generic way, if possible; I know that I could test for a.id.
Thanks so much!
-Jason Ledbetter