Argh!! Can't wrap my head around this Python stuff!
Stefan Ram Stefan Ram
nospam.ram at zedat.fu-berlin.de
Sat Nov 25 16:35:00 EST 2017
Greg Tibbet <gtibbet27 at msn.com> writes:
>I'm an old timer, have programmed in Fortran, C, C++, Perl, and a bit
>of Java and trying to learn this new-fangled Python language!
Which actually is older than Java.
>def ellipse(self, xy, fill=None, outline=None):
> """Draw an ellipse."""
> ink, fill = self._getink(outline, fill)
> if fill is not None:
> self.draw.draw_ellipse(xy, fill, 1)
><...snipped...>
>ellipse() uses the method self.draw.draw_ellipse() Okay, fine...
>but WHERE is draw_ellipse defined?? What magic is happening there?
Depends on the nature of â»selfâ«.
Usually, the answer would be that it's defined in a superclass.
But with Python, one could also decrypt a string and then feed
the result to â»execâ« to dynamically add methods to an object
whose source code is well hidden.
Looking into the matter, it turns out, however, ...
â»_draw_ellipseâ« is defined in the language C in the file
â»_imaging.câ« and then mapped to â»draw_ellipseâ« via PyMethodDef
which is part of Python's C API.
More information about the Python-list
mailing list