Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #61535

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

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder3.xlned.com!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <johannes.schneider@galileo-press.de>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.129
X-Spam-Level *
X-Spam-Evidence '*H*': 0.77; '*S*': 0.02; 'amtsgericht': 0.07; 'hrb': 0.07; 'attributes': 0.09; 'rainer': 0.16; 'ralf': 0.16; 'subject:between': 0.16; 'gmbh': 0.22; 'header:User-Agent:1': 0.23; 'germany': 0.24; 'there': 0.35; 'accessing': 0.36; 'somebody': 0.38; 'to:addr:python-list': 0.38; 'list,': 0.38; 'explain': 0.39; 'to:addr:python.org': 0.39; 'received:194': 0.64; 'skip:+ 10': 0.65; 'tel.:': 0.65; 'between': 0.67; 'press': 0.70; 'special': 0.74; 'received:192.168.57': 0.84; 'subject:skip:o 10': 0.84
Date Wed, 11 Dec 2013 09:23:29 +0100
From Johannes Schneider <johannes.schneider@galileo-press.de>
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20131103 Icedove/17.0.10
MIME-Version 1.0
To python-list@python.org
Subject Differences between obj.attribute and getattr(obj, "attribute")
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 8bit
X-Mailman-Approved-At Wed, 11 Dec 2013 09:59:44 +0100
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.3873.1386752385.18130.python-list@python.org> (permalink)
Lines 23
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1386752385 news.xs4all.nl 2888 [2001:888:2000:d::a6]:38587
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:61535

Show key headers only | View raw


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.schneider@galileo-press.de
Tel.: +49.228.42150.xxx

Galileo Press GmbH
Rheinwerkallee 4 - 53227 Bonn - Germany
Tel.: +49.228.42.150.0 (Zentrale) .77 (Fax)
http://www.galileo-press.de/

Geschäftsführer: Tomas Wehren, Ralf Kaulisch, Rainer Kaltenecker
HRB 8363 Amtsgericht Bonn

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Differences between obj.attribute and getattr(obj, "attribute") Johannes Schneider <johannes.schneider@galileo-press.de> - 2013-12-11 09:23 +0100

csiph-web