[issue38556] Walrus operator in list comprehensions [Python 3.8.0]

2019-10-22 Thread EGN
EGN added the comment: Even the simple code like this doesn't work: [print(p) for n in (p := ['a', 'b', 'c'])] -- ___ Python tracker <https://bugs.python.org/issue38

[issue38556] Walrus operator in list comprehensions [Python 3.8.0]

2019-10-22 Thread EGN
EGN added the comment: But if I'm taking main for loop out of the square brackets everything works fine. from os import getcwd, listdir, rename import re for n in listdir(p := f"{getcwd()}\\{input('Folder: ')}\\"): [rename(f'{p}{n}', f"{p}{''.join([w[:3] if len(w) &

[issue38556] Walrus operator in list comprehensions [Python 3.8.0]

2019-10-22 Thread EGN
EGN added the comment: from os import getcwd, listdir, rename import re [rename(f'{p}{n}', f"{p}{''.join([w[:3] if len(w) > 3 else w for w in re.split('[-_. ]', n)[:-1]])}.{n.split('.')[-1]}") for n in listdir(p := f"{getcwd()}\\{input('Folder: ')}\\")] When I run

[issue38556] Walrus operator in Python 3.8.0 in list comprehensions

2019-10-22 Thread EGN
New submission from EGN : Just tried to use Walrus operator in list comprehensions (for loop) and it is not possible. Is it a bug? -- messages: 355124 nosy: EGN priority: normal severity: normal status: open title: Walrus operator in Python 3.8.0 in list comprehensions type

[issue38556] Walrus operator in list comprehensions [Python 3.8.0]

2019-10-22 Thread EGN
Change by EGN : -- title: Walrus operator in Python 3.8.0 in list comprehensions -> Walrus operator in list comprehensions [Python 3.8.0] ___ Python tracker <https://bugs.python.org/issu