object instance after if isalpha()
Marcelo Urbano Lima
marcelo_urbano at hotmail.com
Wed Apr 12 19:44:11 EDT 2006
Hi
I'm still learning python and I've been loving it, but, that's not the
reason I'm writing.
I'm trying to create an object only if a variable is alpha and see what I
get.
$ cat 1.py
class abc:
def __init__(self):
name='marcelo'
a='STRING'
print a.isalpha()
if a.isalpha():
x=abc()
print 'was x created?:', x,'\n'
print x.name
$ python 1.py
True
was x created?: <__main__.abc instance at 0x186b9e6c>
Traceback (most recent call last):
File "1.py", line 12, in ?
print x.name
AttributeError: abc instance has no attribute 'name'
Why? (I really think I'm doing something stupid but could not see)
btw, it's python 2.4.1 for cygwin.
I'd really appreciate your help.
Thanks
_________________________________________________________________
Seja um dos primeiros a testar o Windows Live Messenger Beta a geração do
seu MSN Messenger.
http://imagine-msn.com/minisites/messenger/default.aspx?locale=pt-br
More information about the Python-list
mailing list