[Python-ideas] Inline Functions - idea

Ethan Furman ethan at stoneleaf.us
Thu Feb 6 01:53:56 CET 2014


On 02/05/2014 04:15 PM, Guido van Rossum wrote:
> On Wed, Feb 5, 2014 at 2:26 PM, Ethan Furman wrote:
>>
>> Possibly, but it's easy enough to simulate (at least in
>>  a read-only fashion) with **locals().
>
> Eew. Use of locals() for any purpose other than debugging should be discouraged.

Well, as I recall (although I can't find it now) there was discussion about auto-filling a functions parameters with 
local values when the names matched, which would be much nicer is this situation (as well as extending situations).  For 
example:

class MyString(str):
   def find(sub, start, end):
     ...
     # manipulate sub and/or start and/or end
     ...
     return super().find(#blah#)

where #blah# means "pick out sub, start, and end from locals and use them".

--
~Ethan~


More information about the Python-ideas mailing list