« first day (4524 days earlier)      last day (425 days later) » 

1:22 AM
@AndrasDeak--СлаваУкраїні well, I'm also running Mint, and in the system Python there is a turtle in the standard library, even though there is no tkinter (and it will fail with a different error messsage)
and in the other question I found, stackoverflow.com/questions/65252348 , OP is running a different linux distribution and has the same problem importing turtle. AFAICT, the common denominator is PyCharm.
especially since that OP did install python3-tk and it didn't resolve the problem.
 
1:35 AM
Build your own Python version using the commands from build-python-from-source.com - if you select "OS-Related Stuff/install required OS packages and development tools", you get these bits installed:
sudo apt-get install -y make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev xz-utils tk-dev liblzma-dev tk-dev
which should give you the Tcl/Tk tkinter stuff.
 
weirdly, this 2014 Stack Overflow question and this Reddit /r/learnpython post seem to involve identical code, down to the variable names. I assume there is a specific tutorial out there
er, not identical at all, but it's curious that both chose to name the screen instance wn and the turtle instance alex
 
searching for "alex.forward(150)" on search engines brought some results
 
interesting.
 
it's quite possibly sourced from a book
 
It seems there's a separate issue caused by some interface Pycharm provides for installing packages.
 
1:41 AM
PyCharm's in-IDE Terminal tab also has a setting to enable/disable improved terminal emulation.
 
which is nice when you don't want to have to think about how pip works, but bad when you want to use the standard library turtle, Pycharm apparently creates environments that don't have turtle.py even though tkinter is available, and someone put a package on PyPI named turtle
(that is, of course, completely unrelated)
(I guess we should count our blessings that it doesn't appear to be malware.)
 
^^ The checkbox "Enable terminal in output console"
Pretty terminal output like rich isn't so good unless you check this box
 
oh, and this PyPI package is 2.x code, which produces distinctive error messages (a syntax error because of old-style excepts)
@metatoaster it does, but these results don't seem to offer much insight
 
books.google.com does not return anything either
 
1:56 AM
sometimes people also have a shadowing problem: python-forum.io/thread-1194.html
but I really do think there's something Pycharm-specific as well
trying to read through stuff like intellij-support.jetbrains.com/hc/en-us/community/posts/… makes me want to do horrible things
 
@metatoaster Let's keep terminology clear: it misunderstood the difference between "geocoding" and "reverse phone lookup"; it didn't make something untrue up out of thin air like "Tasmania does not exist". (Not every article on the internet is true or correct or useful; if it actually provided citations, we could see where the misunderstanding originated.)
...whether sources are reliable (on a specific topic) is not a simple binary. We might expect improvements on assessing and scoring that. Even tabloid newspaper headlines (and the pressure for brevity to reduce nuanced explanations to "X causes Y" are a good everyday illustration of that.)
 
After extensive searching, I don't think I can find a reproduction of the error persisting after installing python3-tk except perhaps in an environment that was created before that installation
My assumption here is that python3-tk works by ensuring there is a Tcl/Tk installation, and then updating the system Python to have _tkinter, tkinter, turtle etc.
It does appear that some tkinter-less implementations omit turtle, and others leave it in (even though it can't work) superuser.com/questions/1510911/…
It's really unfortunate that tutorials like e.g. realpython.com/beginners-guide-python-turtle don't seem to know that tkinter might not be available.
it's also really unfortunate that PyPI allowed a package named turtle to be hosted and doesn't seem to care that the current version is 0.0.2, last updated in 2009.
 
2:16 AM
@metatoaster Sorry, you're right, I'm wrong. I'm behind the times: Oceania Always at War with Eastasia: Generative AI and Knowledge Pollution (bigmessowires.com)
 
I also asked unix.stackexchange.com/questions/738583/… over on unix.SE, related to the general topic.
stackoverflow.com/questions/15286441/python-tkinter-turtle Well, we have a source for the "alex" code at least
 
yeah, things like ChatGPT changes the "knowledge landscape" in such a way that it makes it so much more difficult for those lacking in critical thinking skills to be able to tell fact from fiction, when facts can simply laundered and be spat back out in a form that may be confidently misleading
basically, yes, knowledge pollution
also, ChatGPT does not understand nor misunderstand anything - it simply generates new text based on existing texts as per its model.
 
you find some amazing red herrings here. For example pypi.org/project/Everything-Tkinter literally just defines some constants.
> Weirdly enough, people seem to view this only from one side: "ChatGPT is an expert at lying!". Actually, it was explicitly instructed to sound confident, serious and expertly. The important thing here is: to most people, it is enough to sound like that in order to make them believe. This heuristic is trivial to hack, gets exploited not just by ChatBots and is downright dangerous on a societal level.

> Acquiring and vetting information is a task of crucial importance situated in between journalism and science. Just trawling the internet and autocompleting the acquired driftwood is a weird
of course, everyone else in the ensuing discussion cannot resist injecting their personal political biases and hobby-horses.
 
2:56 AM
@KarlKnechtel Sure, but Sokal and Bricmont (and other hoaxers) previously proved that with papers and journals that given a small amount of social proof, audiences would accept plausible disinformation or nonsense. Now GPT can produce disinformation and fake-news at scale, up-to-the-minute, 24/7/365. The "good news" is we don't have the luxury of time to worry about perfect solutions; this clearly has the potential to taint college exams and papers, college acceptances, the 2024 US election etc.
 
3:31 AM
the infamy of the sokal hoax makes it that much stranger that people didn't raise the alarm about this sooner.
I didn't think of it, either. maddening.
 
4:04 AM
... I'm starting to think that some people are writing questions normally, and then using ChatGPT to generate responses to comment feedback.
 
 
4 hours later…
7:37 AM
@KarlKnechtel What, in SO comments? Why would anyone bother to do that though?
 
8:00 AM
I have no idea what would motivate someone to do that; nevertheless, some comment exchanges I've had lately just feel that way.
stackoverflow.com/questions/26920955 This question is now clickbaiting away from any sort of canonical about list[int] vs typing.List[int]. The original problem is effectively a typo; OP tries to index a dict before creating it, but also is shadowing it
 
 
2 hours later…
9:52 AM
In our code base, I am able to track when the object of a certain python class is initiated (the constructor call ) including from which file name and line number in that file. In a similar way is it possible to track a destructor call to delete an object?

Thanks
 
Destructors don't have explicit calls
Or rather, usually they don't
 
__del__ is the closest to a destructor.
But they are called by the GC, so a) they aren't related to a specific file name/line and b) may be arbitrarily delayed after going out of scope.
 
You really shouldn't find yourself in a spot where you need to track an object's destruction, unless you are optimising every bit of memory used by your program
 
@matszwecja Thanks for your quick response. We are working on an embedded chip (IoT device) where we can make only 30 database connections, so we are able to track the DB Object (DB class) which initiates the database connection but many times database connection pool gets exhausted and we want to track the when it is deleted?
 
That sounds like the job for a semaphore, not constructor/destructor tracing...
 
10:04 AM
@KarlKnechtel this isn't really a problem. I mean, it's mostly because of linux distros's packaging systems. Some include/link tkinter libs with python on installation, some do not. I know that the executable on Python's official site does indeed include tkinter if anything
@KarlKnechtel this might be a reference to this story: amazon.com/Alex-turtle-Ivan-Leon-ebook/dp/B072KM23XY
 
@MisterMiyagi Thanks for your response, Let me see the term Semaphore. Thanks once again.
 
The usual strategy to ensure that a resource (like a database connection) is closed when you no longer need it is using the with statement
 
No, with doesn't close the database connection
I thought you would have seen at least one of my rants about this by now :D
 
Then make your own context manager that closes it ¯\_(ツ)_/¯
 
Dec 2, 2022 at 11:58, by roganjosh
It's my biggest gripe with the DB API. I not only brought our central stack down, but I'd recruited people to help me as "good practice". Once you have a stray conn in a webapp, it'll swamp the cluster very quickly
 
10:15 AM
@KarlKnechtel that might be because the virtualenv (usually used by pycharm by default unless you configure that) might not have access to the "now" installed python3-tk package
if not that, maybe some other path/symlink shenanigans. I bet on the former however
 
There's also a warning about it in the psycopg2 docs but it just goes under most people's radars because of course the context manager would close the resource.... except it doesn't :'(
 
@metatoaster I don't know if you saw my last ping to you, but I was curious in knowing what you had to say about it :)
 
I've got a weird issue. Starting Flask app does not fail when I already have running instance on the same port. Both keep running and only one receives requests.
 
It's not just flask that can do this. I've spawned multiple instances of OSRM servers by accident and it didn't complain about port conflicts. I have no idea what happens to allow this of course, but it's not limited to Flask
 
@roganjosh That's why we always roll out our own abstraction... :head-shake:
FWIW, I've recently stumbled over an interesting blog on backpressure in async code which would map closely to such "limited DB session" designs.
And as far as I can tell, Python default design pattern for such back pressure is... 🤷‍♂️
So, has anyone come across a good design that a) limits the number of sessions and b) offers good feedback on whether it would block or not and when it wouldn't block or not and whathaveyou?
 
10:29 AM
@roganjosh You think it could be related to corporate network doing weird shenanigans with port redirects?
 
Hmmm, my immediate reaction was "no" because I generally work at home. But now you've got me thinking about the fact that I might have been on our corporate VPN in the instances it has happened and just never thought to investigate that angle
I'm relatively convinced you can get docker to trample its own ports without any voodoo simply because of the way they get bridged to the main OS and it just says "meh" and runs the service with no connection possibility. But when it's outside of Docker, I've never had a good understanding of how it happens
 
10:45 AM
@MisterMiyagi admittedly I've only skimmed that doc for now (I intend to read in detail) but it looks like it's all directed at what your code can do. Well, all of our problems stemmed from roganjosh trying to be a helpful citizen using context managers on a shared resource. You only need 1 dodgy client to bring it down for everyone. The only way would be to have a broker in the middle?
The only time it's been an issue with me is on Redshift and I'm not aware of any reporting mechanism that would give you backpressure. It'll just keep gobbling up connections until all 500 connections are consumed, and it'll gladly take some misguided crossjoin creating literally trillions of rows in a single query, and just bork the system for everyone else. Even when it sits at 100% CPU, it'll take more connections that can't do anything
 
It's good* to see we are having the same problems for entirely different usecases. ^^
If we introduce a broker, then how does the client work with that? Does it just block and back-pressure all the way to the user? Does it sleep (when, how, for how long, with a reservation, ...)? So many questions...
 
11:23 AM
There's a few things I guess it could do without me wanting to strangle the broker; the first being just to proxy everything through until > 2/3 of the connection pool was consumed. Beyond that point, I guess it could monitor query run times and kill them if needed (based on some cluster usage pct?) or send a back-off signal to the client which they would have to then handle in their own code somehow
It feels like a lot of bureaucracy and annoyingness. At the same time, we have a cluster that just silently fails probably at least once a week and maybe we're just desensitised to how bad that actually is
The more I think about it, the weirder it becomes. Usually when we have something locking the cluster, the client code goes berserk and just keeps submitting the same query that locked it in the first place, and you have to clear like 40 copies of it from the queue. Somehow that seems less obnoxious than a broker telling me what I can and cannot do. Stockholm Syndrome to the RDBMS :(
 
 
1 hour later…
1:35 PM
Why does set automatically order negative answers to the end? context
 
I don't think it does. Even if it's consistent behaviour now, it'll be an implementation detail?
 
a = [-5, -4, -3, -2, -1, 0, 1, 2, 3, 5, 7, 10]
b = {*a}
print(b) #{0, 1, 2, 3, 5, 7, 10, -1, -5, -4, -3, -2}
Here's an example without as much code golfery
 
I suspect there's a modulo operation somewhere inside the set implementation. It probably has a certain number of "bins" available, and puts each value into bin number hash(value) % number_of_bins
The hash of a negative number is negative, but then becomes positive because of the modulo
>>> hash(3) % 10
3
>>> hash(-3) % 10
7
-1 is an outlier for some reason, but all other numbers have ascending hashes
>>> set(range(-5, 5))
{0, 1, 2, 3, 4, -1, -5, -4, -3, -2}
>>> [hash(n) % 100 for n in _]
[0, 1, 2, 3, 4, 98, 95, 96, 97, 98]
 
the only related SO post I could find about this: stackoverflow.com/questions/68549755/…
Only the OP seems to mention this behavior hmm
 
set's don't have a defined order but seems to reliably be printing negative answers later
 
1:49 PM
this reminds me of the one or two list's "hidden" feature, or at least not documented we mentioned last time
 
"this behavior seems to be consistent" is not contradictory to "this behavior is undefined"
 
I can imagine some people on codegolf abusing using this feature to make smaller code
 
well it happened xd
 
Incidentally that code golf answer works whether or not negative numbers have predictable ordering in sets
 
wdym
 
1:58 PM
In the expression [*{*range(len(a)+2)}-{*a}], the operator "-" doesn't care about the order of elements in its right operand. Whether negative numbers appear at the end of a, or at the beginning of a, or anywhere else in a, makes no difference
 
Oh that's true. I had originally used ^ which needed to make sure that negative numbers were gone....
 
The answer does seem to depend on the ordering of non-negative integers, however. It assumes that {0,1,2,3,4} - {1,2,3} always gives {0,4} and never gives {4,0}
 
Would sets order by hashes?
 
I expect hashes have something to do with it.
The fact that hash(0) == 0 is probably significant here
 
As Aran mentioned earlier, it would make sense if it was hashes
 
2:07 PM
notably, the word "hash" appears 168 times
 
Weird, the hash for -1 is the same as -2
 
don't know about that, but seems like the following line(s) explain why "-1 is an outlier" as previously pointed by Aran earlier: github.com/python/cpython/blob/main/Objects/setobject.c#L349
 
AFAIK PM2Ring had some nice plots on how numbers map to hashes.
The modulo is pretty well visible.
Note that -1 is the canonical C error value, so it's not a valid hash.
 
that explain it, yeah
 
Note also hash(x + 2**64 - 8) == hash(x) for integers other than -1 (or those modulo -1).
(On a 64-bit CPython build)
 
2:29 PM
if not, this is the best candidate at least
 
Yes, those are the ones I had in mind.
 
didn't find the full code for it yet, but I think this is a part of it: chat.stackoverflow.com/transcript/message/43396998#43396998
 
 
2 hours later…
4:13 PM
The hash algorithm for numbers is described at github.com/python/cpython/blob/…. Also of interest: the ~4 sections of the code that check if the hash for an object is -1, and change it to -2
 
You can't reverse the hash algorithm right?
 
Only bijective functions are reversible, and no useful hash function is bijective
 
bijective?
 
injective and surjective, duh
 
No idea what any of those are.
 
4:17 PM
For every distinct input, there is a distinct output. As a simple example, we know Python's hash is not bijective because the distinct inputs -1 and -2 have the same output
Keep in mind that "this function is not reversible" is not the same as "given the output of this function, no information can be deduced about its input".
Even though Python's hash is not reversible, you can still make some deductions. If hash(x) == -2, you can reasonably guess that x is not 3 or 4 or 5 or any of the other small integers whose hash is known not to be -2.
 
bijection also implies that for every distinct output there's an input
 
Yes
 
i.e. one to one correspondence between two sets
 
I'm not well-acquainted with the topic, but I believe "cryptographic hashes" try to make it hard to make any useful deductions about its behavior. Python's hash is not a cryptographic hash.
 
I think part of the cryptoness is that small changes in the input lead to a large change in the output
clearly one should use a hash based on a chaotic double pendulum
 
4:24 PM
I would like to invest in your pendulum idea
 
4:51 PM
@harold: -1 is reserved for an error indicator. It's an invalid hash value. Python will even automatically change your hash if you try to return -1 from a __hash__ method you write, but classes written in C have to manually avoid returning -1. — user2357112 Dec 16, 2022 at 10:24
I'm pretty sure that Raymond Hettinger discusses this somewhere...
Since Python 3.4, the system hash function is SipHash en.wikipedia.org/wiki/SipHash Although it's certainly not a crypto hash function it's getting close. ;) And Daniel Bernstein, one of its designers, has created some very strong algorithms that are heavily used in crypto.
 
 
3 hours later…
7:44 PM
@tripleee sorry, what is "ckaruty"? could you clarify that ;)
@NordineLotfi yes. depending on the platform and/or command line flags, virtualenvs will copy stuff at creation rather than symlinking, and installing a system package will directly modify the system python without heed to a venv being active. From the question I asked, it appears that this package effectively does what a pip install would (if it existed): it adds a binary .so/DLL for the C-level interface (which implements import _tkinter, the corresponding wrapper .py files, and some extra doc
("the question I asked" on unix.SE: unix.stackexchange.com/questions/738583)
@PM2Ring there's a canonical somewhere that talks about integers hashing to themselves, except for -1
@NordineLotfi I doubt it. That seems to be showing a publication date of 2017, and many of these questions are older
 
8:21 PM
@PM2Ring do you happen to have the code for the avalanche effect that you used here: chat.stackoverflow.com/transcript/message/56060290#56060290
if not it's fine, just curious
@KarlKnechtel yeah, that's the usual behvior I think. Nice question btw
@KarlKnechtel I didn't mean to say this was the main culprit, just that there seems to be a correlation with the name "alex" for the question on SO (about turtle and tkinter related question) and the story "alex the turtle". The one I linked is one of many I think (there are other books/title for alex the turtle but I couldn't find the original story (yet))
as you said earlier too, I guess the main culprit might be some popular tutorial or books/courses that introduce this as a naming scheme
 
9:16 PM
Using python-shout when i run s.open() then -> *** buffer overflow detected ***: terminated, under msys2.
 
@ChrisP as usual, please come back with an MCVE
 
10:19 PM
@NordineLotfi I mean, chat bots are generally "dumb" and can only deal with context (in the data) that they have been explicitly presented, I have nothing really more to add to the technical explanation
 
I see. I agree with that (and that's also what I said myself over the course of 3-4 months or so) but just was curious to see if you had anything else to say about it
 

« first day (4524 days earlier)      last day (425 days later) »