Re: how can i know if a python object have a attribute such as 'attr1'?

2010-01-25 Thread Jan Kaliszewski
24-01-2010, 00:38:29 Terry Reedy tjre...@udel.edu wrote: On 1/23/2010 10:56 AM, Arnaud Delobelle wrote: thinke365thinke...@gmail.com 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()

how can i know if a python object have a attribute such as 'attr1'?

2010-01-23 Thread thinke365
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:

Re: how can i know if a python object have a attribute such as 'attr1'?

2010-01-23 Thread Arnaud Delobelle
thinke365 thinke...@gmail.com 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')

Re: how can i know if a python object have a attribute such as 'attr1'?

2010-01-23 Thread Terry Reedy
On 1/23/2010 10:56 AM, Arnaud Delobelle wrote: thinke365thinke...@gmail.com 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