[issue46175] Zero argument super() does not function properly inside generator expressions

2021-12-25 Thread TobiasHT


TobiasHT  added the comment:

I'm not so sure, but I think this characteristic was carried from python 2. I 
guess it's not well documented because they assumed that people would carry on 
the knowledge to python 3. To be on the safe side, I always pass the arguments 
to super.

https://docs.python.org/2/library/functions.html#super

--
nosy: +TobiasHT

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



[issue46188] dictionary creation error

2021-12-28 Thread TobiasHT


New submission from TobiasHT :

I was creating a dictionary when I noticed something weird.
I had a function responsible for creating dictionary keys and then values were 
assigned to the keys in a for loop.
The code goes a little like this:

>>> def key_maker(n):
... if (n % 2) == 0:
... return n
... return None

>>> dictionary = {}
>>> for i in range(10):
... dictionary[key_maker(i)] = i if key_maker(i) else "error"

>>> dictionary
{0: 'error', None: 'error', 2: 2, 4: 4, 6: 6, 8: 8}


when I tried to print out the rest of the values in the "else" clause,
I realized that 0 appeared there as well, so 0 appeared twice.

>>> for i in range(10):
... dictionary[key_maker(i)] = i if key_maker(i) else print(i)
...
0
1
3
5
7
9
>>> dictionary
{0: 'error', None: 'error', 2: 2, 4: 4, 6: 6, 8: 8}

I still can not figure out why the first two elements are inconsistent
from the rest of the dictionary, and why they appear in the first place.

--
messages: 409251
nosy: TobiasHT
priority: normal
severity: normal
status: open
title: dictionary creation error
type: behavior

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