Hi,
Im new to python, and OOP, and am trying to get a handle on list
comprehension.
Say I have a class Foo with a property called bar:
class Foo:
def __init__(self):
self.bar = random.randint(1,100)
and then I make a list of these objects:
Newlist = []
for x in range(10):
Dr Mephesto wrote:
Hi,
Im new to python, and OOP, and am trying to get a handle on list
comprehension.
Say I have a class Foo with a property called bar:
class Foo:
def __init__(self):
self.bar = random.randint(1,100)
and then I make a list of these objects:
Newlist =
Dr Mephesto wrote:
Hi,
Im new to python, and OOP, and am trying to get a handle on list
comprehension.
Say I have a class Foo with a property called bar:
class Foo:
def __init__(self):
self.bar = random.randint(1,100)
and then I make a list of these objects:
Newlist = []
for x in
On Jan 21, 2009, at 10:52 AM, Dr Mephesto wrote:
Hi,
Im new to python, and OOP, and am trying to get a handle on list
comprehension.
Say I have a class Foo with a property called bar:
class Foo:
def __init__(self):
self.bar = random.randint(1,100)
and then I make a list of these
Diez B. Roggisch wrote:
Dr Mephesto wrote:
Hi,
Im new to python, and OOP, and am trying to get a handle on list
comprehension.
Say I have a class Foo with a property called bar:
class Foo:
def __init__(self):
self.bar = random.randint(1,100)
and then I make a list of these
In article mailman.7691.1232554737.3487.python-l...@python.org,
Philip Semanchuk phi...@semanchuk.com wrote:
Other answers have been good; to them I'll add the comment that list
comprehensions are for *constructing* lists, not manipulating the
elements thereof.
HTH
Philip
Well
Lou Pecora wrote:
In article mailman.7691.1232554737.3487.python-l...@python.org,
Philip Semanchuk phi...@semanchuk.com wrote:
Other answers have been good; to them I'll add the comment that list
comprehensions are for *constructing* lists, not manipulating the
elements thereof.
HTH
On Jan 21, 2009, at 11:52 AM, Lou Pecora wrote:
In article mailman.7691.1232554737.3487.python-l...@python.org,
Philip Semanchuk phi...@semanchuk.com wrote:
Other answers have been good; to them I'll add the comment that list
comprehensions are for *constructing* lists, not manipulating the
Dr Mephesto wrote:
Hi,
Im new to python, and OOP, and am trying to get a handle on list
comprehension.
Say I have a class Foo with a property called bar:
class Foo:
def __init__(self):
self.bar = random.randint(1,100)
and then I make a list of these objects:
Newlist = []
for x in
MRAB schrieb:
Diez B. Roggisch wrote:
Dr Mephesto wrote:
Hi,
Im new to python, and OOP, and am trying to get a handle on list
comprehension.
Say I have a class Foo with a property called bar:
class Foo:
def __init__(self):
self.bar = random.randint(1,100)
and then I make a list
You can try this
import random
class foo:
def __init__(self):
self.bar = random.randint(1,100)
def getbar(ls,i):
ls.append(foo())
ls[i].bar = ls[i].bar * 3
ls = []
[getbar(ls,i) for i in range(10)]
On Thu, Jan 22, 2009 at 4:45 AM, Diez B. Roggisch de...@nospam.web.dewrote:
11 matches
Mail list logo