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

14:02
I guess the Stack Overflow crowd hasn't had their coffee yet this morning and is a touch grumpy. — Cyber 3 mins ago
so where can I order my tshirt?
which reminds me of ...
Stick your name in the list, we'll get designs together and then if everyone is happy with it we'll be able to work out costs.
You can always pull out again if you don't like the design or the cost, it's just to get vague numbers for now.
@thefourtheye ^see the edit history there
@AnttiHaapala Right... I guess the enter code here stuff means that it's homework.
I notice that none of the answers to that How do I concatenate strings in a while loop? question use a list to accumulate the input strings. But maybe that would be too advanced for the OP...
14:19
"enter code here" gets added to your post if you press the code sample button when nothing is highlighted. So it may be an innocent formatting error.
Ah, thanks for that info, Kevin. Obviously I've never done that myself. Or if I have, I've forgotten about it. :)
I should know better than to criticize newbie typing errors, Muphry's law aka McKean's Law is inevitable. :)
rhubarb
14:37
I need a job as a Professional Meme-Man.
In a half-asleep state last night, it occurred to me that the Tamarians of Star Trek effectively communicate through memes, and that humans may one day come to do the same.
One day, instead of posting the actual "You're not wrong, you're just an ass####" image, we'll just say, "The Dude at the bowling alley, glowering" and the context will be understood
I like you how censor out "hole" but leave in "ass".
oh the whole, darmok and jalade (or whatever) at tinagra?
@JonClements, yeah
@Ffisegydd, wasn't sure how I wanted to censor that, because neither "ass" nor "hole" are cusses by themselves.
(I should probably mention that I curse like a sailor in real life, but I don't know what kind of audience I have in here. Don't want to upset any grannies and 7 year olds)
I would say that on the sliding scale of swearing, which differs substantially for each culture, that "ass" is more of a swear-word than "hole"
14:46
I wouldn't say "ass" in an elementary school classroom, but I'll say it during dinner.
Unless grandma is present.
I regularly swear at/in front of my parents also. Then again, my parents also swear in front of me.
I would also wear in front of my Nanna (grandmother). Then again, she'd swear in front of me.
I was 25 when I first heard my dad tell a dirty joke.
just catching up on the news - @davidism, whaddya do!? :)
@davidism: however you may feel about the error now, one day you'll have plenty to laugh over with all the meme images flying around. I know I am having a good chuckle. :-P
I am reminded of another anecdote. When I was 10, my 18 year old cousin and I were sharing jokes. He said that he thought of a good one, but he couldn't tell it until I was older. Thirteen years later, I asked him what it was, but he had forgotten! Can you believe that?
14:51
This room is like family now. The number of fun stories my family could tell you about me growing up..
I bet it was the funniest adult joke in the world.
@Kevin well that's not fair!
My youngest (11) is counting down the days that she'll be allowed to watch things like Battlestar Galactica too, and get all the grown-up jokes she's not to hear now.
Lets hope for her sake I won't have forgotten where we left the DVDs then.
:-)
AstroCB just shared this. Looks quite cool.
We'd need to edit/PR it to add Python terms though.
@Ffisegydd Looks nice. I'd love a "convert snippets into code samples" feature so we can get rid of those "run sample" buttons easily.
14:56
f*ing banks
Yeah we could fork it for use on non-JS Qs (don't want to PR that into AstroCB's version as he'd actually use code snippets).
just got a call from a client saying his payment was returned
(which is nice of him)
user559633
@JonClements Have you considered opening an account with MTFL Credit and Loan?
is that the account where I put money in, I end up with zero balance regardless?
user559633
MTFL Credit and Loan "What we lack in customer service, we make up for in terseness"
user559633
14:59
@JonClements for you, no
just f*ing lucky I paid my tax last week... the accounts with money in are "frozen" for some reason, keep getting calls from a branch of a banking team, but they don't appear to know why either
user559633
uhhh, wow.
user559633
brb taking all my money out of my bank and putting it in my mattress
@tristan Withdrawing all your savings is a suspicious activity, so your account has been frozen for your protection. You're welcome.
@Ffisegydd I'm editing it now - what are some of the Python misspellings? So far I've got /(^|\s)(pythong|pyton|pyhton|phyton)(\s|$)/gmi
15:02
thankfully, I've had a friend help me out and I'll be recompensing them later with a bit of interest :)
user559633
@Kevin wouldn't surprise me
An unfreezing fee has been automatically debited from your account. You now have negative fifteen dollars. An overdraft fee has been automatically debited from your account. You now have negative thirty dollars.
user559633
Oof. I just realized that I hadn't checked my bank in half a month. Hello credit card balance. Goodbye feeling of excess money
@tristan I wanted to cry when I paid my tax last week
cel
cel
hmhm, is there any reason for questions tagged with ipython not having python syntax highlighting?
user559633
15:04
Oof yeah, I'm waiting for more forms before talking to my tax guy @JonClements, but I think i'll have to pay in ~10,000
@cel IPython also supports other languages, like Julia and JavaScript
@cel yes, if there's not one of the main languages (say python) then it tries to guess and may get it wrong. Plus IPython supports other languages so it may not work even with python tagged.
@cel nope - either tag it with or - it might be a suitable MSO request for one of the mods to set the default highlighting - although it should really be tagged in most cases
@tristan what are the tax rates there?
@MattDMo I suppose we could have some that do things like numpy > NumPy. Need to make sure that it doesn't effect code though, unless the js does that automatically?
cel
cel
hmh, fair enough :)
15:07
I'll raise an Issue on GH and ask.
@Ffisegydd I wasn't even getting into that yet, but yeah, you'd have to differentiate inline code and blocked code from regular text. I haven't looked over the full code yet to check
I'd imagine that it doesn't affect code blocks. But best to check, I'll ask now.
user559633
@JonClements ~45%
user559633
I've already made an estimated payment, but I ended up making more last year than I expected, which means I have to make a payment before I file taxes
not sure how the US system works, do you get tax free until $N, then it's progressive tax, like 20%, 40%, 45% ?
user559633
15:11
It's more or less a linear scale with a few notches along the way. It's "tax free" until "you find some pocket lint"
My sister and brother-in-law are technically beneath the poverty line, so they are basically tax free.
user559633
And where it's up to states and cities to decide how to tax, that's where my high tax rate comes from (federal, state, city, municipal tax)
user559633
Good lord, I hope they're young and without children @CodyPiersall
They are!
user559633
15:12
Unless its a health thing, in which case, enjoy the free money I guess
I didn't do too well last year, so I didn't have to pay 45% but had to pay a lot at 40%
I convinced my sister to become a web developer, and she's working for a guy for minimum wage. Can you believe it!
user559633
I can't believe it.
user559633
I'm literally incapable and unwilling
It's disgusting.
user559633
15:13
Eh, I'd hire someone just starting out as a web dev at or around minimum wage.
@CodyPiersall I'd take someone on at min. wage if they want to learn, but I'd pay for further education and courses and subsidise in other ways if needs be
Yeah, she's been there ~a year now, though. She'll be asking for a raise when she finishes her current site.
user559633
Given that you end up having to throw out near 100% of the work and pay a non-trivial amount of tax on their rate
It depends on what "starting out" is I suppose. If they were literally being trained on the job it would be low, but not minimum wage. If they had experience but hadn't had an actual job in it, could be higher.
Then again I seem to recall that minimum wage in US is really bad.
but 1 year!? that's just taking the pee
15:15
She works for basically just a Wordpress shop, where they crank out sites as fast as possible.
it doesn't take long to realise if you want to take someone on full time and train them
user559633
@Ffisegydd in a cheap area, minimum wage is fine
She really needs to get paid more. She can take a project from start to finish now.
The minimum wage in UK is $10
(It's not the type of job I would want to do, but I think it's a great way to start out.
15:16
@Cody have her start looking for freelance stuff, get a feel for what the market is charging, then put together a raise proposal for her boss
Some people work for zero dollars. We call these people "interns".
@Kevin or "Graduate Students"
@MattDMo I like that idea.
@Ffisegydd minimum wage in the US varies, but where I am it's $7.25/hr.
As intern, I get paid
Tell an intern that you work for minimum wage, and they'll quote the entirety of the Four Yorkshiremen sketch.
@Cerbrus No true Scotsman intern gets paid ;-)
Hehe
15:21
"We lived for three months in a rolled up newspaper in a septic tank!"
@MattDMo it only affects text, not code, github.com/AstroCB/Stack-Exchange-Editor-Toolkit/issues/41 so I'll start putting together some of the major libraries/stdlib maybe.
"You try'n tell the young people of today that, and they won't believe you" xD
@Ffisegydd OK, sounds good.
Here's another idea - retag a post that only includes or or or whatever also include a standard to increase visibility? I find myself retagging a lot of questions that way...
That's a good one, I wonder if we can add that as a rule.
user559633
anyway @CodyPiersall, i hope your sister gets her raise and your brother in law finds work
15:28
Thanks @tristan! I'm pretty sure she'll get her raise soon. She's got enough skills to find new work now, too, so even if not it'll probably be fine.
It is an interesting question if they OP can reproduce it though. I can't think of what would cause it.
Yeah. I suspect something weird is going on with type=float for the c and p flags
Here's an edit, I wonder if it provides more clues.
I can never seem to log in to meta.chat.se, anyone else have this problem?
user559633
PSA: Don't have a 7 page résumé
15:37
I'm logged in to meta, but it's not picked up by chat, and clicking login just redirects right back.
DSM
DSM
Morning cabbage for all.
cbg @DSM
Times I have confused affect/effect this month: 3
This is going to end like Flowers For Algernon, I just know it
ah, it was because I had https-everywhere enabled for meta.chat.se, it's not supported yet
DSM
DSM
15:44
@Kevin: don't feel bad. I'm looking at a document written by one of our analysts and I'm trying to figure out what the writer means by "commendations" (it's not praises or awards, and in context it can't be "recommendations.")
co-mendations. Working together to mendate, or mend, something.
The car won't start, let's get under there and do some commendation
user559633
Anyone have a list of good interview questions for Python devs?
1. If Python was a tree, what kind of tree would it be?
user559633
I'm going to ask about time complexity, import orders, 2.7 v 3 differences, some questions about dunders on classes
15:46
@tristan implement this in one line: stackoverflow.com/questions/28220999/…
I'm a shoo-in!
shoe-in? Whatever.
answer:
22 hours ago, by Kevin
(lambda t: (t.left(45), [t.forward(20) if dir == "f" else (t.left if dir == "l" else t.right)(90) for i in range(4) for dir in "frflfrflfrfrfrflfrflfrf"], t.right(45)))(__import__("turtle"))
user559633
haha
Got my shoe-in the door so I can shoo-in to employment
@tristan ask them for the dirtiest one-liner they can imagine.
user559633
15:48
bonus points for base64 encoding and passing to exec?
user559633
@PaoloCasciello what do you mean "btree?" ask the candidate to define and implement one or?
Actually, Serious Talk: Ask them about eval and what the think of it.
He was answering my Python tree question ;-)
@tristan i was answering kevin's :D
user559633
@Ffisegydd not sure how i'd answer that
user559633
15:50
maybe "it's used in the standard library and can potentially be run on import, but it's bad practice to trust mutables?"
I was more getting at people that might accidentally use eval in dangerous situations.
an interview is not about how you would answer but looking behind how they answer....
Don't necessarily ask them "What do you think of eval as a person? Do you think they'd go to the prom with me? Do you think they love me?"
@tristan the GIL, different Python implementations, maybe their top 5 most used 3rd party packages.
user559633
@PaoloCasciello sure, but it's bullshit to ask questions that you haven't thought through
DSM
DSM
15:52
I like asking library questions (whether about numpy or bs4 or whatever). Every Python dev winds up using external packages in the real world and it's hard to pick up that knowledge from a book.
user559633
@CodyPiersall we only use cpython here, but yeah, most used 3rd party would be good and maybe so i can early terminate the interview if the person foams at the mouth and murmurs "gil bad"
Maybe ask them about what a setup.py script does/is/how to write one.
user559633
@DSM yeah, good call.
sorry @davidism accidentally tagged you in a github issue :)
15:53
(I still can't write one without looking at the docs a lot)
user559633
I have one that I copy paste around
I don't use too many external packages myself. I guess since Python is more or less a toy to me, I'm more interested in core functionality.
@tristan what sort of position is it? Web dev, analytics, something else?
user559633
I make a point not to ask trivia questions or things that can be solved by googling the syntax
DSM
DSM
Kevin, famous turtle importer. ;-)
15:54
Yeah. Asking what the purpose of the setup script would be better than how to write one then.
Maybe ask about their development routine, ideally you want someone who knows their way around a virtualenv.
Good call Fizzy.
I think my top 3 packages are Pillow/BS4/Pygame, and then usage drops off like a cliff
Make sure they use version control.
user559633
Oh, good call. "What do you do when starting a new project"
DSM
DSM
A surprising number of people, even those who should know better, think that Python treats mutable and immutable types differently in argument passing (not copied and copied, respectively.)
user559633
@DSM elaborate? aren't they passed by assignment?
DSM
DSM
I mean that people say things like "Python passes mutable types by reference and immutable types by value" (maybe not in those words, but that's what they're trying to get at). Three times in the past while I've had to jump in to the comments to untangle things.
That's an odd misconception to have. Why would python make a copy of an immutable value just to send it to a function? If it's immutable, then the function can't change it, so you should be able to send the original object without fear.
DSM
DSM
Wow, I just at-signed myself!
@Kevin: yep, but it matches some observations about how x += something works, so you can convince yourself you've figured it out.
And I know tristan said he wasn't interested in trivia questions, but here's my all-time favourite:
What will list({item: (yield ''.join([item, 's'])) for item in {"a","b","c","d"}}) return in Python 2 and Python 3?
user559633
16:06
@Kevin eh, python is pretty chillwave about its type definitions, so i can see where people would assume that they're getting a 'new' object
DSM
DSM
chillwave: word of the day!
The += explanation seems reasonable to me.
Provided they never tried += on a mutable type and thought, "wait, why isn't this modifying the value outside of the function..."
user559633
which reminds me that maybe i should ask a question about scope and binding in python
Which is entirely possible, since you're more likely to use += on an immutable type than on a mutable type.
DSM
DSM
"When would you use nonlocal, and why?"
user559633
16:08
hahah oh god, if the answer is not "i wouldn't"
x += 1 is common for ints, but seq += [23] is not common for lists.
DSM
DSM
I don't think I've ever used it outside of SO.
user559633
same. i've seen it in a code review once
I did legitimately need nonlocal once. Too bad I was using 2.7.
user3522371
Hello, I need to install OpenCV to use it within Python. From the official website, it says I need to install Numpy first. But my problem is that the processor of my computer is 64 bits. I read this post. I wonder if there has been a solution since that ?
user559633
16:09
"yeah, we don't do that here"
I don't see the "very low quality" reason in the flagging dialog, does anyone know why? I remember seeing some conversation about it here but I can't remember the participants
@Begueradj do what the answer says, use the unofficial binaries.
user559633
@DSM for your trivia question, why does 2.7 have an element in the list that's a dict with none assignments?
Basically I had code like
def frob():
    x = 23
    x = x * x + 5
    do_a_thing()
    x = x * x + 5
    do_a_different_thing()
    x = x * x + 5
... and wanted to instead do
user3522371
@Ffisegydd but I am going to program a serious project, do you think I won't have problems later if I use those unofficial binaries ?
16:10
def frob():
    x = 23
    def transform():
        x = x * x + 5
    do_a_thing()
    transform()
    do_a_different_thing()
    transform()
No you won't, it'll be fine.
Because the actual x = x * x + 5 expression was a lot longer.
user559633
"a serious project"
frob()?
frobenius numbers?
@Kevin why not do that in a decorator?
user3522371
16:12
@Ffisegydd Ok, thank you. I will test that and see.
@MyNameIsKhan I use frob when I need a meaningless function name. I can't use foo and bar, because those are nouns and function names should be verbs.
DSM
DSM
@tristan: as near as I can figure this is right, but from my comment at the top you can guess how much confidence I have in my understanding. :-)
@corvid How would I do that?
actually... nevermind, if it were a single function it would make sense, I don't think it makes sense with different functions
@MyNameIsKhan Oh, I think I originally got it from the jargon file
user559633
16:17
@DSM heh, yeah. the python3 behavior makes sense to me. python 2, i feel like i'm making up an answer
would using some kind of timing interval on the front end for the time a user's token lasts be theoretically be unreliable? The back end would still issue a 401 though
user3522371
is there a Python library equivalent to OpenCV ?
What's openCV?
There are Python libraries for OpenCV
If that's Excel-related, there's xlwt, xlrd, and xlutils
If not, ignore me
16:22
That argparse question from earlier has been solved. The problem was a percent character in one of the argument descriptions. Of course, none of the simplified code the OP showed us had any hint of a percent sign.
DSM
DSM
@MyNameIsKhan: the cv is "computer vision": opencv
Then yep, ignore me
DSM
DSM
:-)
At this point, I would really like that question to be closed as "needs reproducing code", mostly out of spite
DSM
DSM
Don't forget about openpyxl, too, which I use a lot. Slow as anything, but handy.
user3522371
16:24
is there something equivalent to OpenCV to use it within Python ?
@Begueradj as we said above, opencv has a python library
user559633
It's too bad that python doesn't have an opencv library that you can find using bing or altavista
user3522371
@davidism what's that library ?
user3522371
its name
opencv
16:26
@tristan I've never heard of AltaVista, I'll have to Ask Jeeves it later.
DSM
DSM
I may be misunderstanding, but I think the OP is looking for something without an OpenCV dependency.
it's literally the opencv library, compiling it provides a couple python libraries
you can compile them and copy them into a virtualenv
user3522371
my processor is 64 bits, Numpy on which OpenCV depends is avilabe only for 32 bits processors
That's a lie. I'm using Numpy on a 64 bit processor as we speak.
DSM
DSM
To put it more gently: that's not accurate.
16:27
a) you're wrong, b) you're repeating your earlier posts
user3522371
@davidism look to this post
user559633
alright, i'm getting off this ride before i start trolling
Numpy works just fine on 64 bit (I do it all the time)
user559633
rbrb
@Begueradj that post is from 2012.
16:28
@Begueradj no
DSM
DSM
Rhubarb, tristan.
user3522371
@MyNameIsKhan from where did you download it, please ?
Why bother asking us if you're not going to believe what we tell you?
Why rhubarb, of all things? Why not rutabaga?
DSM
DSM
The ways of salad are mysterious and tasty.
16:29
s/mysterious/arbitrary
@Begueradj I don't know, it was a while ago -- if I google numpy 64 bit I see this: stackoverflow.com/questions/11200137/…
I wasn't even sure what a rutabaga was until I wiki'd it
@Begueradj kicked, this is getting ridiculous. Literally download the opencv library from it's official website
I'm not going to contest "tasty" though
So I started to get involved in this data analytics group and the other day they won an award from the council for their good deeds :D alas I wasn't a member for any of these deeds but I will brag about it nonetheless.
16:36
Wooo, babby's first hammer-close
Dupe writers beware
Congrats on the gold.
:o gratz
Out of curiosity, how often do you guys use OOP in Python?
I find that I almost never use / need it, but maybe I just suck
I use classes frequently, but inheritance infrequently.
Why's that?
16:38
I use it whenever necessary really. Which doesn't answer your question at all.
I use it quite frequently
I don't conciously think about using oop versus some other style, I just code. It's always seemed like a weird question to me.
I guess it's because the problems that I am modeling in class form rarely have strong "is-a" relationships that would require inheritance
I don't sit down and say "I'll solve this using oop"
hah, same
16:42
It's all about the goal you're trying to achieve. "recursively delete all files ending with 'temp.html' in these directories" doesn't require OOP, "write a text adventure with RPG battle elements" does require it.
Python seems fairly popular as a scripting language, so I expect lots of people can satisfy their needs without ever touching classes.
This doesn't make them worse programmers, of course.
I feel like I have too much scripting experience and not enough OOP experience
What does that mean?
Too many eggs placed in one basket
... that felt odd to invoke a backwards euphemism, there.
I use inheritance all the time ...
Try to broaden your expectations of what Python is capable of doing for you. It can handle "I'd like to automate tedious task X", but it can also do web servers and games and data analytics and GUI applications and robotics control and...
16:45
How often do you branch outside Python?
You could write your own programming language and call it KhanScript.
scream("KHAAAAAAAAAAAAAAAAN");
we develop commercial GUI software with python ... almost exclusively /.... occasionally we have to write a bit in C if we find a bottleneck we cannot resolve in python
user2555451
It's a typo and the OP even said so.
16:47
we also have done commercial kiosk type system device using android + kivy (which is really just python)
I find that I really love Python... lets me get what I need to get done quicker. Something like Java is so wickedly verbose by comparison (in my experience).
Java is also so strict... Python gives you more room to do something how you want to
well with 20-20 hindsight kivy certainly sped up the developement ... but I feel like a native java app could have solved some memory issues we had and some low level system interaction issues we had
we got around them ... but it ended up taking alot of hackery and black magic
Black magic hackery always comes back to bite me in the ass :(
yeah some of it scares me ... but we vetted it pretty well
16:54
I admire programmers that can track unusual behavior all the way down to a kernel bug.
As for me, my solution to "the code changes behavior depending on the location of comments within the source" is "rearrange everything until it works, then add a note to the README saying not to change anything"
I figure much of that is a matter of "Once you eliminate the impossible, whatever remains, no matter how improbable, must be the truth."
DSM
DSM
Ah, that takes me back to my heavy C days.
@MyNameIsKhan Excellent advice, provided you can list all possibilities.
You mean you don't have an Infinite Improbability Drive?
Mere mortals will tend to get to a point of "I eliminated everything impossible, and now there's nothing remaining"
DSM
DSM
16:57
We use bistromathics exclusively here. We're Salad devotees, after all.
@MyNameIsKhan It is infinitely improbable that one will appear in the parking lot adjacent to my office, as soon as I submit this message.
... Damn, that didn't work. Worth a shot, though.
Keep trying -- it's bound to work eventually
DSM
DSM
What, crickets? This is Llanfair all over again. :P
@DSM Oooh, took me a while to get that one.
user3522371
17:05
I need to deal with images (pixel by pixel treatment, loading & saving a picture, drawing using a mouse any shape on a given loaded picture ...) What do you suggest me to use in parallel with Python ?
DSM
DSM
Wasn't there a meta question recently about what to do with "please explain this long code" questions?
user2555451
Hmm...I can't remember. But it isn't SO's job to explain whole programs.
DSM
DSM
Yeah, but I was hoping to link it as a good explanation of what the OP should do instead.
30
Q: "Explain X to me" questions: How to react?

Jean-François CorbettThe question mould is: How does X work? I've read the [Wikipedia article / original paper / documentation / other resource] but I can't make sense of it. Please explain X to me in plain English. where X is a concept, algorithm, pattern, etc. (Not a code dump.) I've come across a number...

17:19
@Begueradj Pillow can read and write individual pixel data, but for user-driven drawing you'll probably need to write it yourself using a GUI library like Tkinter or PyQt
@Kevin sorry for being a little late, but it's now on hold :)
Thanks :-)
user3522371
@Kevin thank you very much
gong (maybe)
Hmm, no, 1 message doesn't make anyone a regular
That meta post unfortunately excludes "code dumps", and only addresses what you should do for "Explain [concept] to me"
I'm surprised no one in this question suggested splitting on ", ". They all split on just ",".
DSM
DSM
17:30
I just got an invite to a lecture on the history of beer in Canada and Japan. Targeted advertising works, people!
I mean, it works either way, but technically (adjusts glasses) the space is part of the separator, not the number.
DSM
DSM
Adding the space to the split just makes the parsing less robust for no reason.
Users that enter numbers without spaces after their commas are bad and must be punished.
user2555451
And you have to type an extra character! Life is already too short.
Being technically correct sustains my spirit energy, so life would be shorter if I was laid back.
@DSM Brought to you by Molson brand sake.
itadakimasu, eh.
DSM
DSM
17:38
I'd approve of that line but I'm still sulking.
Deploying sulkiness countermeasures.
did I mention I watched "Byzantium" the other night?
@JonClements How was it?
umm.... wouldn't say it was the greatest film I've ever seen
Almost no movies are, I expect
17:41
Anybody want to answer this question?
Or close it :D
@Kevin well it had en.wikipedia.org/wiki/Saoirse_Ronan in it... so errr...
:-)
user2555451
@vaultah - You did answer that and the OP said it helped him. Why delete your answer?
I can name at least 2 reasons
bbiab, need to make something for dinner
17:46
Question ... How to evaluate '2+3.2' as 5.2 without using eval?
exec? :p
How to use that?
user2555451
Python 3 allows you to literal_eval it:
user2555451
>>> from ast import literal_eval
>>> literal_eval('2+3.2')
5.2
>>>
Oh... I almost forgot about ast .. Thanks
17:49
@BhargavRao this was a joke..
In [6]: g = {}

In [7]: exec('a = 2+3.2', g); g['a']
Out[7]: 5.2
Manual approach: If you can tokenize the string into ['2', '+', '3.2'], which isn't too hard, you can then apply the shunting yard algorithm onto it and get an infix expression, which is simple to evaluate
Manually, after splitting, I can skip + in between and add it
... This is assuming you want something fully general to parse all sorts of complex nested parentheses and different operators and what have you
@iCodez oh, why did you delete your answer?
if the string is always of the form "number + number", then you can just do, like, sum(map(float, s.split("+")))
user2555451
17:52
@vaultah To let you take the cake, since your answer was better than mine.
well, thanks :)
word2vec looks amazing.
DSM
DSM
?
Wanted to help this guy stackoverflow.com/a/28241639/4099593 who had used eval
17:55
It converts words into Vecna, the Dungeons and Dragons lesser deity of destructive secrets.
... So probably don't run that module, then.
Plus it already has a Python library github.com/danielfrg/word2vec
@BhargavRao I'm surprised there is no sum(ast.literal_eval(line)) solution.
@MartijnPieters Yeah ... We all had left it for you to answer (Partly because we had forgotten that)
And does literal_eval work in py2 also? (Don't have py2 right now to check)
17:58
2.7 test go!
>>> ast.literal_eval("1,2")
(1, 2)
user2555451
No, it pukes:
user2555451
>>> literal_eval('2+ 3.4+ 5+ 3+ 6.2+ 4+ 7')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python27\lib\ast.py", line 80, in literal_eval
return _convert(node_or_string)
File "C:\Python27\lib\ast.py", line 79, in _convert
raise ValueError('malformed string')
ValueError: malformed string
>>>
DSM
DSM
At some point -- say after 3.5 comes out -- I think I'm going to officially stop answering 2.X questions.

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