24-01-2010, 00:38:29 Terry Reedy wrote:
On 1/23/2010 10:56 AM, Arnaud Delobelle wrote:
thinke365 writes:
for example, i may define a python class:
class A:
def sayHello():
print 'hello'
a = A()
a.attr1 = 'hello'
a.attr2 = 'bb'
b = A()
a.attr2 = 'aa'
how can i know whethe
On 1/23/2010 10:56 AM, Arnaud Delobelle wrote:
thinke365 writes:
for example, i may define a python class:
class A:
def sayHello():
print 'hello'
a = A()
a.attr1 = 'hello'
a.attr2 = 'bb'
b = A()
a.attr2 = 'aa'
how can i know whether an object have an attribute named attr1?
thinke365 writes:
> for example, i may define a python class:
> class A:
> def sayHello():
> print 'hello'
>
> a = A()
> a.attr1 = 'hello'
> a.attr2 = 'bb'
>
> b = A()
> a.attr2 = 'aa'
>
> how can i know whether an object have an attribute named attr1?
hasattr(a, 'attr1')
--
Arn
for example, i may define a python class:
class A:
def sayHello():
print 'hello'
a = A()
a.attr1 = 'hello'
a.attr2 = 'bb'
b = A()
a.attr2 = 'aa'
how can i know whether an object have an attribute named attr1?
--
View this message in context:
http://old.nabble.com/how-can-i-kno