En Wed, 13 Jun 2007 23:11:22 -0300, nik <[EMAIL PROTECTED]> escribió:
> On Jun 13, 6:48 pm, "Gabriel Genellina" <[EMAIL PROTECTED]> > wrote: >> En Wed, 13 Jun 2007 22:20:16 -0300, nik <[EMAIL PROTECTED]> escribió: >> >> > I would like to create a class and then save it for re-use later. I >> > have tried to usepickle, but am not sure if that is right. I am >> > sorry, but I am new to python. >> >> Do you want to save the *source*code* of your class, or do you want to >> save created *instances* -objects- of your classes to retrieve them >> later (like a database)? > It would seem that I want to actually save the source code for the > class. I know that I could of course open up an editor and just make > it, but my ideal would be to have the base class, Map, be able to make > the sub-classes. I don't want the class definition. What I want is an > actual class that I could later import and use somewhere else. I am > planning to have each one of these map objects contain a different > dictionary and then be able to import the map into the application, > but have certain methods defined in the Map super-class to draw data > out of the specific map's specific dictionary. I hope that makes > sense. > > Something like, > class Map: > dict = {} > def DoSomething(self): > pass > > def MakeNewMapSubClass(self, newclassname): > """ make a new file, newclassname.py that contains a new > class > newclassname(Map) that inherits from base-class Map. And are you sure you actually need different subclasses? Will you construct them several instances of each subclass? From the above description I feel you want just different Map *instances*, each with its own dict, not different *subclasses*. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list