« first day (2640 days earlier)      last day (2311 days later) » 

12:16 AM
> this is good example of using lambda imho;
Wat?
I have to say that python's attempt at replacing the ternary operator is confusing.
foo = x if cond else y
why not foo = if cond then x else y?
 
Too similar to a normal if statement I guess?
 
Why introduce a "then" keyword just for the inline syntax?
 
that's what I find confusing about the syntax, it's too dissimilar to if statements
@cᴏʟᴅsᴘᴇᴇᴅ okay, use a colon then foo = if cond: x else: y
of course the parser might have difficulty disambiguating this "expression" syntax from a traditional if statement.
 
It's presumably how you'd read it
 
It doesn't flow nicely when you write it like that.
 
12:25 AM
With no syntactical ambiguity, using if and else. There's a pep I think with bunch of alternatives
It's all redundant since (y,x)[cond] :P
I know, I know; need bool(cond)
 
12:42 AM
It has 19 votes for w/e reason.
 
12:55 AM
Yup, epitome of NAA
Upvotes because the target presumably helps; not an answer though
Eh, that question is only tagged python2 and one of the two spellcheck examples is correcting "colour" to "color" :|
Perhaps we should put down the question :P
 
1:14 AM
"no mcve" or my custom one (indentation error, no problem specification on-site, semantic needle in a haystack/bowl of spaghetti) stackoverflow.com/questions/48133441/…
 
1:25 AM
Those "if" waterfalls tho
 
They sure have "analised" those numbers.
 
2:10 AM
Python programmer and a security expert might be able to help here: softwarerecs.stackexchange.com/questions/47958/…
 
2:50 AM
@AndrasDeak a haystack of spaghetti
anyone familiar with software to draw circuit diagrams? Something simple preferrably. I don't need anything with lots of features.
preferably free software
free as in beer
 
 
6 hours later…
8:39 AM
recbg
 
 
1 hour later…
9:49 AM
cbg
 
 
1 hour later…
10:54 AM
I am planning to add this answer of mine in one of my library: Get continuos datetime objects in Python
Any feedback on this? How this could be improved? Could we add any other parameter to to make it more customizable?
 
11:20 AM
Probably I shouldn't set any default value for "day_range" there
 
@MoinuddinQuadri you are aware of rrule in the dateutil library?
 
No, I wasn't (till now). Found something new and important today. Instead of typing so much there, I should have used this at the first place :D
But still I'm kind off satisfied what I did there
 
question
let' say you have this
 lst = ['a', 'a', 'a']
if you do this
len(set(lst)) == 1
you will get True
However if you do this
In [14]: lst = ['a','a','a','b']

In [15]: len(set(lst)) == 1
Out[15]: False
 
11:36 AM
Yes
Look at set(lst) first
 
@AndyK because now you have two unique elements in your set.
 
I checked and indeed, I have
 
Check the set document here
 
{'a','b'}
 
@Moinuddin we could wait for the actual question
 
11:38 AM
how does Python see that a is different than b?
 
'a' != 'b'
String equality
 
@AndrasDeak how does Python see it? In my database perspective, the two are seen as string
 
Same type, unequal objects
 
how does it see the objects or what is within, mean?
 
The same way that 2 != 3, 'a' != 'b' and [1,2] != [4]
@AndyK I don't understand
 
11:41 AM
These are strings, not variables. There's nothing "within"
 
set(lst) constructs a new set from the items in lst
 
cbg
 
@MoinuddinQuadri Sure - didn't want to deride your work or effort in anyway... it's just normally, in a lot of cases, nothing's new under the sun for what one would think is a common task :)
 
11:44 AM
@JonClements I really loved rrule. I wasn't knowing about it. Thanks for the awesome share!
 
@AndyK not sure what you're asking there about sets?
 
12:01 PM
> I can even post the code, if required.
Hats off to that OP
 
12:29 PM
cbg Jon
@AndrasDeak & @JonClements how would Python knows the difference between a and b? Both are strings
@AndrasDeak I'm starting to realize what you mean
 
They have the same type but different (unequal) values
 
@vaultah ok
 
@AndyK huh? comparing sets containing strings and strings themselves aren't exactly the same?
 
@JonClements I just realized what you mean
I never thought that way, until today
 
Oh - so what are you now thinking? :p
 
1:08 PM
recbg
 
 
1 hour later…
2:46 PM
Roomba
 
3:25 PM
cabbage
 
 
3 hours later…
6:08 PM
I am amazed that the five year old question related to insertion of element in list is missing these answers
 
can't use uninstalled module, sorry I'm new to python stackoverflow.com/q/48139910/5067311
 
@MoinuddinQuadri Timings on small data can be misleading, so make sure that you've timed the solutions for large scale inputs too.
 
Sure, Let me update that
@cᴏʟᴅsᴘᴇᴇᴅ yes, verified for list with 1000 items. List comprehension is way too slower that list.insert. I should have thought about why List Comprehension gave better result earlier. :D
 
6:33 PM
soz, eating with my fam
if I do
In [1]: 'a' == 'b'
Out[1]: False
how python knows that 'a' is not 'b'?
 
@MoinuddinQuadri Looks good now. And yep, it's always nice when you can explain the intuition behind some observation that you record in your answer.
Makes it more valuable.
 
is there some kind of internal dictionnary inside of the cpython?
 
@AndyK what do you mean by "internal dictionary". Do you mean a dict with key, value pairs? Or do you mean a list of words?
 
@Code-Apprentice more like
how Python or its interpreter know that 'a' != 'b'?
 
may be it checks on ascii code, but i'm not sure though
 
6:45 PM
@MoinuddinQuadri aha
Someone told me that in a IRC forum
 
@AndyK computers internally store letters and other characters as numbers. The character a has a different number than the character b. This is not specific to python.
 
@Code-Apprentice aha, that's interesting
 
wim
If letters are stored as numbers, what are numbers stored as...?
 
There are many different so-called "character sets" which assign a number to each character. One early character set was ASCII.
 
bits
 
wim
6:47 PM
(devil's advocate)
 
at this level of abstraction, numbers are stored directly as numbers ;-)
 
wim
where do the numbers go when you turn off the computer?
 
so python is using what is existing in the computer then, nothing less, nothing more
 
@wim /dev/null
 
The cloud?
 
6:48 PM
@wim it dreams of electric sheep
 
wim
I looked in /dev/null but could only find zeroes in there ...
 
@AndyK yes. If you are interested in the details of character sets, you can learn about ASCII and Unicode.
 
try looking in /dev/urandom
 
/pat the badger on the head
 
they are stored in some kind off registers (me remembering old high school classes)
 
6:50 PM
CPU registers are only available when the computer is turned on
 
very very interesting
 
@wim that's just efficient encoding. It's enough to store the zeroes because you know the rest are ones.
 
imagine how much hard disk space you could save by run-length-encoding /dev/null
 
I'm not sure; the length would be long long long long ...
 
 
1 hour later…
8:02 PM
@cᴏʟᴅsᴘᴇᴇᴅ or @piRSquared Any of you guys around? I have a Pandas/Numpy question
 
please don't ping people out of the blue, that's inconsiderate (and possibly against the rules)
just ask your question, if someone can help they'll get back to you eventually
> 3. Especially don't use @username notification unless that user has already told you it's okay to ping them; that's like jabbing someone in the shoulder and saying "Hey! Answer me!", and will quickly mark you out as someone to be avoided.
 
Sorry about that.
 
@Moondra ?
I was busy with another answer. You have a question?
 
Hey Coldspeed. Can I get into a private chat with you?
It's a bunch of small questions and design implementations
 
Sure, I'll see what I can do
 
wim
8:15 PM
anyone done synacore challenge?
was it as good as aoc?
omg Andras your day 11 solution (hexgrid)
 
Guys is it somehow possible to order a Class's Query set by its foreignkey_set's length in django?
 
wim
yes, search django annotate / aggregate
 
That was quick, thanks :D
 
wim
it's a bit simpler than the example I gave here
https://stackoverflow.com/a/36847144/674039
you'll need the Count, you won't need the F expression
 
8:24 PM
I'm actually gonna order it by len(the_object.entry_set.filter(entry_date2__gte=make_aware(d.datetime.today()-d‌​.timedelta(days=1)))) so I better read all the docs :D
 
8:37 PM
@wim at least it's my own intellectual product :P
googling the problem and implementing a fancy elegant solution thought up by someone else is hardly challenging
this is not to say that everyone did that, but most of the remarks here used that three-axis trick
and due to my own ignorance I just assume that most people weren't aware of that trick beforehand :P
 
wim
8:55 PM
I think most people don't google until after solved the problem ...
I'm kind of surprised your code could even work. I thought any approach that uses floats would fail due to the inaccuracy
 
well I kept seeing a particular article that explains the efficient handling of that hex grid :P
@wim either I'm so good or I got lucky
 
wim
it clearly should be solved with integer arithmetic
 
of course
 
wim
Antti posted an article, with a very elegant coord system, but I'm not sure it is necessary to know that approach
I solved it with integers without using or even knowing about the magical special coord system
 
as I said, I'm limited by my own ignorance :P
after I got mine to work I saw the article, so there was no point in me trying to figure out an elegant solution
but something tells me that if I tried, I'd still be working on it...
 
wim
9:02 PM
nah, you would have it in probably under an hour
 
you're overestimating my discrete math capabilities ;)
 
wim
the only insight needed is seeing that NE + NW + S == 0
or whatever 3 directions you choose for basis vectors (I used NE, NW, S)
then the rest falls out pretty trivially
oh, you rounded
probably the instructions weren't long enough to cause any issues, but that approach would probably fail with a big enough dataset
 
yeah, that's quite likely, and anyway I knew that there should be an integral way
but I was also sure that I can pull this off, and that there was an indeterminate amount of thinking involved in other approaches :P
I've never seen 2d space parameterized this way, and I have seen various non-rectangular coordinate systems, so I was strongly primed to do it the way I did
 
wim
that's surprising for a physicist
there's lots of that kind of maths stuff in quantum and particle physics
 
9:17 PM
yeah, I don't do any particles
this sounds more like mathematical physics and qubits and whatnot, which are all too close to CS ;)
 
wim
what kind of physics do you study?
 
solid state physics
technically quantum mechanics, but very very mainstream Schrodinger and Dirac equations, nothing fancy
 
wim
it's crazy thinking that those equations are about 100 years old now
 
more than that I think, Einstein's annus mirabilis was in 1905 and he was deeply involved in arguing with those guys about the nature of reality
 
wim
like, these guys didn't even have computers
 
9:28 PM
losers
 
wim
or, "computers" were women who crunched numbers
 
reject that edit please
 
thanks
 
@cᴏʟᴅsᴘᴇᴇᴅ though I'd note that typo questions are on topic, they are just usually unlikely to help future readers
 
@AndrasDeak Seriously? The CV reason for typo is in the off topic sub-category
 
@wim wow
 
@cᴏʟᴅsᴘᴇᴇᴅ that is another matter, but read the close reason more thoroughly
> While similar questions may be on-topic here, this one was resolved in a manner unlikely to help future readers.
typos are only obvious once they're pointed out, so it's not the same kind of "off-topic" as the rest of the off-topic reasons which OP could realize on their own
debugging questions are on topic, and these are debugging questions with narrow scope and trivial solutions
 
Ah, I get it
 
9:38 PM
answering them of course is still pointless, hence closing
there's probably a somewhere to remove that close reason from the off-topic category
 
9:56 PM
also another target suggested by hpaulj now
the fact that hpaulj doesn't hammer dupes is starting to bug me
thanks @vaultah
 
@vaultah This fellow has somehow devolved into a HNQ
 
:(
 
more like hng, am I right?
 
I didn't notice the votes it was getting because I had hit the rep cap at the time of answering.
@AndrasDeak g for garbage?
 
10:10 PM
That's hnnnng
The more Ns, the better!
It all started when someone downvoted my answer and upvoted the other. From that point, it became a vote war.
 
that's really sad
 
"Let me vote for this answer because I don't like the other user"
Ladies and gents, that's how you get HNQs
 
well HNQ is not for quality posts
"lot of people on the network click on it and upvote" more often than not implies triviality. Sometimes it's genuine brilliance or interesting tidbit, but that feels like the minority
 
Well, some of the C++ language lawyer questions are interesting reads, but most of the python HNQs are help desk questions really
 
you can write the most brilliant pandas.melt answer, but most people won't know which part is the beginning and which is the end, so no HNQ
 
10:14 PM
47 secs ago, by cᴏʟᴅsᴘᴇᴇᴅ
Well, some of the C++ language lawyer questions are interesting reads, but most of the python HNQs are help desk questions really
Or dupes.
 
yup
 
The most successful pandas question I've seen of late, is piR's canonical on pivoting dataframes
But even that didn't take off until I put a bounty on it.
 
Is there a way to get total value counts of select columns ( say columns 3 to 5)? I found something which applies value_counts to the entire dataframe: df.apply(pd.value_counts) , but I want the total value_counts of only three columns.
 
lot of code seems to be missing (no MCVE) stackoverflow.com/questions/48141950/…
@Moondra slice into your dataframe before taking the count?
 
Ah! Completely forgot about that. Thanks.
 
10:17 PM
@Moondra easiest way is with np.unique. u, c = np.unique(df.iloc[:, 3:6].values.ravel(), return_counts=True)
It's faster than apply
But it gives you global value counts. Not column wise ones.
 
Yeah, I want global value counts (total of those columns).
 
wim
@cᴏʟᴅsᴘᴇᴇᴅ Why did you write such a long detailed answer on such a crappy and trivial question?
 
I've missed you, wim
 
@cᴏʟᴅsᴘᴇᴇᴅ Works great. Thank you.
 
@wim I was trying to make up for the initial setback with the downvote I received for whatever reason.
But by that time, the other answer was already accepted.
 
wim
10:27 PM
crazy how some questions/answers randomly get upvoted like this
and other genuinely good / interesting questions can sit there chilling with 0 votes forever
 
I hear you. Well, I can sorta explain why this question received so much traction. chat.stackoverflow.com/transcript/message/40711198#40711198
But sometimes, you can't help it. It's luck by chance
 
wim
@cᴏʟᴅsᴘᴇᴇᴅ hmmm, not a very convincing explanation
I get random downvotes on my answers all the time, they don't usually catch on fire like that :)
 
I literally saw the -1 on my answer and subsequent +1 on the other. Then, a comment "Don't get why this is downvoted" on my answer by someone else and it just spiralled out of control from there.
But you could attribute just about anything to it.
 
^ I was there to confirm on that. All this fire was due to some random anonymous user. And then the chaos started. Then both the answerers started showing off all the possible solutions :D
 
10:44 PM
@MoinuddinQuadri Yes... and I'm a little peeved about the fact that Willem Van Onsem's added a "defaultdict" solution which came from my dict.get answer.
But that kind of stuff happens all the time... People who are seemingly "inspired" by your answers
 
wim
A dict with integer keys like 0, 1, 2 should be a list/tuple
maybe that's why you copped a DV
 
The 0, 1, 2 is specific to OP's problem where a list/tuple would work (as Willem's answer showed), but a dict is the only thing that can work for any generic case, even non-integer keys. For example, if you had keys -100, 10000, and 3.14.
 
cbg
 
wim
11:00 PM
shrugs true
 
:-) Well, I got a Nice Answer badge out of it, so whatever, I guess
 
done
 
hammered, thanks.
 
11:16 PM
good find on that dupe
 
I literally typed in "a, b = b, a + b" and it was the first hit on google :D Goes to show what little research people do before asking questions.
 
11:35 PM
Cbg!
Can anyone here think up some good thing to put on my title. I've been racking my brains all day but I'm out of ideas.
 
Yeah like "The data science guy."
I would like to keep it Python related but it's not so hot when you start answering JavaScript.
 
Oh, nice. You answer JavaScript questions?
 
My first one today.
Python is 69%
 
Congratulations!
I've only answered a handful of JS questions. Mostly because I don't know JS.
I have one answer with 97 votes, because answering it didn't require you to know JS.
 
11:45 PM
Yeah. Mine could have been rephrased "How do I do a multiplication in JS"?
 
I'm still impressed you got 97 upvotes for showing off some basic math. I'm not even joking; you're really good at writing answers.
 
Well any thoughts?
 
@Rawing Thanks... and yeah, that surprised me too, seeing as I (and of course, many others) have written answers much better than that, but not nearly as well appreciated
@Simon How about "I like ike".
 
Hmmm probably not.
A quick google tells me that's Ikerasak Heliport
 
Didn't think so. :p I don't know what it is, Indiana Jones said it once.
 
11:52 PM
I was thinking last year "If I down-vote you your question/answer it is doomed" would make a good title but I've changed my mind since then.
 
@Rawing not to belittle coldspeed's literary prowess, but that's more due to collective insanity than skill
 
@Simon Yeah, that just sounds arrogant
 
@Simon going by that theme, how about, "If your answer has a downvote, it's likely mine B|"
@AndrasDeak can't argue with that, tbh, there's an insane amount of entropy on this site
 
Coincidentally, my highest upvoted answer is also about math and it's also trivial
 
RTFMs and trivialities is where it's at
 
11:56 PM
@Rawing Just testing. @cᴏʟᴅsᴘᴇᴇᴅ It's an option but I'm not desperate enough yet
 
It's a bit depressing that I haven't managed to outdo my old self from 3 years ago yet
 
Give me 3 minutes, need my votes to reset
Also, Rawing, you don't answer frequently enough.
 
@Rawing Speaking of arrogant how about "I'm a legend?"
 
@Simon That's just cringey
 
XD
@Rawing That answer is very elaborate.
Yet complete
 
11:59 PM
@Simon It's better IMO, because at least you're only praising yourself. "If I down-vote you your question/answer it is doomed" sounds like you enjoy ruining other people's efforts
 
cringey is guaranteed once you start asking others what witty thing to write in your profile :P
 

« first day (2640 days earlier)      last day (2311 days later) »