[issue46193] Using a dictionary for open files.

2021-12-29 Thread Keepun


New submission from Keepun :

"""
Using a dictionary for open files.

The file is filled with NULL. Only the last entry is normal.

Result:
00 00 00 00 ... 00 0A 48 65 6C 6C 6F 0A

Ubuntu - 3.8.10
Windows - 3.9.8
"""
fhandles = {}
for f in range(100):
fh = fhandles.setdefault("suffix", open(r"test.txt", "w"))
fh.write("\nHello\n")
fh.flush()
for f in fhandles.values():
f.close()

import sys
print(sys.version_info)

--
components: IO
messages: 409303
nosy: Keepun
priority: normal
severity: normal
status: open
title: Using a dictionary for open files.
type: behavior
versions: Python 3.8, Python 3.9

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



[issue46193] Using a dictionary for open files.

2021-12-29 Thread Keepun


Keepun  added the comment:

I didn't think about calculating the argument before passing it to the 
function...

--
stage:  -> resolved
status: open -> closed

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



[issue43448] exec() ignores scope.

2021-03-09 Thread Keepun


New submission from Keepun :

exec() ignores scope.

Code:
--
class ExecTest:
def public(self):
h=None
exec("h='It is public'")
print(h)
self._private()
def _private(self):
h=None
exec("h='It is private'", globals(), locals())
print(h)

h = None
exec("h='It is global'")
print(h)

e=ExecTest()
e.public()

Result
--
It is global
None
None

--
Python 3.7.10 (default, Feb 26 2021, 13:06:18) [MSC v.1916 64 bit (AMD64)]
and
Python 3.8.5 (default, Jan 27 2021, 15:41:15) [GCC 9.3.0]

------
components: Interpreter Core
messages: 388366
nosy: Keepun
priority: normal
severity: normal
status: open
title: exec() ignores scope.
type: behavior
versions: Python 3.7, Python 3.8

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