Marc Aymerich wrote:
> On Feb 5, 1:06 pm, Marc Aymerich wrote:
>> Thank you all for the answers!
>>
>> I'll try to give you the context in which I need to generate classes
>> like this.
>>
>> I'm developing a reusable control panel for an ISP. I have several
>> modules (VirtualUser, SystemUser, V
> I need to create a pretty complex class at runtime.
You can take the approach that namedtuple does and create a python code for the
class as string and then exec it. See
http://svn.python.org/view/python/trunk/Lib/collections.py?view=markup
HTH,
--
Miki
http://pythonwise.blogspot.com
--
http:
On Feb 5, 1:06 pm, Marc Aymerich wrote:
> Thank you all for the answers!
>
> I'll try to give you the context in which I need to generate classes
> like this.
>
> I'm developing a reusable control panel for an ISP. I have several
> modules (VirtualUser, SystemUser, VPS, VirtualHost, ...) and they
Carl Banks wrote:
> On Feb 4, 1:32 pm, Peter Otten <__pete...@web.de> wrote:
>> Marc Aymerich wrote:
>> > I need to create a pretty complex class at runtime. something like
>> > this one:
>>
>> I have a hunch that you've never heard the famous Kernighan quote:
>>
>> "Everyone knows that debugging
Thank you all for the answers!
I'll try to give you the context in which I need to generate classes
like this.
I'm developing a reusable control panel for an ISP. I have several
modules (VirtualUser, SystemUser, VPS, VirtualHost, ...) and they all
share the fact that you can have limits on resour
On Fri, Feb 4, 2011 at 6:10 PM, Steven D'Aprano
wrote:
> On Fri, 04 Feb 2011 17:19:23 -0800, Ian wrote:
>> On Feb 4, 5:49 pm, Steven D'Aprano > +comp.lang.pyt...@pearwood.info> wrote:
>>> Just add in the class attributes you want after creating the class.
> [...]
>> This would probably cause some
On Fri, 04 Feb 2011 17:19:23 -0800, Ian wrote:
> On Feb 4, 5:49 pm, Steven D'Aprano +comp.lang.pyt...@pearwood.info> wrote:
>> Just add in the class attributes you want after creating the class.
[...]
> This would probably cause some problems with the Django metaclass. It
> inspects the class di
On Feb 4, 5:49 pm, Steven D'Aprano wrote:
> Just add in the class attributes you want after creating the class.
>
> class VirtualUserLimitForm(ModelForm):
> pass
>
> f = forms.CharField # alias for brevity
> for name, value in [
> ('swap_limit', f(max_length=100, initial=monitor1.default_
On Fri, 04 Feb 2011 11:17:39 -0800, Marc Aymerich wrote:
> Hi!
> I need to create a pretty complex class at runtime. something like this
> one:
>
> (note: "" means that the number of attributes can be variable)
>
> class VirtualUserLimitForm(ModelForm):
> swap_limit = forms.CharField(max_
On Feb 4, 2:32 pm, Peter Otten <__pete...@web.de> wrote:
> > (note: "" means that the number of attributes can be variable)
>
> > class VirtualUserLimitForm(ModelForm):
> > swap_limit = forms.CharField(max_length=100,
> > initial=monitor1.default_limit)
> > memory_limit = forms.CharFiel
On Feb 4, 11:17 am, Marc Aymerich wrote:
> Hi!
> I need to create a pretty complex class at runtime. something like
> this one:
>
> (note: "" means that the number of attributes can be variable)
>
> class VirtualUserLimitForm(ModelForm):
> swap_limit = forms.CharField(max_length=100,
> ini
On Feb 4, 1:32 pm, Peter Otten <__pete...@web.de> wrote:
> Marc Aymerich wrote:
> > I need to create a pretty complex class at runtime. something like
> > this one:
>
> I have a hunch that you've never heard the famous Kernighan quote:
>
> "Everyone knows that debugging is twice as hard as writing
Marc Aymerich wrote:
> I need to create a pretty complex class at runtime. something like
> this one:
I have a hunch that you've never heard the famous Kernighan quote:
"Everyone knows that debugging is twice as hard as writing a program in the
first place. So if you're as clever as you can be
13 matches
Mail list logo