Re: getting a class attribute using a keyword argument
From: Nick Coghlan (ncoghlan_at_iinet.net.au)
Date: 01/17/05
- Next message: Hans Georg Krauthaeuser: "platform independent kbhit()"
- Previous message: Guy Robinson: "getting a class attribute using a keyword argument"
- In reply to: Guy Robinson: "getting a class attribute using a keyword argument"
- Next in thread: wittempj_at_hotmail.com: "Re: getting a class attribute using a keyword argument"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 17 Jan 2005 21:18:15 +1000 To: Python List <python-list@python.org>
Guy Robinson wrote:
> Hello,
>
> I have a list of class instances. I wish to get the appropriate class
> attribute in each class instance depending on a SINGLE keyword in the
> calling class.
Py> help(getattr)
Help on built-in function getattr in module __builtin__:
getattr(...)
getattr(object, name[, default]) -> value
Get a named attribute from an object; getattr(x, 'y') is equivalent to x.y.
When a default argument is given, it is returned when the attribute doesn't
exist; without it, an exception is raised in that case.
Cheers,
Nick.
--
Nick Coghlan | ncoghlan@email.com | Brisbane, Australia
---------------------------------------------------------------
http://boredomandlaziness.skystorm.net
- Next message: Hans Georg Krauthaeuser: "platform independent kbhit()"
- Previous message: Guy Robinson: "getting a class attribute using a keyword argument"
- In reply to: Guy Robinson: "getting a class attribute using a keyword argument"
- Next in thread: wittempj_at_hotmail.com: "Re: getting a class attribute using a keyword argument"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]