« first day (1567 days earlier)      last day (3606 days later) » 

18:00
Is there something like from __future__ import ......
for literal eval? Not to my knowledge
Was just jokin .... The future is bleak for py2
To be clear, in 2.7 literal_eval(s.replace(",", "+")) pukes, but sum(literal_eval(s)) doesn't.
DSM
DSM
Must be a slow question day if this is what's capturing our interest.
@iCodez just because someone misunderstood what I meant. Dont replace the commas, sum the output of ast.literal_eval() on the original comma-separated list of numbers.
@Kevin not sure why people thought that'd work. :-P
DSM
DSM
18:02
Fight the power! sum(json.loads('[{}]'.format(line)))
@MartijnPieters Because 3.X has spoiled them by being way more permissive when literally evalling.
@DSM The only answer I've given today...
@DSM I .... er.... .... am not sure I want to see that again.
user2555451
@MartijnPieters - Yea, that works. @BhargavRao came in here earlier and asked if you could evaluate math expressions without eval. I said to use literal_eval and assumed he was referring to that.
@DSM Now that I've achieved ultimate cosmic power via Python gold badge, I don't need to participate in the question rat race any more. This question is now my pet project, the equivalent of a retiree puttering around his backyard garden.
18:05
@Kevin it only works because constants are folded by the peephole optimiser.
so the compiler replaced 2 + 2 with 4 at some point.
Would you say that's an implementation detail, then?
or at least I think it does..
@Kevin You got the gold? Congrats ...
ah, no, they added BinOp support, I see..
Neat :-)
18:06
it is still documented as not supporting operators though.
anywho, time to catch a train.
I was about to say, they need to update their docstring.
DSM
DSM
Train-catching rhubarb for Martijn!
@davidism +1, now at 51 :D
49 more and you get the gold badge
I would like to know what CPython actually does when you call a callable, but I have no idea where in the source I should start looking.
of the T-shirt, it would be most awesome if it were more awesome than the awesome pylonsproject.storenvy.com/products/…
@Kevin 1 sec
18:11
I need to learn Python's secrets, so I may make them my own and integrate them into KevinScript.
Reveal to me the secrets of __new__...
Maybe searching for the CALL_FUNCTION bytecode instruction would be a good start.
ternaryfunc tp_call;
or what do you mean?
the thing is: look up the tp_call of implclass is my guess
I think that's what I want, thanks :-)
It's hard to say for sure because I don't know what I don't know.
The link to PyObject_Call also looks useful.
Yes, it is possible. Any other questions? — Antti Haapala 56 secs ago
@AnttiHaapala Any other questions should be posted as a new question. — Bhargav Rao 30 secs ago
You guys are like a comedy duo :-D
Actually that is not my idea it is a copycat ... I had posted like Antti, and someone replied to me like that ...
I'm indebted to that guy
DSM
DSM
18:17
@Bhargav: your answer looks to me like it'll work regardless of whether or not the last element is a repeat. What am I missing?
@DSM Seriously??? Then I'll edit
DSM
DSM
Well, think it through first, but I don't see why you added that caveat.
How do they do that: come to stackoverflow, then read some questions, read the FAQ, look for duplicates on the issue, and then ask a question that is almost but not quite exactly unlike all the worthy questions on the website.
@DSM I thought so, as I'm doin 1,len(x) ... So added the line
I wouldn't dare. But I am a Finn. Whenever I post a question to stackoverflow, I think about it for at least 2 hours...
DSM
DSM
18:21
But all that's doing is making sure that you have a previous element to compare to. If there is no such element (because the list only has one element, say) that's okay, because if there's only one element then by definition there are no changes.
@AnttiHaapala Me too. Whenever I see a poorly formatted question, I think, "how could they have missed that? Don't they reread their work ten times before submitting?"
Yeah .. I did end testing and it's workin hot
Although for answers it's more like two times, since time is limited
Well people are fast, this wasn't even the first list comprehension answer... by far! — Roberto 5 mins ago
Saw this on another answer by the commenter himself ....
The meta post about David is now one of "Hot Meta Posts"
18:30
link-pls (I sooo want to write [tag:link-pls]
DSM
DSM
@davidism: that image is AWESOMENESS
31
Q: Replaced " with " in edit

PeterI do not understand the edit made on my question: http://stackoverflow.com/posts/22328191/revisions (direct link) If it is a retagging job, why have the quotes been changed? (It even does not work in the code section.)

I can resolve the problem with KevinScript's typing system if I make function calling 25% more complicated. Hmm, not sure if terrible hack or standard technique...
DSM
DSM
I thought you'd decided to make all the dicts.
Cabbage!
18:32
Interesting new behavior with Werkzeug 0.10 (related to Flask): stackoverflow.com/a/28242285/400617
@Kevin ?
@DSM, I did, and that's working relatively well. I can make classes, but classes can't yet make instances.
DSM
DSM
Bah. Being able to instantiate a class just shows your interface isn't sufficiently abstract yet.
@Kevin Wait, KevinScript isn't an actual thing, is it?
@Kevin so did you understand how Python does it?
user2555451
18:33
Comment I got about annotations:
user2555451
I'm still hoping the actual input and return type will be enforced at some point, rather than just serving as a fancy comment syntax. — user3467349 6 mins ago
@Iplodman I feel like you've asked me this before, but yes it is
user2555451
If that ever happens, Python will have lost what makes it great.
@Kevin I don't believe I have ;P
haha, missed my train.
18:33
it is always the obj->obj_type->tp_call...
Also: That's awesome.
In the cold at the station now.
Next one at 18:45
DSM
DSM
Well, I for one don't think it's awesome that Martijn missed his train and is now cold.
must be a new meaning for cold
18:34
@BhargavRao I'd not call that a typo,
There surely is a good dupe target for that common error.
Oh no ... The train missed being greeted by Martijn, It will now have to silently cry
@AnttiHaapala Partially. I determined that a Python class can have different implementations of __call__ in its __slots__ and dynamic attribute dict*, which gave me an idea for my own work.
(*uh, at least I think it can)
@Kevin can't, for obvious reasons.
@MartijnPieters Do you think there may be a dupe for that?
18:35
The reasons are not obvious to me, I'm afraid!
none of the methods that exist in the typeslot can be overridden like that
because it would make python way too slow
In any case, I'm not yet entirely satisfied, because the devs appear to claim that Python could operate just fine without __slots__, albeit slower. So the __call__ collision problem I'm experiencing with KS wasn't solved with slots in Python.
DSM
DSM
override all the methods!
it would need to see if the getattribute slot is empty, and if not then ask it if there is call, then see if getattr is empty and if not then... and what if it needs to ask getattribute if there is getattr to call and .... ...
re-cbg
18:37
cbg
@AnttiHaapala Agreed. But you can still put __call__ in the dynamic dict, even if it doesn't do anything.
interesting
@DSM it's @Ffisegydd's doing, check the trello board as well
Python 2.7 ast.literal_eval() also handles BinOp addition and subtraction.
@MartijnPieters complex
18:38
@AnttiHaapala right, that was it.
been there, had that "interesting".
DSM
DSM
I'm having flashbacks. Didn't we reach this conclusion (re: complex) on this same topic about a year ago?
That was a unintended side effect then: hg.python.org/cpython/rev/884c71cd8dc6
hrm, he made it more liberal in what is accepted..
18:41
@BhargavRao stackoverflow.com/a/24621885/918959 such a helpful answer ;)
> - ast.literal_eval() can now handle negative numbers. It is also a little more liberal in what it accepts without compromising the safety of the evaluation. For example, 3j+4 and 3+4+5 are both accepted.
@AnttiHaapala Answer of the decade
I thought that the UnaryOp handling was meant to do that.
yeah, me too
does Python support Gaussian multiplication?
18:43
Python 2 ast.literal_eval() supported negative numbers just fine.
>>> import ast
>>> ast.literal_eval('-3')
-3
DSM
DSM
My favourite "huh?" answer of the last few years is this one:
> You will need to use recursion for this solution or maybe lambda. How deep can the lists be?
@DSM and why is it still there :D
I'd have flagged everything but I have no flags :(
So deep that you can see ***** rollin in it
But if you can't use the lambda to apply the polymorphic translation for each dictionary, you can try to convert the loop invariant to binary
DSM
DSM
@AnttiHaapala: I like preserving answers like that, though, otherwise I can't look at them later..
And "recursion or maybe lambda" is now my internal expression for "I have no idea how I'm going to solve this problem"..
18:46
hmm, we should make an extra section in sopython, sort of like trophies - screenshots of deleted posts.
a week ago or so I was googling an issue and I found one of my answers on a SO question ... that was nice
If all else fails, run screaming to OEIS and hope your solution has already been found somewhere
DSM
DSM
@Antti: and this guy I think might actually have been drunk.
@MyNameIsKhan at some point when reading your lines I thought you are the most sophisticated markov chain text generator ;)
But how can Markov chains be real if our exponentiations aren't real?
user559633
18:49
annoying
user559633
knock it off
@DSM How is it that your answers attract such answers?
@BhargavRao it is not, it is just that DSM never flags
DSM
DSM
@Bhargav: I don't think it's anything particular to me, it's just that if you answer a lot of questions you come across a lot of.. creative.. material.
And don't flag them too, I will not be able to enjoy them
DSM
DSM
18:52
Okay, it's Friday, which is traditionally a time for me to enjoy the cuisine of the subcontinent. Lunchtime rhubarb for all!
@MartijnPieters I think that is an error there?
rbrb @DSM
>>> ast.literal_eval('+2')
I guess this is the reason
I can't decide if I like Node.js, or really hate it...
you hate it.
18:53
That probably means you hate it.
it has some good things.
there is not many things that do not have upsides
I feel like it's a tool for a very specific purpose, that tends to be overused outside of that purpose
ofc
like php :D
php was meant to embed a counter on your personal home pages, but now it is overused outside of that purpose, for programming.
I remember when I lost a folder with my project's sources, it took about an hour to recover it (using testdisk) simply because of node_modules directory
the node_modules wouldn't be too bad... it is the nice idea there, that every module can have its own version of things it sees.
18:59
I think Node.js is mostly just good for managing queues of events, that seems to be very straightforward here. But Flask was just SO much quicker to develop and seemed much more testable
this is not possible with python.
OSGi makes it possible for java
Now trying to determine how x.__call__(*args) has the same behavior as x(*args), except when x is a type. What makes them so special?
hmm?
getattr?
waat?
>>> int.__call__()
0
The ast.literal_eval thing was bugging me; Python 2 parses -1 as one AST tree number.
19:12
and 3 gives unary -?
>>> ast.dump(ast.parse('-1', mode='eval').body)
'Num(n=-1)'
>>> x = ast.parse('-1')
>>> ast.dump(x)
'Module(body=[Expr(value=UnaryOp(op=USub(), operand=Num(n=1)))])'
in 3:
>>> import ast
>>> ast.dump(ast.parse('-1', mode='eval').body)
'UnaryOp(op=USub(), operand=Num(n=1))'
and that is what Raymond tried to fix.
>>> ast.dump(ast.parse('-1', mode='eval').body)
'UnaryOp(op=USub(), operand=Num(n=1))'
yeah
so what went wrong?
but this should have been enough to handle that:
    isinstance(node.operand, (Num, UnaryOp, BinOp)):
        operand = _convert(node.operand)
        if isinstance(node.op, UAdd):
            return + operand
        else:
            return - operand
19:14
>>> ast.literal_eval('+2')
2
no?
if there is otehr unaryops
unaryop = Invert | Not | UAdd | USub
>>> ast.literal_eval('~2')
That's not a literal though.
waitwaat
This is all about imaginary literals too: docs.python.org/3/reference/…
~2 is an expression.
Granted, - and + are not literals.
I mean: what do you mean by "this should have been enough"
Indeed, those are operators, but so often seen to be part of the numeric literal.
19:18
Hi :)
I meant that I am still pondering why + and - binary ops have been loosened.
and unary + ;)
Someone here who know good Python Challenges any sites?
python 2 did parse - as part of the number but not unary +
@Emyen Loads.
The Python Challenge is a classic one, just figure out the puzzles.
For general coding challenges, CodeEval.com and Hackerrank.com have enjoyable challenges.
For math coding, Project Euler.
Haven't tried Codechef, but it appears to be popular.
19:21
Wouldn't it be great if we had a list of these somewhere? ;-)
there was one site that feels a lot like a game, forgot what that one is now, only looked briefly a while back when a SO question about a challenge there popped up.
@ZeroPiraeus like wiki.python.org/moin/ProblemSets you mean? :-P
rather unmaintained, sadly.
buh... what do people conventionally name a folder where the back end / serverside code lives?
app?
19:24
@ZeroPiraeus as in in a question and answers, on stackoverflow?
I thought app was usually for front end code
it is in the subdirectory of /srv ;)
@AnttiHaapala Yeah, like, if each of the popular "programming challenge" sites had its own tag, you know?
Thx Matijn!
I am trying out hackerrank.com now ;)
@ZeroPiraeus now that could be cool
19:31
KS type system design 4-b might work, but it requires the interpreter to treat type objects differently from other kinds of objects. This seems... impure.
@AnttiHaapala: I'll put it down to specific edge cases with complex numbers where UnaryOp FPnumber BinaryOp UnaryOp ComplexNumber fails or something.
and it is not worth scanning the subtree to ensure that it converts to a valid float-or-int with binop with complex number or something.
So, to summarise, as a side effect of having to handle unary ops and complex numbers in Python 3, ast.literal_eval() grew the ability to also handle addition and subtraction, but lets not advertise this too widely. Consider it an implementation detail.
public_html
hello
I wonder if I should change my answer to fit the question exactly, Or perhaps just making the point is enough.
19:41
cabbages
DSM
DSM
Back from easting tasty svarga. Postprandial cabbage for all!
Jacket potato and chilli. So good.
No torpor for me thanks, I have ingested the energy drink so I can synchronize my waveform with the celestial overmind.
DSM
DSM
Come on, Kevin, ride the chillwave!
Negative, that frequency will not result in a satisfactory language design
all right, 4-b is the least ridiculous of the proposed designs, But now I really need to implement argument (un)packing
DSM
DSM
19:47
I expect the answer is "not very", but how tough is it to add a precommit hook in git to add a certain directory-dependent tag to the commit message or abort if it decides it can't do so?
people do skype interviews now?
35 votes to meta gold. I believe in you @davidism
user559633
@corvid of course
I had a skype interview which got me a real interview once. But then I failed the real-life interview.
In Skype interviews, you can hold your mother's hand for emotional support and the interviewer can't tell, but that doesn't work in person.
DSM
DSM
I like my voice but hate the way I look in photographs, so I prefer anything nonvisual.
my pets keep asking for things though :| they hire crazy cat ladies, right?
I dislike my voice because it sounds different when played back, compared to what I always hear normally.
I must have a weird skull shape or something, affecting the acoustics
19:55
@MartijnPieters cursing you here, now I am spending the whole night solving the PC...
@Kevin you do know that's normal, right?
DSM
DSM
If you curse Martijn he will only answer questions more powerfully than you can possibly imagine.
Yeah, but I think the severity of my dislike is higher than average.
I doubt it, I hate my own voice too. It's perfectly normal
You're not crazy.
my voice is shit
19:57
@Comic why the name change?
DSM
DSM
Am I the only one here who honestly likes the way he sounds? Maybe it's time to look again at book-on-tape career options.
I wanted to. I didn't like vader that much anymore
Like when I presented my senior design project in the school auditorium, I had to take a good ten seconds to rally after I spoke my first sentence into the mic.
@DSM I like my voice as I speak, but not as it sounds in audio.
Then again I haven't heard it on audio for 4+ years anyway.
What you hear in a recording is your actual voice though.
19:58
@AnttiHaapala :-P
How I envied the guy in my Magic: The Gathering club who was nicknamed "chocolate voiced man".
Let me know when you get to the 'etch-a-sketch' level..
That's how others hear you.
@ComicSans Welp, never going to talk again.
That's not gonna be easy
but I support you in your irrational decisions.
3
DSM
DSM
20:00
A few Fridays ago I said to a friend "I think this is only the fourth sentence I've said today." I'd been counting.
I've been there.
user559633
@DSM sometimes i think i have an easy listening voice, but then i hear a recording and remember my voice is really annoying
hackrank looks cool
user559633
rank hacker
hackerrank sorry
20:23
"hacker"
Using " is web-scale.
9
DSM
DSM
Heh.
I just used   to separate a numbered list from a code block, am I in trouble?
Don't mismatch my impetus.
Also, wish list for editor toolkit: if two lines are separated by one newline, add two spaces to the end of the first line so that the lines actually appear on different lines in the resulting markdown.
20:33
@Kevin I sometime forget to take the newlines back out of a paragraph I reformatted in vim while editing, so that would likely bite me.
It is a little tricky to determine the author's intent
It's not that uncommon for a not terrible-looking paragraph, when opened in the editor, to reveal that it's actually written as a list.
Of ridiculously short.
sentences.
When you see two sentences not separated by a period, there's a good chance the author wanted a line break.
that hackerrank is kinda cool
Hammered post #2, I sure hope I'm not screwing up
20:38
although it doesnt seem to take code performance into account at all
@devJunk I suspect that message is an incredible pun on "impedance mismatch", but I don't know enough about RDBMSes to be sure.
... And/or electrical engineering.
I would disagree that PE is mostly math coding
I mean, plenty of it is, but many are just really hard problems that require algorithmic + mathematical insight
I find that PE is useful for learning basic language constructs, memoization, the limitations of fixed-size integers, and how to Google.
All important lessons ;-)
I find that PE, over many other programming challenge sites, really tests your ability to improve your algorithms
Some problems you can't even solve unless you figure out the best method
File under: how to Google "sieve of Eratosthenes" ;-)
20:48
You can't do that for the harder problems, thankfully :)
what is PE?
besides a class I did mediocre in back in the day
Project Euler
oh ... I dont like their interface
I was exceptional in elementary school PE... For being hit in the face with dodge balls more than any other student.
The culprits always seemed apologetic, so if it was a prolonged bullying tactic, it wasn't a very good one because I didn't notice
its clunky ... thats my biggest gripe ... and I dont feel like it enforces dificulty scaling .. (afaik you can just jump to any problem ... instead of being stuck on easy question until you pass enough)
20:53
I think it'd be pretty hard to enforce a linear progression
Some problems are tough to some people, not to others
Might get stuck on something but be perfectly capable of nailing the next 100 after it
user559633
i hate PE because it's math. math is hard. let's go shopping
I've done 100+ problems but I'm still stuck on #60
Nice, Kevin! I've done the first 50, and then stopped.
I have a working implementation but it won't finish until after the sun explodes in ten billion years
20:55
@Kevin if the client doesn't specify that the program has to terminate this century, it seems like it's fair game....
Classic.
user559633
just re-write it in C or C++. i've found that often times you can use a faster language to get away with a naive implementation
PE has a "soft" time limit of one minute. Or at least it did when I was most active, I don't know what its FAQ says now.
Try some of the later problems
You won't be able to get away with using C++ to mask a bad algorithm
Changing languages might speed it up to 10 million years if you're lucky...
20:57
@CodyPiersall the compiler should optimize away a few millenia....
@tristan I admit that probably would make it a hundred times faster. So instead, it will finish after all the Earth's atmosphere has blown into space, but before the land has melted into an iron blob.
user559633
@MyNameIsKhan citation needed.
@Kevin and then the result comes back: "Insufficient data for meaningful answer"
Good luck! >:]

« first day (1567 days earlier)      last day (3606 days later) »