[Python-Dev] Re: attaching methods to an object at runtime and compiler enhancement ideas...

Terry Reedy tjreedy at udel.edu
Fri Oct 10 14:19:51 EDT 2003

"kasper b. graversen" <kbg at kadnet.dk> wrote in message
news:200310101811370393.020A912A at lisbeth.kadnet.dom...

At least your first two questions are about usage rather than
development and would be better directed to comp.lang.python (or
In the meanwhile...

>each object. So far it has been fun playing with python, but I ponder
why it is >only possible to introduce functions and not methods to
object instances?

1. Methods are functions attached to classes as attributes.
2. The need for instance-specific 'methods' is rare.
3. Rare needs are covered by explicitly passing the instance as an
person.role(person, *args)

> I am also wondering if it is possible to change the parsed code at
> time by gaining access to the AST

See compiler module/package and its AST walker.

>Finally, one of the most difficult things of moving from Java to
python is the >lack of checking done by the compiler ;) Here are two
things I really miss >which if would like the future versions of the
compiler to support:

The current interpreter checks only for syntactic correctness and
deprecated usages (to issue warnings).  This is unlikely to change
soon.  Enforcing coding standards is more the province of PyChecker
and PyLint.  If neither have the checks you want, give both authors
your suggestions.

Terry J. Reedy

More information about the Python-Dev mailing list