[issue25564] Document that IDLE -python difference for `del __builtins__`

2016-08-24 Thread Terry J. Reedy

Terry J. Reedy added the comment:

What I meant is that one cannot use __builtin__ or builtins until one has done 
the import, which is why people tend not to bother and instead do things like 
ppperry was doing.

To the extent that tkinter is limited to CPython, so is IDLE.  Still, the only 
reference to __builtins__ is in
F:\Python\dev\36\lib\idlelib\autocomplete.py: 188: (fetch completions)
namespace.update(__main__.__builtins__.__dict__)

I don't know why not just use __builtins__.__dict__, but this follows
import __main__
namespace = __main__.__dict__.copy()

To be cross-platform, you are saying that this should be on 3.x
import builtins; namespace.update(builtins.__dict__)

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25564] Document that IDLE -python difference for `del __builtins__`

2016-08-24 Thread Terry J. Reedy

Terry J. Reedy added the comment:

I added what I think is an improved version of what I posted.

For 2.7 only, a change in the generated html outside of the text proper from 
using — and » to using — and »' resulted in the 
extraneous characters being shown.  The displayed text was preceded by '— ' 
and followed by the closers.  Adding the missing guard 'if self.show' to the 
charref function prevents this.

--
resolution:  -> fixed
stage: needs patch -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25564] Document that IDLE -python difference for `del __builtins__`

2016-08-24 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 862761e4376e by Terry Jan Reedy in branch '2.7':
Issue #25564: Mention exec and __builtins__ in IDLE-console difference section.
https://hg.python.org/cpython/rev/862761e4376e

New changeset 641852513b8e by Terry Jan Reedy in branch '3.5':
Issue #25564: Mention exec and __builtins__ in IDLE-console difference section.
https://hg.python.org/cpython/rev/641852513b8e

--
nosy: +python-dev

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25564] Document that IDLE -python difference for `del __builtins__`

2016-08-24 Thread Steven D'Aprano

Steven D'Aprano added the comment:

Terry J. Reedy added the comment:
> Steven: "You should use `__builtin__` in Python 2 and `builtins` in 
> Python 3."  I presume this is for import statements.

My understanding is that __builtins__ is intended to be for the private 
use of the CPython interpreter only. It may not be available in other 
Pythons, or in the future, and code that needs access to the built-ins 
should treat it as a regular module and import it via __builtin__ in 
Python 2 and builtins in Python 3.

In other words, unless you're the CPython interpreter, don't touch 
__builtins__.

I don't know whether IDLE is considered sufficiently closely integrated 
to CPython that it is allowed to rely on __builtins__, but for an 
ordinary module (even one in the stdlib) I wouldn't touch it at all.

--
title: Document IDLE -python difference for `del __builtins__` -> Document that 
IDLE -python difference for `del __builtins__`

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25564] Document that IDLE -python difference for `del __builtins__`

2016-08-24 Thread Terry J. Reedy

Terry J. Reedy added the comment:

Steven: "You should use `__builtin__` in Python 2 and `builtins` in Python 3."  
I presume this is for import statements.

ppperry: Titles should fit in the box, so they fit in search listing results.

I am thinking of something like "Since Python inserts '__builtins__' into the 
exec global namespace when not present and IDLE uses exec, '__builtins__' is 
defined at the start of each statement or file even when it otherwise would not 
be."

--
title: Document that IDLE behaves differently than python on `del __builtins__` 
-> Document that IDLE -python difference for `del __builtins__`
versions:  -Python 3.4

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com