On 10/09/2013 10:46 PM, Mark Shannon wrote:
There is no need to create an "undefined" value.
Rather than define a parameter by assigning a fake value, just don't define it. We already do this for non-parameter locals and it could be extended to parameters.

'range' would be defined thus:

def range([start,] stop, [step], /):
    try:
        start
    except UnboundLocalError:
        start = 0
    try:
        step
    except UnboundLocalError:
        step = 1
    ...

That's a clever, and intuitive, idea. Though the try/excepts look awfully clumsy.

Perhaps we could add (egad, no, I can't believe I'm saying this) a new built-in function that tells you whether or not a local variable has been assigned to yet?

   def range([start,] stop, [step], /):
        if not bound(start):
            start = 0
        if not bound(step):
            step = 1
        ...



Anyway, this section is in the "Notes For Future Implementors" section, so as long as we never actually implement the syntax we don't need to solve the problem.


//arry/
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to