On Thu, Jun 5, 2008 at 1:47 AM, William Stein wrote: > > On Wed, Jun 4, 2008 at 10:16 PM, Bill Page wrote: >> ... >> Python classes can also take parameters. > > I didn't know that. I thought the only way to create a Python class > is for the Python interpreter to execute Python code that looks like this: > > class Foo(...): > ... > > That makes a new class called Foo. How are you going to make, at > runtime, new classes for each of Z/nZ say, for 1 <= n < 10^5, i.e., > something like this in Sage: > > v = [Integers(n) for n in range(1,10^5)] > > I do not think it is possible to concisely create a hundred thousand > separate Python classes like that. >
See Python MetaClasses. E.g. http://www.onlamp.com/pub/a/python/2003/04/17/metaclasses.html sage: X = type('X', (object,), dict(a=1)) sage: x=X() sage: x.a 1 Regards, Bill Page. --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to sage-devel@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sage-devel URLs: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---