« first day (4431 days earlier)      last day (510 days later) » 

4:18 AM
how did that thing end up with multiple upvotes?
 
 
1 hour later…
5:42 AM
Hi, I have an install issue on a mac...I wanted to try out python3.11 so I decided to brew install python@3.11. Somehow this has broken my install of jupyter (/usr/local/bin/jupyter: bad interpreter: /usr/local/opt/python/bin/python3.7: no such file or directory) which I at this point cannot remember how I installed, maybe through some terminal command? At this point I think I'd be happy with a clean uninstall, at which point I will probably install anaconda.
Question I guess is...any tips to find where jupyter is installed to properly uninstall? Or if you think I should properly format into a question on SO, please say so. Thanks in advance for any help!
 
 
2 hours later…
7:53 AM
@CalvinKhor You should be able to pass a virtualenv to jupyter
 
@roganjosh thanks, i'm not sure what a virtualenv tho is so i'll begin googling. I cant figure out where jupyter or numpy or any of the other things are; I don't see them in e.g. pip3 list
 
It might just be a python package. It's distributed in a few ways these days, it could also be part of anaconda. I don't use it unless forced so it's been many years. But you should be able to create a directory you want to work in and open a terminal there. Then do:
python3 -m pip install virtualenv
python3 -m virtualenv env
virtualenv env
source env/bin/activate
Then follow this
But you should also read up on virtual environments anyway as it's really good practice to not get things broken like this. I have ~20 projects locally but I always know that as soon as I get in their root directory, I can source env/bin/activate and I have an entirely isolated environment from the system that has all the libraries needed for that project. Once you're done, type deactivate, move to the next project, rinse/repeat
 
ok great, ill give that a go. I originally installed python quite a while ago (hence v3.7) and do not remember how I did it.
yeah that sounds brill. learning from experience i guess :) should I not worry about trying to find and then uninstall the jupyter i currently have, before following the instructions to install jupyter?
 
 
2 hours later…
9:36 AM
@CalvinKhor Yes, then you just launch jupyter-lab that is independent from other projects. You can have multiple "installations"
 
9:47 AM
ok, sounds good! thanks a lot
 
10:18 AM
Oops, just realised that the 3rd line is completely superfluous and may even fail. You only need lines 1, 2 and 4 sorry
 
10:49 AM
Using __slots__ for loading argument of a class is clever :o didn't know you could do that
 
 
1 hour later…
12:10 PM
@NordineLotfi because trying to increment a binary float to some decimal place is inherently confusing what the number systems mean. It’s like asking why it is so hard to accurately increment one meter by steps of inches.
 
I have a function with 6 parameters where the return type depends on the value of a parameter, so I need to @typing.overload it. Do I have to list and annotate all 6 parameters in every overload? Or is there some kind of shorthand for overloading only a single parameter?
 
@MisterMiyagi I mean, I understand the majority of people probably don't use floats the way I want to use them, but incrementing floats that way is supported by a lot of libraries (eg: tkinter using the alpha attribute, let you use "1.0", "1.1", etc)
I saw a couple post on SO that didn't really answer this, but mentioned incrementing floats using a specified precision (eg: using 1.XX, instead of 1.XXX, etc), so this isn't that weird, I think, just not part of the major use-case
 
You're doing it wrong, that's not a float, that's two ints separated by a dot
 
I mean that's what a float is. The only difference is that there a signification for the precision/whatever is after the dot. For example, 1.XXX has a totally different meaning compared to 1.XXXX, etc
I'm not actually saying this is what a float is, as I'm well aware of how computers use floats internally (based on public documentation at least). What I'm saying only applies conceptually, I think
(I feel like what I said above might look unhinged to people who use floats in their field of work...hopefully this doesn't sound too bad)
 
12:28 PM
Hi
I have the following problem
my question is
What mathematical operation should be done so that the other numbers decrease their value exponentially in each iteration? Then said function by which the number is going to be multiplied must take a different value because two will decrease faster than 10
 
just a tip, but it's better if you post code as text instead of images (unless it's large code, then post it on an external paste link)
 
decrease exponentially until it reaches its minimum value.
 
This is looking an awful lot like homework. Please also see our formatting guide and post code appropriately, not as images
 
import numpy as np
decrement = 0.9

numbers = np.arange(1,10)
minimo = np.amin(numbers)
for _ in range(1000):
  #mathematical operation
  pass
 
I honestly also don't follow the question
 
12:34 PM
Words more words less, decrease the variable decrease in each iteration to later apply some mathematical formula that makes me converge the other values ​​to their minimum value
 
... how have I just found myself looking online at macbook prices? Something has gone terribly wrong
 
I thought you had enough cores :P
 
In terms of work stuff, indeed. I don't really have space for a tower but sitting here with my 17" monster laptop digging into my leg through poor design (the hinge at the bottom of the screen is off-set such that opening the screen lifts it off the desk to give it ventilation. It also serves at the most ridiculously uncomfortable feature with the screen digging int your knees
 
@Jred0n29 Yeah, I also don't understand the question. What are "the other numbers"? What is decrement? What is minimo?
 
@roganjosh ah, I know what you mean. I don't have one of those but I saw people using them, and it felt uncomfortable for them, at times
it does look cool, but your knees probably have a different opinion
 
12:46 PM
@Aran-Fey I will formulate the question better
 
It weighs far too much. It's a "laptop" in the sense that you can fold it up and move it somewhere, but you definitely can't use it properly without a work surface. At the time my old laptop broke and the cost jump for smaller form factors at this spec was just ridiculous, so I settled for something I really didn't like :'(
 
Hello everyone, I have the following situation:
I have a vector of 9 elements from 1 to 10.
Next step I identify the minimum value of the vector, in order to create a loop to decrease the other values ​​exponentially
But the point is that for them to converge "gradually" the value of the variable "decrease" would not have to be the same for all
And that's where my question comes from.
What mathematical expression would you have to use to modify the value of the variable "Decrement" in such a way that when reaching the last iterations there is a minimum standard deviation?
Code
import numpy as np
decrement = 0.9

numbers = np.arange(1,10)
minimo = np.amin(numbers)
for _ in range(1000):
  #mathematical operation
  pass
 
@roganjosh yeah, I noticed the same thing too about small form factor (or SFF for people who know). The smaller it is, even for the same performance as the bulkier version, the pricier it usually is. Just looking at SFF motherboards, you can notice they cost way more while being less effective, depending on the brand, compared to the normal motherboards
 
To minimize the standard deviation, all the numbers have to be equal, right? So just apply the mathematical operation number = number * 0 to each number?
Ah, I forgot you need exponential shrinkage, not instantaneous. Not entirely sure what that means, to be honest. Is number = number ** (1/2) exponential?
 
1:12 PM
no, it could not be as you propose since the values ​​are totally different, so they will not converge to the minimum value, but rather they will continue to drop more and more
 
Isn't that what it means to converge?
The more iterations you execute, the closer the numbers get to 1
 
remember that you cannot go beyond the minimum value of the vector, you should try what you propose and you will notice that it does not comply with what was stated in my statement
now what if they are not integers but randomly generated numbers between 0 and 1 and you want to converge to the minimum
 
Nah, I'm not gonna write the code for that
 
I guess this is what you mean by that: stackoverflow.com/questions/34141798/…
see the answers on the post, might be related
 
1:32 PM
this sounds like you have a math question, not a programming question.
 
 
1 hour later…
3:00 PM
@NordineLotfi No. This is something that floats are fundamentally not made for. The decimal representation of floats is only an approximation so defining anything "precisely" with float decimals is futile. Floats just don't have a decimal precision.
There's a reason that decimal and arbitrary precision types such as Fraction prefer strings to floats.
If a float has to represent all numbers of a given decimal precision it can also represent some higher-precision numbers.
If it is limited to only numbers of a given decimal precision it cannot represent all of them.
 
@PM2Ring I saw, very sad :( I was never exposed to her solo work, but knew of her through Fleetwood Mac's hits. Plenty of great memories related to Rumours+Tango in the Night. This is a great cover— the intro reminds me of FM's instrumental song Albatross.
 
@MisterMiyagi I know, but I meant what I said mostly for 1.0 -> 1.1. I mean I'm not trying to get the most precise and longest float possible, so I think this is probably fair
 
 
3 hours later…
6:01 PM
Heyo, I'm messing around with the timeit library and I want to time a function I just imported. This function does require an argument so how would I time this?
 
@12944qwerty you want to time to import function ? or time to load function call ? or time to do function excecution ?
 
execution
oh wait, lemme try specifying the globals arg
it worked nvm
lol
 
1578
Q: How do I get time of a Python program's execution?

john2xI have a command line program in Python that takes a while to finish. I want to know the exact time it takes to finish running. I've looked at the timeit module, but it seems it's only for small snippets of code. I want to time the whole program.

 
timeit gives more accurate timings
 
That doesn't answer the question. They are looking to use timeit not find a way to avoid using it
This is where iPython made me lazy. I've forgotten how to do it without magic methods :/
Something like this?
 
6:11 PM
That would work
but I just did
time1 = timeit('part1(data)', number=1000, globals=globals())
Any idea how to get the return value of the function though?
 
Why would you want the return value from a speed test?
 
This is also for aoc, I need the answer. Speed test is just because I want it
 
Either the function would be deterministic for its inputs, in which case you'd just run it normally, or it's non-deterministic and... you'd still run it normally in a loop
 
@12944qwerty what is aoc ?
 
advent of code
I run it again, but when the function starts getting slower, might as well just have the answer already stored from the timeit
 
6:14 PM
Are you doing this as part of an exercise to optimise your code?
 
Yes
 
In which case I would suggest using line_profiler to give you better insight into the bottlenecks of the code. Also, it uses a decorator so you can profile the functions all at once
That will give you a line-by-line breakdown of the runtime for everything during "normal" operation (I say that because obviously there will be some overhead from the fact you're now tracking something you weren't before)
 
Nice. I'll look at it
Side note
Do you know a way to clean this up?
arguments is from ArgParser btw
 
I have no idea at all what that's doing sorry
 
That's fine
 
6:22 PM
Surely the way to clean it up is just to import normally without the dunder?
Ah, ok, I think I understand a bit better what you're doing here, but everything I read suggests importlib, though I don't have an implementation idea handy right now. Someone else might be able to help
 
6:36 PM
The module name is a number? I'm surprised that works
 
 
1 hour later…
7:43 PM
Hmm, did Windows 10 always have to option to open a Linux shell in a directory? I don't remember that option, only powershell
I knew about WSL but I thought it was more isolated than that. Either they improved it in some update or I just wasn't paying attention I guess
 
@roganjosh if you have WSL enabled somehow, then it will probably add that option to the context menu
or maybe it's something else that you installed that somehow made that context menu/option available
 
8:35 PM
stackoverflow.com/questions/74669978 This seems clear enough, but don't we have a duplicate for it?
 
@Aran-Fey me too, the folder is 2022 so
@roganjosh I did look at importlib, but it was so confusing
this is the docs of it docs.python.org/3/library/…
I looked at it again and I understand it better so I'm using that now
 
Pretty sure all you need is sol = importlib.import_module(ifile)
 
8:55 PM
That's when I have the dots done correctly, which I don't want to hardcode.
 
9:52 PM
suppose if we want to insert data into database POST method, Do we use json.loads or json.dumps?
 
What is a database POST method? That doesn't make sense
 
Are you using json as a database?
 
Or is it something like MongoDB?
The fact that I know you're using flask as a backend just complicates things further
 
If we hit a post method API to insert data in DB.What should we use json.loads or json.dumps?
{

"address": "Ahmedabad",
"dob": "2022-06-07T00:00:00",
"password": "123456",
"user_name":"testuser28",
"email_address":"testuser28@example.com"

}
 
Where? In the client or the server?
 
9:58 PM
json.dumps places data into the json file. json.loads parses through the data in the json file
 
in mysql database
 
Do you know sql queries?
 
MySQL works with.... SQL. Not POST requests
 
I've requested json data from postman using request.get_json() now this data passes to validate function in which using marshmallow schema it check the data so for that we need to load/dump data eg: schema_load(data)
 
Ok. I have to stop here for a minute - I won't be the first person here to say that you keep asking really vague questions. This is not a productive use of our time if you keep holding back information like this and just drip-feed it to us. Please take time to actually explain the context in your question
You assume far too much - none of us can see your code or understand even the basis of your project. I will start removing vague questions in future because it's starting to frustrate me now
 
10:07 PM
@roganjosh I totally understand and I respect that. I'll try to be more precise in asking questions.
 
The POST request comes through to flask, I'm guessing?
 
The scary thing here is that the question in itself is worryingly simple - asking "Do I need json.loads or json.dumps?" is kind of like asking "Do I need to wrap my present or unwrap it?". It depends on what your goal is: Are you receiving the present, or giving it away? The answer should be obvious if you know the goal. It shouldn't require 5 follow-up questions.
 
@roganjosh yes
 
And the answers you give to those questions shouldn't be like "I used a chainsaw to fell my christmas tree" or "the wrapping paper is orange"
 
Please forgive me :) .. I’m at initial stage of learning.. so I might be asking silly question. Please pardon me
 
10:12 PM
@NaveenPandia then the answer is probably "neither". get_json() deserializes the body of the POST request and now you just have a python dictionary. I don't use marshmallow but I don't see why it would require any further processing before it can use the dictionary to validate the request structure
 
@NaveenPandia I understand you're in a difficult situation and in way over your head. I'm not saying this to make you feel bad. I'm saying this to make you realize that this isn't productive. You're lacking some fundamental knowledge, and we can't teach that to you
 
@NaveenPandia That's fine. We've all been through the learning phase. One thing I will pick up on, though, is that there are also a number of times that I've said I don't think you're using the tools correctly and tried to point you in the right direction, but you have dismissed them saying "I have it working". I fear you're actually digging a big hole here for yourself
 
@Aran-Fey no I take this in a positive sense .. no worries
 
If possible, ask a coworker for help
 
@NaveenPandia I would also recommend some good tutorials aimed at programming beginners.
 
10:18 PM
@roganjosh Yes, you're right. I may have misunderstood something.
@AndrasDeak--СлаваУкраїні sure
@Aran-Fey my firm mostly works on Js, I'm the only one for python as an intern.
 
Does that mean there's no senior python person to mentor you?
 
Along those lines, I highly recommend the Flask Mega Tutorial. And I recommend working on it from the start. Even if you think you understand what your backend is doing, that only means you'll breeze through the earlier chapters
 
yes @AndrasDeak--СлаваУкраїні
 
@NaveenPandia yikes, that sounds like you were set up to fail from the get-go :( I'm sorry for you.
 
@roganjosh this might help
@AndrasDeak--СлаваУкраїні I'll survive :)
 
10:25 PM
@NaveenPandia You shouldn't have to figure out the basics on your own without proper guidance, but as others have said we can't do that for you. Your coworkers/boss will have to, or you'll have to do it on your own. Which brings me back to my earlier suggestion for a good tutorial. See also Aran's message here which hit the nail on the head.
 
You will survive; my first programming job was 100% remote and I'd never programmed anything before - I had to plough through all this stuff, and I know the temptation to try move quickly but your knowledge becomes more and more leaky and you get to the point that you can't even articulate what the problem is any more. Slowing down a bit here will really help, trust me
 
If you're currently at a point that json.dumps vs json.loads is a non-trivial decision, I doubt something advanced such as a flask tutorial will benefit you. You have to learn the very basics first. Both programming basics and Python basics.
 
Hello! I have a problem with a python code. Can someone help me?
 
If you post your code and describe the problem, probably
 
@oshiono hello, only if this isn't about your fresh question on the main site
 
10:27 PM
Ugh, faster than I could type my usual "room rules" message
 
I have been trying for 3 hours
 
specifically the part about waiting 48 hours for a main-site question to be raised here
 
@AndrasDeak--СлаваУкраїні issue which I'm facing is while testing my code in which I'm mocking my request.get_json() but I'm getting TypeError: Object of type MagicMock is not JSON serializable. So I was like whether my schema is wrong or something else.
 
OK, but that message doesn't change my assessment.
You are in over your head and you need help (from your company) or time (on your own).
 
10:34 PM
I know it sounds crazy but there should be a proper channel where we can communicate through voice for better communication unlike chat.... Anyways I'll follow the tutorial. Thank you, everyone
 
@NaveenPandia try some Python discord or something
and good luck
 
Random question. I have a game that reduces my screen resolution, which causes all of my currently opened windows to shrink. As a workaround, I've written a script that minimizes all windows while the game is running. When the game exits, the windows are un-minimized again.
For some reason, my windows still shrink. I've even added time.sleep(5) after minimizing and before un-minimizing, and even programmed it to wait until the screen resolution is back to normal. Any idea why my windows are still shrinking?
 
The answer is probably right there in your question: windows.
Do you understand the mechanics of how the windows shrink and stay shrunk if you change and restore the resolution?
 
@NaveenPandia Hope it helps get things a bit more aligned for you. As to your first point - don't forget that we're all doing this as part of our own jobs too, and programming is a constant uphill battle of learning. There are plenty of ways for you to talk through the problems and have someone help you out - you pay for them. Like any other service. Here, we help from good-will alone
 
because it seems like a non-trivial assumption that whatever that is, minimized windows are unaffected by it
 
10:39 PM
How does one set hardening flags when compiling Python from source? Running hardening-check on my compiled Python compared to the system included one (on Debian) shows my compiled version is missing a lot. pastebin.com/9v6iPBiF
 
@AndrasDeak--СлаваУкраїні I think so? It's only natural that if a window is larger than your screen, the OS will reduce its size. But a window can't be "too small", so there's no reason for the OS to make the windows larger again when the resolution goes back to normal
 
minimized windows are aware of their unminimized size so that they can be restored, so it's possible that they are merely affected all the same by the corresponding check
how about keeping track of each window's size rather than minimizing them?
 
Looks like I'll have to do that. I'm still curious about what's happening though
 
Do you have any reason to believe that minimized windows are exempt from the "check if too large" check, other than "that's what sane people programming a sane OS would do"?
 
There are 2 interesting tidbits I have omitted: 1) The windows don't shrink as much as they would if they weren't minimized. 2) One window (Geany) is actually unaffected (only if minimized though)
 
10:42 PM
hmm
So the "check if too large" check is buggy for minimized windows, but nobody is fixing it because they are minimized anyway. Gotcha :P
 
Dumb question - why do the other windows need minimising rather than just bringing the game window to the front and expanding to the new fullscreen size?
 
Can you compare all the properties of geany and of any other window to see if there's anything you can pinpoint that differs between the two?
@roganjosh it's the game itself that does the resolution change, Aran can't prevent that
and he just wants the game not to mess with his desktop setup
 
In every game I've launched that messed with screen resolution, incl. DOSBox games, once you quit them, all the windows are still open in the background
 
Not with reduced sizes
 
10:45 PM
@AndrasDeak--СлаваУкраїні Ooof. No, I don't think I can. There are a lot of window attributes, and if I'm unlucky it might actually just be a difference in the program code
 
@roganjosh you're a lucky guy :P
 
Once the game is quit, the screen flickers as it changes its resolution back, but the windows are not minimised to the tray, for example. They're still there
 
@Aran-Fey I meant programmatically, but I assume there's a bunch of them differing anyway
 
This particular game has a resolution of 320 by something
 
@Aran-Fey heh
@roganjosh are you implying that Aran's problem does not exist? :P
minimization is a workaround attempt from Aran, not the game's doing
 
10:46 PM
No, I'm implying that minimising to a taskbar rather than just leaving them as they are could be causing the problem
 
I assume the whole project started when Aran saw his windows not getting restored once the game ended
 
indeed
Hold on, I'll make a screenshot
Oh I forgot, my explorer windows used to shrink too. Those have also been saved by being minimized
 
hmm, that's useful if you ever get desperate enough to compare attributes after all
you could build a data lake from all the attributes and apply deep learning...
keeping track of window sizes might be more straightforward :P
 
10:49 PM
I can read the code. I honestly don't see the problem :P
 
a folder on the desktop named "folder", I wonder what other dirty secrets that screenshot holds
 
I'm good at naming things.
I don't want all my stuff to clutter my desktop, so it goes in a folder. The folder.
 
... Rick Sanchez, is that you?
 
I've got a "misc_documents" directory in my home directory, and in that a "misc" directory (among a dozen other directories)...
 
The home directory gets so cluttered, I wouldn't voluntarily go in there
 
11:02 PM
I use git-bash so I go wherever I mean to anyway
 
11:50 PM
@Aran-Fey I recall some games did the same on certain drivers/setup (eg: Intel, Nvidia, etc). I don't have a specific game in mind, but I do recall it might have forced a smaller resolution/scaling option than my monitor
I think there a trick to prevent it to shrink it, but didn't find one yet
As Andras pointed out earlier, I feel like this is probably some attributes/something part of the window that make them/prevent them from being shrunk.
I bet you could prevent it from doing it too, say by doing something like this: stackoverflow.com/questions/3275989/…
 

« first day (4431 days earlier)      last day (510 days later) »