This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author EGN
Recipients EGN, steven.daprano, xtreak
Date 2019-10-22.14:11:34
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1571753494.3.0.0959845780521.issue38556@roundup.psfhosted.org>
In-reply-to
Content
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) > 3 else w for w in re.split('[-_. ]', n)[:-1]])}.{n.split('.')[-1]}")]
History
Date User Action Args
2019-10-22 14:11:34EGNsetrecipients: + EGN, steven.daprano, xtreak
2019-10-22 14:11:34EGNsetmessageid: <1571753494.3.0.0959845780521.issue38556@roundup.psfhosted.org>
2019-10-22 14:11:34EGNlinkissue38556 messages
2019-10-22 14:11:34EGNcreate