John Firestone added the comment:
Sorry. Duplicates 21591
--
status: open -> closed
___
Python tracker
<http://bugs.python.org/issue23113>
___
___
Python-
New submission from John Firestone:
Python 2.7.8 (v2.7.8:ee879c0ffa11, Jun 29 2014, 21:07:35)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> def outer():
...
John Firestone added the comment:
Thank you all for the quick and interesting responses!
Here is another example, this time showing a simple
s
sometimes behaves like
globals()['s']
and sometimes doesn't.
class Dict(dict):
def __getitem__(self, key):
John Firestone added the comment:
I find the behavior inconsistent. As you can see from this example, the
exec'uted code *does* call the instance's overloaded __getitem__ and
__missing__ methods when outside a function, but doesn
New submission from John Firestone :
exec(source, Dict()) doesn't call Dict().__getitem__ or Dict().__missing__ if
the source string contains a function and the function references an undefined
global.
class Dict1(dict):
def __getitem__(self, key):
print '__getite
Changes by John Firestone <[EMAIL PROTECTED]>:
--
components: Interpreter Core
files: getitem_problem.py
nosy: johnf
severity: normal
status: open
title: __getitem__() doesn't capture all slices if class inherits from list,
tuple or str
type: performance
versions: Python 2.5