> > print(child_pid) # child_pid is undefined > > Why on earth would it be undefined? >
Indeed, users would expect the new uses of "as" to behave as the previous ones. The problem is that "with" and "except" do things differently: In [*1*]: *import* *os* In [*2*]: *with* open(os.path.expanduser('~/tmp/xx')) *as* f: ...: *pass* ...: In [*3*]: print(f) <_io.TextIOWrapper name='/Users/apalala/tmp/xx' mode='r' encoding='UTF-8'> In [*4*]: *try*: ...: print('ok') ...: *raise* *Exception*() ...: *except* *Exception* *as* e: ...: *pass* ...: In [*5*]: print(e) --------------------------------------------------------------------------- NameError Traceback (most recent call last) <ipython-input-5-bb2ea196f768> in <module>() ----> 1 print(e) NameError: name 'e' is not defined > Anyway, if you want to propose an alternative to PEP 572, you ought to > write your own competing PEP. > I don't take that as a challenge. It would be good to have different, maybe somewhat competing PEPs. It's been done before. -- Juancarlo *Añez*
_______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/