object instance after if isalpha()
Marcelo Urbano Lima
marcelo_urbano at hotmail.com
Wed Apr 12 21:49:32 EDT 2006
ops, I forgot to use the self.
so in this example what i was trying to do worked. I'll look further in my
original program.
sorry to bother you.
>From: "Marcelo Urbano Lima" <marcelo_urbano at hotmail.com>
>To: python-list at python.org
>Subject: object instance after if isalpha()
>Date: Wed, 12 Apr 2006 20:44:11 -0300
>
>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
>
>--
>http://mail.python.org/mailman/listinfo/python-list
_________________________________________________________________
COPA 2006: O horário dos jogos do Brasil na Copa Clique aqui!
http://copa.br.msn.com/tabelas/tabela/
More information about the Python-list
mailing list