News for hackers. Stuff that matters.
Re:Basic Intro to Python Metaprogramming by irahul on Saturday July 16, 2011 @10:37PM (#2772359)
>>> Foo = type("Foo", (FooBase,), {'bar' : 42})

is not equivalent to what the blog post says it is to. FooBase should be defined before running this, and the blog post's equivalent make it look like this statement defines FooBase as well.

Re:Basic Intro to Python Metaprogramming by jackpirate on Sunday July 17, 2011 @02:50AM (#2772735)
I think you neglected the line in front of it, which does define FooBase.

   1. >>> FooBase = type("FooBase", (object,), {})  
   2. >>> Foo = type("Foo", (FooBase,), {'bar' : 42})  
Although I am not a python expert, so you may be right... in which case, how does line one not work?
Re:Basic Intro to Python Metaprogramming by irahul on Sunday July 17, 2011 @04:52AM (#2772867)
I stand corrected - I was skimming and didn't notice. The example is correct - I was wrong.