« first day (3462 days earlier)      last day (1469 days later) » 

12:04 AM
can anyone help me with imports...?
. > __init__.py
... (core) > constants.py
... (util) > window.py
when trying to import from util.window import WindowHandler I get a ModuleNotFound Exception
* from my constants.py file
>python constants.py
 
wim
12:46 AM
you have to install the package or get it on sys.path some other way. and don't run modules within packages as scripts.
 
@roganjosh i did, thank you! :D went from 7 seconds to about 2
 
 
3 hours later…
4:05 AM
cross platform porting headache today
 
wim
do we have any acceptable close reason for questions which are presenting some code that works normally, but the user had some bizarre and wrong expectation about how that code should have behaved? asking for this but seen such cases a few times
I don't mind to see these answered when their expectation was a reasonable guess, but often times the expected output is just weird because the O.P. "Lacks Minimal Understanding" (a close reason which used to exist)
 
4:35 AM
...
p = [{'key': 'value'}]*100
p[1]['key'] = 100
this changes all of the dictionaries in the list p. -_-
 
heh.. this one again
 
5:00 AM
cbg
 
wim
@AmagicalFishy in fact, it only changes one dictionary
 
@wim which happens to be all... :D
 
wim
correct :D
 
i.e. what they did say "was not even wrong" :'D
 
wim
5:05 AM
this could be a fun way to confuse OP's ... "what do you mean?? it only changed one
of the lists/dictionaries on my machine"
 
5:29 AM
don't tease the monkeys
 
cabbage
 
good day everyone
dupe By the same OP
 
heh.. regex is too fragile.. more like his understanding of it is
 
it's not about regex at all. he can found it by tag and class. but since he haven't including clear information, i couldn't help as it's even dupe
 
5:41 AM
does this soup module give access to the DOM?
 
@αԋɱҽԃαмєяιcαη Closed
 
why do you suppose he posted the same q 2x?
 
because he need a quick answer., :D
usually new users have a doubt if they duplicated the question, so it's will be in the top listed question. and then it's will be focused on
but once they find the question closed as a duplicated. they act as "oh how they noticed that quickly"
 
5:46 AM
people really are watching
seems like about 75% of questions I see coming through are python
 
it might be, but for a confirmation, you can analyze that :P
 
you're the web scraper =)
 
:P no need for scraping. people here announce it directly check
 
oh... lemme check it out
is there a page that lists out what % of questions have a certain tag?
 
i think the statics one, lemme check
Python is the trend of 2020
 
6:05 AM
i'm sure python is listed as the top language of 2020 on many sites
java's still going strong
 
6:22 AM
hmm.. that page says only 15% of the questions are tagged with python. that can't be right
 
6:35 AM
    Hi good morning can anybody help me in this?

    packages/wand/image.py", line 8779, in read
    raise WandRuntimeError(msg)
wand.exceptions.WandRuntimeError: MagickReadImage returns false, but did not raise ImageMagick  exception. This can occurs when a delegate is missing, or returns EXIT_SUCCESS without generating a raster.
https://dpaste.org/DWpY

for complete code review
 
6:51 AM
@ilj closed
 
can somebody post my question on behalf of mein on SO?
 
Why should be ?
 
bcz My account reached the numbers of question i can post
 
I believe that your account got restriction due to multiple low profile question
 
@Mannya Sounds like a question ban.
 
6:53 AM
Sorry we couldn’t help with that , that’s out of TOS
 
i changed that qustion still my account did not open.
 
You’ve to wait then
 
thats why I am asking to post this question
 
<snickers>
 
7:01 AM
@αԋɱҽԃαмєяιcαη I don't think waiting it out is an option, if it is a question ban.
 
@ilj I couldn’t recommend to register new account.
 
Of course not, and if it is a ban, the only way to lift it is to contribute positively on the site in other ways. It's covered in the meta post.
 
cbg patch
 
7:09 AM
But there are also rate limits that may kick in before a full blown ban. In that case "waiting it out" is an option, but it might be a good time to reflect on why those limits got applied, because the next step might be the ban.
 
@wim I close them as "typo / not reproducible / less likely to help future readers" (if their expectation is a misunderstanding) or "needs details or clarity" (if their expectation is so outlandish, it's unclear what they need to be told). Neither reason suits perfectly, though.
 
wim
"less likely to help future readers" is the explanation for the close reason "typo", it's unfortunately not the close reason itself.
 
7:29 AM
feel free to put the emphasis on "problem that can no longer be reproduced" ;)
hm, didn't find anything on meta after 2014 :/
 
7:44 AM
"needs details or clarity" sounds like the ticket if you are wondering why they are expecting something normal people would not
 
@Mannya looks like you did create yourself a sock puppet; this is really a violation of Stack Overflow rules stackoverflow.com/questions/61096233/…
 
question deleted @tripleee
 
8:39 AM
@wim no repro
@Mannya no. Evasion of restrictions is a bannable offence
@IljaEverilä 1 free question every 6 months
 
@AndrasDeak Right. That's quite some time to wait, instead of trying to improve :P
 
I think our friend is in the process of demonstrating that some just cannot improve
 
@tripleee nice
@tripleee Judging by their interactions here I'm not terribly surprised
 
 
2 hours later…
user10984358
10:32 AM
would like to know more about this stackoverflow.com/questions/61098519/… in case someone is already on it
 
Well, it certainly doesn't work for all integers
>>> hash(99999999999999999999)
848750603811160106
This is the kind of thing that's possible under very specific circumstances (integers below a certain size, running a specific interpreter, ...) and should absolutely be avoided in any real code
 
user10984358
debunked then :)
 
user10984358
it obviously doenst work if numbers are repeated, some cases yeah
 
user10984358
An answer explaining the existence of Radix Sort gets 2 votes? How does that explain what he asked?
 
user10984358
it is O(n) but didnt he ask if thats possible with sets?
 
10:40 AM
"My question is now: Does this mean it is possible to sort integers in python in O(n) time?"
And for what it's worth, i personally will sheepishly admit i had no idea about this kind of sort existing, and so im happy i read this answer.
 
user10984358
Time complexity in sorting a list by converting it to a set and back into a list heading says this
 
shrug we all can kinda figure out what the OP really wanted to know.
 
user10984358
lol I am just getting used to browsing new, go easy on me
 
Sure, you can say that the answer could be fleshed out more to address the set specifics too, but i think the OP probably would be happy with just that too
have fun, if you feel like you're starting to lose your sanity, take a break!
 
user10984358
I just assumed anyone asking about sorting in O(n) new about Count Sort, I will admit I dont know how to write one though
 
11:49 AM
@TheNamesAlc this seems to depend on the size of the set as well. For example, {1, 8} is unsorted, {2, 8, 9, 10, 5} is sorted. I'm guessing it might depend on collision resolution of the underlying hash map.
note that {x, 7} for 0 <= x <= 7 is "sorted" as well.
Fun fact: list({1, 8}) == list({8, 1}) is true on CPython (3.7.4) on PyPy (3.6.9, PyPy 7.3.0)
^ but not on PyPy (3.6.9, PyPy 7.3.0)
 
12:17 PM
I have a flask question and my google is failing. before I post it to SO I'd like to make sure that it's not something trivial.
The gist is that I want to have some dev-only logic in some of my routes that should under no circumstances be executable in prod. A colleague told me that it's a super basic web-framework property to make stuff like that possible without having ugly if config["ENV"] == "dev": ... switches in your prod code, but I have never heard of or seen it.
 
A quick google drive by didn't yield anything for me either. However, I don't really see how one could make that shorted than an if ... check. You might want to check-and-store config["ENV"] == "dev"/.env == "development" once and just use that boolean from then on.
 
@shad0w_wa1k3r but it can't change which code is called given a route, can it?
 
You have to put an if-else in the necessary places, no other way I can see. I do the same in Django (if settings.DEBUG: do_something)
 
@MisterMiyagi I also don't see a way to make it happen without touching the routing table - which just replaces one problem with another
@shad0w_wa1k3r good to know that it's not some kind of well-known antipattern =D
I'll post it anyways, if it tumbleweeds it tumbleweeds.
 
Why touch the routing table? change the view (or equivalent flask term) and use an if-else there
@Arne That variable is quite widely used in libraries which need to behave according to it's values (e.g. to send or not to send an important alert email as described for Sentry)
 
 
1 hour later…
2:01 PM
cbg
 
2:52 PM
cbg
 
hammered
I migrated an old codebase from py2 to py3. I had to get rid of all the prints and replace them with fresh print()s. And that's how I found Will Smith
5
 
for the record I got that
 
@inspectorG4dget thanks
I remember that i seen a package which help to convert script of Python2 to Python3 by shown the difference between both and giving hint on valid Python syntax
 
There's stdlib 2to3 that should fill in trivialities
 
3:05 PM
yes that one
 
3:35 PM
Cbg all
 
cbg
 
What's the difference between these two functions?
def func():
    return

def func():
    yield
(I know what yield is, I'm asking in what situation the second one might be useful that the first one cannot be?)
 
@aderchox neither are useful
 
to be more clear and specific:
from contextlib import contextmanager
import pytest


@contextmanager
def does_not_raise():
    yield


@pytest.mark.parametrize(
    "example_input,expectation",
    [
        (3, does_not_raise()),
        (2, does_not_raise()),
        (1, does_not_raise()),
        (0, pytest.raises(ZeroDivisionError)),
    ],
)
def test_division(example_input, expectation):
    """Test how much I know division."""
    with expectation:
        assert (6 / example_input) is not None
 
3:49 PM
Do you really know what yield is? If so then I don't understand your question
@aderchox that probably has to do with how context managers work
 
Why is this working with yield, but no with return, is that part of the syntax of how context managers work?
@AndrasDeak hm... thanks
 
4:01 PM
@AndrasDeak yes, sorry for replying again, I guess it has to be "yield", so that does_not_raise can remain alive in the context of the context manager block..., probably :D
 
In any case it can't be return because then does_not_raise() would just be None, which would in the test turn into with None: ... which is an error because None is not a context manager
 
@AndrasDeak Right, thanks
 
wim
4:18 PM
Better yet, don't parametrize raising cases and non-raising cases in the same test parametrization. It's trying to be too clever in the test suite (tests should be as dumb as possible)
 
ugh
They can't even support smaller sites, so why do they spam us with them all the time?
 
4:56 PM
@user10007925 If your question is eligible for a bounty (>= 48 hours old) and hasn't received a useful response, then you may link to it.
 
im new here did not know that rule
 
@user10007925 now you do
 
dirname('__file__') <- oh jeez
 
@Aran-Fey in comments, please
 
nowhere it is
 
5:04 PM
@user10007925 for future reference: local rules.
@αԋɱҽԃαмєяιcαη quoting without a link is not terribly helpful
 
alright, i was checking if i can reference the specific rule or not but it's not. but ok next time will share though
 
242
A: ValueError: setting an array element with a sequence

Sven MarnachFrom the code you showed us, the only thing we can tell is that you are trying to create an array from a list that isn't shaped like a multi-dimensional array. For example numpy.array([[1,2], [2, 3, 4]]) or numpy.array([[1,2], [2, [3, 4]]]) will yield this error message, because the shape ...

So this is wrong: numpy.array([[1,2], [2, [3, 4]]])
If you wanted to do that, then, how would you?
To avoid XY: The goal is to speed up my program by using numpy arrays. I am trying to get around using objects by only using a mutable list that consists of two integers
How can I?
 
You want each array element to be a list of two integers?
 
@JohnnyApplesauce numpy array of lists = slow
 
I used the example from the top post, but what I myself am doing is more like
`[0, [0, 0]] * 3dimensions`
 
5:18 PM
If you need to store ints and lists in your numpy array, then it'll have to be of type object
 
Does numpy add any value then?
 
You could turn that 1-2 combo into a flat 3-length dim. Shape (n, 3)
 
STOP! Hamertime
(I hammered it)
 
5:30 PM
:P
@inspectorG4dget another one dupe
 
someone get me my parachute pants :P
 
Opera sound again :O
 
I think that's not a dupe, the OP is asking about GET requests which he sends using selenium
 
eep! Me jumps out a plane with my newly acquired parachute pants
 
the error is about the headers, both can be set within requests or selenium.
like that
 
5:41 PM
cool, have added it as another dupe tag
 
is that available for higher rep only?
 
gold badge I think
 
5:56 PM
I think that SO need to address the point of applying the theme once changed to all other tabs (other tabs with posts you viewing). something like auto reload the page once navigating to it.
 
6:43 PM
Alrighty, Django question. I've got a ManyToManyField in my users modal that'd like to apply to both users.
For instance. One user matches with another, so in the ManyToManyField I'd like to put another user, and in the other user they would also have the first user in their matches
 
wim
@tripleee yes, thanks
 
Hey, I'm creating a game with pygame (movements are like snake). I won't the character to move until he is align on the (imaginary) grid. For example in snake this is useful so that the snake is always aligned with the apple. If you have an idea how I can implement it, thanks a lot!
If you need more details, tell me
 
wim
7:19 PM
@ParitoshSingh It was discussed in here a while back, check out chat.stackoverflow.com/transcript/message/41051171#41051171 if you want to review
not to be confused with radish sort
 
7:31 PM
@TristanWiley Sounds like something like this but I don't use django. In SQLAlchemy you'd make an association table; I'm guessing django must do that under the covers
 
@wim Ah, thanks!
 
@TristanWiley it seems it does automatically create the interim table based on the docs. That particular section references the creation of the table and the .through option allows you finer control over the association table itself
 
7:46 PM
@wim O(n) in time. Seems like memory complexity can be arbitrary
 
wim
8:37 PM
@AndrasDeak I think it's O(n) space too?
 
what if a_n = n!?
unless we specifically use it to sort text
 
wim
so, if you iterate first and find the minimum and maximum numbers
then you allocate an array of max - min
that's O(n) right?
 
in a_n = n! the max is n!
 
wim
there is not any way to account for the holes?
hmm, wikipedia says worst-case space is O(w + n) where w is the number of bits to store each key
so I guess there is a trick possible here, but not good enough trick to get to O(n)
 
O(w+n) doesnt sound too bad
I guess it might involve some hashing
and I suspect most natural use cases don't have maxima that blow up
handling of ties might be a greater issue in practice
 
 
2 hours later…
wim
10:22 PM
@AndrasDeak HNQ in your face!!
Samuel Liew userscript to hide it coming in 3...2..1...
 

« first day (3462 days earlier)      last day (1469 days later) »