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

00:04
lmao... no everyone is free of charge... you didn't read my :p properly
just remember, we all have jobs to do or other things to worry about than your specific problem
you mentioned 3 options... did you try them out for instance?
I retagged this from python-3.x (only); please help me hammer it stackoverflow.com/questions/55847201 (SOCVR doesn't care about questions without other recent activity)
@OneRaynyDay I don't understand what you'd need this for. What functions would you have the metaclass create?
I totally understand @ jobs and other obligations :) I don't expect anyone to e.g. make a parser and implement the 3 options and get back to me on what is the optimal approach. Just wanted to know if anyone has run into this and can save me significant regret by sharing their experience

regarding the 3 options, I worked on compilers at work and we don't mainly use visitors to, e.g. transform 1 AST to another. I've taken some compiler classes (a long time ago) where I wrote the visitor by hand and it was pretty painful. I also tried 1) already and wasn't too happy w/ the lack of ide support
@Aran-Fey if you have nodes X,Y,Z, you can have a metaclass A that they all inherit from where you can override __new__ and modify the classdict to include extra fns, or just setattr() the created class with this fn
@KarlKnechtel done
these would be the def visit(visitor) functions required from a visitor
and then you can also do the same thing on the visitor class with some metaclass B that keeps track of all nodes X,Y,Z and setattr on the visitor to generate visitX(), visitY(), visitZ()
00:15
sounds like you'e sounded out the idea... why not show some code so others, if they wish, can critique that?
anyway - bed time... rbrb
What would those functions do, though? Would visitX, visitY and visitZ just do pass?
they would initially do pass as it's meant to be an interface that others can specify behavior for
I'm actually not sure if this is how python's libast works, since they also have visitX for every node
one sec, checking if it's codegened
looks like it is, but it also comes w/ its own custom grammar language just like ANTLR
here's the library as-of right now: github.com/OneRaynyDay/treeno without a visitor
here's a long shpiel on why this library should exist: github.com/trinodb/trino/discussions/10410
00:47
stackoverflow.com/questions/67323995/… the title is such a strange way to describe the problem.
(I am in the process of cleaning up and hammering/re-hammering a lot of stuff)
@JonClements one more, please? stackoverflow.com/questions/35372657
stackoverflow.com/questions/65791230 good lord, someone actually attempted this interoperation once
01:05
@KarlKnechtel umm... if you're on a "mission" as it were... put together and share something like a gsheet doc
I can't guarantee I have time but if you include the post link, a destination link, and a reason why etc... I'll get around to it eventually
01:21
I think I'm most of the way through honestly x.x
most of what I'm doing does require manual review, is the thing
01:33
@JonClements I'm sorry, I got confused with that code in Ruby (I don't know anything about Ruby). For some reason I thought that 'f' was a variable. Interesting to know that Ruby allows you to insert expressions into a function without using a variable.
@Marco nah... if it "runs off the end" - it does the "last expression" kinda thing as return instead of "None"
f there is a function
got it, interesting anyway
thanks
jon@minerva:~/development/testing$ cat test.rb
def cabbage number
	if number > 10 then
		return 'more than 10'
	end
	2 + 2
end

puts cabbage 5
puts cabbage 11
puts cabbage 9
jon@minerva:~/development/testing$ ruby test.rb
4
more than 10
4
uhh
strange
01:41
after some time thinking I am able now to understand the behavior of the '2 + 2' print
if there's no explicit return - it's the last evaluated statement
def cabbage(number):
    if number > 10:
        return 'more than 10'
    return 2 + 2
it's basically that
jon@minerva:~/development/testing$ cat test.rb
def cabbage number
	if number > 10 then
		return 'more than 10'
	end
	#2 + 2
end

puts cabbage 5
puts cabbage 11
puts cabbage 9
jon@minerva:~/development/testing$ ruby test.rb

more than 10
else it just falls off the end as Python does and returns nil
01:58
if I try searching for site:stackoverflow.com python join strings in either DDG or Google (incognito), I can't easily find the canonical (stackoverflow.com/questions/12453580/…).
@Karl do we have anything on sopython.com/canon ?
doesn't look like it. closest I can find is sopython.com/canon/32/using-a-list-comprehension-with-str-join which is nowhere near as significant and also not high quality
Okay, I'm done for now. There were only three questions outstanding where I can't hammer them due to the tag thing.
however, more interesting is a batch retagging job I'd like to request.
if you login..,. you should be able to edit sopython.com/wiki/Karl%27s_ideas
consider it a scratch pad or something
for links to put in the canon?
yup
I'd need some consensus from the other RO's to enable access to edit canonicals - but if you start there maybe?
it supports markdown
02:13
mm
honestly that's not my highest priority thing at the moment; I'm more interested in figuring out whether we have canonicals, deciding what should be canonical, and creating what's missing

publicizing the results is kinda secondary
oh scratch that... you're already an editor
I'll delete that post
oh yeah I straight up have a 'create common question' button
I'll have to remember that
so create a wiki thingy - put yours ideas into it
so we don't loose track of your ideas
then we can work on the CQ stuff later or something?
02:54
My ideas are already being tracked on my GitHub.
er, the CQ stuff is.
I'm not really sure what other ideas I have a lot of :)
03:05
@JonClements right
@JonClements yeah
03:36
https://stackoverflow.com/questions/24839305
https://stackoverflow.com/questions/72854452
Another common pattern of misunderstanding: expecting a function call to work like a goto
(you can probably find a lot more examples by searching for questions about that one particular exercise from LPTHW)
04:07
(I'm aware, but people who try to design "adventure games" commonly invent the same problem)
(and in fact Zed actually tries to point people at a solution, it's just that the overall pedagogy is so bad)
 
1 hour later…
05:24
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. :/
05:44
Maybe stackoverflow.com/questions/8609153 is better for __init__ specifically.
stackoverflow.com/… I suspect there is a lot of unrecognized duplication in here.
06:28
@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…
07:33
@KarlKnechtel Meh. Unless the OP edits it into shape, there isn't anything lost in my book. No use keeping around broken signposts.
07:54
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
08:17
nicely done, great to hear
 
2 hours later…
10:45
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
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
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
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
@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
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
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…
14:51
@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].
15:09
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
15:28
@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
15:43
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.
16:01
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…
17:37
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
18:01
"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.
18:52
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
19:10
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 :)
19:26
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
19:33
@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!
19:40
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
19:46
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
20:19
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
20:28
"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
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
20:35
@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?
21:25
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))
21:43
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
22:33
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.
23:04
wow. I didn't know StackOverflow had chat rooms

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