« first day (2910 days earlier)      last day (2036 days later) » 
02:00 - 16:0016:00 - 23:00

2:35 AM
2K finally!
4
 
 
1 hour later…
3:51 AM
Unreal , so Op and answer are going back and forth on this list comprehension that has 3 upvotes that produces the wrong result because no one ran it and it doesn't even work
I post a solution that solves the problem correctly and get downvoted 20 mins later after telling poster multiple times it doesn't work , he says " you are right, updating' .... lol
 
 
1 hour later…
5:11 AM
@wim "make downvote penalty same magnitude as upvote gain" If that happened, voting rates would plummet. I'd prefer a change that would effect the power of your votes, not their cost. I expect that it would be too hard to implement, though. And it wouldn't be consistent with the existing vote values, but we have that already with ancient basic questions & answers having 1000+ scores.
My idea is that your voting power in a tag is proportional to your rep in that tag. If you're a newbie in the tag, your votes have the basic value, but as your rep increases so does the power of your votes. So if you get upvotes or downvotes from a bronze badger they have more effect than newbie votes. I guess we'd need a cap on that, otherwise a single downvote from the likes of Martijn could wipe out your entire score. :D
 
Follow up to my last clock... pirsquared.github.io/clocks/TxtClock
I think I can go back to my regular scheduled programming
 
5:29 AM
@piRSquared Cute. Clocks are fun, and a good exercise when learning a graphics lib. If you want something a little more challenging, do a sundial simulator, or at least a clock that displays local solar time somehow.
Or if you're up for a little algebra puzzle, figure out when the time on a standard 12 hour clock with no second hand is ambiguous. That is, if you swap the hour & minute hands the clock displays a valid time.
 
Great. Just when I thought I was done with my tangent (-: sleep rbrb
 
wim
5:52 AM
@PM2Ring I was talking about penalty to the downvoted, not the price the downvotee pays.
 
@wim Ah, right. Now I get it. :)
 
I don't know about making an answer downvote equal -10. -5 sounds sufficient, and maybe increase it to -3 on questions. But I guess equal up & down amounts is simpler. And it would probably eliminate the problem where a poor answer gets -4 and then +4 from sympathy upvotes, so the answer has a net score of zero but the answerer still gets a 32 point reward.
 
I don't think answers at zero should get rep regardless of the total score
 
wim
6:14 AM
Yes, nothing else but symmetry makes sense imo. A question or answer at zero score should get zero.
 
wim
6:26 AM
Man, how can you help the people when the answer is literally in the error message. Is there a canonical for "read the exception message"?
I was talking about this one but I've seen many variations on the same theme recently
 
At some point you have to believe it takes more effort to create a new post than to just google the error message
 
6:49 AM
On a related note... We don't expect coders to be expert mathematicians. But we do expect them to understand basic arithmetic, like being able to add or subtract one. :) This OP wasn't happy when his question got hammered. The target has heaps of useful information, and he got two specific answers anyway. stackoverflow.com/questions/52600341/…
Admittedly, the new answers don't adequately show what to do when the found index is at the start or end of the list.
 
7:25 AM
Cabbage
 
cbg
 
This question's title is so confusing if you don't know how to parse it.
 
Hi, forgive me if this is obvious. In a producer-consumer problem implemented using processes, how does can I inform the producer if task_done was called by the consumer?
I guess, I could make the worker push something like 'done' into the queue after processing. Which would be read by the producer as acknowledgement.
 
7:41 AM
I don't think the producer has to know that. I think usually the producer and consumer run in separate threads/processes/whatevers, and the producer simply puts new tasks into the queue 24/7 - when the queue is full, the producer will be automatically paused (and it'll automatically wake up when the queue is no longer full, as well)
 
@Ajit If you can, try to avoid a setup where the producer needs to poll for answers. Either by avoiding the need for it, or having a library that works with futures/promises.
 
user8892462
 
Please don't post your fresh questions here. Be patient and read the room rules while you wait for an answer
 
8:04 AM
Hmm. Thanks I will rethink my design. I was considering scenario where my consumer stalls indefinitely. I would need up a timeout for based on some sort of ack sent by the consumer.
 
8:18 AM
@Aran-Fey I have mixed feelings about closing that. Apart from the fact that it's ancient, it's not necessarily a request for a 3rd party resource. Sure, the OP should've found the XML modules in the standard library, but that is a pretty confusing part of the stdlib, so IMHO it's reasonable to ask for some guidance about that.
 
~600k people reached \m/
^^ but I still CVd.
 
@shad0w_wa1k3r Well done!
 
thanks :D
 
I'm a bit surprised that warnings.catch_warnings does not provide an input parameter that lets you chose which warnings you want to filter.
 
@PM2Ring Not sure why it would matter if it's a 3rd party resource or not? Either way there are plenty of 3rd party module answers there, so...
 
8:26 AM
@Aran-Fey To me, a resource request implies 3rd-party, not something that's virtually built into the language itself.
 
I think there are 2 reason why we close those:
1) Recommendations attract opinion-based answers
2) Nobody can be bothered to keep the list of recommended libraries up-to-date

Point (2) probably isn't much of an issue if the question is only about the stdlib, but surely point (1) is still relevant?
 
I suppose point 1 is still relevant, although with Python there is often one best way to do stuff, but it might not be obvious where to look if you aren't intimately familiar with the stdlib docs. And when there are multiple ways to do stuff it's often possible to give objective reasons about the different options, eg using Requests vs the standard libs, or using f-strings vs format vs % formatting codes.
 
Well, it's always possible to list objective reasons. I'm really not sure how this question is different from other tool requests that would be closed within 2 minutes
I also don't see any answers listing objective reasons
 
@Aran-Fey Fair enough. I guess if I saw a fresh question like that, I'd link the OP to the relevant section of the docs, and VTC as Too Broad.
piRSquared's pretty clock programs inspired me to write an old-school 7-segment clock. It shows hours, minutes, seconds, and microseconds, but that's easy enough to modify. It requires a terminal that understands ANSI control sequences.
from datetime import datetime
from time import sleep
digits = (
    ' _     _  _     _  _  _  _  _ ',
    '| |  | _| _||_||_ |_   ||_||_|',
    '|_|  ||_  _|  | _||_|  ||_| _|',
)
segments = {str(i): [row[3*i:3*i+3] for row in digits] for i in range(10)}
space = [' '] * 3
def convert(s):
    buf = [[], [], []]
    for c in s:
        for row, seg in zip(buf, segments.get(c, space)):
            row.append(seg)
    return '\n'.join(map(' '.join, buf))

while True:
    current = datetime.now()
    print(convert(format(current, '%H %M %S %f')) + '\n\x1b[4A')
 
8:46 AM
@PM2Ring I admit, I don't always agree with questions being closed as opinion-based or tool requests, for precisely the same reasons you brought up. I've even asked one or two questions that were almost closed as OB myself. But I think unless the question explicitly asks about advantages/disadvantages of a few specific options, we should be consistent and close those questions.
 
I guess that's reasonable.
 
9:14 AM
recbg
 
9:24 AM
I can't figure out why this was downvoted. stackoverflow.com/a/52642647/4014959 Building fresh lists is simpler than using deepcopy. FWIW, I wrote my answer before I saw that one.
Yes, it is essentially a dupe, but the OP did her research, and linked some relevant questions. She obviously needed some additional help to understand what was going on with her nested lists.
 
user8795229
Any suggestions about it?
 
@PM2Ring All is revealed. The original answer was borked. :)
 
@VaibhavAcharya Maybe you could tell us what's wrong with the code, or if you're just asking for stylistic improvements?
Also see An Illustrated Guide To Formatting Code In Chat (or even better, upload your code to a paste service, since it's pretty long)
 
@VaibhavAcharya You didn't actually ask a question. Also, try to keep code snippets here no longer than a dozen lines or so. Long stuff should go on an external site like dpaste or Github gist.
 
user8795229
First time here....I didn't know what actually happens here.
 
9:43 AM
@VaibhavAcharya That's ok. But we still don't know why you posted that code. ;)
 
10:06 AM
@VaibhavAcharya please repost that with proper formatting and a well-formed question, or even better, use a code paste service for the code (and a well-formed question)
 
10:23 AM
syn-recbg. ok got a problem again: anyone knows the best and easiest and the most complete and the most liberal HTTP server implementation for Python that will also give me the exact(ish) binary representation of the socket comms, kthxbye :D
 
10:56 AM
I'm using Google Text to Speech why are there text=mytext like assignemnt inside function call? soundClip = gTTS(text=mytext, lang=language, slow=False)
can't we simply pass arguments like gTTS(mytext, language, False)?
 
those are keyword arguments of a function
 
@AbhimanyuAryan yes you can. it's a matter of taste, in this case
 
they would also work in a different order, and it's possible the function is defined in a way that you can't provide those arguments based on position
@Arne are you familiar with that function?
 
no, but it's syntactically identical to leaving it out, right?
 
Nope
 
10:58 AM
and I know people that will always put kwargs in function calls. so i assumed this was another such case
 
def foo_gTTS(*, text, lang, slow):
 
Or def gTTS(lang, slow, text):
 
yup
 
hey guys how u do logging across multiple threads ?
 
naming your keywords makes it clearer and more foolproof
 
11:00 AM
def gTTS(lang, slow, text):

so with this basically I get independence of getting arguments mapped whatever the order I pass them into?
 
yup
you don't have to rely on the order in the function definition, or even remember the order
 
alright, I checked the order. It's text, lang, slow, but you guys are right of course
 
is it ok to generate uuid at the starting of each thread and include that uuid in the logger name, in order to be able to differentiate among logs from different threads in the same file?

Something like this:
time | uuid1.class1 | INFO | message1
time | uuid2.class1 | INFO | message1
time | uuid1.class2 | INFO | message2
time | uuid2.class2 | INFO | message2
time | uuid1.class2 | INFO | message3
time | uuid2.class2 | INFO | message3
 
fwiw, I think something like gTTS(mytext, language, slow=False) is most readable, where non-obvious paramters are keyworded, and those where the variable name essentially contains the keword name are passed in order.
 
Ha. Hahahaha. lots more schadenfreude laughter. This just popped up on Codementor Freelance, estimated budget $100: Undergraduate python project ... Project is due within 25 hours, and time required should be no more than 5 hours.
Sure, $20/h is going to get you a great developer doing your late homework for you.
 
11:04 AM
thanks guys
 
At least they didn't post this on SO. And 5 hours is not going to cut it, either.. Complete undergraduate project task that consists of 4 parts: How to build a population network (Question 1), How to model an infectious disease outbreak on this network (Question 2), How to identify the central person in a population network (Question 3), How to measure the impact of vaccinating this central person (Question 4)
 
@AbhimanyuAryan you're welcome =)
 
@MartijnPieters so...did you take it?
 
So this is a Python project that does what, machine learning? Pandas dataframe analysis? Scipy network simulation and analysis? A web service pulling this all together?
@AndrasDeak Not sure, ask me when I stopped laughing at it.
 
So you're still thinking about it (:
In a way, it's flattering that that person has such a high opinion of the average developer though. They're like "I'm sure this is no problem for these people"
 
11:09 AM
@Aran-Fey what makes you think that? And a side question, when was the last time you callibrated your sarcasm detector?
;-)
 
What are you talking about, my sarcasm detector is perfectly calibr- ... oh, that was sarcastic :D
 
I'll take my $100 now, thanks.
 
@MartijnPieters Oh wow, I missed that description. Hilarious :D
 
@AndrasDeak I just made a Gist: crocheted_sphere.py. Hopefully, the output makes sense. It's pretty close to the notation used in the craftster thread, but I made a couple of minor changes. So if your wife has any suggestions to improve the notation I'm using, please let me know.
The patterns my code makes are very close to the 2 patterns given in that thread, since I basically reverse-engineered those patterns to create my code. And hopefully where there are differences, my code is more mathematically accurate.
 
@PM2Ring awesome, thanks, remind me if I forget
 
11:23 AM
@AndrasDeak No worries.
 
I wish there was a "mark as unread" in chat :D
 
I suppose that if you make n too small the pattern will be silly, or at least not very spherical. But I didn't think there was any point in doing sanity checking on the argument.
 
11:58 AM
@AndrasDeak Like a star, but private
 
@Aran-Fey Hammered
 
12:17 PM
@PM2Ring you there
 
Yep. Did you see my 7 segment clock up there^?
 
look at this
why when i print d its 0 1 2 3 4 but when i pass it to the list of dicts im getting only 4s
i know its the last value of the ragne but if print d before assigning it to the dict its value is a: 0 a:1 a:2 a:3 a:4
when i assign its alll a:4
 
@vash_the_stampede Do you want to try that again, using proper formatting? :)
 
hwo do i paste in here
it never carries over my formatting
l = [{'b': i } for i in range(0, 5)]
d = {'a': 1}
for i in l:
    d['a'] = i['b']
    print(d)
    i['c'] = d
print(l)

l = [{'b': i } for i in range(0, 5)]
 
@vash_the_stampede Paste in your code, then hit Ctrl-k, or the Fixed font button. Don't mix code and non-code.
 
12:21 PM
yeah i just put 2 n 2 togetehr and figured was same as answering posts
:)
 
2 days ago, by Antti Haapala
 
leave out that that last list comphrension
 
@vash_the_stampede There's only one dictionary named d. You're adding multiple references to the same object into l
 
yeah but the time of assignment isnt the dicitonary only equal to the current loop pass
 
BTW, don't use a single lowercase L as a variable name. It's unreadable. :D
 
12:24 PM
yeah i get that alot :/
so its because im updating the dictionary within the loop and that transfers to all instances fo the dicionary outside of the loop
 
@vash_the_stampede Irrelevant. There's only one dict object. You're modifying the value in it, but that doesn't matter. Python isn't making a fresh copy of that dict each time you store a reference to it in l.
 
thats what confused me in the loop pass if its {a:0} when i assign it it become {a:4} but I think I understand using diff method now
l = [{'b': i } for i in range(0, 5)]
d = {'a': 1}
for i in l:
    i['c'] = {'a': i['b']}
print(l)
just using this
 
Or in other words there aren't multiple instances of the dict. There's one instance being referred to in multiple places.
@vash_the_stampede Have you read this yet? Facts and myths about Python names and values, which was written by SO veteran Ned Batchelder.
 
I ended up just eliminating the entire d and just using the for loop as is
ha PM I was just thinking today I have to start reading learning more there is an abundance of questions I pass over that I'm going to need to answer if I was to break the top 50
 
Take a look at this:
>>> a = []; a.append(a); print(a, id(a), a[0], id(a[0]))
[[...]] 3071645164 [[...]] 3071645164
 
12:40 PM
is that for I? what am i looking at
 
@vash_the_stampede Yes that's for you. I appended the list a to itself. So a now contains a reference to a. That is, it's a recursive list, which is infinitely deep. Python is smart enough to print that out in a special way using the ... ellipsis notation.
 
hmm I will save this for future reference to when I become smart enough to print that out in a special way
How did a 2k user just post an answr with eval
O.o
 
There's not much correlation between reputation and... anything other than "willingness to post a lot", really
 
Sometimes I wonder how people like Jon Skeet and Martijn can be so active on SO without being bored to death
 
12:55 PM
Some people build model train sets in their garage, some people answer questions on Stack Overflow.
 
Good point, I'm probably just overthinking it.
 
Sometimes I feel being able to write good answers are very satisfying.
 
Teaching is addictive. And part of being a teacher is being able to teach the same stuff over & over to newbies. Sure, it's repetitive, but it's like working out in a gym, doing woodwork, or practicing a musical instrument. With repetition comes fine-tuning & refinement of skill.
 
yeah @PM2Ring
 
I spend easy 10 hours a day on here
still not bored :)
 
1:03 PM
@PM2Ring Makes sense.
 
just having trouble making time for actually learning python cus its so addicting
@PM2Ring couldnt have been said better
 
Or cooking. Sure, a master chef might have minions to peel potatoes and shell peas. But any good cook will be happy to chop the ingredients that they need for a dish, knowing that nobody else will do it exactly the way they do it.
 
Got rejected at my first job interview....Just got the mail...
 
Sorry to hear that, Azazel.
 
I need Stack Overflow to fulfill my emotional need for people to tell me I'm doing a good job, which I can't get at my actual job because I spend too much time on Stack Overflow
11
 
1:07 PM
Sometimes I wonder, if I have problems solving something at work, is it okay to post about it here?
@PM2Ring Actually I thought I did fairly okay at the interview.
 
I sometimes wonder if I will make this into a career of if my OCD personality will forget SO like every other hobby and in a month I'll be stacking cups instead :(
 
Pretty much the only time I'm desperate enough to ask a question on SO, is when I'll get fired if I don't figure it out in the next N hours
 
@Azazel Of course. SO is for professional coders, not just students.
 
Should I be sharing codes that is owned by the company? I know I will have to hide the code as much as possible...but...still sometimes doesn't sound right.
Makes sense @Kevin
 
@Azazel Definitely be careful about that. But if you make a proper MCVE that shouldn't be an issue.
 
1:11 PM
Ideally you would construct a piece of code from scratch that happens to exhibit exactly the same problem that your real code is having
 
If it's proprietary code, then you will need to paraphrase it so that you don't break company regulations. But you should still be able to create a MCVE that illustrates your issue.
 
@Azazel part of being a good coder is honing your ability to generalize. You should attempt to break down a problem to it's core and present that to SO. Apply the lesson to the real code and move on. That is what MCVE is all about.
 
That's quite helpful guys...thanks.
 
What to do when the entire answer seciton is filled with solution that is iterating an int which is not possible, why do people just fling out code and not run it
do you comment on every answer pointing it out, or just post the correct answer and ignore
 
If an answer is factually wrong, if I'm feeling generous I leave a comment and wait five minutes to give them a chance to fix it before I downvote. If I'm not feeling generous, I just downvote right away.
 
1:19 PM
I have edit privileges do I edit all there for i in number to for i in range(number) seems kind of pointless to do so
 
If a question does not yet have a correct answer and I know the correct answer, I post it. This is independent of whether there are existing incorrect answers.
 
but what about something as trivial as that where they are just trying to iterate a num instead of range(num) obv they know its a oversight they rushed out their solutions if they tested them they would know
 
@vash_the_stampede It's generally frowned upon to edit someone else's code for any reason
 
@vash_the_stampede The usual practice is to not make major changes to other people's answers like that, unless it's a prominent wrong answer and the poster is no longer active. Get them to fix it if possible. Fixing typos is ok, but not changes that "conflict with an author's intent", even if they're wrong. Some people (eg Wim) disagree with that approach though.
 
yep yep all points noted
 
1:24 PM
The only time I edit code is when it's from a post that's years old. Think of it as the difference between archaeology and grave robbing.
(disclaimer: adding monospace formatting to code does not count as editing code)
 
user8777433
selamün aleyküm
 
@vash_the_stampede Don't put a bunch of identical comments on a series of answers. That just looks annoying to other readers. But if there are a bunch of bad answers all doing the same wrong thing, put a full comment on one of them, and a short comment linking to the full comment on the other bad answers. And make sure to check later to see if anyone's fixed their stuff. And of course, make sure that they are wrong and you're right before doing stuff like that. :)
You can get a link to a comment by hovering over the comment's timestamp.
 
cabbage all
 
@PM2Ring ty noted
 
1:42 PM
I just got a couple of upvotes on old answers. Which is nice, but I hope it's not a serial upvoter...
 
You'll know in 10 hours (:
 
the best is you wake up check your phone and its like +50 from two days ago answrers <3
 
oops. I answered a question a few hours ago, which has now been marked as a possible dupe, with the answer at the dupe target being written by the person who marked the new one as a dupe. I guess someone should hammer the new one, but it would look weird if I hammered it.
FWIW, I originally gave a short answer in a comment, but I'm trying to break that habit.
 
@PM2Ring hammered
 
Thanks
 
1:57 PM
Does the typing module have support annotations like "the type of this parameter must be exactly Foo, not a subclass thereof"?
 
That seems like a very rare use-case
 
@Aran-Fey TypeVar supports a contravariant=True keyword for this usecase
 
In Pass class as function argument and reset class repeatedly within in function, does self.__default__ have special behavior, or did the OP make it up? I don't see it listed in the data model, which is usually a good refeference for dunders.
 
if I understood you correctly
 
@PM2Ring one more question for you and your off the hook
s = "username:password;username1:password1;username2:password2"
d = dict(v.split(":") for v in s.split(";"))

s = 'username:password'
d = dict(s.split(':'))
why does the top produce a dictionary with keys and values and the bottom does not
how does this use of dict work
 
2:09 PM
cbg \o
 
@vash_the_stampede not PM, but here it goes:
dict(list of single values) -> TypeError
dict(list of pairs) -> dictionary
a pair is something iterable of length two, like a list, or a tuple, or a generator that yields exactly two objects
 
What Arne said.
 
yeah I see we need to create a list of 2 items to work
 
@Arne Hmm, no, unfortunately that doesn't work for me. I need something like Exactly[Foo]. I guess it's no surprise if the typing module doesn't have that.
 
but does not splitting username:password at ':' create a list of two items
 
2:11 PM
@vash_the_stampede You need a list of pairs for the dict constructor
 
BTW, the top one is better as dict(v.split(":") for v in s.split(";") if v). That copes with a final ";" in s
 
@vash_the_stampede There's a difference between "a list of two items" and "a list that contains some number of lists, each of which have two items"
 
^
 
so how could you make username:password into a dictionary using dict
 
d = dict([s.split(':')])
 
2:14 PM
Also, d = dict(zip(*s.split(':'))) works. It's silly, but it works. :)
 
that being said, I wouldn't actually write this code
 
@vash_the_stampede Your first code, d = dict(v.split(":") for v in s.split(";")), still works fine for s = 'username:password'.
 
yeah agree just think its strange that dict can turn [['username:password']] into a dict but not ['username:password']
@Kevin not my code was a solution I thought was interesting im used to using dictionary comprehension but in this case using dict was cleaner wanted to learn how to implement it
 
I don't know what you mean. dict([['username:password']]) produces a ValueError.
 
@vash_the_stampede IMHO, a dict that only contains a single key-value pair is a bit dumb, unless you intend to add further items. But we see lots of code on SO that uses lists of those stupid single item dicts.
 
2:17 PM
s = 'username:password'
print(s.split()) # ['username:password']
d = dict(s.split(':'))
print([s.split()]) # [['username:password']]
d = dict([s.split(':')])
@Kevin this is what i mean bottom works top doenst
 
dict(('a', 'b')) # bad
dict([('a', 'b')]) # ok
 
s.split() and s.split(":") are different things
 
should have been split(':')
same thing wont work without being inside []
 
"dict([s.split(':')]) works" does not disprove my statement that dict([['username:password']]) does not work
 
@vash_the_stampede Do you dislike dictionary comprehension? I feel like this kind of stuff would be way clearer if you used them.
 
2:20 PM
@Arne I only use dictionary comprehension but for hte solution of the problem i was speaking of, user used dict and it worked out nicely
2
A: Generate a dictionary from a file of key-value pairs separated by semicolon

Jean-François Fabreyou need to hierarchize your split operations: s = "username:password;username1:password1;username2:password2" d = dict(v.split(":") for v in s.split(";")) print(d) result: {'username2': 'password2', 'username': 'password', 'username1': 'password1'} for a multi-line file, just add one mor...

 
The .split stuff is a side-issue. The core issue is that to use the dict constructor like that, you need to pass it an iterable of key-value pairs
 
here the answer was very neat I enjoyed it
s = 'username:password'
print(s.split(':')) # ['username', 'password']
print([s.split(':')]) # [['username', 'password']]
d = dict([s.split(':')])
sorry this is clearer picture of what im speaking of
s.split(':') produces an iterable with 2 items
but dict will not accept that only [s.split(':')]
 
@Arne dict comps are good, but sometimes using the dict constructor is more compact, eg if you feed it from an existing generator that yield tuples. OTOH, a dict comp might even be faster in that situation. It's certainly faster than running a gen exp inside the dict constructor. Similarly, running a gen exp inside the list constructor is slower (and uses more RAM) than the equivalent list comp.
 
but from the error output I guess it makes sense element 0 must have length two and it being one list element 0 becomes just 'username' and if I use [['username', 'password']] element 0 is now two items so its iterating a list of lists, no further explanation requried thank you all for your time
 
Not a problem. We enjoy watching those "the penny finally drops" moments. ;)
 
wim
2:27 PM
@Arne that ... is surprising
everything below Zero's answer here
 
Let's Golf Find the most succinct way to turn a string inside out.
s = 'a>b>c>d>e>f>g><7<6<5<4<3<2<1'

# Turns into
# '1<2<3<4<5<6<7<>g>f>e>d>c>b>a'
My go -> k=len(s)//2;s[:k][::-1]+s[k:][::-1]
 
> simplest ways to get around this problem [...] is to get used to concatenate any kind of objects to a string using a comma ( ',' ) as the concatenation operator
delightful
 
Hmm, I'm unclear on what "inside out" means here
 
@PM2Ring comprehensions are also faster since they are literal constructs and avoid a function call to the constructor =D
 
Can you provide an example where inside_out(s) != s[::-1]?
 
2:32 PM
@AndrasDeak Yeah, that won an instant downvote from me.
 
@wim I think ngub's answer should stay. Some people like that kind of answer that just shows how to do it with no fluff whatsoever.
 
@wim It looked like something super obvious to me, but maybe I'm just using it wrong.
 
@Kevin I suggest string.ascii_lowercase as example input
 
Ok, I'll try it.
 
Splitting at the midpoint of the string (assume even length) reverse each half and glue back together.
 
2:36 PM
That's not really descriptive of the Turns into output in the original message. Is that a typo?
 
@Kevin ARGH! My example was wrong. should have been '>g>f>e>d>c>b>a1<2<3<4<5<6<7<'
 
Ok, that explains it :-)
 
@wim I asked a question on packaging a while ago, and it's tumbleweeding impressively. Any chance you have a solution or opinion on the matter?
 
Try that again (-:
s = 'a>b>c>d>e>f>g><7<6<5<4<3<2<1'

# Turns into
# '>g>f>e>d>c>b>a1<2<3<4<5<6<7<'
 
4 chars shorter:
>>> l=len(s)//2;(s[l:]+s[:l])[::-1]
'>g>f>e>d>c>b>a1<2<3<4<5<6<7<'
 
2:38 PM
How about k=len(s)//2;(s[::-1]*2)[k:-k]
By doubling my memory footprint, I save two bytes!
 
Smart.
 
cbg
 
ah, nevermind, I misread
 
My extremely low effort Python 2 version that saves a single character over Kevin's: k=len(s)/2;(s[::-1]*2)[k:-k]
 
@user3483203 *applause*
 
wim
2:44 PM
@Arne posted answer
the "hefty dry-build to get the package list" is not avoidable
in the general case, distributions must be downloaded to determine their dependencies, since setup.py can contain code which determines the dependencies conditionally
 
I read that as "distributions must be downvoted"...
 
wim
@Aran-Fey nah. users that answer on other people's canonicals are parasites.
 
@vash_the_stampede I'm curious if you've had a look at any languages other than Python?
 
This is my first month ever touching a programming language :(
 
I'm too tired to argue, so I'm just going to state my disagreement with that statement
 
2:57 PM
well now im on my second month
I think a while ago maybe in highschool i wrote something in C++ that used classes but then I got to pointers and was like nevermind so about 3 days in C++ haha
 
For that type of question, you need to have some passing familiarity with how other languages work. I think you were only able to see it in the context of Python, but what python does in that for loop is different to a lot of other languages
 
or C whatever it was that was about 10 years ago
yeah I understand I looked back and he was unsure of how a could be used without being declared prior to the loop, which then became clear by his remarks would not be possible in his native language
 
80% sure that C doesn't have classes, so it was probably C++
 
@wim as long as it's properly handled as a dry run, all is well. Since I don't write to write that myself.
Do you want to put a "disclaimer: I'm the author'" on that answer? I've seen some people getting hissy when they found such a relationship between answerer and 3rd party lib
thanks a bunch for the answer, btw =)
 
indeed, disclaimers are often necessary to prevent spam allegations
especially since there's no sign of authorship in wim's profile
 
wim
3:06 PM
a spam allegation would be rich, when I was invited to answer
 
Yes, but whoever stumbles upon that post won't know that. Common thing on meta.
> If there were only one or two posts it would have been fine to just ask in a comment for the user to disclose their affiliation [...]
or Brad Larson, even better meta.stackoverflow.com/a/306542/5067311
> You flagged two posts as spam by a 4k user who had left nearly 200 answers. These posts suggested the use of an open source library that this user was the author of. They state that they are the author of this open source library in their profile.

The two answers did appear to be genuine attempts at helping someone, and not obvious self-promotion for their library.

It would have been nice for them to indicate in the posts themselves that this was their library, but before jumping right to a spam flag I'd suggest leaving a polite comment pointing that out. If someone has been a longtime
these all implicitly suggest that you should at least put the project in your profile if you're using them to answer posts
> The community here tends to vote down overt self-promotion and flag it as spam. Post good, relevant answers, and if some (but not all) happen to be about your product or website, that’s okay. However, you must disclose your affiliation in your answers.
 
In general I see beginners using global alot , but most comments say to refrain from global, is global generally considered a bad practice?
 
yes
 
wim
"affiliation" implies I get more than $0 per user
 
3:11 PM
you needn't convince me, this is just a heads-up concerning the status quo
 
@roganjosh confirms my assumption
 
I still get a kick when a solution involves eval like I just start cracking up waiting for the downvotes and comments, I remember once the user was arguin with i believe @roganjosh over the validity of his use of eval in constructing a dictionary hahaha
loved it
 
Sounds like me
 
wim
@AndrasDeak I dunno, I think those meta posts are more intended for people who advertise about their library on hundreds of answers, even if it only vaguely related
 
3:15 PM
well, mostly because if there's only a few posts then nobody will notice
 
If an answer is good, I don't care who wrote it.
 
wim
It's not that - more like, I never saw anyone who got in a hissy about such thing solely on principle, it was always when the answerer was being tacky or obviously spammy.
 
@wim you'd be surprised
 
wim
are you in support of "warning: coffee is hot" disclaimer on hot coffee?
 
I'm not sure whether I'm curious about why you would be averse to declaring it
 
3:16 PM
I'll test it a bit more tomorrow, but it will be great to have a less breakage-prone pipeline
rbrb
 
If the coffee can cause literally third degree burns, yes
 
@wim I mean the President did state 'warning this hurricane is big and tremendously wet' I think americans need warnings that coffee is hot haha
 
@vash_the_stampede I'd rather you didn't imply that "americans" are stupid
 
If this is referring to the woman getting burned at McDonalds, she was actually really seriously injured and the media fed her to the dogs IIRC
 
wim
@roganjosh not adverse. would edit it in later should it be deemed necessary, I just don't see it as necessary in all cases, more like, use your judgement on a case-by-case basis
 
3:25 PM
@AndrasDeak I am american, my statement didn't declare we are stupid but maybe for lack of better words , we overlook the obvious often
 
wim
in some other cases (e.g. here, here) I did think it was worth mentioning authorship, so I'm not opposed to it as a blanket principle
 
new to this cabbage, but by the grace of this room could I ask a framework/library recommendation?

I'm designing a python server that will need to update about a dozen clients with the state of some scientific simulation or something (which is a couple dozen kb of doubles encapsulated in python objects) hopefully around once a second. A few small events would come from clients, but that's it.

I was planning on serializing all the objects (using pickling or protobuf) and sending them out using TCP sockets, which seems simple enough. But it seems like this is a common problem in distributed
 
3:43 PM
@roganjosh questions like that make me think there is something or someone who has simply designed an AI to auto generate questions to keep the ranks of SO users gainfully employed. That can’t be the product of real human thought
 
@pmelanson I don't have any recommendations for you, but don't send pickled data over a network. (More accurately, don't unpickle data you've received from an untrusted source.) You're opening yourself up to arbitrary code execution.
 
@W.Dodge it came moments after I starred user3483203's comment about PVS and being a contributor
 
Ha!
 
I have a feeling it is the most basic question I have encountered thus far. But, I think they just worded it really badly and they actually had a dataframe
 
@Aran-Fey ah yes, the existing system that I'm trying to replace is also super insecure, so much so that we keep it disconnected from the internet. But yeah, I shouldn't open myself up to that, I'll not use pickling/unpickling.
 
3:45 PM
I refuse to believe they could create a dictionary and not know my_val = int(my_string)
 
cbg
Does anyone know where Abarnert is btw?
 
@Aran-Fey True, but pmelanson's sources are all trusted. Assuming the LAN's security problems are dealt with at the appropriate level. :) I guess there's the possibility of one of the participants accidentally pickling & sending something stupid. Still, I'm not a fan of using pickle for communication. Or long-term storage.
Cabbage, @Nasrin.
@roganjosh He comes and goes. Sometimes he's absent from SO for very long stretches. Like years.
 
Yeah, I got the impression he returned just around the time I was joining chat regularly. I just wondered whether he had announced anything in particular
 
Last posted in Python room on Jul 16. Last seen on main site on Sept 17.
 
3:55 PM
@PM2Ring I was expecting your sentence to finish with weeks, but years is also ok :-))))
 
chat.stackoverflow.com/users/908494?tab=recent doesn't reveal anything of note.
Thus ends my Internet Detective stint.
 
:)
I do hope all is well and he just burned out for a bit with SO, he was hammering out answers
 
02:00 - 16:0016:00 - 23:00

« first day (2910 days earlier)      last day (2036 days later) »