Posts: 4,558
Threads: 1,463
Joined: Sep 2016
i will have a dictionary of objects. each object will have some key that identifies it in the big dictionary. the objects are dictionaries, too (so it's a dictionary of dictionaries). when processing an object, there a many functions involved to which a reference to the object will be passed. i would like to also include the object's identity within the object itself. the big question i have is what key to store it under, given that each object could potentially have data items that could conflict with they key chosen to story its identity. the defaultdict is close but not the solution. it stores that default somewhere; it just uses it in a way that is incomparible with this problem. so i'm thinking i could store the identity as an attribute. would this be possible?
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Posts: 4,558
Threads: 1,463
Joined: Sep 2016
Oct-03-2018, 11:41 PM
(This post was last modified: Oct-03-2018, 11:42 PM by Skaperen.)
so how do i set the object's identity? suppose i have an object of type dictionary (any possible key could be used for data) that i want to identify as 'Skaperen'. would i do
foo.id = 'Skaperen'
or
setattr(foo,'id','Skaperen')
?
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Posts: 4,558
Threads: 1,463
Joined: Sep 2016
(Oct-04-2018, 01:46 AM)ichabod801 Wrote: skaperen = id(object)
what i want to do is store the identity with the object in a way that some code like a function or class that needs the identity can get it by having nothing more than a reference to the objecr.
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Posts: 4,558
Threads: 1,463
Joined: Sep 2016
storing the identity with tho object was my original goal.
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.