diff options
author | Pierre Glaser <pierreglaser@msn.com> | 2019-02-07 20:36:48 +0100 |
---|---|---|
committer | Antoine Pitrou <pitrou@free.fr> | 2019-02-07 19:36:48 +0000 |
commit | df8d2cde63c865446468351f8f648e1c7bd45109 (patch) | |
tree | 1cc555d57319990602a4987cbf21ee225c4ff2a1 /Lib/types.py | |
parent | f289084c83190cc72db4a70c58f007ec62e75247 (diff) | |
download | cpython-git-df8d2cde63c865446468351f8f648e1c7bd45109.tar.gz |
bpo-35911: add cell constructor (GH-11771)
Add a cell constructor, expose the cell type in the types module.
Diffstat (limited to 'Lib/types.py')
-rw-r--r-- | Lib/types.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/Lib/types.py b/Lib/types.py index ce4652f371..53b588da75 100644 --- a/Lib/types.py +++ b/Lib/types.py @@ -15,6 +15,13 @@ CodeType = type(_f.__code__) MappingProxyType = type(type.__dict__) SimpleNamespace = type(sys.implementation) +def _cell_factory(): + a = 1 + def f(): + nonlocal a + return f.__closure__[0] +CellType = type(_cell_factory()) + def _g(): yield 1 GeneratorType = type(_g()) |