getattr for modules not classes

Heiko Wundram me+python at modelnine.org
Fri May 26 06:39:56 EDT 2006


Am Mittwoch 24 Mai 2006 15:43 schrieb Piet van Oostrum:
> >>>>> Heiko Wundram <me+python at modelnine.org> (HW) wrote:
> >
> >HW> y.py
> >HW> ---
> >HW> from x import test
> >HW> print test.one
> >HW> print test.two
> >HW> print test.three
> >HW> ---
>
> Or even:
> import x
> x = x.test
> print x.one
> print x.two
> print x.three

Or even:

---
from x import test as x
print x.one
print x.two
print x.three
---

--- Heiko.



More information about the Python-list mailing list