« first day (3788 days earlier)      last day (1143 days later) » 

3:39 AM
cbg all
 
 
1 hour later…
5:00 AM
I have installed django via pip3, showing in pip3 freeze -> Django==3.1.7. When I tried to run django-admin terminal shows

Command 'django-admin' not found, but can be installed with:

sudo apt install python3-django


any idea ? why I need to install django as sudo apt install python3-django
 
 
5 hours later…
9:58 AM
@NishantNawarkhede you shouldn't need to do that. Have you tried using a virtual environment?
 
10:44 AM
Hi.
What would be the easiest way to reproduce this image in python? pbs.twimg.com/media/EvPFPTmXYAEs0oJ?format=jpg&name=small
I can't work out which module is suitable for this sort of geometric drawing
 
i guess just turtle? my google fu is failing me.
there's also scikit-image, and apparently PIL has a .draw method too
but yeah maybe see if turtle fits your need
 
11:00 AM
Interesting. I didn't think of that.
 
11:12 AM
I should have installed IDLE so I could have had Tcl/Tk to try turtle now :/
 
I don't think you'd need IDLE for that?
 
the install box on Windows lets you choose IDLE and Tkinter as a whole :/
I thought I could save a few MB not installing IDLE
I thought I could pip install tkinter later, but windows is being windows here
 
wait, tkinter should have been included no? what's an install box
 
11:56 AM
ah. i'd probably just rerun the setup then
is there an "update/modify" option? (im just guessing here, ive never actually installed python from that setup window)
 
12:15 PM
marking a question as a dupe of another that's not even in the same language... :-/
 
12:37 PM
@python_user I don't recall it being separate when I installed on Windows - it's interesting; maybe they're trying to sheer it out of python in general?
 
@ParitoshSingh I have to check, need to download the exe for the version I am using
@roganjosh seems kinda unproductive to not have IDLE as a separate check box, people use tkinter for GUI but not IDLE once they pass the learning stage
 
I think IDLE launches its windows using tk?
 
still they could give an option to exclude IDLE
far better than installing 1 gb of visual studio to compile C code I guess
 
ooo... congrats on 2k @python_user :)
 
ahh the puppy noticed :D, melon, now I can edit all the 3.x tags without needing an review
 
 
1 hour later…
2:01 PM
stackoverflow.com/q/66374467/4799172 needs debugging details. For context: this in chat
I'm trying to get better with tab management. Chrome pooped itself and I lost everything but it doesn't seem to have impacted me too much. Maybe I don't need to set the baseline at 80 tabs to be productive!
And congratz @python_user, a nice milestone :)
 
thanks josh, also wont Chrome tell recover tabs or something?
I usually have some incognito tabs open and I cant recover them when my browser crashes
 
It usually does with ctrl + shift + t. This was an extra big poop, apparently :P
In reality, I must have done something dumb and not recovered the tabs properly but I can live with it
 
most of the time a crash happens, I realize I just didnt need what I had open :D
so I walk away
 
2:36 PM
my tabs are a passive aggressive reminder of all the things i wanted to read
they stick around for about two weeks, until im finally annoyed enough to close most of them :P
without reading any of them ofcourse
 
I'm distressed that my re-take has most tabs starting with "P" imgur.com/a/pxMnUf5
I'm not used to being able to see letters, I just went off favicons and memory
 
user13727121
is it possible to reuse user input in a while loop? like, without the use of a function
 
Sure, it's possible
 
you save in a variable?
 
I think you're going to need to be a lot more specific
 
 
1 hour later…
3:47 PM
I'm having a weird bug with fork/qt/glib/X. -> python - Creation of QApplication object affects code in subprocess started with multiprocessing module - Stack Overflow (question on main site, more than 2 days) -- any idea how can I debug it?
 
There's a lot going on in that question. Why do you have nested functions with .run() in the inner-most function? Why do you have imports in the function itself?
 
Wouldn't it be easier to let Qt create a tray icon?
 
I know people would ask that, I did say that it's just for educational purpose.
For now the issue is that the code must be run in an external thread (see background section), but If I look at it for long enough I might figure out ways.
@roganjosh ... Okay, perhaps the import is unidiomatic Python.
 
I think I'm gonna back out of this one. GUIs are not my area, and I might be missing the "lesson" you're testing if you're pushing for educational purposes
 
Good point, I guess.
Not really, I find out a workaround but it's ugly.
 
4:00 PM
But I don't think I understand what you're testing against and what you want to learn
 
Thanks to the comment I figure out a way to reproduce the issue without qt thing, I guess.
 
user13727121
@python_user yes, something like name = input("Enter your name:")
 
@CoreVisional that is how you reuse a variable, but as pointed by roganjosh you need to be specific if that is not what you want
 
But it could be a different issue. In any case if it can be reproduced without qt then it's a pystray bug.
 
user13727121
@python_user Here's an example: dpaste.com/9RKSJQQPJ
 
4:16 PM
while True:
    name = input("\nEnter a name: ")

    another_name = input("Would you like to enter another name? (y/n): ")
    if another_name.lower() == 'n':
        break
?
 
name is already available in the scope of what you posted @CoreVisional
In other words, you just need to reference it by name
 
I guess they want to do something like name = input("\nEnter a name: ") inside the if
but without calling the input?
if you want to get a new input you have to call input or you can just use name as such, it works
 
 
2 hours later…
5:58 PM
Is it possible to create a seaborn swarm plot with a dictionary of data?
 
6:10 PM
(without using Pandas)
 
6:31 PM
is it ok to create a new tag for an async version of a python library?
if it is not encouraged to do so, then can anyone add asyncpraw as a synonym to the praw tag?
 
6:42 PM
In the .sorted function, is it possible to retrieve the output of the key funtion? e.g. sorted(x, key=lambda y: func(y)) ?
 
why not map or just a list comprehension?
.sort you mean?
 
@python_user no, sorted()
Can I post links here?
Ill send you the wiki
@python_user I guess, that could work. map first, sort after
 
if all you want is to sort that is what the key does
 
applies a function to the data before sorting
 
7:08 PM
I can't tell if your problem was solved or not
 
well, not really
 
@MiguelL just to see the result or also use it to sort? if just to get the output of the key func, then do list(map(lambda y: func(y), x)) ...or in this case, just list(map(func, x))
 
@aneroid And from there how can I sort the original array acording to the output of that function?
 
@MiguelL if you want the output of the sort function to be part of the result, then do sorted(zip(x, map(lambda y: func(y), x)), key=lambda t: t[1])
 
@aneroid ew
 
7:12 PM
yeah, ew indeed
 
sorted([(func(val), val) for val in lst])
 
oh yeah, lol of course. i was overthinking it
 
I guess they want sorted(map(fun, lst))
 
@python_user no
@MiguelL when you say "array" do you really mean a list, or are you using numpy by any chance?
@python_user my hunch is that it's not a good idea. But only users with score in the tag can suggest and vote on synonyms.
 
@AndrasDeak sorted(x, key=lambda y: func(y)) -> yes, x is a list
 
7:18 PM
@AndrasDeak well I will leave it upto the watchers of the non async tag to deal with it then
 
In [116]: x = - np.arange(3)
     ...: sorted(x, key=lambda y: y**2)
Out[116]: [0, -1, -2]
x is not a list D:
 
@aneroid sorry , what would be the output here?
 
@MiguelL try and see? Assuming there's no syntax error in it.
 
I think you want keys, vals = zip(*sorted((key(val), val) for val in lst))
 
@MiguelL the code by @AndrasDeak does a better version of what i suggested. so can be ignored
 
7:27 PM
I didn't want to add the zip unpacking step to reduce the cargo factor
 
The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
@AndrasDeak I am getting this error with this
 
@MiguelL hahaha, excellent
(that's a numpy/pandas error)
 
I'm tempted to throw the solution out there... but then we'd really reach maximum cargo culting
Also, sorting a list of numpy arrays seems... odd
 
Well the list has a 2D numpy arrays
 
Also, I probably misunderstood the cause of the problem anyway. Let's just pretend I never said anything
 
7:36 PM
@MiguelL but what about... " yes, x is a list"
 
I shall not-so-eagerly await a Minimal, Complete, and Verifiable Example
ah, where's my mcve userscript there we go
 
@aneroid we've had trust issues with askers for a while now
It's like they don't want us to solve their problems for them ¯\_(ツ)_/¯
I'm not the type to help someone against their will
 
@AndrasDeak hhaa, understandable given ... <scrolls up>
with an mcve (=mre?) would make a decent main site question, i think
 
most likely a duplicate though
 
please don't suggest vague questions be re-asked on the main site, there's enough psychic activity going on there as it is
Anyone would need 10 minutes of hands-on discussion with a willing party to figure out the X in this XY problem. The solution is probably 3 lines of code at most.
 
7:43 PM
@AndrasDeak thanks, that gave me a chuckle...as i'm guilt of said assumptions when there's not enough info and it looks solvable
 
The error suggests a deeper issue with understanding the problem at hand.
(OK, maybe not, but we can't be sure.)
 
yeah, and some part of the code we don't see, perhaps in the key function, doing if x or something but x is a numpy array and not a unit-item of a list
 
ended up with this:
 
no, there's a straightforward likely cause for the error
but fixing that might not fix some underlying issues
 
pop, score = zip(*sorted(zip(pop, map(lambda genome: func(genome), pop)), key=lambda t: t[1]))
not the best im guessing
 
7:45 PM
👍
 
typical data scientist code
 
@MiguelL just add the key=... part to my solution (with t[0]) and it will probably "work"...
 
@MiguelL yeah but i said don't use my version.
 
@Aran-Fey especially that map lambda? :P
 
:sorry, Ill try it the other way
brb
 
7:47 PM
@MiguelL btw, if ur function does take just one argument... then lambda genome: func(genome) can be just func
 
@aneroid there's no "if".
that lambda is always superfluous
 
i assumed (silly me) they key function was doing more than just calling one function wth one argument
 
It doesn't matter what anything outside that lambda does. lambda val: f(val) is the same as f but slower, except the latter could be called with additional arguments
but that's a very bad way to enforce a call signature
 
@MiguelL using the version @Aran-Fey gave, you could just do score, pop = zip(*sorted((func(val), val) for val in pop)) - note that score & pop are flipped in the assignment
 
@aneroid no
the error comes from trying to sort by secondary key, i.e. the arrays
 
7:54 PM
@AndrasDeak is that not what he's getting?
 
@aneroid no
Aran's solution is a slightly more elegant version of mine (generator instead of list comp) plus unpacking
It will raise under the same conditions. If you read what I told Miguel you'll see what I think is missing.
 
that the 2nd part of the tuples val being a numpy array messes with sorted evaluating the key correctly?
 
There's no key to be evaluated correctly
 
the (func(val), val) being the whole "key" being evaluated
 
@aneroid Sort of. At one point it will do if val1 < val2, but then val1 < val2 is a 2d boolean numpy array
 
7:57 PM
yeah, instead of the usual int, string or whatever
how about score, pop = zip(*sorted(((func(val), val) for val in pop), key=lambda x: x[0])) ?
and if the key is then explicit, then may as well unflip score and pop
 
needs more asspressions
 
score, pop = zip(*sorted(((func(val), val) for val in pop), key=lambda t: t[0]))
is this what you were going for?
 
only if you're not using numpy
 
pop is a list, but each val is a 2D numpy array
 
but you're not so it'll do :P
 
8:05 PM
perfect, thank you !
 
@MiguelL yeah, that's identical to chat.stackoverflow.com/transcript/message/51687727#51687727 except the t vs x in lambda
 
It is! Thank you
 
@aneroid that needs operator.itemgetter just to be less ugly; regardless of perf improvements
and would be much better as two separate lines itemised = ((func(val), val) for val in pop) and then score, pop = zip(*sorted(itemised, key=lambda x: x[0]))
 
@Aran-Fey Pistols. Dawn. Don't be late.
 
heh
 
8:17 PM
@aneroid why? readability?
 
@roganjosh Now, now, before we resort to a duel, please use your abilities as a data scientist to verify if this town is really too small for the both of us?
 
Hoping for the code to run for a week?
 
Hohoho, sounds like you're not worried about having to duel roganjosh after he's done with me :P
 
@Aran-Fey I've run the numbers on the general trajectory of mud in this slinging and I'm not liking the AUC figures. <some other nonsensical metrics here>. I'm afraid it doesn't work out.
Although, to be fair, half our team actually uses R and I can't easily see whether there's bad practice there because... it's R
 
8:35 PM
*shakes fist* dang data scientists... they ruined data science!
 
@MiguelL yes. readability. and the performance would be the same because itemised is a generator - so is not evaluated/expanded until the 2nd line
 
 
2 hours later…
10:17 PM
@aneroid Thank you!!
 
@Anush you've already asked that. Did you follow-up on the advice with turtle?
 
Yes I looked it up in turtle. That seems possible. Was wondering if that was really the best way. Turtle looks a bit like a toy
 
Did you get it to work?
 
Wow you killed the question :)
 
rip
 
10:26 PM
I haven't got it to work yet
 
Indeed. I don't have a lot of patience if people ask a repeat question without showing progress from the advice they were already given. If, instead, you came back with feedback on the the feedback you got, I wouldn't be moving the comments
 
Fair enough. I guess my question is to learn the different ways you can make this sort of image
You suggested turtle which is one
Maybe someone else knows another
 
I didn't suggest it
 
Someone suggested turtle
Maybe matplotlib?
Or pygame? I really don't know
 
Or turtle as suggested?
FWIW I'd probably have a go with SVG in JavaScript/HTML, but that's me. But I don't want to re-visit something where you didn't move forwards on the advice given in the last iteration
 
11:10 PM
Can one create a scatterplot of words in seaborn?
 
How would that work? Labels instead of markers?
I'm not a seaborn user but I'm doubtful
 
So it's a numeric plot but with words as the marker?
 

« first day (3788 days earlier)      last day (1143 days later) »