« first day (1909 days earlier)      last day (3262 days later) » 

user559633
00:03
My job is doing tedious work and automating away terrible legacy hacks, then getting asked why it's taking so long.
user559633
My new year's resolution was "no complaining," and I think it's funny I didn't even make it a full week in before deciding "right, well, that's enough of this job."
00:19
soon - everyone shall be assimilated by ClemCo :)
Air
Air
00:38
@JonClements Free Clamato for everybody - great corporate perk or greatest corporate perk?
user559633
oh man michelada mondays unlocked
@Air umm...
Air
Air
Haven't tried it but my money's on godawful.
Two great tastes that should never meet. Or be juiced.
sad, first world problem to be annoyed with, I had a shower this morning, the delivery company had to replace my "manly" smelling stuff with "guava and lime juice" gel
so I've spent today smelling like a health fruit drink :)
Air
Air
I bought some guavas from a fruit stand while in Hawaii a couple months back. They were pretty much impossible to eat; almost entirely small, hard seeds.
Smelled pretty nice, though.
user559633
00:49
i solve this problem by not showering. best not to risk it.
@tristan you'll make sopycon very interesting then :p
user559633
i have a waterbed. it's essentially a bath.
Air
Air
Something something soapycon
user559633
most calls are JSON actually
Air
Air
01:03
rhubarb
user559633
take care @Air
01:33
Does anyone know how can I apply four differently parametrized function for input of 10 numbers?
For example i have func(param1, param2) and i have four different param1's in array, and i have 10 different param2's in array. How can I get resulting matrix of outputs for each combination?
Woooo, I think this is my first computer build where I didn't mess anything up.
user559633
01:50
What color is the case?
Black. The case is the same from the last build.
user559633
That's a good color for a computer case.
Thanks, I think so too.
 
2 hours later…
04:22
Hey - I have a question. Does anyone know any possible explanation for the number of down votes my answer here got?
04:50
just a guess, but maybe because your answer is very convoluted and uses eval() for some reason, when all the OP had to do was int(value)?
05:12
@MattDMo. What I think now when looking at the question is that for the test cases, the user had to use int(value). But, I wanted to create a more versatile solution that will work if say, the input was 3.4.
05:45
cbg
Cbg all.
 
1 hour later…
07:09
cbg all
I have small Question on exception handling while I have invalid url from the source
I got the below trace back
from my ubuntu terminal
2016-01-07 07:07:29,692 8112 ERROR dynaweld_15_09_15 openerp.osv.osv: Uncaught exception
Traceback (most recent call last):
File "/home/best/workspace/dynaweld/server/openerp/osv/osv.py", line 131, in wrapper
return f(self, dbname, *args, **kwargs)
File "/home/best/workspace/dynaweld/server/openerp/osv/osv.py", line 197, in execute
res = self.execute_cr(cr, uid, obj, method, *args, **kw)
File "/home/best/workspace/dynaweld/server/openerp/osv/osv.py", line 185, in execute_cr
return getattr(object, method)(cr, uid, *args, **kw)
how to resolve my issue
?
any idea ?
 
1 hour later…
08:36
cbg
@DaSaDiYaChaiTAnYa I'm not very familiar with Python's XML stuff, but it looks like you've got a malformed XML file, and the docs say "Warning: The XML modules are not secure against erroneous or maliciously constructed data". You might have better luck with Beautiful Soup, which I hear is pretty good at dealing with broken HTML / XML, but I've never used it myself, so I can't offer specific advice.
Hey up all
@DaSaDiYaChaiTAnYa without some code and some example data it's difficult to guess (and we would be guessing)
08:51
And we probably don't want to see an XML file that has 959 columns. :)
@DaSaDiYaChaiTAnYa Also 1. I see that you posted this exact same question in rec.sopython.social. We can't stop you from posting in there, but it's actually a room we just use for social discussion and so it's not actively monitored for questions.
2. You requested access to Python Trash I see. I'm not sure why you requested access to it seeing as how that's where we move all the trashy messages we don't want, but I assume it was to ask your question in there also. Please don't request access to there - it won't be given and there's no reason for you to ask in there anyway.
okey so sorry about it
09:26
Cbg
Cabbage!
09:47
I have a small problem with a code i am trying to work with. I am trying to remove some specific characters from all the files present in a directory.
import os
for filename in os.listdir('D:\\newjpegimages'):
os.rename(filename, filename.replace('.jpgnew', ''))
please, ignore the indentation.
file names have a character .jpegnew in them. i am trying to remove that. and i am getting FileNotFoundError error.
can i get some idea, please?
*.jpgnew
os.listdir only returns the file names, but not the full file path. So in order to find the file to rename it, you need to specify the folder as well:
directory = 'D:\\newjpegimages'
for filename in os.listdir(directory):
    os.rename(os.path.join(directory, filename), os.path.join(directory, filename.replace('.jpgnew', '')))
newjpegimages is a folder which has around 200+ files.
ohkay. That makes sense now. Thanks a lot.
it worked smooth.
Incidentally, what you originally said was you wanted to remove characters from all files; you actually wanted to just remove them from file names
yeah. I was wrong at that part. I learned it and i hope not to do the same mistake again.
No worries; just a friendly hint :)
10:00
Thank you. xD I really appreciate it.
Speaking of file name vs file contents confusion, here's one I answered earlier today which has the opposite problem: the OP wanted to operate on the file contents but instead was operating on the file name.
Jon Skeet’s flair looks so bad.
@intboolstring I hope that OP doesn't discover this Chat. He has posted 10 low quality questions over the last 2 weeks that all appear to be about the same program. I guess he's working way out of his depth.
Cbg all .
cbg, @The6thSense
10:13
PM thanks for the clarification mate :).
No problem!
So if we needed to compare 2:30 with 10:30 we have to convert it into time and then check?
You could do that, but it's faster just to pad short time strings. Of course, life is much easier if the time strings are created with the proper padding in the first place. :)
Assuming the source data isn't based on a 12hr clock
I think that will complicate the sorting Robert
10:21
If you have to deal with 12hr times that don't have an AM / PM suffix you're permitted to take extreme action, IMHO. :)
@PM2Ring padding yeah could do that :).
10:36
OP is posting partial code making it more broken than it originally is and then is complaining that we point out that the code is broken because of the stuff he left out (without telling us)…
And wtf, could people stop upvoting my simple and stupid rant/answer that fixes those issues?!
Poke with 100k comes more upvote :P.
But that other answer I posted earlier about argparse which is really nice and all didn’t even get half of the attention.
More the reputation more upvote you get?. One of the hidden law of SO.
Makes me sad :(
Umm I have to find new law for that :P.
10:46
any browser+server webdav clients written in python?
@Air I revised my answer, thanks
Hi people :D how're you
pyd.io exists but it is agpl... not good.
@MarkoMackic fine mate. What about you?.
good :D
11:06
cbg all
a quick question: how possible/easy is it to parse a received e-mail with Python?
as in, an e-mail already downloaded to the computer
Pretty easy. There's probably a library, to make it effortless
there is an email library
but I'm not sure if that works with parsing e-mails as they're received or something
I just found that from Googling
Well try it
11:09
What I can't see is where you specify the location of the email
I don't know what parsing them as they're received even means, but you should just try it
Yeah what exactly do you mean by parsing them? What are you trying to parse?
There's literally a email.message_from_file function
Please reads the docs. I've never parsed an email in Python before and I just found it out now
Basically I have a pile of e-mails generated by a feedback form on website. Each one lists the questions asked in the form and their score, so it's very human-readable, but not very easy to quantify
so I want to read each e-mail, and tally up the scores for each question
That's nothing to do with email parsing really, and much more to do with text parsing.
11:17
yes, I'm just looking at exporting from Outlook, as it happens
not sure if it's possible to export whole e-mails
ah, it is
as CSV. That's nice.
@poke: On the contrary, you should almost never check boolean values by identity. Checking booleans using identity is quite strongly counter to the usual practice, and an is True check would run a risk of someone removing it without realizing that it's actually necessary in this particular case. — user2357112 6 mins ago
Anyone wants to go in?
Heh, no.
meh :(
I don’t want to either.
Walk away, it'll be better for your health.
11:33
@poke Imagine how poor old Margin Peters feels, eg this is a good answer, but does it deserve 119 upvotes in a couple of days? Maybe not.
Maintain a supercilious silence (with alliterative sibilance to boot)
@PM2Ring lol
> Don't compare boolean values to True or False using == .

> Yes: if greeting:
> No: if greeting == True:
> Worse: if greeting is True:
@thefourtheye But it also says: “Comparisons to singletons like None should always be done with is or is not , never the equality operators.”
11:34
I agree, but they explicitly say that is True is worse.
PEP-008 internal contradiction klaxon. The world will undoubtedly end imminently
But if you are making a difference between boolean values and trueish values?
@thefourtheye if bool(greeting) is True works correctly but it's still bad.
Pfft. It's a style guide, not a programming guide. If you need to know that something is the boolean singleton True then use is.
@poke Also, True and False are not singletons in Python2.7
>>> True = 0
>>> False = 1
11:36
@thefourtheye You disqualified yourself arguing with me as you mentioned Python 2. It’s 2016. Python 3 is the default.
And changing True or False is a terrible thing anyway.
ha ha ha :D
True, False = False, Falser
Dec 31 '15 at 17:48, by poke
In 2016, can we agree to not give Python 2.x hints by default? Let’s just assume everybody uses Python 3 unless they tell otherwise.
Where Falser is a class that __bool__ on will cause your PC to melt.
@poke The answer to your question is "No, we can't agree." :P
class FalserType:
    def __bool__ (self):
        return random.randrange(1000) == 999
False = FalserType()
@Ffisegydd No, we did agree. It’s a rule now.
:P
11:40
We need a secret police force that will arrest python 2 users.
The Dark Council needs a job, we can use them here ;-)
Along the lines of the Stasi.
Or the KGB.
@poke Sure
@user2357112: Generally, what you're saying is perfectly correct. But here we need to distinguish between True and various truthy integers, so if args.resize is True is appropriate in this circumstance. — PM 2Ring 21 secs ago
yay, parsing CSV.
And the question is explicitly :D
11:45
@thefourtheye But chat was not :P
I have a CSV file which contains feedback scores, so for example, 'How satisfied were you: 5'. How can I step through the file and tally all the scores after a specific string?
@poke Yup, our discussions are okay :) Personally, I follow the if value: pattern
I do to, except when I distinguish between bool types and truish values.
@ElendilTheTall What does a typical row of this (so-called) CSV look like?
Exactly. They're two different use cases: one is "Is bool(val) True?" whilst the other is "Is val True?"
11:52
val is always true if not null ? :D
95% of the time you only need 1., but occasionally it's important to distinguish 2.
how about setting python as backend in xampp with cgi ?
@PM2Ring well, it's an HTML e-mail exported as a CSV
so it's subject, body, from etc
I'm only really interested in the body
or one particular string in the body
Is the body actually in HTML? Or is your email simple and "plain text"?
an extract from the body: I would recommend this product to others: 5 \r\n
plain text, no tags to worry about
11:56
Then write some regex and search the string.
@PM2Ring well that escalated quickly :P.
well, I can find the string with in. How do I then get the next character (ie the score)?
@ElendilTheTall in is great for telling you that one_string is in another_string, but it doesn't give you location data. If this is the only info you're trying to extract then I agree with Ffisegydd: you can search the whole email & get the score with a simple regex. You could do a line by line search, but that's slower, and probably not necessary in this situation.
does that still hold true when the string appears multiple times?
basically the csv is an aggregate of many e-mails
so I each time the string occurs, grab the next character and add it to a tally
That's still easy to do with regex, using re.findall.
Have you had any experience using regex?
12:08
cbg
@BhargavRao I recently saw a chat between you and Aron Hall. You were saying python was difficult :P. It was at the time you started learning it.
@The6thSense It is still difficult, I am still learning. :)
what is regex exactly :D
I would say it is easier then other languages
@MarkoMackic Read this docs.python.org/3/howto/regex.html ... Explains it beautifully :)
@The6thSense True. :P
@PM2Ring Did you see this stackoverflow.com/questions/34650576/… ?
12:27
@BhargavRao No, I didn't. Thanks. And congrats on hitting 20k!
Thanks :)
@PM 200 more for moar powers
Can 10K people see deleted comments ?
Nah, No one can.
@ElendilTheTall Here's a short example that fetches the current contents of this Chat room's Transcript & scans it looking for the word "email" (case-insensitive). We parse it with 2 different regexes: the first grabs "email" plus the following word, the second only grabs the following word.
#Look for "email" and the following word in the SOPython Chat transcript
import urllib, re
url = 'http://chat.stackoverflow.com/transcript/6'
fd = urllib.urlopen(url)
data = fd.read()
fd.close()
print(re.findall(r'email\s+\w+', data, re.I))
print(re.findall(r'email\s+(\w+)', data, re.I))
So you could only see deleted posts ?
12:33
Those regexes only find "email" if it's followed by one or more whitespace chars.
@The6thSense Yep.
Umm not that powerful :P.
Room owners can see deleted messages, if you consider those "comments"
I too saw it :P Bargav.
12:37
I can see my own deleted message \o/ ....
BAD UI There --- No title for that page.
I have to sacrifice privacy to protect our freedoms. More specifically, everyone's privacy but mine.
12:40
Lol :D
I thought there are more than one room owner so no one's privacy is safe here :p.
Yes there are a few room owners here: everyone who's name is in italics, plus Jon & Martijn.
Maybe there's a code of honor that makes ROs unwilling to look at each other's deleted posts. I don't know, I've never asked.
Could you flag a comment on a deleted post ?
I don't know. Find me a deleted post and I'll try.
12:46
I am 5k user I can't even see deleted posts listing :p.
Where is that canonical post where the user prints columns using format? Can't find it :(
I dunno, I just use this script when I want to print tables.
There was one, afaik. Need to use Google then :/ Nvm, Martijn answered so mustn't be a dupe. :)
cbg
so :P
cbg Antti
12:54
Needed: ajax remote file system browser, preferably written in Python, with file / multifile upload and such. I googled and didn't found anything good enough, anyone have experience on these?
I'm old-fashioned, so I use '%*s' % (field_width, field_value) to print tables.
@PM2Ring ...
Thinking backward :D
@PM2Ring hmmm
I've tried to adapt that to my existing code, and it half works, but it seems to return empty lists
13:01
afternoon ... am I missing something obvious here? stackoverflow.com/a/34655846/874188
Python answer to bash? Didn't know you could do that :/
any external tool really -- I would not approach that in native Bash ever
though I suppose it could be done
IMO Sometimes it's appropriate to post an answer using a language outside of what's tagged. This question is a good candidate because it's more "how do I do this task?" than "what is wrong with my existing code?" Since he's starting from scratch no matter what language he uses, you may as well pick the best tool for the job.
True, I'm reading all the answers one by one. :)
13:07
Cbg
@BhargavRao fun Bash-only alternative added (or POSIX sh really)
Doesn't rstrip take care of \n or should we pass it explicitly?
@BhargavRao Btw. congrats on (shared) first place!
Thanks :)
>>> "abc\n".rstrip()
'abc'
13:15
@BhargavRao yeah, you're right (old habit to pass it explicitly because I don't usually want it to strip other whitespace)
Lol, was typing out a reply bout that.
With a few files ending with \r\n, it's better to use rstrip(). imho
Language chat. I've always been unclear about how to reply to questions of the form "doesn't <factual assertion>?" using only one word. If I reply to "Doesn't rstrip take care of \n?" with "no", does that mean "no, it doesn't" or does it mean "no, it does"?
The former extended version sounds a little more natural to me but that would mean that "doesn't rstrip take care of \n?" and "does rstrip take care of \n?" would have exactly the same meaning and possible responses. It's weird to me that "does" could be interchangeable with "doesn't".
A full answer would be the best.
Are you surprised to find someone in this programming chat room that's obsessed with concision?
Reminds me of the joke, Fill up the blanks with yes or no, ____, I have brains.
13:20
@Kevin I don't know of any language which makes this distinction, though many languages have a distinction between "yes, it's true" vs "yes; it's untrue" (oui vs. si in French; ja vs. jo in Swedish; etc)
I would like to know if there's a "canonical" rule, insofar as English has any canonical rules since it doesn't have a single governing body. But I have no idea how I would google this.
Googling "Answering 'doesn't'" returns a lot of results like "why doesn't god answer my prayers?", which is not what I'm looking for.
Related: Yeah, no
I have no words.
"Doesn't rstrip take care of \n?" => "rstrip takes care of \n, does it not?"
@tripleee Another one, mention xrange is for python2.
@PM2Ring ah ha! got it - the Regex was looking for whitespace, but my string already included it
13:26
I suspect that fashion suffers from a race-to-the-bottom effect where each designer must take their sensible idea and make the most outlandish expression of it in order to leave any kind of impression on whoever decides what is "in" this season.
"I like fabric with square patterns" -> dress model in thousands of sticky notes -> "I am the fashion king and I think that sticky note model is quite bold" -> next spring, fabric with square patterns is popular. Step #2 is ridiculous, but the ends justify the means.
Now, I'm not sure what sensible idea would lead to wearing an entire upside-down person. Maybe designers just choose concepts at random if they don't have a strong agenda.
Think of the positives, you can permanently cartwheel to places.
Lol, :D
Brief rbrb, Got a "Come immediately" call :/
Ooh, I hope it's a surprise party.
I may make a question on English.SE for my "doesn't" quandary. Isn't that a good idea?
13:38
For your what?
21 mins ago, by Kevin
Language chat. I've always been unclear about how to reply to questions of the form "doesn't <factual assertion>?" using only one word. If I reply to "Doesn't rstrip take care of \n?" with "no", does that mean "no, it doesn't" or does it mean "no, it does"?
oh
yeah, do it
“Isn't that a good idea?” – You know, it kind of applies to “isn’t” too…
is it possible to rename files inside a zip file in python?
the web suggests it's at least hard but maybe an expert knows more
Lazy solution: unzip the zipped directory into a regular directory. Rename the ordinary file. Zip the regular directory back into a zipped directory.
@Kevin I think it's the answer "yes" that's ambiguous
13:45
Ok, why is this throwing a list index out of range error?
each row is a list - row[1] is the body of an e-mail converted to CSV
URL blocked my FizzyCorp but I'm going to psychically guess you're using len(x) somewhere and not taking away 1.
so I am searching each row for that string, and grabbing the number that follows it, a score
Either row[1] is going out of bounds because row has fewer than two elements, or i[0] is going out of bounds because i has no elements.
@ElendilTheTall why don't you write a regex like I suggested over an hour ago?
You can determine which one is the case by inspecting the stack trace and checking the line number.
13:48
@Ffisegydd I have (or rather PM2 did, and I tweaked it)
@Ffisegydd Here is the same snippet, but hosted at pastebin, if that helps.
It doesn't, I think all text sharing sites are blocked.
@Ffisegydd the regex isn't the problem
`import csv, re

with open('feedback.csv', newline='') as csvfile:
message = csv.reader(csvfile, delimiter=',')
score = 0
x = 0
average = 0
for row in message:
if test_string in row[1]:
i = re.findall(r'I would recommend this product to others:\s+([0-5])', row[1], re.I)
score += int(i[0])
x += 1
average = score / x
print(average)`
hmmm
@Ffisegydd Ok, here it is in the sandbox.
@ElendilTheTall Formatting tip: backticks don't work on multi-line messages. Instead, press the "fixed font" button.
@ElendilTheTall do you have some empty rows in your data?
A blank line would register as a row of length 1, meaning that row[1] would fail.
13:51
patiently waits to be told which line the error is occurring on
continues to psychically debug because bored and got 5 minutes to kill before my meeting
Hey man, you do you.
sorry, it's line 12, score += int(i[0])
Looks like your regex hasn't found a match, and thus is an empty list.
Agreed.
13:53
But it rattles off a dozen or so print(average) before crapping out
So the first dozen or so lines are successfully searched, and then one fails.
So? The regex matches a dozen or so emails before failing.
ah, I see
let me look at the data
That'll be £1000 in consultancy fees, payable to Fizzy And Kevinson, inc.
ah ha, yes, there's one that isn't a number.
13:55
This is the point where I'd add assert len(i) > 0, "failed to find any match for line: {}".format(repr(row[1]))
right after the findall line.
Interesting gedankenexperiment: if we made everyone who came in looking for help donate £1-5 to charity, do you think we'd end up raising much? Or do you think we'd have zero customers?
Why use findall instead of search/match ?
@Ffisegydd the latter :)
how many people actually donate to wikipedia when they ask?
Enough to keep it running
Traffic would divert to free alternatives. 1 dollar/euro/quatloo doesn't break the bank for most people, but it does form a powerful psychological disincentive.
13:58
how can I make it 'skip' when it doesn't match?
See also: why free mobile games get 10x as many downloads as 99 cent games
@ElendilTheTall Perhaps some kind of conditional that uses len.
Morning cabbage.
(advanced option: you don't even need len. Disregard this message if you find it confusing)
@ElendilTheTall Thanks for valuing mine and Kevin's time so much.
Anyway, meeting.
Also paying anything is way more effort than not paying anything.
13:59
@Ffisegydd :) I do very much appreciate your help

« first day (1909 days earlier)      last day (3262 days later) »