[Python-ideas] Specifying constants for functions
Nikolaus Rath
Nikolaus at rath.org
Tue Oct 27 16:22:22 EDT 2015
On Oct 27 2015, Yury Selivanov <yselivanov.ml-Re5JQEeQqe8AvxtiuMwx3w at public.gmane.org> wrote:
> On 2015-10-27 3:02 PM, Bruce Leban wrote:
>> It's not a micro-optimization in this case:
>>
>> def foo(x, SENTINEL=object()):
>> ...
>>
>>
>> I don't like mangling function signatures to do this. What I really
>> want is the equivalent of C's static here:
>>
>> def foo(x):
>> static SENTINEL = object()
>> ...
>>
>>
>
> Why not
>
> SENTINEL=object()
> def foo(x):
> ...
>
> ?
Because it leaks into the enclosing scope.
Best,
-Nikolaus
--
GPG encrypted emails preferred. Key id: 0xD113FCAC3C4E599F
Fingerprint: ED31 791B 2C5C 1613 AF38 8B8A D113 FCAC 3C4E 599F
»Time flies like an arrow, fruit flies like a Banana.«
More information about the Python-ideas
mailing list