this post was submitted on 13 Jun 2023
10 points (100.0% liked)

Python

6289 readers
2 users here now

Welcome to the Python community on the programming.dev Lemmy instance!

πŸ“… Events

PastNovember 2023

October 2023

July 2023

August 2023

September 2023

🐍 Python project:
πŸ’“ Python Community:
✨ Python Ecosystem:
🌌 Fediverse
Communities
Projects
Feeds

founded 1 year ago
MODERATORS
 

Some surprising, but valid, python syntax examples.

top 8 comments
sorted by: hot top controversial new old
[–] msage 5 points 1 year ago

Hey, I do Perl for money, you can't scare me.

[–] verstra 3 points 1 year ago (1 children)

People designing Python surly didn't think of this. And when they see this now, the reaction would probably be "this should not be in any codebase, ever". But it can be. It is valid Python.

And it's a consequence of pushing features like unpacking and array comprehension and slice assigning and f-strings without fully exploring how they will interfere. One could argue that Python would be better of without some of these features.

But I don't blame them - exploring all possible combinations of features is just too much. The number of combinations grows exponentially and even if you have a fuzzer generating all possible expressions, you don't have enough time in your life to review all of the combinations.

[–] msage 4 points 1 year ago (1 children)

Ultimately it's about the project leader what kind of code gets in.

You can write unmaintanable code in every language - some even ascending to esoteric levels, like JsFuck

[–] verstra 1 points 1 year ago (1 children)

Well, I'm saying that we could design a language where code would have to be formatted, so it would not be up to the project leader, at least syntactically.

[–] msage 1 points 1 year ago (1 children)

I personally hate when code forces me to format things one way.

And there always be a way to go around formatting. Once I forced formatting on git server just to never worry about it.

[–] verstra 2 points 1 year ago (1 children)

Yeah, that's true, auto formatters will always have cases which format weirdly and have a nicer alternative.

But in the end, the formatting does not matter much, so we all benefit for it being formated one way, and one way only.


How would you format on git server? Create commits automatically, or ammend commits on push?

[–] msage 1 points 1 year ago

I... don't actually remember. It was a server side hook, I guess it tackled a new commit at the end. But it has been too long ago.

Nowadays I don't enforce such strict formatting, I just comment on MRs where I notice transgressions.

I never liked ammending commits. Had a colleague, team lead, who ammended other peoples commits. Ugh. That's when I started signing my own work.

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

I really don't see this as an issue, you could find this in any programming language. If you decide to abuse it, that's up to you