« first day (4205 days earlier)      last day (758 days later) » 

4:28 AM
did python3 remove encoding a source with rot13?
I mean the source file itself, not just encoding using codecs
 
 
1 hour later…
5:56 AM
@ParitoshSingh There is V, which is basically an improved Go but with Rust features
 
6:22 AM
I'm seeing an increasing number of technical "blogs" that are full of spyware-type tricks. Like "Click allow [on allow notifications] to prove you're not a robot" complete with a fake recaptcha if you click block before trying to navigate back. Kinda feels like the sector escaped a lot of the internet nonsense for quite a while, but now it's here in full force :(
 
 
2 hours later…
8:16 AM
..tried searching on [pandas] lookup based on column value score:5, and similar
 
I hardly get what they are asking... the title makes some sense, but the question body is pretty poor.
 
@MisterMiyagi They want to lookup columnB based on specific value in columnA. It's about as blatant a duplicate of the tutorial as can get.
@roganjosh Which sector? Parasitic technical blogs?
 
This answer (and the general Q&A) seems to do what they want.
 
@MisterMiyagi Great, thanks. Well strictly we only want to select columnB, not the entire row. Anyway, I didn't find it because I searched on 'lookup' instead of 'select'. 'indexing' is another term.
 
8:38 AM
@smci Stuff that kinda masquerades as the Medium-type articles or TowardsDataScience. I do browse them quite a bit on new topics, usually to grab some package names or visualisations I hadn't thought of (even the "legit" versions of these blogs are often terrible, but I guess you already knew that, so I don't follow their actual content)
 
8:55 AM
Hello all! I hope you're doing well. I tried several commands now for the following question, but it doesn't work until now.. I got the ECB website with EURO Rates: ecb.europa.eu/stats/policy_and_exchange_rates/…
it is a xml file on the website. I'd like to somehow receive the data of this URL in CSV form so that I can process it in Python, as I want to merge the data with a dataframe...
Does some of you know how I can receive this xml data of this URL?
 
@ParitoshSingh seems like the opposite of progress. And yay I found my memory leak, valgrind is so awesome <3
 
Using this solution for example doesn't give a dataframe: stackoverflow.com/questions/24124643/…
 
@Baobab "tried several commands" sounds convincing. But have you googled "pandas read xml to dataframe" or something similar?
 
9:12 AM
@Baobab That looks like a good approach; surely if you have the data as a dict you can find a way to turn it into a dataframe?
 
9:29 AM
@roganjosh If they contain malicious JS, you can and should report them to Google and have them delisted: safebrowsing.google.com/safebrowsing/report_badware Also please list them here.
 
There's so much crap online, let's not list them here please
 
@AndrasDeak--СлаваУкраїні Only the worst offenders, i.e. the ones that are doing $$$ SEO to appear above SO or docs.python.org in the top-10 ranking for the same query. They're quite insidious and I often get tricked into clicking on them instead of the legit sites.
 
@smci strangely I think sopython actually comes up out ranking a couple of SO results...
 
@JonClements Yes we've been remarking on these sites for several years, they must be spending $$$ on white-hat SEO. What, SOpython outranks SO?
 
9:45 AM
yeah... apparently for some error messages
will check that in incognito though... two ticks
 
@smci you should look at the url before clicking, and filter your search for specific sites ;)
 
ahh... 4th for "the truth value of an array with more than one element is ambiguous. use a.any() or a.all()"
 
Wes
mornin. how do i define type hints for structs in python?
Foo = {bar: str, baz: int}
 
The irony is that some of the people writing the software for those fake sites learned Web "scrapping" from SO.
 
Wes
classes are the only thing, right?
 
9:54 AM
What is a "struct"?
 
Wes
more or less a class with no methods
commonly used for data transfer objects
 
Well, then type hints work just like they do in any other class
 
Wes
like there's no way to validate a dictionary against a class' type hints?
{foo: "foo", bar: 123}

class MyClass:
    foo: str,
    bar: int,
 
There isn't even a way to validate an instance against its own type hints
 
Wes
lol
i'll just create a class then
 
9:59 AM
Assuming you mean at runtime
 
Wes
i meant statically in the ide
 
But how does the IDE know that the dict and the class are related? Are you calling the constructor like MyClass(**some_dict) or what?
 
Wes
structural typing vs nominal typing
def foo() -> {id: int, name: str, surname: str}:
TypeAlias = {id: int, name: str, surname: str}
def foo() -> TypeAlias:
you can do this type of stuff in typescript for example
 
Are you looking for TypedDict maybe?
 
Wes
indeed
nice
thanks
 
10:50 AM
@AndrasDeak--СлаваУкраїні well this is my code, # -*- coding: rot-13 -*- cevag("hello") it gives a syntax error in python3
 
That's not a thing anymore in python 3, python 3 scripts must always be utf-8
 
@Aran-Fey then the tutorial needs a PR
 
that is what I wanted to know, Andras linked to the docs and it made it seem like it is possible
 
4 hours ago, by Andras Deak -- Слава Україні
@Jake https://docs.python.org/3.11/tutorial/interpreter.html#source-code-encoding claims any codecs encoding is valid
 
?
 
10:53 AM
Hmm, guess I was wrong then
 
using other encoding does seem to make the syntax error go away, so at least the encoding comment works
 
The list of codecs is here but rot13 has its own section away from the others and states that it's not supported by str.encode so I'm guessing it was referring just to the list in my first link
 
could be, but I have no idea why they would remove something that worked in python2
 
You mean like a print statement?
 
well, I didnt consider that as removed, it just got a better version
 
11:01 AM
They considered it a "transcoder" and apparently it wasn't documented previously: bugs.python.org/issue21171
 
Python 2 strings were bytestrings per default, so python 3 brought lots of changes in regards to text and encodings
 
Perhaps there were weird edge cases with unicode source code
 
i have an actual question anyways, if I have foo which creates several intermediate dicts, what is the best way in which I can have these dict sent as an email, should I return these intermediate dicts and then use my mail function or should I call the mail function in foo?
I have a working mail function which dumps the dicts as a json
calling mail within foo seems like not following "a function must only do one thing"
but its a lot more readable
 
Separating data generation from IO is probably more maintainable if it doesn't make your logic too complex
 
Good day fellow overflowers, i'm new to programming in general so please bare with me. I have a python script with multiple functions, these functions are asking for input that then writes/appends to a .txt file - I'm trying to figure out a an function for a reset option. the reset option should flush all input given in previous functions. In python do i need to flush the variables or only "wipe" the .txt file of its information. The reset function will afterwards call the other functions again.
 
11:08 AM
@dekenzbre Hello. Sounds like you could add a function that's an entry point to your current code, calling the current code in a loop. If your current code wants to reset it just returns to the enclosing function.
 
@AndrasDeak--СлаваУкраїні I will take this into consideration
 
@Jake for instance if you start testing your code you wouldn't want the data generation test to try and send emails. You'd have to mock the email part for that test etc.
 
that is a fair point, did not think of this, returning it is the way then
 
Being able to write scripts in ROT-13 was a casualty of the Python 3 separation of str & bytes.
 
@AndrasDeak--СлаваУкраїні Thanks, so if i understood correctly i can only call the functions again but with 'w' instead of 'a' for the .txt file so it overwrites the current content inside that .txt file?
 
11:13 AM
@dekenzbre sorry, I have no idea how your text file interacts with your code and what exact mechanics you expect.
But in general if you want code to "reset" the easiest way is to tuck it all in a function and call the function anew. You'd have to write the function in a way that it cleans up after itself if it has to, obviously.
 
Yeah, it would help if we could see some code, just for demonstration purposes
 
or if you really had to I'm sure you could use a class to hold the state and purge it on demand...
 
It's unclear who opens the file and when/how the reset happens, etc
 
def GetName():
    while True:
        user_firstname = input('Please enter your first name: ')
        user_lastname = input('Please enter your last name: ')
        # if statement checks if the input given for user_firstname & user_lastname only contains alphabetic characters.(.isalpha)
        if user_firstname.isalpha() and user_lastname.isalpha():
            print('Thank you', user_firstname, user_lastname, ', your name has been registered.')
            # The .txt file will already have information in it, therefore we need to open it with "a"(append)
The input will be stored in a .txt file, i would like to be able to have code that clears the .txt file if that makes sense? :)
 
11:18 AM
If the text file will already have information in it, what does "clear the .txt file" mean?
Do you really mean "clear everything including whatever was in there before this function was called"?
Or do you always want to keep the contents from a single call to the function?
 
@Hakaishin well no, its just a different level of abstraction. "someone" has to deal with the ugliness of memory management, and rust decided to tackle UB in that specific lower level gnarly world that we pretend doesn't exist as we write python. The use case is just different. What's revolutionary is their approach to it, using ownership models.
 
Right, just delete the file with os.unlink or pathlib.Path.unlink. I'm not sure what you meant by "resetting variables", but I don't think you need to worry about that
 
When writing to files, there are 2 main strategies. 1) You can write stuff character by character, or line by line, or section by section, as you create it. 2) You build up everything in memory, and when it's complete you write it the file in a single write call. The second strategy is more flexible, but it consumes more RAM, and may not be practical if your file has gigabytes of data.
 
@AndrasDeak--СлаваУкраїні yes, i would like to remove everything from it so the user can enter new input there without there being a trace of what was there before
 
@dekenzbre when you call the function, is the file initially empty?
 
Ace
11:20 AM
im pretty sure you don't even need to delete the file
 
@AndrasDeak--СлаваУкраїні Not when i call the reset function that i want to code
 
Ace
if you just create file in w mode it will delete everything in it right
 
@dekenzbre sorry, I don't understand that reply
 
@ParitoshSingh It might be revolutionary, I can't judge since I never used it. Just from a user perspective and from a making real progress perspective I think languages should strive to be like python but fast. That's really the only thing python is missing. And I'm sure there is a way to do that, it's just that nobody has figured it out yet
 
Dont worry, you guys gave me much good information, thank you all!
 
11:22 AM
@Hakaishin yeah, rust aint trying to tackle this, though "people" sure seem to be trying to fit it anywhere they can for fun :P
 
@dekenzbre last advice: if you only need to keep the contents of the file from a single call to the function, open the file outside the infinite loop with 'w' mode. Then when you call the function you automatically wipe all earlier contents. And when you want to "reset" you return from the function and call it again.
that's my best guess based on available information
 
And i speculate the issue is probably one of traction also actually, python's so big that for anything only marginally better, why make the investment into leaving a fairly robust ecosystem
(eg nim comes to mind)
 
@ParitoshSingh But say you want to make a new project involving low level sensors like lasers and cameras would you chose rust or c++? Also I have never seen rust drivers for any of the sensors I work with. Can I simply use C++ drivers or do there need be rust drivers? Also ros doesn't support rust at all so to me it seems like rust is more of a toy project now than a real language I can just pick up and use
yeah my question goes kinda into the ecosystem direction
 
That's actually more so related to traction and ecosystem again i think. Rust is just new. but it's definitely got momentum, so there's a good chance it gets things like that sorted as adoption grows
Also, i personally probably would still end up using python (or micropython) first and foremost if im able to. python's just nice :P
the whole -use python as glue- really works in its favour for these kinds of use cases
 
12:03 PM
@Hakaishin Rust is able to use C and C++ ABIs/APIs. For example, there are Rust bindings for building CPython extension modules. AFAIK the interop is pretty straightforward, but I haven't used it myself.
 
@Hakaishin it's not really a toy language though you might struggle with some drivers. I took my heuristic solver as far as I reasonably could in numpy before I'm left with C, C++, Cython or Rust. Cython was a much easier sell internally but to get it on parity with hand-crafted code, it'd probably be just as alien to my colleagues as Rust in the first place, so I spent a lot of time angling internally for Rust
 
Since Rust defaults to using LLVM+C under the hood, interop is basically for free for them.
 
I see, interesting
 
FWIW, I haven't really seen it being talked about in the context that I want to use it but then I guess most scientific libraries are already well-embedded in C/C++ with python wrappers, and they're perfectly fine as they are. It's a bit different when I really work more in Operational Research under the title of Data Scientist, and roll most of my own heuristics from scratch
 
 
1 hour later…
1:17 PM
@dekenzbre You were correct when you said earlier that opening with "w" would create the file anew, while opening with "a" appends to the existing content. So one way to do what you want is to open the file for writing and immediately closing it again.
 
 
1 hour later…
2:24 PM
Client: "I would like the page to have three red lines. See the attached document for a mock-up."
[I open the document. It depicts four blue lines.]
Me: "... I'll get you those three red lines ASAP."
[I implement the three red lines feature. Time passes.]
Boss: "The page doesn't match the mock-up. Please fix it."
My suspicion is that the client really does want three red lines, and I can disregard the mock-up. I just need to play a few rounds of email tag before everyone agrees.
 
You really need to work on the entire "get three transcripts, signed in blood" part.
 
That reminds me of The Expert fredlybrand.com/2014/05/03/…
 
@PM2Ring You are most perceptive :-)
 
yes, the expert comes to mind
 
I count myself lucky that the line does not need to be in the shape of a cat. All the designs asked of me are possible, just not all at once.
 
2:33 PM
btw ubuntu 22.04 should release today, but it still says beta at the end. releases.ubuntu.com/22.04 Is this the proper official release and they just left the beta in the name or is this still the beta. I can't find proper information about this
 
I don't see "beta" on that page. Maybe your browser is showing you a cached version? Try shift-F5.
 
3:30 PM
wow it changed in the last few minutes
It wasn't cached it really just released, because I tried to just f5 the old open tab and it also switched. Maybe because of timezones it just released in the afternoon(EU)
have a nice one peeps
 
Kind of crazy how often all of these linux flavors release new versions. Rolling release is so much less of a hassle (at least for me as a user)
 
3:52 PM
I imagine that a project's release process becomes quite streamlined if they have to do it every day. That's beneficial to the end-user even if they only bother updating once a year.
 
4:11 PM
Every day seems a bit much...
 
The wheel that desires grease must be persistently squeaky
 
My manager expects me to share a new idea to the team every Wednesday, I am expiring my sick leaves on Wednesday because of this :P
bdw cbg :)
 
4:28 PM
My idea for next week: A bagel sandwich. Don't ask me to elaborate.
 
I bequeath unto you this idea: a text adventure with 1 additional spatial dimension. "Possible exits are: north, south, east, west, up, down, ana, kata"
Update from client: "I'm sure I want three lines, but now that you mention it, better make them blue". Now boss and client and me are on the same page, and thus I am at peace.
 
You can draw 7 mutually perpendicular lines in 7d space
 
Hepta-spaced
 
4:44 PM
Ana/kata won't cut it there. You'll also need strange/charm and kiki/bouba and yanny/laurel
 
Laurel
Wonder what are the difference in terms of the co ordinates
 
5:17 PM
The same as the difference between 2d coordinates and 3d ones. You just stick extra numbers in the tuple
 
5:56 PM
Or you choose a letter from the alphabet and write stuff like 2+5i
 
 
2 hours later…
7:49 PM
@holdenweb Thanks, I went with this option.
 
8:04 PM
Is floating point math always the same regardless of hardware? If you take any 2 PCs in the world and let them do floating point operations, will they always produce the exact same results?
 
@Aran-Fey nah
Or, well, if the two operations are the exact same: maybe? I think part of the problem is there's usually more than one operation, and their order can easily change across compilers and whatnot.
but if there's one recurring theme about hardware, it's "but there's that one weird architecture where..."
 
I found out about a video game that supposedly has 100% deterministic physics, and I've been wondering how the heck that's even possible
 
integer arithmetic under the hood?
Do they really claim 100% determinism across all possible machines? Not just within a given machine?
And, more importantly, can this claim be verified in any way?
 
@AndrasDeak--СлаваУкраїні Hmm. Possible
Alright, so, it's a racing game. Whenever you play a track, the game records your inputs and lets you save a replay. Other people can take your replay and verify its legitimacy on their own PC
 
ah
Do you think floating-point errors could lead to noticeable differences in replay?
I would expect that this would only happen in super edge cases. Like, speedrun hack level edge cases.
 
8:14 PM
Oh, the game has replay verification built in as a feature. It's not just a matter of looking at the replay and eyeballing it. If there's any difference at all, you'll know
 
I see
Out of curiosity, what does it verify against?
 
Ah. The replay contains both the player's inputs as well as the location+speed+etc of the car. So it simulates the inputs and checks if it matches the recorded data
 
Yeah, I wouldn't dare try and rely on that without emulating float arithmetic ourselves
unless the verification has granularity larger than machine precision
if you print with 1e-4 precision you can sweep 1e-10 relative error under the rug
 
Hmm, yeah, that's also possible
 
If I implemented something like this, I'd be tempted to correct my dead reckoning error at each verification point, ensuring that float errors only accumulate from one point to the next one.
 
8:23 PM
You mean after comparing the simulated values to the recorded values, you discard the simulated ones and use the recorded ones from that point on?
 
I imagine that would be tricky to implement. Would you really design a physics engine that can do that?
Well, then again, this whole thing is tricky to implement even if you do it some other way...
 
It wouldn't be the physics engine per se, just the verifier. It does its thing, evolves the simulation according to the inputs, reaches a verification point, notices that the relative error in position is 1e-10, ticks a box saying the replay is OK, then replaces the current value with the other one, 1e-10 relative error away. Then gets back to the physics engine.
the assumption being that if reference points are dense enough then legit errors will be so small that throwing away your error in the replay run is not noticeable in any way
Probably a lot more feasible than implementing your deterministic architecture- and compiler-agnostic floats. In terms of computational overhead too.
unless the racing game has the graphics of elastomania, 3d racing simulators these days probably can't afford to run on a virtual machine
(speaking on the grounds of "pulling things out of my butt")
 
@Aran-Fey What Andras said. However, it's extremely conmon these days for systems to adhere to the IEEE 754 standard. en.wikipedia.org/wiki/IEEE_754 So if you do an operation involving IEEE 754 binary64 (which is what Python floats use) on any conforming system the results will be identical if the systems use the same rounding options.
A conforming system doesn't have to provide all the IEEE 754 features, like all the different rounding options, or the signals that may be raised. The Python decimal module does all the stuff that a fully conforming system needs to do.
 
Actually, there's something that makes this unlikely. The players regularly abuse bugs in the physics engine, where they essentially crash into a wall going super fast and it launches them into the air with insane speed. Something like that could easily turn out very differently on someone else's PC
 
8:34 PM
@Aran-Fey yeah, that's the kind of speedrun hack level edge case I mentioned earlier
 
(i.e. different enough that verification of the replay would fail)
Integer math seems to be the most likely option
 
curious
Have you tried replaying speedruns on a raspberry pi? :P
apple M1 might be more plausible
 
I don't even play this game! I just watch hours and hours of youtube videos about it because they're so well-made
 
Some CPUs don't actually have an integer divide instruction, so all divisions are done with floats. Which makes integer division slower than float division. My ancient coding instinct find that difficult to cope with. :)
 
I guess it doesn't make much of a difference as long as the numbers are small enough to be accurately represented by a float?
 
8:48 PM
I don't think that's how floats work
There are floats, and there are gaps between floats. When you hit a gap you choose a representable float. The larger the numbers, the larger the gaps, but all sorts of numbers are not representable with floats. E.g. 0.3.
Question is what you mean by "doesn't make much of a difference"
 
Mostly. But you need to do your arithmetic so that errors don't accumulate too much. But there are well-known techniques for that when you're integrating equations of motion.
There's also the issue of catastrophic cancellation, but that shouldn't be much of an issue for a racing game. en.wikipedia.org/wiki/Catastrophic_cancellation
 
the best kind of cancellation
 
FWIW, the math module has a cumulative sum function, fsum, that's designed to minimise cumulative errors. docs.python.org/3/library/math.html#math.fsum "Avoids loss of precision by tracking multiple intermediate partial sums"
en.wikipedia.org/wiki/Loss_of_significance has more info on this topic, eg, rearranging computations to preserve precision.
In relativity, you often need to do stuff like y = 1 - sqrt(1-x), where x is small. If you do it in the naive way, you generally lose a ton of precision. But there are transformations that you can do to preserve the precision. I give an example here: physics.stackexchange.com/a/595175/123208
 
9:14 PM
everyone knows that 1 - sqrt(1 - x) = x/2
 
Sure. :) But you can get more precision, if you need it, with just a tiny bit of work.
One of the math.se mods, robjohn, wrote math libraries for Apple, back in the day. He knows all sorts of neat tricks for working with floats, and finding awesome approximations for functions.
 
 
1 hour later…
10:25 PM
Evening mateys
 
 
1 hour later…
11:42 PM
@Aran-Fey Ok but the editor/IDE may not necessarily know that, and mangle the UTF-8.
@AndrasDeak--СлаваУкраїні Obviously I do the basic stuff. My point was if the sites that pay for top-10 ranking to outdo SO have malware/misleading JS, that's grounds for getting them blacklisted by Google. As to what rj experienced: misleading JS masquerading as a captcha that tries to fool you into Allow notifications. If that comes from JS (could be third-party JS), filtering the site domain isn't going to detect it.
 

« first day (4205 days earlier)      last day (758 days later) »