Re: class factory question

2013-06-27 Thread Tim
On Thursday, June 27, 2013 11:56:24 AM UTC-4, Irmen de Jong wrote: > On 27-6-2013 15:48, Dave Angel wrote: > >> The behavior for these is all the same so they're subclassed > >> from one base class, but they need to have these particular names so the > >> parser knows > >> how to consume them whe

Re: class factory question

2013-06-27 Thread Irmen de Jong
On 27-6-2013 15:48, Dave Angel wrote: >> The behavior for these is all the same so they're subclassed >> from one base class, but they need to have these particular names so the >> parser knows >> how to consume them when encountered in the source file. That is, for every >> custom >> command t

Re: class factory question

2013-06-27 Thread Dave Angel
On 06/27/2013 09:37 AM, Tim wrote: On Thursday, June 27, 2013 9:16:50 AM UTC-4, Joshua Landau wrote: On 26 June 2013 14:09, Tim wrote: I am extending a parser and need to create many classes that are all subclassed from the same object (defined in an external library). When my module is loa

Re: class factory question

2013-06-27 Thread Tim
On Thursday, June 27, 2013 9:16:50 AM UTC-4, Joshua Landau wrote: > On 26 June 2013 14:09, Tim wrote: > > > I am extending a parser and need to create many classes that are all > > subclassed from the same object (defined in an external library). When my > > module is loaded I need all the clas

Re: class factory question

2013-06-27 Thread Joshua Landau
On 26 June 2013 14:09, Tim wrote: > I am extending a parser and need to create many classes that are all > subclassed from the same object (defined in an external library). When my > module is loaded I need all the classes to be created with a particular name > but the behavior is all the same

Re: class factory question

2013-06-26 Thread Fábio Santos
On 26 Jun 2013 14:14, "Tim" wrote: > > I am extending a parser and need to create many classes that are all subclassed from the same object (defined in an external library). When my module is loaded I need all the classes to be created with a particular name but the behavior is all the same. Curr

Re: class factory question

2013-06-26 Thread Joshua Landau
On 26 June 2013 16:40, Peter Otten <__pete...@web.de> wrote: > Joshua Landau wrote: > >> I would say if a dict isn't good, there are still some cases where you >> might not want to use globals. >> >> I _might_ do: > >> # Make a module >> module_for_little_classes = ModuleType("module_for_little_cla

Re: class factory question

2013-06-26 Thread Peter Otten
Joshua Landau wrote: > I would say if a dict isn't good, there are still some cases where you > might not want to use globals. > > I _might_ do: > # Make a module > module_for_little_classes = ModuleType("module_for_little_classes", > "All the things") > module_for_little_classes.__dict__.update

Re: class factory question

2013-06-26 Thread Joshua Landau
On 26 June 2013 15:46, Peter Otten <__pete...@web.de> wrote: > The clean way to > cope with the situation is to use a dict: > > classnames = ["Vspace", ...] > classes = {name: type(name, ...) for name in classnames} > > Then you can access the Vspace class with > > classes["Vspace"] > > If that is

Re: class factory question

2013-06-26 Thread Tim
On Wednesday, June 26, 2013 10:46:55 AM UTC-4, Peter Otten wrote: > Tim wrote: > > I am not completely understanding the type function I guess. Here is an > > example from the interpreter: > > No, you are not understanding how Python namespaces work ;) > To get a Vspace in the global namespace yo

Re: class factory question

2013-06-26 Thread Peter Otten
Tim wrote: > I am not completely understanding the type function I guess. Here is an > example from the interpreter: > > In [1]: class MyClass(object): >...: pass >...: > In [2]: type('Vspace', (MyClass,), {}) > Out[2]: __main__.Vspace > In [3]: x = Vspace() > ---

Re: class factory question

2013-06-26 Thread Tim
On Wednesday, June 26, 2013 9:39:12 AM UTC-4, Peter Otten wrote: > Tim wrote: > > I am extending a parser and need to create many classes that are all > > subclassed from the same object (defined in an external library). When my > > module is loaded I need all the classes to be created with a pa

Re: class factory question

2013-06-26 Thread Peter Otten
Tim wrote: > I am extending a parser and need to create many classes that are all > subclassed from the same object (defined in an external library). When my > module is loaded I need all the classes to be created with a particular > name but the behavior is all the same. Currently I have a bunch

class factory question

2013-06-26 Thread Tim
I am extending a parser and need to create many classes that are all subclassed from the same object (defined in an external library). When my module is loaded I need all the classes to be created with a particular name but the behavior is all the same. Currently I have a bunch of lines like th