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 wrote:
> MRAB schrieb:
>
>> D
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
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 11:52 AM, Lou Pecora wrote:
In article ,
Philip Semanchuk 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 this seems to work just fine. Wh
Lou Pecora wrote:
> In article ,
> Philip Semanchuk 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 this seems to work just fine. What
In article ,
Philip Semanchuk 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 this seems to work just fine. What am I missing:
A=[1,2,3]
p
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 object
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 ob
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
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:
>
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):
Newlis
11 matches
Mail list logo