Re: Differences between obj.attribute and getattr(obj, "attribute")

2013-12-11 Thread Johannes Schneider
thank you guys. On 11.12.2013 10:36, Chris Angelico wrote: 2013/12/11 Johannes Schneider : can somebody explain me the difference between accessing attributes via obj.attribute and getattr(obj, "attribute")? Is there a special reason or advantage when using getattr? You use getattr when the at

Re: Differences between obj.attribute and getattr(obj, "attribute")

2013-12-11 Thread Chris Angelico
On Wed, Dec 11, 2013 at 8:30 PM, Jurko Gospodnetić wrote: > Also, you can not test whether an object has an attribute when using the > object.attribute access method without raising/catching an exception and > then it can be hard to make sure no other code caused the exception. It's pretty easy

Re: Differences between obj.attribute and getattr(obj, "attribute")

2013-12-11 Thread Chris Angelico
2013/12/11 Johannes Schneider : > can somebody explain me the difference between accessing attributes via > obj.attribute and getattr(obj, "attribute")? > > Is there a special reason or advantage when using getattr? You use getattr when the attribute name comes from a string, rather than a literal

Re: Differences between obj.attribute and getattr(obj, "attribute")

2013-12-11 Thread Jurko Gospodnetić
Hi. On 11.12.2013. 9:23, Johannes Schneider wrote: can somebody explain me the difference between accessing attributes via obj.attribute and getattr(obj, "attribute")? Is there a special reason or advantage when using getattr? You can not use obj.attribute if you have the word 'attribute'

Differences between obj.attribute and getattr(obj, "attribute")

2013-12-11 Thread Johannes Schneider
Hi list, can somebody explain me the difference between accessing attributes via obj.attribute and getattr(obj, "attribute")? Is there a special reason or advantage when using getattr? bg, Johannes -- Johannes Schneider Webentwicklung johannes.schnei...@galileo-press.de Tel.: +49.228.42150.xxx