« first day (2610 days earlier)      last day (2354 days later) » 

1:05 PM
That’s a pretty low bar though xD
 
1:19 PM
@poke that's not "haha", that's "yam microsoft". Do they also suggest firefox for opening urls because edge sucks, linking to knowyourmeme.com/memes/subcultures/internet-explorer? :|
s/microsoft/devs/ if it's third party
 
Not sure who you’re targetting that complaint at now
Git for Windows is not by Microsoft no
 
Who wrote that vim remark complete with SO blog link
 
And I consider it a good step to suggest alternatives to Vim in an environment where Vim is a rather irrelevant default tool
 
Discouraging a steep-learning-curve editor is fine; I object to the finger-pointing circle-jerk when vim is not bad
 
I don’t consider that “finger-pointing circle-jerk”
 
1:23 PM
unclear stackoverflow.com/questions/47714207/… And despite several attempt, the OP seems incapable of clarifying.
 
@poke I should read the SO blog first, perhaps I misremember the tone or the post altogether
I'll do that from laptop
 
Vim is hard to use and has a very non-intuitive user experience, especially for the target audience on Windows where doing everything through arbitrary keyboard sequences is completely illogical.
 
Admittedly I'm having a real crap day so perhaps my views are more bleak than usual
 
That blog post was merely (over-)analyzing the views to the question, but the facts are still true: That basic question does get a lot of attention, so obviously it is a problem for users.
 
I think it's less of an insult against vim and more of an insult against Git for Windows' users ;-) "Sorry, you must be this smart to use vim."
 
1:33 PM
heh :)
Which is absolutely appropriate too
Many Git users on Windows use some GUIs to do most stuff anyway.
So when they eventually have to do something from the command line, they are rightfully trapped in Vim
 
But to be fair, if I can't close an application by pressing the X button in the upper right corner, then it doesn't really jive with the Windows aesthetic
 
Well… you can… xD
But then Git Bash or whatever console you are using is closed :P
 
Hmm not ideal then
Modern versions of vim have a startup message telling you how to close the program, don't they? If this is still a problem, maybe they need to display that in a bigger font
 
Not if you open a file, probably
 
Worst case, Vim will create a temporary swap file, so when you retry it, instead of just getting to the editor, you will actually get a prompt to resolve that first
 
1:38 PM
But ctrl-c will. But again windows...
 
Just starting looking into recurrent neural nets and my head is throbbing. Friday's are not for thinking in 3 dimensions
 
Yeah, the startup message is only there if you open a blank Vim instance. But the users having those problems will never launch Vim directly. It will always be a prompt caused by a random Git action.
 
"Welcome to vim. To begin, please enter the following into the text box below: 'I can quit vim by entering Command mode with the Esc key, then entering ":" to enter Command-line mode, then "q" and Enter'"
 
@AndrasDeak You can’t Ctrl-C out of Vim
 
Yup
@poke but it tells you :q
 
1:40 PM
@Kevin “Welcome to Vim. Please close Vim first to start using it. Otherwise, in 10 seconds, we will show you how to RTFM”
 
type :quit<Enter> to quit VIM is not perfectly descriptive because it assumes the user knows about command-line mode
 
To be fair, modal editors are a bit weird when you aren't used to them. Of course, when you are used to them, they're easier on the fingers than emacs-style that requires the use of control-key sequences. But modern users, especially Windows users, are conditioned to controlling stuff with menus and mouse clicks.
A couple of weeks ago, I was watching a Windows user copying & pasting a bunch of stuff. It was almost physically painful for me to see her doing it all via menus, instead of using ^C and ^V.
 
Most users will end up with a document containing ":quit" and a newline
 
@Kevin Very true. Should be “Escape, escape, escape, escape, :q, enter”
 
@Kevin I doubt that
unless they start mashing the keyboard at one point, in which case it's all man for himself :P
 
1:41 PM
Remember that stupidity is the only unlimited resource in the universe :-P
 
ctrl+c only shows you that when not in input mode
 
@PM2Ring You have to understand that the knowledge range of users on Windows is a lot greater than on other platforms though
 
so when you see that message, you literally have to type :quit<Enter> to quit VIM
 
@AndrasDeak Ohh, so that’s what you meant. I thought you meant that it would quit vim
 
yup:)
 
1:43 PM
@poke Well sure. But part of that woman's job is to teach raw beginners how to use computers…
 
ouch then ^^"
But then again, when I look at how one of my superiors at PokeComp types on his computer… knowing that he has been actively programming a few years ago… it hurts.
 
by the way I've reread the SO blog post and I'm still "meh" about that remark
 
When I have to do stuff on Windows it takes me about half an hour to get used to not being able to paste stuff with a middle mouse button click.
 
chalk it up to my day
can't even read today
 
:waves: @JRichardSnape I don't know if you saw this when I posted it several months ago: Davy Knowles & Matthew Curry doing an epic version of Traffic's Dear Mr Fantasy. Also, Davy doing a cover of Cream's arrangement of Blind Joe Reynolds' classic Outside Woman Blues.
 
1:53 PM
@PM2Ring So different OSes do different things and doing something you’re not used to takes you time. That’s totally fine, I’d say.
 
Ideally all you need to figure out is how to set up a virtual machine ;)
 
hi folcs, how can I visualize this data?
I have no idea how I can do it in a way that you can actually "see" something
 
like that
your data are out of order
 
out of order oo
nooooo
 
1:55 PM
@AndrasDeak Great idea! :P
 
@Suisse I think you need a bit more blue…
 
haha
im blue daba dee...
hmm
 
@Suisse I don't intend to understand your code, but if you don't either just sort your data (or disable the lines first to see if the points are on a sane curve)
 
ah yeah with points! a good idea!
 
1:57 PM
by "sort your data" I mean "sort x and use those indices to reorder y too"
 
@poke Sure. And arguing whether modal or modeless editors are better is silly, since it mostly comes down to what you're used to and personal taste.
 
also @Suisse max and enumerate look a bit weird on that seemingly numpy-oriented input dataset
odds are there are better tools (with no loops) that do what you want to do
 
@PM2Ring Yup, I like both, depending on the situation I’m in. I write all my code in modeless editors but write all my commit messages in Vim… – but that’s why I think giving choice with the installer is a good move :)
 
definitely
 
@PM2Ring I can accept someone who wants a modeless editor but I'd always be the one with superior taste.
"Anyone who shows resistance towards vim is inferior to me." - Unihedron
 
2:05 PM
Anyone have experience with PyCharm saying you can't merge because the merge would undo your local changes, but git says there aren't any uncommited changes?
 
It’s likely because you have local untracked files that are not untracked in the commit you are attempting to merge
@Unihedron lol
 
PyCharm should somehow outsource the problem to git
 
In the scifi book Too Like The Lightning, anyone is free to have any religion, but it's illegal to tell anyone except your priest/therapist. Maybe we should do the same thing for text editors and IDEs.
when you install vim you get the email address of an emacs user; and vice versa. You can argue about the merits of your software to them and them alone
 
I learned last week that in France it's a fireable offence to talk about your religion in the workplace
 
hm with points.. not really clearer
 
2:09 PM
yup, so your data in this form is gibberish
 
what I really want is to find the correlation between those two datasets
 
you need to 1. figure out what you want to actually do, and 2. do that correctly
 
Maybe you need to put it through a modem to get out some clear data
 
these points are from the first dataset
 
@Suisse you're only plotting the one...
if you want correlation, plot the values in one vs the values in the other
 
2:10 PM
yes
 
drawing correlations require an awareness to the problem to use the right plot type
 
@poke beeeeep BOOP BOOP BOOP krskrkrksksks
 
ok let me do that haha
 
that jolt of terror when you pick up the phone and realize that you're breaking up the internet D:
 
@poke I might be misunderstanding what you said, but shouldn't git add . in the project root directory and then git commit fix that?
 
2:12 PM
@Rawing git add . won’t add files that are ignored for example
 
Maybe the real problem is just my inexperience with git :D
 
@Suisse That looks rather chaotic
 
@Rawing I would suggest you to attempt the merging from the command line. That might give you better feedback where the conflicts would be
 
yeah ok these are the data:

I had two wav audio files. and should check if they are the same (same content - repeat recognition)

than a friend of me run his fancy machine deep high learning algorithm over it and got these 2 datasets

one row shows the frame with the highest probability that a searched utterance is in it
 
wow. So it IS a modem sound xD
 
2:16 PM
ahaha
 
>git branch
* abstract-base-classes
  master

>git merge master
Already up to date.
I am very confused right now.
 
Not a very exciting AoC today... I didn't even get to use regex to parse the input.
 
@Rawing git log --oneline --graph --decorate --branches
 
good I'll have more time for getting caught up :P
 
I think I spent most of the time trying to come up with good names for each value in the line. "so inc and dec are operations performed on the register, should I call them op? But then what do I call the operator that compares a register with a number?"
 
2:21 PM
does that show you something unexpected for the relationship of the two branches?
@Kevin comp :P
 
I went with cmp, in the end :-)
 
that's even better, no silly vowels
 
It was a fun exec exercise for me
 
I named "the amount to increment or decrement by" amt. Couldn't quite get all the vowels out of that one.
I considered using exec but eventually went with a dict of callables from the operator module.
 
@Rawing What are you trying to do actually? :P
Because you are on abstract-base-classes and just attempted to merge your local master branch into that.
 
2:25 PM
Yes, I wanted to resolve merge conflicts in my own branch so that my teammates can take a look at the merged code before we actually push it into master
 
@Kevin iec, or dnc
 
so there are no conflicts with master perhaps?
 
Now, I'm not sure what I should be seeing, but the history doesn't show the branches being merged:
* a9d36e6 (HEAD -> abstract-base-classes) added GameMonitor class
* fb0b134 finished implementing Card base class
* 1e228df (origin/abstract-base-classes) fixed DTOs, implemented most ABCs related to Cards
* 0447d4f (master) README
 
It’s possible that your local master branch is outdated, so you could switch to master first and pull there, or alternatively merge origin/master
“doesn't show the branches being merged” HEAD is ahead of master, so no merge was necessary.
 
Oh. I was under the impression that git pull pulled all branches :/
 
2:27 PM
No, git pull will fetch the remote tracking branch and only merge that one :)
 
@Rawing I don't think it does
that would affect all your branches
 
So checkout master, pull, checkout ABC, merge. Got it.
 
yup
 
\o/
(or rebase if that's your thing)
 
or git fetch && git update-ref refs/heads/master origin/master && git merge master if you fancy using plumbing commands… :D (only do that if you don’t have local commits in master though!)
 
2:28 PM
That sounds dangerous. I'll stay away from that until I grok git :)
 
the end result is the same as merging, but it ends up with different history: it's as if you had directly done your changes to master
but this copies your commits over as a successor to master, throwing away the original actual commits
some people prefer rebasing because the end result is cleaner, some people hate rebasing because it falsifies history
that's my understanding at least
the git master can correct me if I'm being wrong again :P
 
I likely have “some” good answers that explain rebasing… for example this one, or this one
 
I see. I think I'd rather leave the history as is
 
Rebasing can be very useful later while working on stuff
 
I'm probably leaning towards merging myself but I can imagine the kind of spaghetti where it would've been more beneficial to rebase ;)
 
2:33 PM
But yeah, just avoid it now if it’s too scary for you. Take your time to get comfortable with it :)
 
@poke The first paragraph already answered another question I've had about git. Very useful, thanks!
 
just bookmark his body of work in
 
The second answer really goes into the details on how branches actually work. I think it’s very helpful to understand that model when working with Git. Especially since other VCSes usually don’t work like that.
 
there's also the git parable for the philosophy
 
I think I'm going to spend a few hours reading about git and then I'm going to log that time as time I spent working on the group project
 
2:39 PM
hehe
 
don't forget to play the JS game
 
"What did you do this week?" "I grokked git" "Okay, you get an A+"
 
Also this answer on how Git works internally (which I think is also useful to know)
 
I'll read that
 
What Linus says about rebase: gist.github.com/kstep/e28d1c762da4e97065fe
 
2:41 PM
originally here, right?
 
@AndrasDeak Yep.
 
Jul 25 at 19:52, by davidism
@Suisse unfortunately, this chat is not the place to get step by step help as you learn. We just aren't able to do that in a non-frustrating way. Instead, spend time reading tutorials and experimenting. You need to have a base understanding of Python before we can help you.
Jul 25 at 19:52, by davidism
@Suisse please read http://www.skidmore.edu/~pdwyer/e/eoc/help_vampire.htm before continuing.
garlic
user image
2
 
all you want for Christmas is a duck typist?
 
:-|
 
Something is wrong with that partridge, and the pear tree isn't looking so hot either
 
2:50 PM
If it typoes like a duck, then it is duck enough.
 
Did anyone use exec for day 8? I considered a simple rewrite of the input to do it.
 
I did
 
I wonder if it ends up being any faster, since you still have to parse and write the file again.
But I like the puzzles where that's an option.
 
@Kevin, it is ducks quacking
 
wim has an exec one for both parts
 
2:54 PM
@davidism there was exec also in the reddit megathread
I used eval only :D
 
I had to read this sentence a dozen times until I finally realized that it's actually correct english: "Each letter represents a commit and all commits one is connected to to the left are its parent."
 
So there are three to five missing ducks. Could they all be hiding in the branches of that one tree? Unless the visible duck is unusually large compared to the average duck size, I suspect not
 
*ducks*
 
2:59 PM
An input-rewriting solution would be interesting, but it's not as fun if you need to do an initial pass first to collect all the variable names and set them to zero
 
@Kevin wait, is this duck the famous one with the red beak?
 
duck is too greasy, chicken is much better
 
I'd say it's more of a burnt sienna
 
Passing a custom dict type... Clever.
 
3:01 PM
With exec you can pass a defaultdict as globals.
 
@rlemon <insert gif about a horse casually tracking down and swallowing a little bird"
 
Andras-wim-Kevin'd
 
the python ninjapede...or something
 
Mine is "saner" spoiler
 
3:14 PM
cbg everyone
 
cbg
 
I announced that Werkzeug is dropping support for 2.6 and 3.3 on /r/flask, and someone responded "there's still a lot of embedded py 2.6 hardware out there."
The argument's just ridiculous in general, but was anyone actually running Werkzeug on some ancient embeded hardware?
 
"Where's the comment? Oh, under the >show downvoted comment< button"
 
Someone probably is. I was in a plant 2 months ago that still had hydromatic controls for some of their core processes.
 
@davidism And if they are, do they need to run the newest Werkzeug version on that ancient Python versions?
 
3:20 PM
They hadn't QUITE gotten around to upgrading to a PLC yet.
But, in fairness, they weren't worried about the latest firmware upgrade from AllenBradley on them, so I see your point
 
If one is capable of installing newer versions of Werkzeug on one's embedded system, what is stopping one from also installing a newer version of Python? Am I missing something here?
Tangent: this kind of "getting mad on other people's behalf" really rustles my jimmies. If the embedded systems engineers are hurt by this, then let them speak for themselves.
 
@Kevin Let not your jimmies be rustled.
There is no need to be upset.
 
[rustling intensifies]
 
@Kevin they can't, they're just too comfortable neatly tucked into their sheets...
 
If their code is in Py2, I could see some managers not wanting to update it to the newest version to "save" effort... not saying it's right..
 
3:35 PM
2.7?
or do you mean if they don't go to 3 they might as well stay with 2.6?
 
I would assume the latter....
I don't know why or want to know why they don't wanna go from 2.6 -> 2.7 (this one baffles me)
 
Abandoning support for something you know still has a reluctant user base is still a net good because one day will come when they can do absolutely nothing with their dusty old platform and their bosses will either go bankrupt or let them upgrade
 
maybe managers don't wanna take the risk of their code breaking ?
 
When the risk becomes "1% of it not working if we upgrade, vs 100% of it not working if we don't upgrade" then the problem solves itself
 
Wise words :D
 
3:42 PM
too bad that developers of open source software are usually not the kind that go on a Punisher-esque vigilante spree against obsolete systems
 
On the other hand, Fortran systems still exist.
 
and it's not obsolete
fortran 77 is
 
On the other hand, Fortran 77 systems still exist.
 
I guess
 
OK, so appending items to a list as you're iterating through it is a bad idea.
TIL.
 
3:46 PM
Alternate solution: the target audience dwindles in size as users find new jobs or retire or die. But this happens asymptotically, so they never totally vanish. They just become so small that nobody cares about their problems any more.
 
morning cbg
 
most of the things hated in fortran are listed under things noted as obsolete in fortran 90
oops, we have a few of those in our code base
 
@JGrindal Similarly, removing items from a list as you're iterating through it can also not do what you expect, unless you iterate backwards.
 
In an efficient market, the pain of using an old ass legacy system would be offset by a higher salary. We can ignore the cries of anguish of those that weep into a wad of hundred dollar bills.
 
that sort of works with COBOL, doesn't it?
 
3:48 PM
a = list('abcdef')
for c in a:
    a.remove(c)
print(a)
#output
['b', 'd', 'f']
a = list('abcdef')
for c in a[::-1]:
    a.remove(c)
print(a)
#output
[]
 
interesting
 
A lot of the time you can refactor mutation-in-a-loop into a list comp. for item in seq: if condition(item): seq.remove(item) becomes seq = [item for item in seq if not cond(item)]
Perhaps using seq[:] = ... if you insist that the id needs to stay the same
 
OK, here's a question, I need to loop a function while any element of a list has a certain property.
 
I'm thinking while any(has_property(item) for item in my_list):
 
while( any elements of constraint_list.empty() ):
    do_function()
@Kevin any is exactly what I needed. Thanks, buddy.
 
4:01 PM
@JGrindal though, that is a bit expensive as it is...
why wouldn't you have a set of something that has the property, then remove from that set
 
But as I said the other day, it's generally a good idea to avoid .remove (and do what Kevin just did), because .remove has to do a linear scan to find the item to be removed, and then it has to move all the subsequent items down to fill the gap. Both those O(n) operations run at C speed so if you're only removing a single item, then .remove can be a valid thing to do. But if you're removing a bunch of stuff with a O(n) loop, using .remove makes that process O(n²).
 
It seems to be a common intuition that, if a class X has function F, then you should be able to do my_list_of_X_instances.F() and get some kind of coherent answer back. I wonder if there are any languages where this is actually the case.
A bit tricky to implement in practice, I think, because then how do you distinguish attributes/methods of the list type from attributes/methods of the elements of the list?
 
@AnttiHaapala Because I would have to rebuild the set after every iteration, considering the do_function() could, conceivably add or remove elements from a set that is being checked.
 
class DelegatingList(list):
    def __getattr__(self, name):
        try:
            return self.__getattribute__(name)
        except:
            return [getattr(item, name) for item in self]

seq = DelegatingList()
seq.extend((1+2j, 2+1j, 0+9j))
print(seq.imag)
#[2.0, 1.0, 9.0]
 
4:08 PM
class DelegatingList(list):
    def __getattr__(self, name):
        try:
            return self.__getattribute__(name)
        except:
            return DelegatingList([getattr(item, name) for item in self])
    def __call__(self, *args):
        return DelegatingList([item(*args) for item in self])

seq = DelegatingList([
    "Coconuts are {}",
    "Spam is {}",
    "namespaces are {}"
])
print(seq.format("neat"))
#['Coconuts are neat', 'Spam is neat', 'namespaces are neat']
 
@davidism oh that must be that weird black oily bottled baby thing
 
Death Stranding is an elaborate ruse that exists only to give an excuse for Mads Mikkelsen and Hideo Kojima to hang out together.
 
oooooh that explains it
I've seen them together on imgur but didn't know who Kojima was, and I saw Mikkelsen in that trailer a while back
 
keeping it open for future answers
 
4:26 PM
@davidism something something blank cheque :D
 
@Kevin "Hideo and Mads are best buds" is my favorite narrative arc of the whole thing.
 
cbg
 
If you're not using eval in AoC today then you're dead to me.
3
 
A mysterious old woman placed a geas on me not to use eval or exec, unfortunately.
 
4:34 PM
@Ffisegydd view spoiler
 
I spent an hour today going through functional programming and pure functions and best practice with a minion today, then I came home and wrote dpaste.com/27BRSY5
@piRSquared I had the same word, but my specific usage of eval meant it wasn't an issue
 
Ahh
 
Quick question - Best editor for python...?
 
@HarshDubey pycharm
 
vim
 
4:40 PM
3 hours ago, by Kevin
In the scifi book Too Like The Lightning, anyone is free to have any religion, but it's illegal to tell anyone except your priest/therapist. Maybe we should do the same thing for text editors and IDEs.
None of you are free from sin
;-)
 
@Kevin
@Kevin I knew it you would say something exactly like that,
 
I'm going to go to lunch so I don't taint my ears with that-which-should-remain-secret
 
I like punch cards
 
@piRSquared Artichoke :)
 
@HarshDubey You're right of course (-:
 
4:46 PM
But just to have a secondary option apart from punch cards what would you suggest @piRSquared
 
IDC, I use a combination of vim, pycharm, jupyter notebook
 
So clearly nobody's suggesting sublime. I thought it kinda looks cooler. :P
 
VSCode is good as well
 
Honestly the real reason I like pycharm is because of its pep checks. It keeps my code well formatted. Handy tools for inserting doc stubs. But is someone told me to try something else, I might. DON'T EVER SUGGEST GIVING UP VIM TO ME! CUZ... NOT GOING TO HAPPEN!!!
 
Sublime is nice but I feel like it's getting more and more outshined by the competition recently
 
5:02 PM
pycharm is rather amazing especially if you have type annotations
I do my aoc in Pycharm
 
vscode is really nice
 
@PM2Ring :waves back: Thanks PM2. I'm a bit of an irregular room guest currently, but aiming to up my Cbg quotient over Christmas and New Year
 
It's good to see you here again, JRS, even if you're just mostly lurking.
 
JRS! JRS! JRS!
 
5:18 PM
I don't get a "FIZZY! FIZZY! FIZZY!"? ;__________;
That's you off the Christmas card list.
 
Cabbge
I use VS Code, I read a article that said there are 55 million lines of code in it, BUT IT LOOKS SOO NICE... starts to tear up... snuff
 
the "but" there implies that very large programs can't be nice, but I think the qualities are unrelated.
Or, if they correlate, they do not correlate absolutely
 
I am so happy about using the "Queue" before I was peas about why it was there but know I am using it for so much, XD
 
You doing a lot of threading, then? That's primarily what it's for.
 
I agree, as long as the program run smoothly it is fine to write 55 million lines of code, it may just be a wast of time for the devs
To the treading part yes
 
5:29 PM
Ambitious.
 
I know right
Right now I only have 3 threads(including the main thread), but it is still cool
Boy, I am still a bit of a Green Bean, threading for the first time.
Rhubarb all!
 
Henlo friends
 
cbg @corvid
 
I didn't know it was possible, but I found a Youtube video whose comments section doesn't make you regret reading the comments section. youtube.com/watch?v=34UutDrXV2Q
No chain letters, no political arguments, no conspiracy theories, no flame wars. Is this the power of japanese retro minimalist easy listening music?
 
6:08 PM
Woo I got a bounty on a bug, free $500
 
SO is now pay to win? Oh, nevermind silly me.
 
Yes, pay with your time!
 
I'm jealous. I don't need the money, but I could use the validation.
 
Hi, Everone
Can anyone help me with a problem? I'm python newbie. I'm trying to solve SPOJ problem
http://www.spoj.com/problems/DOUGHNUT/

How can I take user input separated by space for a certain num of times and assign them to each variable

1. First line contains n no of input lines
2. For n times I need integers assigned to varible a,b,c

Input:
3
5 15 3
1 5 4
13 25 2

I was trying to do this way, but it was not correct

n = int(input())
for _ in range(n):
a,b,v = [int(x) for x in input().split()]
 
You are a valid Kevin to me.
 
6:18 PM
@AshishSahu Other than the problem of assigning to v instead of c, and the incorrect indentation, looks OK to me.
What version of Python are you using, incidentally?
 
@Kevin
I'm using python 3.6
 
So what's not working?
 
OK, just checking. Because input().split() would almost always crash if you tried it in 2.7.
I have a feeling the actual problem is "after the loop, how come when I do print(a) it says 13 and not [5, 1, 13]? I assigned it three times so it should have three values"
But of course that is not how assignment works
 
When I'm trying to access a, instead of list of three integers, it's just showing me 13
 
Yesss nailed it
 
6:24 PM
@dav
 
@AshishSahu please try to type a whole message first. Also, you can edit your message for up to two minutes.
 
DSM
Brief cabbage for all.
 
So you want to make a list of inputs. Make a list, then append the result of [int(x) for x in input().split()] to it in the loop.
 
DSM
x = 2
x = 2
print(x)
@AshishSahu: would you expect to see 2 printed there or [2, 2]?
@Kevin: impressive psychic work there.
 
Small question: In Python 3, if I have a list of pairs such as [('foo', 1), ('bar', 3), ('baz', 2)] with unique first elements, how would I obtain, say, the second element of the pair starting with 'bar'?
 
6:27 PM
Perhaps the confusion comes from the line containing the list comprehension. "The right hand side of this assignment is a list object, therefore each of the variables on the left hand side should also contain a list object". But of course, this is not how assignment unpacking works.
 
@LegionMammal978 next((y for x, y in pairs if x == 'bar'), None)
Or just convert it to a dict.
 
DSM
Aw, I was going to suggest dict(pairs)["bar"] as a shortcut if the keys were hashable. :-/
 
I was going to suggest davidism's without the None
 
DSM
I'd even typed out next(v for k,v in s if k == 'bar') but davidism was too fast.
 
I can never remember how to create a dict from a collection of 2-tuples. It's like plugging in a USB drive, I always get it wrong the first two times.
 
6:31 PM
@davidism I got it. Thanks for help.
 
Predicted next problem: "I have three lists a, b, and c, and I want to iterate through all of them in parallel"
Thus revealing that it was never necessary to have a monolithic collection of input values, and it would have been sufficient to process them line-by-line and discard them
 
@Kevin Wrong the first two times? How many ways are there to attempt plugging in a USB drive?
 
There are two ways, and one of them is right, and two of them are wrong. It's the exception that proves the rule of the pigeonhole principle
 
6:47 PM
Sooo... One of those two ways is wrong and right with each state having some probability attached. Only one state materializes upon attempt. The other attempt is 100% wrong.
And... I'm 90% sure ^ is right... but 30% sure ^ is wrong
And I'm certain of ^
 
@piRSquared USB drives obey Fermi-Dirac statistics , so you have to rotatate them by 720° to return them to their initial state.
 
@PM2Ring I can watch that gif all day!
In fact, I've been watching it too long already
 
Here's a better one:
 
@DSM qz.com/1126615/… may be of interest to you
 
wim
@Ffisegydd oh man, what a beautiful office
 
6:58 PM
Or Cloudera, depending on when the photo was taken
 
Go Pandas!
 
wim
@davidism I timed my sane solution vs the exec one .. the exec one was slightly faster
 
Pandas is basically the reason I have any rep at all on SO.
And all directly corresponding with that chart of the rise in popularity.
 
7:19 PM
Is this truly the best way to test for iterable / str?
lambda obj: hasattr(obj, '__iter__') and not isinstance(obj, str)
 
wim
> I believe the widespread use of format strings in logging is based on two presumptions:
1. The first level consumer of a log message is a human.
2. The programmer knows what information is needed to debug an issue.
I believe these presumptions are no longer correct in server side software.
great article
I moved a few of my Python apps to structlog recently and couldn't be happier with it!
(same author as attrs, btw)
 
7:44 PM
I think you may want to recheck that first sentence. — user2357112 Dec 5 at 18:38
@user2357112 I got a downvote after I made my last edit, so I guess the missing space was not the issue. Can I get another hint?
Is it because I didn't use backticks...?
Maybe the nested quote marks make it impractically difficult to parse.
 
Does anybody know how hash is computed for strings?
Actually, for any immutable datatype? Is it just a manipulation of id or is something going on there?
 
I think github.com/python/cpython/blob/master/Python/pyhash.c contains the implementation
Or, hmm, that might just be for numbers?
In any case I usually expect hashes to be consistent across executions, and for ids to not be consistent, so I doubt hashes depend on ids
 
I see
 For numeric types, the hash of a number x is based on the reduction
   of x modulo the prime P = 2**_PyHASH_BITS - 1
 
I assume github.com/python/cpython/blob/master/Include/ucnhash.h has something to do with unicode hashing, but I can't find a .c file to go with the .h. Maybe it's a default C library? idk
 

« first day (2610 days earlier)      last day (2354 days later) »