« first day (4280 days earlier)      last day (659 days later) » 
00:00 - 05:0005:00 - 00:00

5:24 AM
stackoverflow.com/questions/625083/… ugh, this is awful. It's clearly too broad (two questions that are only related in the vaguest of ways), and the self half of the material is already covered by stackoverflow.com/questions/2709821/…. But we don't have anything nearly as good/specific for the __init__ half.
(Also, the code example in the question is utterly nonsensical)
OP's account appears not to exist any more.
but I guess it's hard to talk about __init__ without talking about self, since that's the thing being inited. :/
 
5:44 AM
Maybe stackoverflow.com/questions/8609153 is better for __init__ specifically.
stackoverflow.com/… I suspect there is a lot of unrecognized duplication in here.
 
6:28 AM
@MisterMiyagi I already voted on stackoverflow.com/questions/72864733 as unfocused, but based on what seems to have been the sticking point, it's arguably a duplicate of stackoverflow.com/questions/3277503/…
 
 
1 hour later…
7:33 AM
@KarlKnechtel Meh. Unless the OP edits it into shape, there isn't anything lost in my book. No use keeping around broken signposts.
 
7:54 AM
hi everyone, i am sending a searlized string through ajax
how do i unsearlize it in python 😐
trying different method of unicode, decode, beautifulsoap
nothing working
 
depends on what serialized means in this context, you just need to apply the reverse operation to it. so the question actually boils down to whether you know exactly what type of operations are happening to the string in question.
if you don't, one option is to just take the string on the python side and print it's repr. get a sense of what you're dealing with.
 
this+is+a+test+string+!%40%23%24%25+hell
this is the string, and special char are there !@#$ they getting encoded
 
okay. now from the other side, can you console.log the string right before it's being sent via ajax, and see how that side looks
 
yes i can, just a sec
this is a test string !@#$% hello
or maybe my problem is jut to display that string decoded, anything would work
either decode and save it like that *this is a test string !@#$% hello* in DB then simply display it or save it like "this+is+a+test+string+!%40%23%24%25+hello" then display it in decoded way
found the solution,
urllib.parse.unquote_plus(about_txt)
Thanks so much @pa
@ParitoshSingh
 
8:17 AM
nicely done, great to hear
 
 
2 hours later…
10:45 AM
inputs:
messages = [
    {
        "message": "test message1",
        "tenant_name": "test1"
    },
    {
        "message": "test message2",
        "tenant_name": "test2"
    },
    {
        "message": "test message3",
        "tenant_name": "test2"
    },
    {
        "message": "test message4",
        "tenant_name": "test1"
    },
    {
        "message": "test message5",
        "tenant_name": "test1"
    }
]
y = ["test1", "test2"]
Required output:
g = {
    "test1": {
        "errors": [
            "test message1",
            "test message4",
            "test message5"
        ],
        "err_count": 3
    },
    "test2": {
        "errors": [
            "test message2",
            "test message3",
        ],
        "err_count": 2
    }
}
Challange is how to form that required output dictionary?
 
Didn't you ask this two weeks ago?
 
The answer hasn't changed since the last time you asked
 
Yes. This is answer I received.
messages_by_tenant = collections.defaultdict(list)
for message in messages:
    messages_by_tenant[message['tenant_name']].append(message['message'])
Output it produce is
defaultdict(<class 'list'>, {'test1': ['test message1', 'test message4', 'test message5'], 'test2': ['test message2', 'test message3']})
As you can see I need to do slight modifictaion in the expected output.
 
Yeah, I can see that
 
Tried something like this:
import collections

messages_by_tenant = collections.defaultdict(list)
for message in messages:
    messages_by_tenant[message['tenant_name']['errors']].append(message['message'])
Getting - TypeError: string indices must be integers for
messages_by_tenant[message['tenant_name']['errors']].append(message['message'])
 
10:59 AM
Programming challenge: Your input is ['foo', 'bar'], and the output should be {'errors': ['foo', 'bar'], 'err_count': 2}. How do you do it?
 
Giving a try! Give me some time!
 
11:32 AM
hey everyone, I seem to not understand why inside_print does not take "self" but inside_foo does, I understand how self works for the most part, but this just does not make sense to me
def foo(*args):
    print(args)

class Foo:
    inside_foo = foo
    inside_print = print

Foo().inside_foo()
Foo().inside_print()
 
I was trying to solve the original problem till now ! Couldn't solve it yet!
 
Foo().inside_print() why is this not printing the object?
 
Solution for the challnge -
z = ['foo', 'bar']
out = {'errors': ['foo', 'bar'], 'err_count': 2}

b = {"errors": z, "err_count": len(z)}
 
Good. Next part of the challenge: Your input is {'x': 1, 'y': 2}, and the output should be {'x': '1', 'y': '2'}
@Jake Strictly speaking, that's a bug. It should print the object. It doesn't because print is a builtin function, and those don't always behave like regular functions
 
I did try the same with itertools.accumulate and "self" was not passed there too, so the assumption / takeaway is builtins don't have self passed implicitly?
 
11:44 AM
Builtin functions don't have a __get__ method comparable to that of user defined functions.
 
It's an implementation detail. It might work differently in pypy or Jython or whatever. But in CPython, that's correct
And itertools.accumulate is actually a class
 
thanks MisterMiyagi and Aran-Fey, so builtin as in C functions / classes or anything in python library that is not user defined?
 
Answer to challange 2:
h = {'x': 1, 'y': 2}
h['x'] = str(h['x'])
h['y'] = str(h['y'])
print(h)
 
That doesn't count, you need to use a loop
 
Okay
 
11:49 AM
@Jake Stuff written in C
 
alright, thanks you two
 
h = {'x': 1, 'y': 2}
for key in h:
    h[key] = str(h[key])
print(h)
 
Ok, now you're ready for the final challenge: Input is {'foo': [], 'bar': ['hi']}, output is {'foo': {'errors': [], 'error_count': 0}, 'bar': {'errors': ['hi'], 'error_count': 1}}
 
Has anyone seen a list of iframe domains that are often whitelisted in text editors? E.g. codepen, youtube, spotify...?
 
Semantic nitpick: a typical text editor does not have web browsing capability. An IDE might, though.
I mention this not because I love Well Actuallying*, but because you may get better search results if you look for "IDE iframe whitelist" rather than "text editor iframe whitelist".

(*I do love it, but that is neither here nor there)
 
12:07 PM
I guess I'm considering draft.js, quill.js etc to be text editors
maybe WYSIWYG is the better word, but that always looked like a Norse spelling of Bigfoot
 
Maybe my personal definition of the term is too rigid... Am I out of touch? No, it's the children who are wrong
 
haha
Are there stats on the domains that are most commonly iframe'd?
 
hehe chat helped me rubber ducky, by just having an input field. Amazing how it works, it's as miraculous as placebo :D
 
I'll take credit for that, yes thank you
@duhaime Not that I'm aware of. Perhaps you could make one yourself, if you know of a few open source text editors, and can find where they keep their whitelists
I see that draft.js is open source. I don't see anything obviously whitelisty though.
Searching for "youtube", for example, just gives me parts of their website
 
I think specifying such a whitelist is generally an exercise left to the user
 
12:25 PM
I think I'm missing something.
 
like draft and quill and tiptap etc are libraries for building a rich text editor, but they don't give you like text-editor.min.js fully featured that you embed in your site; you use those libs to craft the UX you want
part of that is specifying whether you want to support iframes and if so from which domains, and we're looking to support a critical hitlist but haven't found such a list yet...
 
I thought the question was something like, "when a developer writes an extension or plugin for a text editor, if the extension is going to display content from the web, the developer needs to send a whitelist of urls to the editor ahead of time. Some editors save them some effort by having a global whitelist of urls known to be reputable, such as youtube. Where is this list?"
 
I'm a fan of "add domains to the list as users request them" but we're looking to streamline the process a bit
oh no, I don't believe such a list is specified in any lib; I'm looking for like the most commonly iframe'd domains in the web so we can pick from that list
 
Ok, reasonable. I don't know where to find that kind of data, unfortunately.
 
yea same; the search continues
 
 
2 hours later…
2:51 PM
@Aran-Fey Sorry for the late reply. Went out for some personal work. Here is the solution for final challange:
u = {'foo': [], 'bar': ['hi']}
# expected_output = {'foo': {'errors': [], 'error_count': 0}, 'bar': {'errors': ['hi'], 'error_count': 1}}

a = collections.defaultdict(dict)
for key in u:
    a[key]["errors"] = []
    a[key]["error_count"] = 0

print(a)
 
FWIW, if you are going to assign to each key only once you don't need a default dict.
You can create the entire nested dict at once and assign it to a[key].
 
3:09 PM
I've been stuck on this for hours now and there's something I'm not understanding. I need to create multiple heatmaps and I want the x and y ranges to be the same (even if there's no data in the cells). It will happily accept np.nan and just leave cells empty. However, when I try to set the axis ranges, somehow it gets scrunched up and I don't know why
import numpy as np; np.random.seed(0)
import seaborn as sns; sns.set_theme()
import matplotlib.pyplot as plt

uniform_data = np.random.rand(10, 12)
fig, ax = plt.subplots(1, 1, figsize =(8, 8))

sns.heatmap(uniform_data)
# ax.set_ylim((-15, 15))
# ax.set_ylim(-15, 15)
# plt.ylim((-15, 15))
plt.show()
I've also tried it as in their actual guide which suggests ax = sns.heatmap(uniform_data) and not use fig, ax = plt.subplots(1, 1, figsize =(8, 8)) but it has been the same for everything I've tried :(
 
I believe in you
 
I, frankly, don't at this point :'(
 
@MisterMiyagi ,@Aran-Fey This one?
u = {'foo': [], 'bar': ['hi']}
# expected_output = {'foo': {'errors': [], 'error_count': 0}, 'bar': {'errors': ['hi'], 'error_count': 1}}
a = collections.defaultdict(dict)
for key in u:
    a[key]["errors"] = list(u[key])
    a[key]["error_count"] = len(a[key]["errors"])

print(a)
 
I wonder if I can just put some fake data in at the extremes
 
I believe you will either succeed, or perhaps fail in a stylish and dignified way
Like an angel falling from heaven, a brilliant streak across the starry night
 
3:28 PM
@owgitt Just replace a with a regular dict, i.e. a = {}.
You could even run this as a single dict comprehension.
a = {key: {"errors": errors, "error_count": len(errors)} for key, errors in u.items()}
 
Fake data at the extremes wins. Just awful. Nothing should be that difficult to plot :(
 
Unironically an injustice
 
Wait, no it doesn't :O. Now it has a nonlinear scale on the axes and just jumps from where ever it likes to the extreme value in a single tick
I officially give up. I'll just have to cope with trying to compare lots of heatmaps that are all on their own weird scale depending on whatever data is available for their category
 
3:43 PM
If you put a sparse speckling of data at the extremes and that didn't work, try putting some hefty & hot fake data instead. Maybe the heatmapper is willing to snip out cold areas, but not hot areas
Also try sns.heatmap(uniform_data, scrunch=False)
 
Point is, I don't think I should be doing any of this. I don't see what's unreasonable about being able to specify a set, linear, axis range. It's only just after I tried my fake data that I realised I was looking at a plot with a non-linear axis in the first place
 
I also think you should be able to specify a set linear axis range. And furthermore I think you shouldn't have to specify "linear" at all. If someone wants a nonlinear map, make them specify it.
 
4:01 PM
Thankfully it's seemingly only the last tick where it truncates the range to get to the outlier but it still gives a skewed view of just how much of an outlier the points on the perimeter of the plot are
In happier news today, I found out about SDKMAN which neatly gets around a lot of sudo restrictions I have in workspaces. We're not to be trusted with such power
 
 
1 hour later…
5:37 PM
And here we have the problem with seaborn. Why have they packed so much logic in? "If True, plot the column names of the dataframe. If False, don’t plot the column names. If list-like, plot these alternate labels as the xticklabels. If an integer, use the column names but plot only every n label. If “auto”, try to densely plot non-overlapping labels."
Setting it as not "auto" still gives auto behaviour because you're taking a pivot table and nowhere does it tell me that I need to auto-pad the dataframe with missing intervals to make it sparse
So in the end, the tick length gets misaligned with the index values :/
If I get chance I'll put a PR in for that and try disentangle that parameter and then reindex the pivot table so that at least it will lose the "auto" behaviour if you specify an integer tick interval
"# Get good names for the rows and columns" LOL
 
@roganjosh That just about sums up my experience with just about any one-size-fits-all plotting framework ever. D:
Is seaborn generally like this or is it the first real gotcha you had with it?
 
I rarely ever try to do something with plots other than eyeballing tbh, so normally it's just some crude matplotlib plot spat out and I hand the code off to others to get it pretty for reports etc.
A big part of the problem here, which is what wasted most of my time, was assuming it was my misunderstanding of matplotlib because I don't have a good mental image of how that library actually works. I should have just jumped to the seaborn source and I'd have spotted that straight away
 
6:01 PM
"it's just some crude matplotlib plot spat out and I hand the code off to others" sounds pretty awful behaviour, actually. I mean to say that normally I'm just handing off an algo for others to play with and I only need to check it does what I think it does :P This one I need to get the plots for a customer report directly
 
I've had to deal with pretty diverse personal plotting preferences, so just handing off a crude setup sounds like a decent thing to do TBH.
Sure doesn't help to build the experience for doing some "real" plotting, sadly. 😅
 
Yeah, not at all. The stuff I plot isn't even things that the other people I pass off to will be plotting, either. I'm just looking for algorithm correctness in the solvers I make; plt.plot(x_vals, y_vals); plt.show() usually suffices. I have a renewed appreciation for those on the front line that make some pretty spectacular reports.
 
6:52 PM
They're all in the graphic design group chat, betting on whether you'll hand this project off to one of them
"Based on the profanity coming from his office, he's trying to do an axis aligned heatmap series. Little does he know that this is the #1 newbie pitfall in all of Seaborn"
 
"On the correlation of WTFs per minute to plotting primitives and piracy"
Come to think of it, they probably have a plot for that.
 
No they don't. I'm resolved to believing that good plotting is impossible.
They're just very good at colouring in between the lines
 
Good is unattainable, all we can do is be less bad than the day before
 
import picasso as plt
 
Let us at least fail in an elegant and stylish way
 
7:10 PM
Apparently picasso is taken. I might just make hirst and, my god, your scatter plots will be perfect
I'll ignore the skulls and dissected animals. They can be extensions; I'll make a nice interface though. I just wanna focus on spots.
 
Yam. Who in the world thinks of vangogh for geometry calculations?
All the good names are taken on PyPI... :(
 
Can't remember if I've asked you, but do you have something on PyPI?
@MisterMiyagi you, at least? :D
 
What is that?
 
What is what?
Hello btw :)
 
7:26 PM
oh Hi
this chat
what is it for?
 
Ok, then I definitely wouldn't have guessed that "that" referred to this room. It's a place where you can discuss python things a bit more informally than the main site, which should be straight Q/A. We have room rules that might explain a bit more
 
Sorry..
 
No need to be sorry :)
 
@roganjosh what you have on PyPi?
 
I don't have anything on PyPI
Much to my regret
 
7:33 PM
@roganjosh Yeah, a few packages. Mostly stuff of our science infrastructure tooling that we make available to the community, plus some utility libraries that hopefully someone out there can make use of as well.
 
@roganjosh no worries Python will die eventually...
 
Well that escalated quickly
 
Xd
I have one but i dont think anyone would use it really...
 
I do wanna push for a vehicle routing library. This is a fantastic library that the guy actively maintains/develops but it's general-purpose and I want to strip some cruft. Plus I found non-contiguous matrices yesterday and it's hardened my resolve
 
Pick a punny name and go for it!
 
7:40 PM
No idea what you said there but goodluck bruh
 
Billions/trillions of lookups going through that :'( But we've failed to get it integrated fully through the API we've slapped on it, so I still have major work outstanding that I need to feedback first before I start complaining about nested Vecs
@MisterMiyagi I already have beatroute internally. Still my favourite name. That's the name of my python interface to a whole raft of backend solvers in any language
Not sure how it holds up if you're not a native speaker, but it's pronounced "beetroot" - the vegetable - but it's "beat (your) route" in meaning. It's great for confusing new people to the company, where I can say "I bet we could get beatroute to solve that, but we'd just need to tune a few parameters" and watch their confused expressions for about 30 secs before I explain
 
Apparently it isn't
 
I mean if you make that joke to newbies, it's not. But if you say "my library called beatroute" it is. The pun I mean.
 
It comes up in company docs, even now, as beetroot from people with us for over a year
So, there are still plenty of people utterly confused about this thing that our company sells
 
7:46 PM
Well, that's the best marketing you can get.
Just print a few ask me about beatroute badges.
 
Just write another library called "Sal addressing" and you get to make an entire "why did the beatroute blush?" joke.
 
Challenge accepted
 
exact name optional, functionality left as an exercise to the reader :P
 
We might soon be supporting mapping in India so I might be able to get it into the route plotting wrapper around leaflet/folium
 
8:19 PM
stackoverflow.com/questions/510348/how-do-i-make-a-time-delay am I alone in thinking this is closed the wrong way around?
 
why this question is not a duplicate one?
 
I think it's a better version of the question, than what it was closed as a duplicate of.
so that it should go the other way.
I got curious and decided to look at top-voted, closed Python questions.
 
hmm
@KarlKnechtel yeah, so I agree
Would it be a paradigm shift not to mark a question as a duplicate just because a question of the same content already exists? Reason: the previous question was not comprehensive enough.
 
@Marco yes, it would, and no, we don't want that.
 
Wow
 
8:28 PM
"question of the same content already exists" is literally and exactly what duplicates are for.
 
I understand your view even though I don't agree, I have the same view as Karl has
 
@Marco I'm not sure I'm clear. I propose to close the other question instead, as a duplicate of this one. instead of what we have now
 
Yes, I understood exactly this
 
ah ok
 
the other question is (logically) older than the one marked as a duplicate
that's why Andras said that what happened is correct
this fact is enough, following the vision of Andras
Of course, the question has the "same content" too. But that's subjective
 
8:35 PM
@Marco You seem to not understand after all.
 
of course I understood
 
everything is crystal clear, you think it is correct to leave that question as a duplicate, right?
@KarlKnechtel can you do it?
 
9:25 PM
question age has nothing to do with it. Duplicate links are supposed to be directed towards the best version of the question, upon sober second thought.
however, for two very popular questions like this, I will not impose my will, without community consensus.
 
fair enough
@KarlKnechtel I have the same vision
@KarlKnechtel unfortunately isn't this the default community action?
(act over older "same content question" (but not the best one))
 
9:43 PM
well, normally it's easier to use the older question as canonical. Firstly, it had a chance to establish itself, in the time between the two questions.
and some people are not in agreement about the policy, yes.
 
I see
 
10:33 PM
I've asked this before to no response but maybe I'll catch a different group this time. Is anyone familiar with psychopy (psychopy.org)? I have a question related to how clocks work with screen flips, and their dedicated forum has not been the most helpful.
 
11:04 PM
wow. I didn't know StackOverflow had chat rooms
 
00:00 - 05:0005:00 - 00:00

« first day (4280 days earlier)      last day (659 days later) »