« first day (4542 days earlier)      last day (389 days later) » 

5:35 AM
sigh
0
Q: Python - ModuleNotFoundError thrown when calling a function that imports another module in the same directory

alextcI have the following Python file structure. -- main.py -- scripts/ -- __init__.py -- helper_functions.py -- mytest.py mytest.py has the following function. def test(): print("test") helper_functions.py imports the mytest module and use the test function as import m...

I hate the import canonicals so much
this is the same sort of trivial debugging question we get constantly, but I can't find a proper fit
even though there are multiple questions with like thousands of upvotes each
in theory, stackoverflow.com/questions/4383571 should cover it. but look how bad it is
 
6:05 AM
Insofar as I can count myself a pythonista, I have been known to brute force my way through import logic. Do we have a "hit 'n' hope" answer in the pipeline?
 
6:17 AM
@Aran-Fey you monster. Wait till Andras finds out about what you've done :P
 
6:39 AM
We may not like walruses, but we shouldn't let them go extinct either. He's a scientist, he'll understand
...I hope. If not, maybe I'll go extinct soon
 
On the contrary, our media was tracking a walrus for like a month. We love walruses apparently. But it didn't wear a special "operator" hat, just lounged around on beaches and ruined our celebrations. Maybe it was a walrus operator after all...
 
It was canceled over one walrus?! O.o
 
Not any walrus. Thor. Have you no respect?
 
I'm not religious
 
6:56 AM
I mean, I totally suspect the council wanted to save the cash for a boozy evening, but I kinda like the charade that they did it for Thor. It's a fun twist to their tales
 
DB1 is Postgres (django), DB2 is Postgres (sqlalchemy FastAPI). The tables are slightly different. Is it possible to create a connection to DB1 with models that I define locally and don't have the foreign key relations?
 
7:12 AM
This is your question from a few days ago, reformulated? Two things stand out to me
1) You can get django to work with SQLA so you could standardise the models between them. 2) A website is just an API that happens to serve a HTML response. There's no reason to have them as separate services
If the argument is "FastAPI is faster than Django" gets raised, I have my shotgun ready to take that one down btw
 
@KarlKnechtel if it starts with "sigh" then please don't one-box it.
 
If you're literally stuck with two separate postgres DBs that are isolated but closely related (this is an issue) then I imagine you could use dbt to set up some kind of transfer pipeline but I can't say I've done it myself
 
wasn't intended
too easy to forget it's a "feature"
 
7:28 AM
If you put anything else in the message it won't onebox. And you can edit chat messages for 2 minutes.
 
@roganjosh yes. I managed to get some things done, but now i m looking into my options for the rest.
 
@Riya Cool. I was just making sure I had my context right, because the db was tiny IIRC and that means you can (hopefully) move a bit on this. My answers are different to someone who has 50 billion rows
 
Is it worth the effort to create the models? Or a simple dict mapping keys1 to keys2 is acceptable? I mean, are there any serious risks involved which mandate modeling?
Indeed the DB is tiny. Speed is no issue (except perhaps the fact i must use pagination when querying DB1).
 
Something seems fundamentally flawed in this design. I can see you spinning off an API service for high traffic (let's assume hundreds of thousands of calls a day) and you might want to containerise that and use kubernetes, while the website interface might get minimal traffic... but they'd still write to the same database
 
I didn't understand what you mean by that.
 
7:38 AM
You have two databases doing (as far as I can tell) almost the same thing, but with an arbitrary distinction between "API" and "Django" (which I'm taking to mean a user interface in the browser, primarily). Why two databases?
 
Moving to microservices. The django is DRF in particular. Indeed they'll be doing pretty much the same thing.
 
Oh my
 
That doesn't sound good :P
 
Microservices won't stop you using a single source of truth. You can get them reading and writing to the same storage
 
I think eventually DB1 will be made obsolete.
 
7:46 AM
Which is way more fault-tolerant than this hypothetical data transfer pipeline we're thinking about
@Riya That's surely a one-off move. Let's architect for the future :)
I'm a postgres fanboi and I've missed it dearly at my current job. Dare I say, it's web-scale. I would normalise the tables to take API and GUI inputs, and maybe there'll be things that need nulling in each case, but get the data in one place. You're creating a headache for yourself with this DB syncing design and hopefully you're early enough to change it
 
8:33 AM
Time to nuke this laptop from orbit :'( I wonder if I can charge them for electricity if I send it back to work fully charged?
 
8:52 AM
I am trying to validate the integrity of my data so between and within each .csv files there shouldn't be any duplicates (completely the same rows or based on a subset of a couple columns). I noticed there is about a 1% duplicate rate and want to inspect further. What's the best way to approach this? Only thing I can think of if look at the data with duplicates and manually filter them.
 
Pandas has a drop_duplicates function, or you UPSERT into SQL or... probably lots of other ways to do it
 
I did do drop duplicates but I had like 380,000 data points and there were 10,000 duplicates. Which shouldn't even have been there in the first place
Just want to know what is wrong with the data so I was hoping to see them visually
Enumerating each file and which files they duplicate with seems to be a little complicated to do not sure how it is done normally
Oh around 4,500 duplicates but still trying ways to make sure the data isn't going to cause problems
 
9:22 AM
Question: Why are the sums of randomly rolled dice in Python always 7?
Related questions:
1. What are metaclasses in Python?
2. What's the canonical way to check for type in Python?
3. What does the "yield" keyword do in Python?
Go home SO, you're drunk
 
MetaClasses are the answer to everything.
type(type(42))
 
Is github's copilot X worth it over getting the $20 gpt-4 via chatgpt? It does help me speed up development and learning in python even if it's not that perfect yet anyone tried using both?
 
9:50 AM
Okay apparently I had duplicated files on a different subdirectory containing the same data which I downloaded years before which was included in the merging due to using the wrong path. I was able to find after being able to visually inspect the full paths of the duplicated files. Took a while for gpt-4 to give me something that works but it did the job
 
10:35 AM
Shame it didn't read the room rules and post it off-site for you
 
11:19 AM
Are there python programs that aren't too big and are golden standards in terms of programming style/technique/form? I'm a beginner looking to improve my code quality/form
 
12:06 PM
requests is generally regarded as being "pythonic". Flask code is more complicated (IMO) and pushes the boundaries of inheritance, but I really like reading it
 
12:30 PM
Hello
Greetings of the day.
 
1:16 PM
at roganjosh: thanks for the suggestion!
 
1:32 PM
@Pherdindy That sounds like a tedious way to program
 
Actually for my level it's much more beneficial since it does give useful things than doing a search in the forums or google
It would normally talk me hours to days and it won't even work if I did it lol
 
Well, did you actually learn something from the code you got so that you can do it better next time?
 
I did especially when I ask it to make charts and make other useful things
It does tell me which libraries to use and makes them usable for me
Normally it'd take a long time to learn the basics of a new library and don't really got the time to do it myself so my progress is really slow
Expecting fast improvement on the AIs in the coming years so hoping most of the syntax will be mostly done by the software soon so can focus efforts on the results more than the designing process
 
1:58 PM
@Pherdindy Depending on how the lawsuits go. Copyright is such an interesting topic, I can see arguments for both sides and I really wish there would be a nice win-win solution for everybody. But such a solution seems to be nowhere in sight
 
I remember I was scriptwriting 2 years back and I had to spent days to come up with a catchy 150 word script for 7 of my products
Took me days and had to hire a freelancer to help me write them now AIs can write em in seconds
But true copyright issues is a problem since everyone will be claiming it is their work
Pretty sure by this time a lot of freelancers will be abusing gpt-4s work and selling them to people in Fiverr/Upwork as we speak
 
GPTZero FTW!
 
I hope AI forces schools to rethink how they do homework and exams
 
I, For One, Welcome Our New Insect Overlords.
 
Although really great stuff. Really that i'm actually able to get something that I can use without spending such a long time. Honestly i've never gotten a program working so well and quickly too
Even though it messes up quite a bit it just takes a bit of tweaking
 
Back in my day we cargo culted with our own hands
7
 
2:28 PM
It can't be wrong if the majority of the internet does it.
 
2:50 PM
Can't wait for the perfect waifu in the form of a robot
 
3:46 PM
@Aran-Fey One of my teachers spoke about how everyone needs to learn how to properly use AI, so teachers should help assign homework that lets them learn use AI properly. Obviously, he also said that AI shouldn't be used for cheating purposes.
@Pherdindy chatgpt at least notes that anything generated is our content. OpenAI doesn't claim them. Idk about the other gpt versions or other ais
 
The copyright issue is not about "written by chatgpt". It's about the copyright of the code the systems are trained on, and that they reproduce.
 
Some of the smaller SE sites such as law and ai have pretty interesting background discussions of those topics.
 
>>> asyncio.run(asyncio.sleep(1))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  [snip]
  File "C:\Python311\Lib\socket.py", line 633, in socketpair
    lsock.bind((host, 0))
OSError: [WinError 10055] An operation on a socket could not be performed because the system lacked sufficient buffer space or because a queue was full
asyncio is such a mess under the hood >_>
 
4:08 PM
windows is such a mess under the hood >_>
Honestly though, asyncio on windows is scary brittle.
It's pretty clear what most asyncio devs are working on and Windows it ain't.
 
 
4 hours later…
7:51 PM
@AndrasDeak--СлаваУкраїні ChatGPT is the best cargo-culter on the planet.
@AndrasDeak--СлаваУкраїні It's tricky, because GPT isn't exactly copying stuff, it's stochastically regenerating it. I guess you could say it's "merely" decompressing it from a fancy file format with a ~56 compression ratio. Sometimes it regenerates long passages perfectly, but it's much more likely to produce something that only locally matches its training data
 
It's easier to just say it's not true
 
Our copyright law, and our attitudes towards content creation have never had to deal with something like ChatGPT before. I don't know what the solution is. I think it's too early to figure out how we're going to deal with this stuff. I feel like we're horse & buggy experts trying to make decisions about the impact of the internal combustion engine...
 
8:17 PM
@roganjosh Sorry, I'm not sure what you're trying to say.
 
8:53 PM
Uhh.
I just realized something. This is pretty bad.
Probably tons of questions get closed as dupes for the "how can I read inputs as numbers" canonical where the question is really about how to handle the exception for non-numeric input.
and the answers don't actually cover that.
 
I'll try not to let that keep me up tonight
 

« first day (4542 days earlier)      last day (389 days later) »