this post was submitted on 16 Sep 2024
717 points (97.5% liked)

Programmer Humor

32469 readers
658 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 5 years ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 18 points 1 month ago (1 children)

Imo is more intuitive the need of () in print,like is a function like any other, why would not use ()?

[–] [email protected] 1 points 1 month ago* (last edited 1 month ago) (1 children)

If you developed it to not have brackets for the first one or two decades. Especially if there’s no possible way to easily edit it. You’re a psychopath to not consider this.

[–] [email protected] 2 points 1 month ago

That's what major versions are for - breaking changes. Regardless, you should probably be able to fix this with some regex hackery. Something along the lines of

new_file_content = re.sub(r'(?<=\bprint)(\s+)(?!\()', '(', old_file_content)
new_file_content = re.sub(r'(print\(.*?)(\n|$)', r'\1)', new_file_content)

should do the trick.