« first day (4944 days earlier)      last day (22 days later) » 

3:50 AM
@MahNeh Python while... else is pretty rare (I've personally never seen it used) but yes it's acceptable syntax. Else clause on Python while statement Note the else-clause doesn't get executed if you break out of the loop, but it does get executed when the while-condition tests False, even if it that's the first and only time it gets tested.
Both for...else and while...else syntax have been in Python forever, i.e. since before v1.4 (1996)
15
Q: Which version of python added the else clause for for loops?

MoeWhich was the first version of python to include the else clause for for loops? I find that the python docs usually does a good job of documenting when features were added, but I can't seem to find the info on this feature. (It doesn't help that 'for' and 'else' are particularly difficult term...

 
huh, 0.9.0 confirmed as first public release eh
 
Right. But personally, I almost never see them used. As to whether using them is considered "acceptable", that's subjective if they're not present/ different semantics to other langages (Java, C/C++, Scala etc.)
4
Q: What languages have a while-else type control structure, and how does it work?

DanA long time ago, I thought I saw a proposal to add an else clause to for or while loops in C or C++... or something like that. I don't remember how it was supposed to work -- did the else clause run if the loop exited normally but not via a break statement? Anyway, this is tough to search for, ...

So if your coders or intended audience are language-agnostic, I'd say no it's not a great idea to use the else-clause on for/while. Just use a clunky control variable to do this instead.
 
oh wow, that post is why python.org/download/releases/early exists
 
Wow, blast from the vault...
Does that mean the doc for previous to 0.9 or 1.4 is not readily available?
 
4:13 AM
yeah. if you want doc for those versions, basically you need to unzip the tarball and read or "build" it fromthe files in there (iirc it's LaTeX source)
 
 
4 hours later…
8:04 AM
@MahNeh I use it regularly for linear searches. The else clause then is the "nothing found" case.
 
 
2 hours later…
10:30 AM
@PM2Ring preach, brother, preach!
@MisterMiyagi Yeah with for it's common and useful, with while less so
 
@Hakaishin I think queue-based graph BFS could use while/else for similiar purpose
 
@matszwecja I can see uses for it, it's just increasingly rare. But I would so go for it if it is elegant, chances are others will find it elegant as well
 
It's one of those things that's handy to have in vocabulary, but shouldn't be abused too much
 
11:22 AM
Booking my flights in Japan has definitely both raised my blood pressure and reduced my anxiety about how accessible my own software will be internationally. Just wut?
I can't even enter my own birth date even ignoring the borked dates. It mangles the month names but November just defaults to January anyway :/ I don't think I'll be getting on that plane
Actually, it's just getting worse on other sites. "Please enter your name exactly as it appears on documents" and then it automatically capitalizes it and strips all whitespace, plus asks for my surname twice. If anyone has experience booking national flights in Japan, I'd actually buy you the coffee or whatever to say "thank you" if you could jump in a chat room with me and help
 
11:41 AM
@roganjosh I only booked to and from japan never inside of it. But it can be insanely frustrating, my condolences :P
 
I'll just get the Shinkansen. At least I know that. Whatever is powering this app translation to English (in lots of cases) is utterly bonkers.
 
12:31 PM
@roganjosh chatgpt :D
 
Even worse than something like babel. There's no way I'm booking a flight with something like what I got; that's just asking for a headache
 
or a plane crash :D
 
I also can't remember if I was born into "fire" or "Money" :P
@Hakaishin I mean... yeah, thanks for that sentiment? It's not a Boeing, though, so that's a blessing
 
@roganjosh dude that Boeing story is so wild, reaching Russian level of mob power. That was hella scary how they dealt with the whistleblower
 
 
4 hours later…
5:03 PM
This is a pretty decent question on datetimes. The second part is readily reproducible and I'm at a complete loss on how to explain it
 
5:21 PM
pypi says that pytz has an MIT license but doesn't exactly make it easy to find the source
 
erm, you can directly download the source tarball from pypi
 
but I like browsing repos online :(
 
I think that's actually not something that MIT guarantees.
As in, not at all.
 
I did find it, but it seems like the problem (if reproducible) is in the data somewhere
either that or there is some weird reason why pytz's result is actually technically correct
 
It is reproducible:
from datetime import datetime
import pytz

print('datetime values showing different offset')
print(datetime(2024, 10, 27, 0,0,0, tzinfo=pytz.timezone("Asia/Kolkata")))
print(datetime(2024, 10, 27, 0,0,0,tzinfo=pytz.timezone("Europe/Brussels")))
print(datetime(2024, 10, 27, 6,0,0, tzinfo=pytz.timezone("Europe/Brussels")))
 
6:18 PM
How can I write unit tests to check that my static typing is working as intended? Neither mypy nor pyright seem to be usable as a python module. Do I have to dump every single piece of code I want to check into a temporary file?
 
 
1 hour later…
7:30 PM
@Aran-Fey What is your problem with invoking pyright/mypy via python -m? It's how I run pytest, so they all work kind of the same for me.
With typing.assert_type you can write actual type tests now.
 
I want it to be a part of my test suite, i.e. executed by pytest. And I also need to verify that certain expressions do result in a type error. Basically I want something like
@pytest.mark.parametrize('expr', [
    'd: Distance = seconds(3)',
    's: Speed = seconds(5) / meters(2)',
])
def test_error(expr: str):
    assert not mypy.verify(expr)
I guess I'll just launch mypy as a subprocess, it lets me pass the code as a command line argument
 
8:24 PM
Does anyone know how to increase the precision of the output values of this tqdm callback?
 
8:46 PM
@Aran-Fey I gather your TODO list has picked up a new item, "pytest plugin for mypy"
 
That's honestly a neat idea, but no, I have no intention of adding "glue two probably very gross code bases together" to my list
 
9:25 PM
Teaching the type checker math be like
# N = kg * m / s / s
Force = Union[
    Div[Mul[Mass, Distance], Square[Duration]],
    Div[Div[Mul[Mass, Distance], Duration], Duration],
    Mul[Div[Mass, Duration], Div[Distance, Duration]],
    Mul[Mass, Div[Div[Distance, Duration], Duration]],
    Mul[Distance, Div[Div[Mass, Duration], Duration]],
]
Let me know if I missed a combination
 
@Aran-Fey I'm curious about your software project, what does it refer to? Can you tell?
 
I got tired of unit-less numbers in programming, so I'm making a library for statically typed units. pypi.org/project/u
Not to toot my own horn, but I think it came out really well. I love the reusable prefixes in particular. Being able to write u.mega(u.bytes)(5) is fun
 
"Doubles weren't broken enough so I added a type system" :P
 
@Aran-Fey hmm, interesting
This project is very nice too
 
We're planning to launch in february. This year. It's not going too great :D
2
 
You meant we were?
 
Yeah
 
And are you talking about Rio?
 
Yep
 
hmmmm
Nice
But...
Isn't it already released?
 
That's the temporary pre-official-launch license
 
I see
good "hands off" license :D
 
@Aran-Fey hmm
Congrats, Aran, very nice project, when I have time I'll test it, it's something that interests me a lot
 
Glad to hear that. Feedback is always welcome
 
Why the name Rio? Does it happen to have anything to do with the city of Rio de Janeiro/Brazil?
@Aran-Fey Nice, you're welcome
 
9:38 PM
Funny story, that. We were originally planning on "reflex", but then guess what happened? Pynecone renamed itself to reflex :/
We kinda knew we wanted to keep the "r" (like "react"), and rio won the democratic election
 
@Aran-Fey oh
@Aran-Fey I see, so nothing to do with the Rio city, hahah
 
@Aran-Fey Mass * (Distance / (Duration**2)) and the Mass <-> Distance swapped version? I..e Square[Duration] vs Div[Div[...]].
 
@Marco Nope, no connection. Made the domain pretty expensive, though!
 
Why?
 
Because rio is a rather well-known name, short and memorable
 
9:44 PM
oh
curious
 
@AndrasDeak--СлаваУкраїні Well spotted, thanks...
 
10:03 PM
@Aran-Fey small world. (I'd never heard of the project before.)
 

« first day (4944 days earlier)      last day (22 days later) »