![]() |
Available news archives:
comp.lang.tcl
-
comp.lang.python
-
comp.security.firewalls
-
sci.crypt -
comp.lang.php -
comp.lang.javascript
|
|
comp.lang.python archiveRe: Array construction from object members
From: Gerard Flanagan <grflanagan@yahoo.co.uk>
Date: Sat Dec 31 2005 - 18:16:03 CET
MKoool wrote:
> Hi everyone,
not sure if this is what you want to do, but does this help:
class myclass(object):
mylist = [ myclass('one'), myclass('two'), myclass('three'),
alist = [ A.a for A in mylist ] #this is called a 'list comprehension'
print alist
output: ['one', 'two', 'three', 'four']
Gerard
|