[sage-devel] Re: Customizing hash for an instance of ?

Sat, 10 Sep 2011 06:32:53 -0700

You should really learn about metaclasses. The basically allow you to change 
the way classes are created. Normally this is done by type. I.e. the 
following are equivalent.

sage: class Foo(object):
....:     def a(self):
....:         return 1
....:     
sage: f=Foo()
sage: f.a()
1

sage: Foo=type('Foo',(object,),{'a':lambda self: 1})
sage: f=Foo()
sage: f.a()
1

I found the video talk at 
 http://code.google.com/edu/languages/#_python_understanding very usefull 
for understanding metaclasses


-- 
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org

Reply via email to