That would work, but it's bad if you later want to introspect on __name__ and do something useful with it.
 
Better to pull out table.name and use something based on that as the class name.
 
-J
 
On 1/5/06, limodou <[EMAIL PROTECTED]> wrote:
2006/1/5, Jonathan Ellis <[EMAIL PROTECTED]>:
> no; the point was, it doesn't matter what name you give the class object;
> that only affects its __name__.  I wrote
>
> class Foo: pass
> class Bar = Foo
>
> but I could just as easily have written
>
> Bar = new.classobj('Foo', ...)
> or
> Bar = type('Foo', ...)
>
> (which is the non-deprecated way of creating a class dynamically, btw)
>

So what you mean just like:

>>> import new
>>> A = new.classobj('T', (object,), {})
>>> B = new.classobj('T', (object,), {})
>>> A
<class '__main__.T'>
>>> B
<class '__main__.T'>

Class A and Class B is not the same, only have the same __name__ 'T',
is that right?
So that I could rewrite the assign_class(class_name, table, **kwargs)
to assign_class(table, **kwargs), but all the class may be the same
__name__?

def assign_class(table, **kwargs):
   ...
   klass = new.classobj('TableClass', table, **kwargs)
   return klass

--
I like python!
My Blog: http://www.donews.net/limodou
NewEdit Maillist: http://groups.google.com/group/NewEdit


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_idv37&alloc_id865&opclick
_______________________________________________
Sqlalchemy-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users



--
Jonathan Ellis
http://spyced.blogspot.com

Reply via email to