« first day (4436 days earlier)      last day (513 days later) » 

2:13 AM
@imbAF math-inclined person passing by; I find your problem puzzling but for a different reason: an exponential rv can be arbitrarily large, so you cannot strictly speaking impose a tmax. For what you are confused by- each choice of tau gives a differrent exponential distribution. You actually cannot produce values without giving tau, if you can then you are probably assuming e.g. tau=1.
@imbAF If you want to discuss this mathematically further you/we can consider the main math chatroom which has people more qualified than me
 
 
3 hours later…
4:56 AM
Hello, anyone there?
I use shutil.copytree to copy some directory for backup reason.
In one of those directory i have a pyqt5 file icons.qrc which have relative path to assets folder. I see a lot of this messages: Cannot find file: ../assets/images/folder-images/folder-weather-news.png. If i remove the icons.qrc file from the folder then there is no any related message.

What's wrong about?
shutil.copytree doesn't copy only files and subfolders (no paths inside files copy)
 
5:39 AM
ok i found the problem. It isn't shutil related.
 
user18313765
6:20 AM
Hello everybody. Is there anyone online who could help me troubleshoot a question?
 
user18313765
6:51 AM
It is bountied in the Python tag
 
7:01 AM
@SantiagoE.98 I've just taken a look at it and I have no idea what it is asking specifically. This looks like a debugging problem but it is totally unclear to me what output you actually receive and what you expected instead; take note that code that requires to set up a DB table just for filtering tuples is very, very far away from an MRE. At a glance it seems to be a simple "typo" problem in that you calculate the condition outside of the loop so of course it is the same for every item.
Oh, and it looks like you attracted a ChatGPT answer.
@SantiagoE.98 Take note that bountied questions are protected from the usual close voting so any shortcomings that would result in a close vote are likely to attract downvotes instead. Due to the bounty it will also attract more attention in general. So I strongly recommend to work on the debugging shortcommings, e.g. clarify what output you get and what you expect instead and shorten the code to an actual MRE; the text could be shortened significantly as well.
 
user18313765
Ok, I'll fix it. Thank you
 
7:44 AM
A bit off topic, but would appreciate help on this one. How do I replace a non-whitespace string enclosed within quotes using sed?
$ echo '"hello"' | sed -e 's/"\S+"/foobar/g'
"hello"
 
user18313765
7:59 AM
I improved my question. For anyone who would like to help, you can find it with BOUNTIED in the Python tag (concerns the "for" loop). Thank you
 
9:12 AM
The Windows flag CREATE_NO_WINDOW is not really that useful in Python's subprocess library, right?
I mean, if I don't set "stdout" and "stderr" to "subprocess.PIPE", nothing will be piped to the terminal, so why would I need "CREATE_NO_WINDOW" to suppress output?
(On subprocess.Popen)
 
 
2 hours later…
10:44 AM
I had a use case for this once. Basically, depending on what you're doing, there are instances where a terminal on Windows will be seen, even if you use shell=False, etc. It really depends however, as I can't recall why I used this, but this can happen
in such cases, using this sometimes work, otherwise, it doesn't (I think I managed to do it using ctypes or something)
if you make unittest/test cases to make sure it doesn't ever happen on Windows with your library, I think you wouldn't need it then.
 
 
2 hours later…
12:21 PM
How can I test if a function from a module was imported? This works for import math. But I need to check if from math import cos was imported.
 
That's not possible in the general case. So... why do you need to check that?
 
I guess you could try to do something like:
import math
from math import cos
if cos == math.cos:
    print('True')
But that's a weeeird test to write
 
You can do some shenanigans with gc.get_referrers, or keep it simple with a for module in sys.modules: if cos in vars(module).values():, but both of those have their own edge cases
 
There's a 3rd party lib that defines cos in 2 different ways in 2 different modules. If I import it anywhere in my code from the wrong module I ll get bugs.
 
just limit the scope and use that function in that scope only
 
12:28 PM
Or write some intermediary module that gives those functions distinct names and use that
 
@Riya you could do this with AST or the inspect module I think
 
@sahasrara62 what do you mean?
@matszwecja that's a good idea, but I can't trust myself to import from the intermediary module in 5 month.
 
something like this: stackoverflow.com/a/30037835/12349101 but it only uses the top import statements. Otherwise, this could work, but it does so recursively (through your whole file): stackoverflow.com/a/30037842/12349101
you could also do this while inside your own logic/program, by using it on the same file, and maybe importing a specific one using an if condition.
 
@Riya Do you just need one of the two versions for your entire program/module/package?
 
@MisterMiyagi yep
 
12:32 PM
@Riya like a funciton need cos of module1 then before that cos function usageage use import cos not in all file package part or you can use this as different name like from module import cos as cos_module and use this cos_module
 
In that case it might be simplest to expand your testing/CI (you have that, right?) with a regex or even just plaintext check against the import statements.
If you need to check it at runtime, then what @matszwecja showed above should work. Make sure to check with the is operator instead of == to be sure, though.
 
Thanks everyone. I ll give your suggestions a try.
 
Half serious suggestion: just don't import the buggy function.
Anywhere you have from badmodule import cos, instead do from goodmodule import cos
Do you have any import * statements in your code? If so, that can cause variables to get assigned or reassigned in surprising ways. Consider replacing the asterisk with only the names you need. from badmodule import * might reassign cos against your wishes, but from badmodule import sin, tan will definitely not reassign cos
Odds that I'm completely misunderstanding the problem: 50%
 
 
1 hour later…
1:53 PM
@Kevin it's easy to mistakenly import it. Bad design by the library dev. from math1 import cos (wrong one) vs from math1.funcs import cos (correct one). A new dev could easily auto-import the first.
@Kevin that's a good tip, but nearly never use * anyway.
 
Sledgehammer approach: math1.cos = lambda: DontUseThis
 
class IncorrectFunction(Exception):
    pass
def x():
    raise IncorrectFunction
math1.cos = x
x(*args, **kwargs) I guess
 
2:13 PM
This looks very interesting and simple. I like it.
 
Hi, i need some help regarding .. scrapy , and tkinter...
 
2:54 PM
@Riya Just be aware that it WILL break anything inside the library that happens to use this function
So if it relies internally on math1.cos unexpected parts of this module might stop working.
 
@matszwecja That's unfortunate. Then it doesn't sound safe to use that solution.
 
@Riya feel free to check what I said above: chat.stackoverflow.com/transcript/message/55660537#55660537 might not be immediately useful, but might give you some ideas on how to approach this
 
@NordineLotfi thank you. I will.
 
3:21 PM
@Riya You could get really fancy and try inspecting the call stack to see whether the caller is you or the library, but that seems shady.
But depending on how/why the two functions are different, you could always submit a bug report to the library maintainers.
 
3:46 PM
cosine sounds like something that shouldn't be messed up
 
 
2 hours later…
user18313765
5:19 PM
-2
Q: Problem with the for loop in a calculation and filtering the results of the loop with a condition >=

Santiago E. 98I need help with a "for" loop for a little video game i'm making. The problem is the for of for row loop in Rows_NextFights[0:] and its contents. Premise that the arithmetic average is already calculated correctly for a single monster, my idea is: Calculate the average Attacks for each monster (...

 
user18313765
Can anyone help me find a solution and reply to BOUNTIED? Thank you
 
6:37 PM
Is there a neat way to unpack something into a dict? So the way we can do a, b, c = foo, is there something to get {"a": foo[0], "b": foo[1], …}?
 
dict(zip('abc', foo))?
 
Oooh, that's neat indeed.
 
 
3 hours later…
9:51 PM
Cabbages and felicitations everyone!
 

« first day (4436 days earlier)      last day (513 days later) »