![]() |
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: Paul McGuire <ptmcg@austin.rr._bogus_.com>
Date: Sat Dec 31 2005 - 20:00:06 CET
"MKoool" <mohankhurana@gmail.com> wrote in message
-- Paul
class A(object):
# define _repr_ to make it easy to print list of A's
Alist = [ A(i*1.5) for i in range(5) ]
print Alist
# create new list of .a attributes, print, and sum
# if original list is much longer...
# ... creating list comprehension will take a while...
# ... instead use generator expression - avoids creation of new list
|