On 21/09/12 03:18, eryksun wrote:
On Thu, Sep 20, 2012 at 12:57 PM, eryksun wrote:
I forgot the obligatory warning about class variables. The subclass
gets a shallow copy of the parent class namespace. The in-place
^^^
>>> Y.data += [1]
>>> X.data # modified p
On Thu, Sep 20, 2012 at 3:39 PM, Steven D'Aprano wrote:
> On 21/09/12 02:57, eryksun wrote:
>>
>> On Thu, Sep 20, 2012 at 12:25 PM, eryksun wrote:
>
> Preferred terminology is attribute, not variable. Class attributes live
> in the class and are shared across all instances. Instance attributes
>
On 21/09/12 02:57, eryksun wrote:
On Thu, Sep 20, 2012 at 12:25 PM, eryksun wrote:
cls._count += 1
I forgot the obligatory warning about class variables.
Python is not Java. In Python, classes are first-class objects (no pun
intended) and can be assigned to variables the same
Ara Kooser wrote:
> Morning,
>
> I dug out some old code from 5 years ago to clean up and get in working
> order. It's a simple agent based model. I have class called Ant which
> contains all the ant-like functions.
>
> I have a list that tracks the ants but I did this is a very crude way. I
>
On Thu, Sep 20, 2012 at 12:57 PM, eryksun wrote:
>
> I forgot the obligatory warning about class variables. The subclass
> gets a shallow copy of the parent class namespace. The in-place
^^^
> >>> Y.data += [1]
> >>> X.data # modified parent, too
> [1]
> >>> Y.da
On Thu, Sep 20, 2012 at 12:25 PM, eryksun wrote:
>
> cls._count += 1
I forgot the obligatory warning about class variables. The subclass
gets a shallow copy of the parent class namespace. The in-place
addition above works because numbers are immutable. However, an
in-place operation o
On Thu, Sep 20, 2012 at 10:41 AM, Ara Kooser wrote:
>
> I have a list that tracks the ants but I did this is a very crude way. I
> basically copied and pasted everything in there like this:
>
> ants =
> [Ant("Red_1","Red","yellow_food"),Ant("Yellow_1","Yellow","red_food"),
> Ant("Red_2","Red","yel
Oscar,
Thanks for that. I feel a bit silly. I forgot about the % which was
hanging me up. I am trying to be a better coder. More work ahead for me!
ara
On Thu, Sep 20, 2012 at 9:01 AM, Oscar Benjamin
wrote:
> On 20 September 2012 15:41, Ara Kooser wrote:
>
>> Morning,
>>
>> I dug out some
On 20 September 2012 15:41, Ara Kooser wrote:
> Morning,
>
> I dug out some old code from 5 years ago to clean up and get in working
> order. It's a simple agent based model. I have class called Ant which
> contains all the ant-like functions.
>
> I have a list that tracks the ants but I did th
On 9/20/2012 7:41 AM Ara Kooser said...
Morning,
I dug out some old code from 5 years ago to clean up and get in
working order. It's a simple agent based model. I have class called Ant
which contains all the ant-like functions.
I have a list that tracks the ants but I did this is a very crud
Morning,
I dug out some old code from 5 years ago to clean up and get in working
order. It's a simple agent based model. I have class called Ant which
contains all the ant-like functions.
I have a list that tracks the ants but I did this is a very crude way. I
basically copied and pasted everyt
11 matches
Mail list logo