In alister
writes:
> why not simply use pythons builtin id function?
> each new instance of an object is automatically assigned a unique ID
It's only guaranteed to be unique for objects that exist at the same time.
If an object is created and destroyed and then another new object is
created,
On Tue, 29 Sep 2015 09:17 pm, Anssi Saari wrote:
[...]
>> The problem is that in python you can't change a class variable through
>> an instance. The moment you try, you create an instance attribute.
>
> That much is clear but why does his other version of __gen_id() work
> (after a fashion)? It
Op 29-09-15 om 13:17 schreef Anssi Saari:
> Antoon Pardon writes:
>
>> Op 29-09-15 om 11:27 schreef ple...@gmail.com:
>>> I have a perplexing problem with Python 3 class variables. I wish to
>>> generate an unique ID each time an instance of GameClass is
>>> created. There are two versions of the
Antoon Pardon writes:
> Op 29-09-15 om 11:27 schreef ple...@gmail.com:
>> I have a perplexing problem with Python 3 class variables. I wish to
>> generate an unique ID each time an instance of GameClass is
>> created. There are two versions of the __gen_id method with test run
>> results for each
On 09/29/2015 01:02 PM, jmp wrote:
class GameObject:
@property
def id(self):
return id(self) #use the builtin id function
print GameObject().id
Cheers,
JM
I should add that until you don't serialize your object you're fine.
If you need to serialize it, you may want to look at
h
On 09/29/2015 11:27 AM, ple...@gmail.com wrote:
I have a perplexing problem with Python 3 class variables.
Your problem is that when assigning values to your class attribute, you
are actually creating a instance attribute.
class Foo:
bar = "I'm a class attribute"
def __init__(self):
Op 29-09-15 om 11:27 schreef ple...@gmail.com:
> I have a perplexing problem with Python 3 class variables. I wish to generate
> an unique ID each time an instance of GameClass is created. There are two
> versions of the __gen_id method with test run results for each listed below
> the code.
Th
On Tue, 29 Sep 2015 02:27:23 -0700, plewto wrote:
> I have a perplexing problem with Python 3 class variables. I wish to
> generate an unique ID each time an instance of GameClass is created.
> There are two versions of the __gen_id method with test run results for
> each listed below the code.
>
I have a perplexing problem with Python 3 class variables. I wish to generate
an unique ID each time an instance of GameClass is created. There are two
versions of the __gen_id method with test run results for each listed below the
code.
Originally I used the version which is now commented out