« first day (2648 days earlier)      last day (2283 days later) » 
00:00 - 16:0016:00 - 00:00

12:05 AM
Hmm, after reading the documentation for dir, I'm not sure if I ever want to use it in real code...
> Because dir() is supplied primarily as a convenience for use at an interactive prompt, it tries to supply an interesting set of names more than it tries to supply a rigorously or consistently defined set of names, and its detailed behavior may change across releases.
 
ouch
 
I have yet to come across a situation where dir would have been helpful in real code
 
now I feel less bad for always shadowing dir for various orientation vectors
 
I think I have a working implementation now... but I'm definitely going to write a bunch of unittests for this tomorrow.
 
Am going thru David beazley presentation on meta class that avoids class based decorator to debug every class using debugmeta, as shown here
 
12:20 AM
In another 3 hours, JS is going to hit 1M when I award his bounty. If anyone's interested, you can pounce on the opportunity to make a meta post and garner hundreds of 0-point up/downvotes
 
But debugmeta applying class based decorator on class instance(debugmethods(clsobj) )
 
my knee-jerk response is unfortunately incompatible with the moderation habits of this room
 
It is suppose to apply on class at import time. clsobj is not class
 
I expect nothing less
 
def special_method(func):
    import sys
    loc = sys._getframe(1).f_locals
    loc['my_special_method'] = func
    return func

class A:
    @special_method
    def f(self):
        pass

a = A()
print(a.my_special_method == a.f) # -> True
cc @Rawing (disclaimer: I don't know how robust this is)
 
12:27 AM
@cᴏʟᴅsᴘᴇᴇᴅ how do you see the number of posts for a tag?
 
@Code-Apprentice If you click on that tag, there's a counter on the top right
 
nvm...js == Jon Skeet, not JavaScript
 
he's down to hours...last I looked it would take until Wed
guess he got some bounties today, eh?
@cᴏʟᴅsᴘᴇᴇᴅ is that an emoji? All I see is tofu
 
@vaultah I'm already in the process of trying to break it, but so far it's proven surprisingly resilient!
 
12:29 AM
Yes. An emoji. Only an elite may view
 
I guess I'm not 1337 enough
okay...now that I reread that several times, I get it. What question are you awarding a bounty on?
 
his badge already says 1000k...such cheat
I never even noticed that he's already rounded up
 
@vaultah I'm impressed; it withstood all my attempts to trip it up. I'll be using that, thank you.
 
:D you're welcome
 
12:38 AM
@cᴏʟᴅsᴘᴇᴇᴅ why 3 hours? Is that the soonest SO will allow you to manually award the bounty?
 
Yep
Need to wait 24 hours to award it
 
I might be asleep by then. You should just wait until tomorrow.
 
Well, he'll just accumulate it himself, and it'd spoil the fun ;)
 
"fun"
whatever spoiling is going to happen will be thanks to you
 
I don't know about you, but it'd be funny to catch all the people waiting to spam meta off guard
Who'll do it first, I wonder.
 
12:41 AM
you indeed don't know about me
 
Just watch, don't be a sour puss
 
you've seen my meta post about the planned celebrations, right?
 
The one with a tonne of downvotes?
 
yah, that's the one
 
Yes. It was dismissed pretty quickly
 
12:46 AM
not sure why all the dv's...I find it amusing
 
@cᴏʟᴅsᴘᴇᴇᴅ I'm trying to find an appropriate visual representation of my impression but can't. So here's what this bounty business of yours feels to me: imagine a huge hangar filled with the most elaborate domino record ever attempted. When it's smoothly gone its way and almost about to end, someone throws a cat into the middle of the endgame, knocking over the remaning two hundred pieces with a splash.
you're the cat
 
That's what I do
Or I should say, that was my intention all along, you put it so eloquently.
 
lol
 
I just want to note that the only reason cats are tolerated in this society is that they are cute and catch mice.
 
Well, there are 6 days left, so I could technically do nothing and let him get it himself
All I'm saying is I could
@AndrasDeak Also, I appreciate the compliment ;)
 
12:58 AM
Honestly, I don't care about Skeet's 1M rep event at all. I care about the attention-mongering self-gratification event of yours because you keep pushing it into my face here.
 
Oops, that's going to get a few more stars
 
@AndrasDeak what other reasons could you possibly need?
 
s/mongering/whatever I mean/
 
@cᴏʟᴅsᴘᴇᴇᴅ I think your bounty is funny, but I'd stop talking about it if people are getting annoyed.
 
for the record I'm the only one who has actually mentioned their annoyance so far
 
1:05 AM
@AaronHall Obviously, the intention was to make conversation, not annoy people
And I've needed to change the topic on a couple of occasions over the last 24 hours, if you've read the transcripts you probably already know
 
Well since we're all here, what's the state of the Python tag?
 
We're losing her, doctor.
 
state in what sense?
 
Here's what I think we need:
- better answers
- more voting (especially in the downward direction)
- flag more redundant comments
- make comments redundant so they can be flagged
- especially on Q&A with more page-views
 
I see plagiarism and copied answers a lot, too
Would be nice if there was a way of automatically detecting plagiarised content
 
1:15 AM
If only we could make these computers do what we want them to do...
3
 
If a question is asking about some API where the proper way to call it is foo([arg1, arg2]), but they call it as foo(arg1, arg2) without the list, then is that a typo, or a misunderstanding of the API?
 
Are 2nd and 3rd arguments passed(exec("a=3",globals(),locals()) ) to see the affect of code execution on both locals and globals?
 
The main point of a typo is not the typo, but "unlikely to help future readers". Use that to determine whether to close.
 
Okay, in that case, as a typo. stackoverflow.com/q/48255853/4909087 Please see my comment there for context.
 
you could be a bit more verbose in your comment to make sure OP actually sees your point
it's not the asker's fault for not realizing their typo-grade problem, we just don't want these posts to stick around
Better, thanks
 
1:32 AM
If I don't cv-pls those questions, they're almost always answered and upvoted
 
yup
 
1:47 AM
Considering how range is implemented in python3, I find it unsettling that in checks with floats don't return a result that you'd expect.
In [1958]: 11 in range(10, 13)
Out[1958]: True

In [1959]: 11.5 in range(10, 13)
Out[1959]: False
When __contains__ can be implemented with x[0] <= val < x[1], unless I'm missing something.
 
"don't work" how?
11.5 in range(10,13) should be equivalent to 11.5 in list(range(10,13))
 
I wish range worked more like an interval than a list.
 
thank goodness it doesn't!
 
For example, this is so satisfying.
In [1961]: 11.5 in pd.Interval(10, 13)
Out[1961]: True
 
because...that's an interval?
as if it was designed for this very use case, unlike a range
 
1:50 AM
yes! And I wish range was too. But it's not, and it's too late to change that now.
 
it was never early enough
 
Actually, that wouldn't make sense given you can vary the step :/
Nvm.
So, I have two lists `a` and `b`.

a = [10.0, 20.0]
b = [1.0, 10.0, 15.0, 20.0, 30.0, 100.0]

I've found a way to get at all items in `b` that are within the interval specified by `a`.

list(filter(pd.Interval(*a, closed='both').__contains__, b))

I'm wondering if there's some higher order function that allows me to wrap around the `__contains__` so that its result is negated. I don't want a lambda.

What I'm trying to get at is something like this:

list(filter(pd.Interval(*a, closed='both').__notcontains__, b))
 
itertools.filterfalse
 
Fantastic, that's exactly it.
In [1983]: list(filterfalse(pd.Interval(*a, closed='both').__contains__, b))
Out[1983]: [1.0, 30.0, 100.0]
And she's alive.
 
quick, put her out of her misery :P
 
2:02 AM
whoa! JS only got 130 rep on Dec 22.
 
psh. I think it's pretty neat
 
He's been slackin'
 
Yeah, unlike us (me), he's got things to do, places to be etc
 
2:19 AM
@cᴏʟᴅsᴘᴇᴇᴅ What is contains checking?
 
@Moondra __contains__ is invoked on an instance when you use the in operator
 
@cᴏʟᴅsᴘᴇᴇᴅ So you are checking if an element of bis in pd.interval? Or Maybe vice versa? Thanks.
 
Yes, what you said first
 
@coldspeed Ah, thanks. So Pandas doesn't have something like that in their API. It seems it could be useful.
 
when you do b in pd.Interval(...) it literally calls pd.Interval(...).__contains__(b) for you
 
2:28 AM
They do. Use in. But I'd need a lambda in conjunction which I don't want
 
that's one layer below the hood of the python you see
anyway, rhubarb
 
@Moondra Try and avoid lambdas where possible.
 
...when using numpy/pandas :P
 
yus
Especially with numpandas
 
I'm not saying they can't be abused in vanilla python but it's not like your hand will fall off if you use a lambda appropriately. But with numpy/pandas a lambda usually implies a complete lack of vectorization for the given application, so there are hopefully (and usually) more efficient alternatives
 
2:33 AM
I don't like using lambdas, but a lot of code seems to use lambdas. I just want to get used reading lambdas so I can understand the code.
 
(I'm just noting this because a categorical rejection of lambdas in the python room without further context might be counterproductive)
@Moondra also, whatever you can do with a lambda you can do with a regular function
(and more)
 
I usually resist the temptation to lambda it. Even where I have to, I define a function that does the exact same thing.
Mostly when I have to use pd.DataFrame.apply shudder
 
3:00 AM
@cᴏʟᴅsᴘᴇᴇᴅ When does the hammer drop?
 
I don't feel like dropping it anymore
You'll have to wait till Wednesday :(
 
There's part of me that would love to see a preemptive jump to 1 mill.
 
Yeah, me too... I could throw that cat on the dominos anytime I wanted to.
 
DSM
3:18 AM
It's not about you, though, and IMO it's quite distasteful to try to make it so. I'm unstarring the related comments, and suggest that any follow-up conversation be taken to another room.
 
@DSM I am well aware of that, and don't wish to do so either. Also, thanks for unstarring those comments, they were all starred in bad taste.
If I had known this would be taken so negatively, I wouldn't have done it to begin with
 
 
1 hour later…
4:36 AM
cbg
 
 
2 hours later…
6:32 AM
Guess who has 1 mill now... And no, it wasn't me who gave him a bounty
 
I just noticed
 
7:16 AM
please help in this line of code
jData = json.loads(myResponse.content)
raise TypeError(repr(o) + " is not JSON serializable")
 
What is the actual error you are getting?
 
calling POST API using python code
response = requests.post("http://35.176.187.30:8080/api/authenticate", data=json.dumps(parameters), headers=headers)
print(response.status_code)
if (response.ok):
    jdata = json.dumps(response.content)
same raise TypeError(repr(o) + " is not JSON serializable")
 
Cabbage
 
@JacobWood okay let me try
 
7:31 AM
cbg
 
7:48 AM
@JacobWood thanks alot, it works
 
cbg
how's life guys
 
8:51 AM
late night cabbage
or is it early morning?
either way I can't seem to fall asleep
 
cabbage
 
of course, staring at a bright computer screen isn't helping my brain know that it's time to go to bed...
 
My brain's favorite way to tell me that it's time to go to bed is a stream of letter L's and drool down my chin.
 
L's are the key I tend to press as I nod off
 
8:53 AM
I don't agree that this question is unclear. stackoverflow.com/questions/48258625/how-to-tilt-image-with-pil Sure, it's a bit too broad & contains no code. OTOH, if you don't know the right terminology it's not easy to know how to do this operation. I don't expect a newbie to know about affine transformations, and if you're not a native English speaker, you may not know that this is a shear transform. And so if you don't know to Google "affine" or "shear", you're sunk.
 
@PM2Ring It's not unclear, but really, not worth saving, right?
 
@piRSquared yah...that's not happening for me
 
Sure, I feel bad for the OP, but you can't take every OP's situation into consideration when deciding what questions are good for the site and what aren't
 
@piRSquared ObXKCD: xkcd.com/269
 
@PM2Ring I'm a horrible sleep troll
 
9:00 AM
@Code-Apprentice fyi, flux helped me fall asleep at more appropriate times.
 
@cᴏʟᴅsᴘᴇᴇᴅ I looked for other questions that show how to do affine transforms in PIL, but didn't find anything useful, apart from this: stackoverflow.com/questions/14177744/… which I think might be a bit too confusing for a newbie.
But I guess it's worth linking, just in case.
 
Fair enough, it's upto them from that point.
 
@ArneRecknagel I'll look into it
blindly following the "Install on Linux" instructions in the github README and puzzled why apt commands don't work...then I realize I'm on Arch Linux, not Ubuntu
 
what package manager does arch use? I remember a similar utility for yum called redshift, but it was more of a pain to set up.
 
Arch uses pacman
looks like redshift is available for installation without too much trouble
no idea how to use it, though
 
9:15 AM
it usually only needs your timezone, and maybe a 'lighting flavor', but the default one was ok. If everyhting goes right, you should get drowsy when the sun goes down
 
well, I found a "Nightlight" option in the settings control panel. Not sure if that is from redshift or if it is just built into gnome
@ArneRecknagel that presupposes an interface to make any settings. When I clicked on the app from the menu, nothing seems to happen.
haha, I have 8 instances of it running now
 
I remember I had to do the configuartion via command line, and the documenation was .. bad
It seems it hasn't gotten better
 
or maybe it just spawns multiple processes...
well, killing it didn't change the reddish tone of my screen back to normal...so it looks like GNOME just has this feature built in
 
all the better. just don't restart :p Setting it to survive init was a whole other headache
 
okay, I'm gonna try to go to sleep again. Hopefully my mind is read to wind down for real now.
the last time I restarted this machine was...I dunno when
this week, I think...and I accidentally powered it off
$uptime
02:24:38 up 7 days,  1:40,  1 user,  load average: 0.71, 0.96, 0.96
yup, exactly a week ago
 
9:26 AM
Nifty command, thanks
 
9:55 AM
@cᴏʟᴅsᴘᴇᴇᴅ Using sum on tuples isn't very efficient. How about:
def mirror(t):
    return tuple(mirror(u) for u in t[::-1]) if isinstance(t, tuple) else t
 
@PM2Ring Chris Rands suggested itertools as a faster alt to sum.
Which I thought was pretty good, so I added that in too
 
@cᴏʟᴅsᴘᴇᴇᴅ sum is a slow way to build collections. It's essentially the same as `result=(); for u in thing: for v in u: result += (u,)
That chain.from_iterable should be pretty efficient.
 
I am a little saddened by how the beauty of conciseness is marred by performance hindrances
 
10:16 AM
cbg y'all
 
@ReblochonMasque cbg
 
@ReblochonMasque Welcome to the rice fields
 
rice fields? @cᴏʟᴅsᴘᴇᴇᴅ ?
 
Nothing, it's a dead meme.
 
10:18 AM
okay :-)
 
Appreciate the cleanup, but you haven't taken out all the trash yet
 
I hope I did not interrupt Jacob making new friends... ;)
Pfew, thanks for the fresh air @AnttiHaapala
 
user image
7
 
catmouse
 
Thanks the stars for cute animals
 
11:00 AM
cabbage
 
12:32 PM
@cᴏʟᴅsᴘᴇᴇᴅ you avatar has changed!
 
No, it's gone
Anyway, rbrb
 
Rbrb then :S
 
@Code-Apprentice I use redshift and it works fine
redshift -l 47.50 19.04 -t 6500 3700
man redshift is mostly self-explanatory
you tell it where you are and what color temperature you want during day/night (it's binary)
I used xflux before that, that was a bit better but then it stopped working. And neither works with Wayland...which is probably used by arch by default
hmm, now I can see that the syntax for those command line arguments seems to be wrong :D
 
What do we do with non-questions like this? stackoverflow.com/questions/48263257/…
 
12:48 PM
unclear what you're asking, or custom
 
That is posted by a 1k user... Sigh
 
Maybe they can turn it into a self-answered question... but I don't really think there's much point in that, as I said in the update to my comment.
 
Hmm, my answer to this question would contain 105 lines of code... maybe I should close it as too broad instead...
 
Well, broadness isn't strictly determined by the length of the answer. If you think it's adequate, go ahead
 
I'll just make my answer 200 lines of text to compensate for the length of the code /s
 
1:00 PM
@PM2Ring gone
 
@AnttiHaapala Maybe they're turning it into a self-answered question...
@Rawing I tried to do something with a metaclass, but I got confused and gave up. :)
 
considering how the question now just reads "How to put a time delay in a Python/Java script.", I don't have high hopes for its future
 
Me neither
 
I know what you mean, it was pretty confusing to implement. And not just because descriptors and metaclasses are used everywhere.
 
I'd be interested to see what your code looks like. But I guess the OP wants something a little more compact than 105 lines. ;)
 
1:05 PM
OP schmOP
 
I mean, I could probably cut it down to ~95 lines if I throw out comments and pep-8 newlines...
@PM2Ring here's a gist for you while I write my answer
You set DependencyMeta as your metaclass and decorate the getter function with @cached_dependent_property
 
  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND
 8377 l0ser     20   0 28.621g 8.316g 222856 R 102.6 53.5 504:55.39 firefox
ummm
 
@Rawing That looks great. It's a lot nicer & more powerful than my feeble attempt. I didn't even think of subclassing property: I was creating a new variant of property from scratch.
 
1:21 PM
I only realized I could subclass property halfway through implementing my properties too :D
I'm not sure if I actually gained anything from doing that though. Implementing your own descriptor isn't too difficult, and might well be less confusing.
 
I got a seven line solution by abusing functools.lru_cache
 
I'm currently experiencing a very complicated feeling of shock, disbelief, curiosity, and disappointment in myself.
@vaultah Are you going to post an answer?
 
Yeah, I'm trying to break it
 
1:43 PM
@vaultah Wow!
 
Impressive solution. Shorter, better, and less error-prone than mine.
 
Thanks :)
 
Although Rawing's solution also handles non-property dependencies.
 
@PM2Ring So does vaultah's. He's using operator.attrgetter to access the dependencies' values; it doesn't matter if they're properties or not.
 
Oh, ok.
 
1:56 PM
Neat
 
I guess there's nothing wrong in principal with wanting to combine Python & assembler, but still, I'm not entirely happy with the concept. stackoverflow.com/questions/48264135/… I guess a simple way is to use assembler to create a library, then access it from Python via ctypes.
 
@vaultah That's insufferably cute.
 
2:19 PM
\o cbg
 
cbg
 
cbg o/
Style question:
return defaultdict(
    str, **{prefix+'_'+_TOOTH_ORDER[idx]: codes[idx] for idx in range(32)})
or rather this
ret = defaultdict(str)
for idx in range(32):
    ret[prefix+'_'+_TOOTH_ORDER[idx]] = codes[idx]
return ret
 
latter is more readable
Go with the first one if you don't think anyone will be reading or maintaining your code.
 
I was hoping there might be a better way to use the dict constructor. But since the maintainer would be me, the latter it is.
 
I agree with MooingRawr. OTOH, I rarely use defaultdict, I tend to use .setdefault with a plain dict
 
2:26 PM
d = {prefix+'_'+_TOOTH_ORDER[idx]: codes[idx] for idx in range(32)}
return defaultdict(str, d)
Third option
 
keys = (f'{prefix}_{order}' for order in _TOOTH_ORDER)
return defaultdict(str,zip(keys,codes))
 
First time I've ever seen a defaultdict used with more than the default argument... (actually had to double check you definitely could do that...)
 
@PM2Ring I guess it depends on what OP is using ret for. Does it need to be a default Dict or not, only they know :D
 
@MooingRawr Management: There must be no key errors in this functions. Arne: o7
 
As long as a default empty string makes sense and you're not accidentally masking that a key doesn't exist when it should... :)
 
2:32 PM
I think vaultah's version is the best. You get the speed of a dict comp, without making it harder to read by having it as an arg to defaultdict, and although it might be slower than your 1st version, the speed difference will be microscopic. And vaultah's version is definitely more readable.
 
I like Andras's version more, to be honest
 
@vaultah I am currently trying to understand it
 
I like AD's more personally, but only if we can use f-strings. (hopefully Py2 isn't supported)
 
Am I the only one that is pondering what "_TOOTH_ORDER" is all about? :p
 
f needs 3.6
 
2:35 PM
hmm that didn't come out as how I thought it would :\
 
@MooingRawr You were right though, it is the order of teeth in your mouth
 
I would only assume the program is something dentist related. <- think I wanted to say this without the x and y being mixed together.
 
And I am currenly using 3.7 =) So fstrings are no problem
 
@vaultah It's good, but I think it'll be slightly slower, due to the extra function call. OTOH, zip is pretty fast. One might even say that it zips along. :)
 
sometimes I want to say either 'have a nice day' or 'good bye', and I end up mixing those two together to create and incoherent mess.
 
2:38 PM
there's a middle gound where you use vaultah's dict comp that loops over a zip
 
@PM2Ring While speed could be an issue, it looks like we are in the scale of 32 range limit, so I don't think speed matters too much in this case, but it's still good to keep in mind if this program needs to be adapted for an animal that has a few thousand teeth.
 
2:50 PM
Only bad thing about Andras' solution is that PyCharm has a bug with with the defaultdict constructor.
 
I was just about to post this cryptic one-liner in the comments, but the OP deleted stackoverflow.com/questions/48265151/… [u*-4//1/-4 for u in seq]
@AndrasDeak I noticed in the transcript that you were looking for this
 
@PM2Ring indeed, thanks! SEO: don't post text as images . Don't post code as images
my SEO is not working :D Might be caching
 
This OP was happy to be informed that he didn't have to post code as a screenshot, he could post it as text. :) stackoverflow.com/questions/48265304/… :facepalm:
 
3:21 PM
cbg
what's the word birds
 
I would be really curious how many times I have started writing a post on SO that I ended up scrapping because pulling a MCVE together showed me what I was doing wrong
When I die and that isn't one of the stats I can check would make me very sad
 
Impressive it wasn't the fear of being criticized and downvoted that got you to scrap first. You're doing well, internet friend stranger.
 
That just makes an interesting stat #2
 
I'm newbie to Python. But I learn quickly. Can somebody give me personal guidance on first PyPy3.5 installation (Windows), and how to properly install modules? I have particular module to install. Is somebody have some time for me?
 
Even though it is for Python 3.6, the process is the same
the dropdown in the top left will let you change for a specific version
 
3:33 PM
What about personal guidance now or later today?
 
DSM
@green: do you really need pypy as upposed to cpython?
Morning cabbage for all.
 
@green That's not how the help system is set up here. Read the rules here: sopython.com/chatroom
Go through the steps yourself. It is the best way you are going to learn. Take your time with it.
If you get in to specific problems in those steps, you can ask.
 
cbg you two
 
yo
 
3:48 PM
Alright, rbrb guys, thanks for the help =)
 
3:58 PM
I'm a bit hesitant to commit to confidently using mimetypes.guess_type()
just because the method is called "guess"
:P
"sorry bruh....we did warn you....this is on you"
clearly Python....clearly.
 
00:00 - 16:0016:00 - 00:00

« first day (2648 days earlier)      last day (2283 days later) »