« first day (2933 days earlier)      last day (2025 days later) » 

12:09 AM
 
Paz
12:30 AM
I'm still stuck with this stupid echo server.. all I'm trying to create is a simple echo server, that prints what the client sends, where if the client sends a port number, the server becomes a client and the client becomes a server at this port.

The thing is, after more then one round of sending a port (& switching), the "exit" won't work
Any ideas? I'm stuck for hours with this mess
 
Dat friday night moment, where drinking alcohol while trolling fellow SO chaters sounds better than going out.
 
1:20 AM
I was trying to remember what I had realized I had to fix in an SO answer while showering. After 10 minutes of frantically looking at my recent answers I realized that my revelation was regarding a bug in my work code, not on SO...
 
1:31 AM
The center cannot hold, he comes
 
 
1 hour later…
2:40 AM
@Johnathan While I'm sure the problem you're working on is great and all, I would refrain from using questionable phrases like "wet dream" to describe it.
 
@Johnathan How are you going to do that?
 
 
3 hours later…
5:28 AM
cbg
I lost 50 rep because somebody deleted a question which had my answer with 5 upvotes. I don't understand why would someone delete a question having a useful answer.
 
Usually can't delete questions with well received answers without a vote
Can you link the question?
 
6:31 AM
@wim "too honest"
@BlackThunder the question wasn't useful. People upvote answers that are useful to the asker...
 
6:49 AM
Hi all,

I am working on project to detect inline mathematical expression from research paper

model will label the expression as I-Math,O-Math,B-Math

I-Inline math expression
O-Outside math expression
B-Beginning math expression

I am following this blog http://www.albertauyeung.com/post/python-sequence-labelling-with-crf/
CRF implemented in the pycrfsuite cannot handle multi-label tasks.

is there other library to handle multi-label tasks?

Thanks lot.
 
 
2 hours later…
Paz
8:20 AM
https://pastebin.com/Ne9mWE37
a simple echo server.. anyone knows why the while loop on the InitClient function never ends?
Found the problem, don't know how to fix though.
Here's the problematic part:
https://pastebin.com/FHVVS4Br
It returns [Errno 22] Invalid Arguments
god it working, needed to initiate the entire socket again in the loop
 
 
2 hours later…
10:27 AM
@Johnathan this is not a job bulletin board. There are appropriate means of offering money for programming work; SO chat is not one of them. This sort of thing is spam here
 
 
1 hour later…
12:14 PM
cbg
 
12:36 PM
@PM2Ring that ^ seems to be in the Cookbook co-authored by Alex Martelli
it's in the "algorithms" section of the cookbok
 
12:56 PM
@AndrasDeak Not just Martelli, but also Guido & Tim Peters contributed. My guess is that it predates sum and even xrange.
I'm on my phone, so I didn't bother checking the PDF.
 
> Release Date: July 2002
 
@PM2Ring was this a legitimate thing in Python at one point??
 
That's definitely before we had generator expressions. I can't be bothered right now finding out when sum & xrange were added.
 
It's so ugly but I'm a python newcomer
 
@roganjosh What in particular? I guess the original randrange might have only accepted a single arg, necessitating that stupid addition.
 
1:07 PM
I guess I'm not sure what I'm asking so much, but that code seems... bizarre. I wondered whether that had even been "pythonic"
If it's in a cookbook from ages passed, presumably it was relevant at one point? Or was it never a good approach?
@AndrasDeak oops, I've just realised you guys were already discussing the exact same thing :P
 
@roganjosh If it predates sum, then it's reasonably valid. It definitely predates gen exp. I just checked the 2.4 docs, and randrange is from 1.5.2, and there's no indication that it had a simpler signature in the earlier versions.
 
Does anyone know why Martelli went silent on python?
 
@roganjosh Guido never liked reduce. And before gen exp, it would definitely better to use a traditional for loop. I guess passing a list comp to sum isn't that bad, though.
 
Oh, I know he never liked it. I have never actually used it tbh. It was more about curiosity on the history of python.
 
@roganjosh From his rants, I get the feeling that he disapproved of several changes that were made to the language, and didn't like the direction it was evolving in. And I suspect he had some "heated" discussions with other core devs...
 
1:21 PM
so i am looking through a json file and this doesnt work print(item['variation'][0]['image']['thumbnail']) it gives error on [0]
whats the correct way to do it in python?
in java .get(0) works
 
@PM2Ring my question was only whether stackoverflow.com/questions/53021880/… was ever the pythonic approach at the time the cookbook was written :P
 
i just need to select first object inside variation
 
I've used reduce a few times, eg to multiply a bunch of numbers together. But I agree with Guido that if you try using it for anything complex it's slower to read than equivalent code that doesn't use reduce.
 
@Rudolph what is the actual error?
 
in command line - KeyError: 0
 
1:25 PM
Then it's not a list but a dict
Youre trying to parse the structure incorrectly
Paste the response into jsonlint.com and look at the structure
 
its "variation": { "randomNumber": { "image": { "thumbnail": "value" } } }
i just want to get the first item under variation
because of the random number
 
yeah, that's still not a list
have you read a good python tutorial yet?
 
literally first time using python
just need a script to fetch some images
 
Then please read a tutorial before trying to use it :)
at least to cover the very basics
 
so how do i get the first item then...?
 
1:34 PM
if you get stuck on retrieving items from a dict you'll likely need further help down the road
@Rudolph the tutorial will tell you
 
...
 
That isn't valid JSON that you posted
 
its part of it
 
But I did suggest how to view the structure properly
 
not going to post here a huge ass json object
 
1:36 PM
No, I don't expect you to
 
we don't want you to
 
From what you've posted, there are no lists, though
 
@roganjosh that's clear
they have a dict now
they just need to learn how to retrieve items
 
I would still rather help in this case, if possible. It's not necessarily garlic.
 
I never said it was, but I'm a huge fan of teaching people to fish. "just need a script to fetch some images" -> how trivial is that when cargo culting?
 
1:40 PM
Think we're gonna disagree on this one, mate :) I'd rather discuss JSON parsing here than it become a question on SO
 
sure
 
@Rudolph The integer 0 is different to the string "0". In Python, integers can be dict keys, but in JSON all keys must be strings. I assume you're using the standard json module to load that JSON data into a Python object.
 
@Rudolph there are no lists in your example so you cannot take an index
 
I'd also note that it's unclear whether the key is literally "randomnumber" or just...a random number
 
"I was amputating this guy's arm, but after he woke up he complained that I was supposed to amputate his leg. So I tried again, and amputated the guy's leg this time. Afterwards he thanked me for a job well done. I don't understand why he yelled at me the first time?" This guy, if he was a surgeon
 
1:55 PM
I need more rep :/ I can't see the discussion
 
Pet peeve: when the OP posts code and error message, but they don't match. Eg, stackoverflow.com/questions/53022522/…
 
 
1 hour later…
3:25 PM
What do we do about duplicate answers? N00bs just don't get tired of re-posting existing answers... There doesn't seem to be a flag for this purpose?
 
if it's a blatant copy then flag, otherwise downvote and peer-pressure
you can see some of my handiwork near the bottom here
no, no
downvoting is a personal thing, don't request votes ever
please delete that
still no
 
better?
 
we're not a voting mob
thanks
 
Okay, so what do I do if there's no realistic chance of getting the answer down to a negative score?
 
if it has a bunch of upvotes: nothing, really
 
3:30 PM
Why do I even care anyway? I need something better to do in my spare time than trying to clean up SO
 
I'm afraid I can't argue with that
Policing old content is pretty hopeless. All we can do is weed out the new sprouts.
 
I found a print to stderr in a fairly core library (immediately preceding a sys.exit(1)), that I instinctively want to replace with logger.critical(msg) - thoughts?
 
3:47 PM
Would that default to stderr? Just curious
 
Maybe sys.exit(msg)?
logging defaults to stderr, yes
 
k, if anything goes wrong with numpy packaging via pip let's credit vaultah. :D (j/k)
thanks!
 
4:09 PM
"Fairly core" might be a stretch for numpy. And its code base is chock full of debt
 
I'm participating in the Bloomberg sprints today - If anyone wants to participate in the sprints virtually, here's Paul's presentation: pganssle-talks.github.io/pypa-sprint-2018/#
 
4:36 PM
and here's the kanban board: github.com/orgs/pypa/projects/1
 
recbg
 
why is there -3 rep for bracket miss? — Andriy Maletsky 1 min ago
@AndrasDeak gone
 
4:52 PM
FWIW I don't think typos should be downvoted just because they're typos. But that was worse than just a typo. Then again I didn't downvote it.
 
I did
 
I figured :P
 
the downvote button still says "not useful"
 
yup
 
and there was no research effort ("I googled this... and)
even Zed would downvote them
 
4:53 PM
I wouldn't want someone being able to ask a coherent question with a silly typo they couldn't spot to be question banned just because they have a typo. If the problem starts at "coherent question" that's a different story
 
they didn't have a question :D
also the formatting was off, martijn fixed it
and the error really didn't match the code :D
 
If you read my messages you'll note that I never said that the question wasn't downvote-worthy
 
and it was tagged python-requests :D
 
Recbg
@AnttiHaapala That tag has been misused several times that I've seen for "please give me the codez" :/
 
yes, I've figured :D
 
5:01 PM
we had with was a synonym for ...which is a GUI creator
 
@AndrasDeak Sorry, I was not quick enough.
 
5:16 PM
It's OK ;)
 
Is there a way to reopen a file once you've closed it?
I.e. after
fout = open("file.txt", "wt")
fout.write("test')
fout.close()
 
yes
fout = open("file.txt", "wt")
fout.write("test')
fout.close()
fout = open("file.txt", "wt")
 
Okay, so there's no method to reopen it within the file class
 
I don't think there is one. Trying to rewind it tells you ValueError: I/O operation on closed file.
 
It's really not a big deal, I was just curious after I hit file.close() when I should have typed file.flush()
 
5:23 PM
@AndrasDeak how about r+t or at:D
 
minor details ;)
 
you open with 'wt` and you just lost the contents
 
yup
 
Ooh, good to know.
 
15
Q: What can I do with a closed file object?

SuperBiasedManWhen you open a file, it's stored in an open file object which gives you access to various methods on it such as reading or writing. >>> f = open("file0") >>> f <open file 'file0', mode 'r' at 0x0000000002E51660> Of course when you're done you should close your file to prevent it taking up mem...

spoiler alert: not much
@AnttiHaapala technically the question didn't include non-destructivity ;D
 
5:24 PM
@malan Once it's closed, it's closed, and you shouldn't try to do anything with that file handle. For convenience, it's not an error to close a closed file.
 
@AndrasDeak I'll keep that in mind...
ask Andras a thing like "can this mushroom be eaten"...
 
... "technically you didn't ask if you can survive..."
 
you can eat it once
genie logic
 
Are people that post questions like that just script kiddies?
 
5:26 PM
no, but they are often cargo culters
 
there are niches in web programming, machine learning, image recognition, game design and other high-level areas where people don't feel like learning the underlying language before starting to use it
 
Markdown like failed on me on that one
 
you failed it :P
 
Perhaps, but in my edit I couldn't see what was wrong
 
5:28 PM
wrong order of URL and text
 
Wow
:facepalm:
 
rhubarb for a while
 
same.
 
5:43 PM
converting more prints to logging - finding some %s formatting, someone is telling me to preformat before the function call, but my inclination is to use the delayed formatting by passing the %s args positionally... thoughts?
 
5:57 PM
@PM2Ring literally that gave me a headache
 
6:19 PM
@AaronHall what was the outcome with ODBC?
 
@roganjosh a freakin' long email with some actual response from important persons...
 
I'm guessing it's infrastructure for their IT team to set up?
 
I cargo-cult with the best of them...
 
ODBC has important persons?
 
I'm just as confused with the response :P
@AaronHall Also, what does "telling me to preformat before the function call" mean? :)
 
6:26 PM
The ODBC front-end was one option of many, and I was doing analysis of how to get data available for Tableau users. Looks like we're probably going to have a serious discussion with senior DBAs on the need for some flexibility for dynamically created tables...
 
On the logging side, I don't see why you'd pre-format the logs
 
print('foo %s bar' % whatever) #preformatted
logging.info('foo %s bar', whatever) # formatted after the call if info level is logged...
 
No, there's a Martijn answer that it's a bad idea
 
It's an attempt by the logging lib to be a little lazy...
what's a bad idea?
 
I agree with your intuition
 
6:29 PM
ok, smart guy here disagrees with me, but he's on a different project...
 
print('foo %s bar' % whatever) #preformatted
The string interpolation only happens if the log level is relevant
 
@roganjosh whatever = 'foo', 'bar'
 
So if you have a load of DEBUG messages and the level is set at INFO, the logging message never gets string formatting.
@AnttiHaapala not sure what you're illustrating?
 
@roganjosh try it
 
Well, it'll give me a tuple?
 
6:32 PM
and...
 
and...
 
separate them by spaces?
 
You've lost me mate :)
 
the result is slightly different. the logger gives the repr (good!) but the % does:
 
@roganjosh why would you not try print('foo %s bar' % whatever) #preformatted
 
6:35 PM
>>> 'foo %s bar' % 'foo', 'bar'
('foo foo bar', 'bar')
>>> 'foo %s bar' % ('foo', 'bar')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: not all arguments converted during string formatting
 
@AaronHall ...
 
@AaronHall Anyway, I'll try dig out the answer that I'm thinking of, but your idea on logging is correct because it won't cause any overhead unless the logging level is relevant
 
>>> import logging
>>> logging.error('foo %s bar', ('foo', 'bar'))
ERROR:root:foo ('foo', 'bar') bar
 
@AnttiHaapala because you're passing an argument to logging and it's entirely different?
 
ah:
>>> 'foo %s bar' % (('foo', 'bar'),)
"foo ('foo', 'bar') bar"
 
6:37 PM
@roganjosh logging makes a tuple of it
 
logging will insert the second argument into the string if the level is relevant
You could have a bajillion DEBUG messages but if you set the logging level to INFO, they'll never be string formatted
 
but I get why this can easily give different results than expected...
 
Both of you are way above me on Python so I'm totally prepared to have my ass handed to me, but it hasn't happened thus far
 
I'm more confident it's the right thing to do...
Now that I understand the FUD...
can't be called a FUDdy duddy
 
Bottom line of my understanding of logging is that the the logging level is checked first, then the string formatting happens if the level is relevant
Antti has destablised my thoughts because he's usually right but I don't understand the illustration
 
6:52 PM
@roganjosh you're correct.
 
Totally a screenshot moment :P
 
there are stars
 
7:32 PM
recbg
matplotlib/pandas: a badger hammered this post but I don't think they're right. There's an answer which actually answers the real question. I pinged the gold badger 18 hours ago but no response. Any thoughts?
badger has neither matplotlib nor seaborn in their top tags
 
@AndrasDeak what do you want the fate of that question to be?
 
as far as I'm concerned it should be open
I'm too lazy to install seaborn to test it myself
 
Open and unanswered? The dupe aside, is it a good question?
 
huh, turns out I already have seaborn
@roganjosh open and answered
> There's an answer which actually answers the real question.
 
opened
 
7:41 PM
It's closed and has an answer
Fair 'nuff
 
what do you know, I can repro the problem oops, no, I can't
@AnttiHaapala thanks
Either way the dupe was wrong. It should be open or closed as no repro/MCVE at worst
perhaps one has to run it in jupyter...
(I can't repro it in jupyter qtconsole)
 
Ugh, I'm so tempted to raise on meta just how ******* horrendous the mobile experience is
 
go ahead, they won't care :P
 
I'm trying to open the link again that you've given and it's giving me the interface to flag it, with it auto-collapsing at the same time. Just awful
 
I don't usually see that. Mobile or reactive desktop?
 
7:49 PM
What is "that"?
 
> the interface to flag it, with it auto-collapsing at the same time
 
I've screentshotted it
And now can't find how to post
Just emoji garbage
Oy, chat is just messed up
 
yeah, mobile chat is broken
 
8:07 PM
Good job the team focusses on the important stuff
 
chat has been an orphan for a long time
 
I can raising in meta. Does anyone wanna be my friend on Twitter if I start an account?
 
you'll have more luck with main rather than chat
 
Eh, I'm not even fussed mate. Rbrb
 
Also, read Jon Ericsson's new blog post which kind of explains that things only happen when the company wants something, and any impression that this is due to community demand is just a coincidence
 
9:08 PM
could someone please explain what I actually have to do to get this to work? bugreports.qt.io/browse/PYSIDE-559
 
9:18 PM
no repro (/no MCVE), OP admitted in a comment stackoverflow.com/questions/53026180/…
 
cbg
@AndrasDeak done
 
thanks
 
9:39 PM
cbg
 
cbg
 
9:56 PM
@AndrasDeak Do you use programming for work?
 
yup
 
@AndrasDeak that's really cool what do you do (nonspecific)(data science, apps, websites, ect.)?
 
computational solid state physics
 
so you work alot with quantum mechanics?
 
technically yes but not really
 
10:09 PM
what do you mean?
 
Everything we do fundamentally has to do with quantum mechanics, but not the stuff usually taught in QM. "Density functional theory" is a typical keyword
 
oh okay
 
10:49 PM
I know we've had questions like this "Why is 999999 is 999999 True?" question, but I can't find a dupe. Anyone?
 
11:00 PM
A huge amount of askers only use . On one hand I'm happy they're using python, but on the other hand I find their lack of generic tag disturbing
 
11:10 PM
Today I encountered this fine specimen who went out of their way to remove relevant tags
 
11:30 PM
honestly me too
 
you too what?
 
Aran-fey's "this fine specimen"
 
hi , i am new programmer, i want to test if target is in 2d matrix , if yes i want to print True else False(false should be printed only once)how should i do that?

matrix = [
  [1,   3,  5,  7],
  [10, 11, 16, 20],
  [23, 30, 34, 50]
]
target = 15
for row in matrix:
    for item in row:
        if item==target:
            print(True)
            break
        else:
            print(False)
 
11:46 PM
@user_01_02 inviting users to "private" rooms with no precursor is considered rude. Please don't do that.
You have that code. Does it work? Does it not? If not: how does it not work?
 
It prints more then 1 false he wants it to print only 1 False if 15 is not in the lineup in matrix
 
1. Because break only breaks out of the innermost loop, and 2. because it prints False the first time it sees a non-matching item
you need to 1. stop iterating all together if a match is found, and 2. only print(False) if no match was found at the end of both loops
 
target = 15
if target not in matrix:
print(False)
else:
print(True)
why won't this work?
 

« first day (2933 days earlier)      last day (2025 days later) »