[Python-Dev] Why are so many built-in types inheritable?

2006-03-13 Thread Fabiano Sidler
Hi folks!

Let me explain the above question:
For debugging purpose I tried this:

--- snip ---
def foo(): pass
function = type(foo)

class PrintingFunction(function):
  def __init__(self, func):
self.func = func
  def __call__(self, *args, **kwargs):
print args, kwargs
return function.__call__(self, args, kwargs)

class DebugMeta(type):
  def __new__(self, name, bases, dict):
for name in dict:
  if type(dict[name]) is function:
dict[name] = PrintingFunction(dict[name])

--- snap ---

Now I tought I were able to let all methods of classes with DebugMeta
as metaclass print out their arguments.  But I got the following sad
error:

TypeError: Error when calling the metaclass bases
type 'function' is not an acceptable base type

That's a pity, isn't it?
What could I do to get the above code to work? (No, I don't want to
reimplement  without this unpleasant behaviour in
Python.

Greetings,
F. Sidler
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


[Python-Dev] compiler.pyassem

2006-02-10 Thread Fabiano Sidler
Hi folks!

Do I see things as they are and compiler.pyassem generates bytecode
straight without involve any C code, i.e. code from the VM or the
compiler? How is this achieved? I took a look at Python/compile.c as
mentioned in compiler.pyassem and I'm trying to get into it, but about
6500 lines of C code are too much for me in one file. Could someone
here please give me some hints on how one can do what compiler.pyassem
does?

Greetings,
Fips
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com