A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2009-April/088025.html below:

[Python-Dev] issue5578 - explanation

[Python-Dev] issue5578 - explanationR. David Murray rdmurray at bitdance.com
Wed Apr 1 17:00:06 CEST 2009
On Wed, 1 Apr 2009 at 13:12, Chris Withers wrote:
> Guido van Rossum wrote:
>>  Well hold on for a minute, I remember we used to have an exec
>>  statement in a class body in the standard library, to define some file
>>  methods in socket.py IIRC. 
>
> But why an exec?! Surely there must be some other way to do this than an 
> exec?

Maybe, but this sure is gnarly code:

     _s = ("def %s(self, *args): return self._sock.%s(*args)\n\n"
           "%s.__doc__ = _realsocket.%s.__doc__\n")
     for _m in _socketmethods:
         exec _s % (_m, _m, _m, _m)
     del _m, _s

Guido's memory is good, that's from the _socketobject class in
socket.py.

--David
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4