Ancestors

Toot

Written by Ned Batchelder on 2025-01-13 at 13:49

Comparison operators in #Python can be chained together, but using them that way could be controversial. I wrote this this other day:

=> View attached media

=> More informations about this toot | More toots from nedbat@hachyderm.io

Descendants

Written by Eric Matthes on 2025-01-13 at 13:50

@nedbat I'm a big fan of parentheses for clarity, even when they're technically not needed.

=> More informations about this toot | More toots from ehmatthes@fosstodon.org

Written by Ned Batchelder on 2025-01-13 at 13:53

@ehmatthes But parentheses would break the comparison here.

=> More informations about this toot | More toots from nedbat@hachyderm.io

Written by Eric Matthes on 2025-01-13 at 13:54

@nedbat 🤦‍♂️

=> More informations about this toot | More toots from ehmatthes@fosstodon.org

Written by Sybren Stüvel 🧡🤍 on 2025-01-13 at 13:51

@nedbat I like how ... is actually a usable value in Python, so the code as you wrote it is literally runnable as well.

=> More informations about this toot | More toots from sybren@mastodon.art

Written by O'Schell on 2025-01-13 at 14:12

@sybren @nedbat ... or ... ? If it's the first one, can you develop more ?

=> More informations about this toot | More toots from OSchell@mastodon.social

Written by Ned Batchelder on 2025-01-13 at 14:22

@OSchell @sybren The Unicode ellipsis is not a valid identifier :(

… = 1

File "", line 1

… = 1

^

SyntaxError: invalid character '…' (U+2026)

=> More informations about this toot | More toots from nedbat@hachyderm.io

Written by Sybren Stüvel 🧡🤍 on 2025-01-13 at 22:11

@nedbat @OSchell that's a shame. Well, at least we do have the ASCII ellipsis.

=> More informations about this toot | More toots from sybren@mastodon.art

Written by Tin Tvrtković on 2025-01-13 at 13:57

@nedbat a little too clever for my tastes

=> More informations about this toot | More toots from tintvrtkovic@mastodon.social

Written by Jonathan Hartley on 2025-01-13 at 14:02

@tintvrtkovic @nedbat the counter argument would be that the chaining of these operators is precisely the same as chaining inequalities in my sixth grader's math homework. I think they are unintuitive only when one still has a "thinking in C" sort of mindset, where this would be impossible.

=> More informations about this toot | More toots from tartley@mastodon.social

Written by Tin Tvrtković on 2025-01-13 at 21:49

@tartley @nedbat No, I get it. But it also looks like

Proxy Information
Original URL
gemini://mastogem.picasoft.net/thread/113821363511315210
Status Code
Success (20)
Meta
text/gemini
Capsule Response Time
331.838263 milliseconds
Gemini-to-HTML Time
1.779989 milliseconds

This content has been proxied by September (ba2dc).