[Tutor] How to model objects aimed to persistence?

Knacktus knacktus at googlemail.com
Thu Jun 17 06:07:26 CEST 2010


Am 17.06.2010 02:17, schrieb Alan Gauld:
> "Steven D'Aprano" <steve at pearwood.info> wrote
>> Deliberate misspellings in class and variable names will cost you
>> *far* more in debugging time when you forget to misspell the words
>> than they will save you in typing. Trust me on this.

Thanks for that hint. I can imagine the nightmares ... It was just a 
spelling mistake. English is not my native language and I sometime tend 
to skip trailing "e"s ;-).

But I think I need to clarify my question a bit. The point I'm unsure 
with is how to best model references in python for persistence when not 
using pickle or any dedicated python. Python doesn't even need names as 
reference to the objects location in memory. I could do something like this:

###########################################################################
my_favourite_movies = FavouriteMovies([Movie("Gladiator", "Russel Crowe")])
###########################################################################

When I want to rebuild the data from a xml file or database, my objects 
somehow need to know which references to other objects they hold.
I don't now wether I have to use explicit indices in my python code to 
make it "xml-ready" and if that's the case, how to do it smoothly. Or 
whether there's some other trick.

Cheers,

Jan


More information about the Tutor mailing list