« first day (4022 days earlier)      last day (909 days later) » 

2:23 AM
Hello Guys!
I answered the following question based on the question where the questioning was looking for the number:
-1
A: python regex pattern to get stracer output

AvraThanks for the question. You mentioned you need the numbers, so can you please try the following: If you want just to get 2 numbers: pattern = re.compile(r"\d{2}") If you want to get all numbers: pattern = re.compile(r"\d?")

 
 
2 hours later…
user16319883
4:10 AM
How to create h5 after every iteration in for loop, can anyone explain with example?
 
4:28 AM
I wonder just how many hours, accounts, and fake upvotes you've invested into that question by now, instead of sitting down and reading a programming tutorial
 
@Aran-Fey. :(
For regexpressions, I am trying to write a regexp that stops at first match of 2 digits each. Example:

import re
pattern = re.compile(r"\d{2}")
string = "write(1, "\33(B\33[0;1m\33[90m3.8\33[4;52H", 24) = 24\"
above 33 is the first, so how to stop at it please?
Hopefully this is enugh context now ?
 
first_match = pattern.search(string)?
 
 
2 hours later…
6:42 AM
Hey guys maybe anybody knows, how to prevent input from clearing after pressing on the . (dot key)? I have a number type of input.
 
if youre talking about python input, that doesnt clear on pressing a . (dot key).
 
6:59 AM
How do I plot a python function in mpl?
I know this is possible: y = x**2
But I want to do this:
def y(x):
    return x**2
 
@ChristophBühler scriptverse.academy/tutorials/… came up as first search. i think the only trick you're probably missing is this: plotting is being done here by using arrays. So, all you need is an array of multiple x values, and the corresponding results for y(x) for them.
 
@ParitoshSingh That example is using y = x**3 as well. Probably there is some way of assigning all the y-values to an array in numpy. Could not find a standard way yet.
 
just calculate them yourself, you're probably overthinking this.
results = [y(x) for x in your_array_of_x_vals]
# and if need be, convert `results` to numpy array.
similar thing whether you use map, pd.Series.map, or whatnot, you simply are just plotting a bunch of x-y pairs. matplotlib doesn't understand the underlying functions, it's just plotting points.
 
Ah, got it. Thanks! :)
 
7:32 AM
@ParitoshSingh if you're using arrays you should convert x, then y = x**2
 
@AndrasDeak aye. im going on the assumption that the actual function is non trivial to vectorize
 
 
5 hours later…
12:29 PM
morning cabbages, folks
 
cbg
 
@Hakaishin I don't quite remember the outcome of this conversation from the other day, but are your course notes online by any chance?
 
no not really. I'm not sure I can put them online. Also the basic course is in german so I'm not sure of how much use that would be :P
 
I can share the intermediate when it's done, but right now it's not shareworthy
nice bio, also your career 2.0 link is broken
 
12:42 PM
ooh! thanks for the headsup. Will check it out right now
might have to take a look at this from home tonight. I think Careers 2.0 changed something from when I last used it a billion years ago
 
Vague problem statement: I want to compare xml files with similar schemas. Vague resource request: any good tools that do that?
 
vague answer: how about a web browser? If it's not web content, then you're likely looking for a tree-comparison algorithm with a custom, fuzzy comparator for node-level similarity
 
autoformatter plus vimdiff :P
 
Example use case: the top level element of both documents is a WidgetCollection, which contains any number of Widget elements. I want to look at the 23rd Widget in both documents, and compare their color tags.
 
run it through a linter and use a diff?
 
12:54 PM
Is this like a one-time thing you need to do or something you want to program in python?
 
Having one browser tab open for each document is not great for this use case, since I'd have to manually count Widget tags until I found the 23rd one, then search through the Widget's children for a color tag. Then I'd have to do it again for the other document. And I can't just say "document A's 23rd widget's color is on line 100, so I'll just jump there in the other document", because widgets take up a variable number of lines
 
@Kevin The Python stdlib has modules for parsing XML, but they smell strongly of Java. The docs are almost unreadable if you don't know Java, and the standard Java library methods for handling XML. :(
I managed to glean some info from them a few years ago, and even wrote an answer or two, but it was pretty painful, and I've forgotten most of what I learned, although I guess it wouldn't take me too long to pick up those rudiments again.
XML isn't too bad if the document is nicely structured. Unfortunately, XML allows some annoying things, and people have been known to create stupid structures with it.
 
I'm moderately deft with the xml-walking stdlib. It would be a minute's work to navigate to the 23rd widget and search for the color node. But I'm a bit dissatisfied with the presentation of the output.
 
Oh, ok. My code's probably not much use then. My output presentation was pretty basic, IIRC.
 
Suppose that the color element is more complicated than an RGB trupple. Maybe it indicates what kind of paint the widget is coated with, and where I can buy it, etc. Then just doing print(widgets[23].findTag("color")) will produce a lot of output.
A UI would be nice in this case because it could show a nice collapsed "<Color>...</Color>" tag, and I could click on it to incrementally reveal more detail
 
1:05 PM
have you just described a web browser's Inspect Element feature?
 
Yeah, all I got is "parse simple XML & convert to JSON" stackoverflow.com/a/51669003/4014959
 
@inspectorG4dget Yeah, it's pretty similar. But I would want two elements be be inspected in side-by-side windows. Expanding the color tag in document A should also expand the color tag in document B.
I'm undecided about what should happen if A has a color tag and B doesn't. Perhaps a segfault.
 
BTW, we did the "60° from cube diagonals" thing a few weeks ago: chat.stackoverflow.com/transcript/message/53096735#53096735
 
I think what you want is something like git-diff that does a tree-diff and accordion-open's the differing node with from-root context... for two side-by-side documents. It's a sufficiently straightforward task, but I think it needs a custom solution, which I unfortunately don't have the time to write right now
 
@inspectorG4dget 90% of business problems :D
 
1:12 PM
it's actually a pretty fun hackathon project at a company that would benefit from this
 
It's nice of you to even consider writing anything :-) the only outcomes I expect from this conversation are "you want popular and featureful tool TwoXmlDocumentsComparator, here is the link to the download page", or "dang those are some crazy requirements, good luck tho"
 
This looks potentially useful: display an XML in a Tkinter Treeview. stackoverflow.com/q/30759516/4014959
 
I was just thinking about TreeView :-)
 
It just does a single XML, not the comparison. But I guess it could be adapted...
 
It doesn't have a collapse/expand feature, but this website with the "inline diff" option enabled might be workable
 
1:15 PM
TreeView certainly looks capable of producing the UI I'm imagining. Whether I can hook my logic into the appropriate areas, is less of a certainty. I must investigate further.
 
duckduckgo gave me a7soft.com/examxml.html, excellent 2000s website vibes
30-day free hopefully-not-malware trial
 
If I can register callbacks as fine-grained as "when a color node is hovered over, give it a red tint" then I'm in great shape
 
I remember using WinMerge for side-by-side document comparison (kinda like git-diff). Also, MSWord has a similar feature
 
Diffs are "easy". XML-aware diffs are not that easy.
 
I would argue that xml diffs are easier than plain text diffs :P
 
1:19 PM
true. Sorry, I was going off the assumption of step 0: lint both files
 
@Aran-Fey fair enough. What I meant is that it's a lot more specific so there will be fewer tools
 
I'm willing to lint beforehand, although I worry that a diff tool could still get confused
For example. Suppose document A is <X><Y z=1/><Y z=2/><Y z=3></X>, and document B is <X><Y z=2/><Y z=3/><Y z=4></X>. A clueless diff tool might say that the documents are the same at <Y z=2/><Y z=3/>. But in fact all three of the Y tags should be considered different.
 
I'm decently sure that git has some knowledge of common contexts' for its diff. For example it will display the class header if you make changes to methods.
 
Clueless diff tool output:

<X>             |<X>             | same
    <Y z=1/>    |                | different
    <Y z=2/>    |    <Y z=2/>    | same
    <Y z=3/>    |    <Y z=3/>    | same
                |    <Y z=4/>    | different
</X>            |</X>            | same

Desired output:

<X>             |<X>             | same
    <Y z=1/>    |    <Y z=2/>    | different
    <Y z=2/>    |    <Y z=3/>    | different
    <Y z=3/>    |    <Y z=4/>    | different
</X>            |</X>            | same
"Clueless" is an unkind term because it's probably easier to write a diff tool that doesn't search for ways to insert blank lines in order to minimize difference
 
Surely, a sane XML parser knows to collapse whitespace (unless it's inside a string).
 
1:32 PM
True. But there may be contexts where a good diff does retain some whitespace... I'm way out in the Fog of Requirements so I can't give a beautiful example. But suffice to say that corner cases lurk around every corner
 
XML does have that annoying thing that allows you to have stuff after a tag
 
I'll just turn it into an <AnnoyingStuffAfterTag> element during the linting stage :-)
I think I've solidified my requirements enough that I could put together a v0.1 prototype... Thanks for the feedback, gang
 
I wonder what a group of rubber ducks is called
 
a rubber badling?
 
> A group of ducks can be called a raft of ducks, a team of ducks, or a paddling of ducks.
I think "rubber raft" would be my favorite out of those
 
1:42 PM
I should also set aside some time to play with ExamXML. The vibe I get from the UI is "I have received feedback from Marketing regarding the interface, and have elected to ignore it"
When the devs have supreme executive power, that's when you see some interesting features
Possible drawback: devs with supreme executive power might put 300 hours into writing the world's most cryptographically secure 30 day trial timer, just because it's interesting. I probably won't be able to just open settings.ini and change deadline=11/20/2021 to deadline=1/1/2099
 
hehe
 
2:40 PM
Hmm, I don't think I can embed arbitrary widgets inside a TreeView, which makes it unsuitable for my dumbest and least important feature, heretofore unmentioned
Ah, a less dumb way presents itself. Rubber duck session #2: success
 
 
2 hours later…
4:35 PM
Can you share what that dumbest of features is?
 
5:21 PM
I wanted to put an RGB color picker inside the view, so the user could change the value of a color tag. Instead, I'll put the picker in a panel to the side of the view, and control its visibility based on whether a color tag is selected
 
5:37 PM
I see
 
6:06 PM
Is there any good book to improve python knowledge for machine learning?
 
I think O'Reily might have something
 
Thanks @inspectorG4dget
 
anyone deploy or use self-hosted wikis at work? I'm looking for a recommendation. JS.wiki seems to be popular choice. Would love your inputs. Specifically looking for local auth (third-party/oauth is a bonus)
 
6:50 PM
use a markdown in your repo
 
Create a file named important_information.txt on the network drive and give everyone edit access to it
Name it important_information.dat if you want to block people who only know how to use Microsoft Word
 
7:20 PM
Well well, If it isn't my old nemesis... Lack of magically-DWIM scrollbars and stretchy widgets
 
You made a non-stretchy widget in tkinter? Please tell me you didn't use .place()?
 
Nah, pack. Then I gave up and used grid.
 
Huh. So the treeview just refuses to use all the space you give it? That's weird
 
Then I fiddled with the sticky parameter and rowconfigure method, etc etc, and I have finally achieved a treeview that resizes when the window resizes
I'm pretty sure all widgets work this way, not just Treeview
 
...you're right. Has tkinter always worked this way? Looks like I've finally gone senile
 
7:34 PM
You can still lead a rich and full life
Normally I leave everything un-stretchy and size all of my widgets so that they comfortably fit all their contents. But the Treeview widget has no width parameter, and I need to know what letter comes after "Liechtenstei",
 
What is it with GUI toolkits picking the weirdest possible defaults? You give a widget all that space and it just doesn't use it, because... why? And Gtk took it a step further and made newly created widgets invisible
 
Wrappers that run on top of TCL can just shrug and say "ask the TCL devs". Standalone frameworks have fewer excuses.
 
@Kevin Why didn't you say so? It's "n".
 
Phew, you saved me
 
Any of you write Ruby too?
 
7:47 PM
Ah, the quirky cousin. No.
My wife had a RoR project for an undergrad course 10 years ago. Does that count? :P
 
haha, yes, my count of Rails 1 developers has incremented by one
 
Back in the day I read quite a bit of Why's Poignant Guide to Ruby, mostly because I liked the funny pictures
 
"If necessary, fashion a makeshift hip holster for Why’s (Poignant) Guide to Ruby, so you can always have this book’s tender companionship." ❤️
 
If I can replicate 10% of this man's vibe, I will be unstoppable
Chapter 2, entitled "Kon’nichi wa, Ruby", reminds me of a fact I learned recently. "Kon(o)", "nichi", and "wa" translate respectively to "this", "day", and "the sentence clauses and sentences following this one will have a subject or topic related to the preceding words". In XML terms, it translates to <today>.
 
That's sick. Is there an end tag? The ra in sayonara?
 
8:04 PM
"oyasumi" is often used as an equivalent of "goodnight", but its literal meaning is more like "O listener, rest / break / take a day off". Perhaps "take a day off" could be interpreted to mean "pop the top element of the day queue"
Let's see sayonara's etymology... "Shortening of earlier 左様ならば (sayō naraba), itself a compound of 左様 (sayō, “like that, that way”) +‎ ならば (naraba, “if”, now somewhat archaic, often replaced by なら (nara)).[1] Literally “if that's the way it is”.
Yikes, an if with no following block? That's even worse than a missing end tag
There is a certain romance to parting with what is essentially a promise to meet again and continue where you left off
 
Where was I? Oh yes, SyntaxError.
 
Oya oya, Kevin-kun has been studying nihongo again
 
I'm jouzu as heck bro
 
nani
 
The more causal "mata ne" ("again ok") maps rather directly to continue
If that nani is an authentic request for more information, "jouzu" means "good at", but it has garnered a reputation among foreigners as a patronizing compliment given to non-native speakers that can say anything more complicated than "hello"
 
8:16 PM
naruhodo
 
nani is great because it accurately represents my attitude when I see people talking in weeb Japanese
 
Perhaps the compliment giver is really truly impressed that you know how to ask where the bathroom is, but you can only jump over a low bar so many times
 
8:43 PM
DenverCoder9 asks, "how do I make sure the full contents of my Treeview are visible?". Answer: switch to wxPython. stackoverflow.com/questions/49039772/…
There are answers elsewhere on the site that are variations upon "calculate the necessary width using the font object's what_width_would_this_text_be_if_I_rendered_it method", but I'm guessing you have to add some fudge factor for padding etc
All of the prooves of concept I've seen are for the rectangular grid style of treeview, not the tree style. This worries me.
If I can't programatically fetch the width-in-pixels of the indent used for child items, then I'm up to my neck in fudge
 
@Kevin hey, at least there's an answer
 
True. I'm glad he made it out alive.
If I go a level or two up the XY problem hierarchy, I can probably find less frustrating ways to display my data. But I'll beat the dead horse for a little longer, as is my way.
 
this is the way
 
 
3 hours later…
11:26 PM
So I dont undertand why the method overloading is not working here:

img: PIL.Image = Image.open("PATH")

drawShapes(img) #calls numpy method


@overload
def drawShapes(pil_image: PIL.Image):
    print("not called")
    drawShapes(numpy.array(pil_image))


def drawShapes(img: numpy.array):
	#calc code here
    pass

The type hint at both variable and parameter match only at the first method, so why it calls the other one, resulting into errors since the passed image is still as PIL object?
 
11:41 PM
@McMidas where did you import overload from?
Therein lies your answer
What you're looking for is docs.python.org/3/library/… but you should just make your one function handle different inputs (potentially with different private backends)
Making type hints affect runtime is a sin
 
imported from typing. do you mean to check the instanceof(img) in an if-else statement and re-assign it to numpy array?
inside the single drawshapes function
img: PIL.Image = Image.open("PATH")

drawShapes(img)

def drawShapes(img):
	if type(img) == "PIL.Image"
		img = numpy.array(pil_image)

	#calc code here
    pass
 

« first day (4022 days earlier)      last day (909 days later) »