Oh, here's something worse: stackoverflow.com/questions/1798465 it was once used as a dupe target (which I've since rerouted) for a question that actually did match the title :/
hey all, has anyone used requests-cache.readthedocs.io/en/stable in production code? I want to cache my requests and this seems like a drop in replacement for requests, if you have not used this, how do you cache requests in your projects?
@AntoinePinsard did not know about the timetuple method, thanks
Let me rephrase/correct that: importlib.import_module('.', 'tools') is functionally equivalent to import tools, but it should be a relative import, it just isn't because the project structure is a mess
From my experience, a good chunk of frustration about Python's imports and packaging is people complaining that it hurts after shooting their own foot.
@Govind75 does the class work otherwise? I assume it's nontrivial to combine pyplot's event loop with that of tkinter, but I have no experience in this area.
Essentially I have a run routine which calls a live_plot routine which reads a file every 10 seconds using the .after method - I then want to plot this data, but whenever I attempt to plot it, the GUI plots the first iteration and then freezes.
@AndrasDeak--СлаваУкраїні Yes the class works otherwise I can receive the data and print it out perfectly on each .after call.
It's just the live-plotting which I am struggling with
In my experience it's pretty normal to call after inside the very method that you previously registered using after. I've never had recursion depth problems even when I'm after-ing 60 times a second.
On a conceptual level it should be fine, since each instance(?) of the method will have the opportunity to finish executing before the window's event processing loop continues
"combine pyplot's event loop with that of tkinter" is perhaps possible. you can execute one iteration of the tkinter event loop with root.update(). Or maybe it's root.update_idletasks(). Tkinter can (in principle) play nicely with any other event loop if you periodically call update/update_idletasks within that other event loop.
On the topic of recursion depth problems. I'm trying to decide if it's possible, in Python-powered lambda calculus, to enter an infinite loop without eventually causing a RecursionError. My guess is that it's impossible, but I don't have a rigorous defense.
"Python-powered lambda calculus" is essentially equivalent to: any Python expression that uses only function calls and/or lambda expressions with exactly one argument.
For example, (lambda x:x(x))(lambda x:x(x)) qualifies. It crashes with a RecursionError quite quickly, but I won't hold it against it.
Sounds impossible. At any given point, you have two options: Do 1 operation (a function call) or 0 operations (return). Without a way to come back and re-execute an earlier part of the code (like a goto or something), you can't go infinite without blowing up the call stack
(lambda g: lambda I: g(g(g(g(g(g(g(g(g))))))))(I)(I))(lambda f: lambda x: f(f(x)))(lambda x: x) runs for, I think, 2^(2^(2^(2^ ...[like 8 iterations of this]...^2))) arbitrary time units, while only reaching a maximum recursion depth of like 16
So it's not too hard to keep the computer busy until the universe dies, but that's a far cry from an infinite loop
Is there a way to refresh the plot (simulate closing the window)? Or is my code incorrect, it seems once it plots the graph it remains in that subloop whilst also running the GUI
If a real-time-updated file is truly necessary, I can try to meet you half way. make the rest of the code MCVE-worthy, and I'll figure out the one missing piece
Oh, my lambda expression just finished, after running for about ten minutes. I guess arbitrary time units are pretty short.
You could edit it into your question on the main site. We usually don't like to discuss fresh questions in here, but I think I'll let it slide this time.
No, endianness is about bytes, not bits. It's more about whether it's a number or not. In numbers, the least significant bit is usually considered the "first". If it's not a number, then... probably still the same, but I'm not sure
So yeah, when you close the plot window it then actually plots the new data - but when I leave it it just stays on that window instead of plotting on top of it
OK. I'm think it's supposed to be a number, but I'm not 100% sure. It's part of a file header describing the version of the file format, read as 0x10. Anyway, that helps, thanks.
I'm pretty sure plt.plot(self.channel) is a blocking operation. In other words, The rest of the live_plot method can't finish executing until the user closes the plot window.
I am having problems trying to make matplotlib plot a function without blocking execution.
I have tried using show(block=False) as some people suggest, but all I get is a frozen window. If I simply call show(), the result is plotted properly but execution is blocked until the window is closed. Fr...
Yeah, I think sticking plt.ion() above the tkinterApp() creation will do it.
plt.ion()
app = tkinterApp()
app.mainloop()
On my machine, this makes the plot window gain new points every second. It's a little obnoxious that the plot window reappears after I X it out. But overall the functionality is there
I think plt.pause(.001) isn't necessary because tkinter does a bit of sleeping on its own. Maybe?
Continuing my geometry problem from yesterday... As a test, I'm using the parametric curve for a figure 8. cx(t) = sin(t); cy(t) = cos(2*t). I believe I can find the point on the curve closest to (px, py) if I solve 0 = (cos(t) * (px - sin(t))) + (-2*sin(2*t) * (py - cos(2*t))) for t.
@Aran-Fey Absolutely agree. Tutorials, when it comes to Python are useless and even introduce misconceptions in best case scenarios (e.g: The classic: variables in Python) and just harmful at worst.
* It must not already be imported;
* You must use a correct name for it;
* Python must be able to find it;
* Python must not find something else first;
* The code must execute successfully.
that's part of why I want to gather as much case info as possible into one place
like, yes, you have to learn "oh, pypi's name for the package is foo but I have to import bar" individually, from e.g. the documentation on the pypi page
but you can be made aware of the general principle that there can be a mismatch
(as for "variables", well, I get what you mean but the cat is out of the bag. A "name" by any other name...)
(and Python is hardly the only language with that kind of issue; I recall Java's "Java has no pointers" marketing running smack into the awkwardly named NullPointerException (which leaks the underlying abstraction))
@dhiaagr as in, math.py in your own project interferes with trying to import math from the standard library (sometimes even indirectly when standard library modules import each other)
if you want import foo to import specifically from the path/to/foo.py you had in mind, then that has to be the first thing that is found by searching the options in sys.path
@KarlKnechtel Oh I see. Well that's a given, I believe. For my personal modules, I try to nest them in a main module, so I can achieve main.module otherwise come up with a naming convention
main isn't a name I use for my own modules, I feel like I must emphasize, lol
Yes, A=sin(t) and B=cos(t). I'm using dot product rather than sqrt((cx-px)**2 + (cy-py)**2). My scratchy notes can be found at pastebin.com/raw/M0QhfzmZ
Me and the lads decided yesterday that the shortest path from P to the curve will surely intersect the curve at a right angle
PM correctly guessed that the math would be unbeautiful. But I had to see for myself.
Method looks good to me and the thing about right angles true. I wonder if there's a further trig identity that can make it a bit easier to solve. I sometimes plot the original against my new equation on an online graph site to check I've done all my trig ID's right
@KarlKnechtel I'm sorry, I misunderstood. I disagree that it's arbitrary, but I believe you're right. it is a an analogy to the __init__ method in classes.
And it's faithful to the there should be one, and preferably one, way to do stuff postulate.
I reckon that the average American middle school curriculum includes the textbook definition of "quadrilateral". The average adult probably doesn't remember what it is specifically, but they might make an educated guess. "He's been talking about shapes for fifteen minutes, so it's probably a shape. And 'quad' can be used to describe vehicles with four wheels, decorative plots of grass with four sides, drones with four propellers, and the power up in DOOM that multiplies your damage by four"
And for the 13% of Americans that speak Spanish, they'll skip most of that and think, "oh, quad like quatro. Yeah, must be a four sided shape."
In regular Euclidean geometry, I'd expect a shape with four corners to also have four sides, yeah. Maybe there are some other systems where that's not always the case.
On a toroidal surface, you could draw four lines that intersect at only two points. One might argue that the result is a four sided shape with two corners.
Hmm, or would it be three sided... I guess it depends on whether line segment AB is considered a distinct side from line segment BA.
@dhiaagr There's Shannon Entropy, which calculates how much information you can encode in a system. I understand almost nothing about it.
Oh yeah, I brushed that subject while reading this book (I can't recommend it enough). But I believe that separates the semantics from the integrity of a given message.
Which I didn't understand until I read the example* of radio waves.
I'm sure that iwhat I'm looking for is somewhere along the concerns of applied linguistics. But I would like to see some equation.
Not that I will understand it, lol, but just to know it already exists.
https://stackoverflow.com/a/27680109/6732828 How come when I replicate this answer, I get a different result? Has the way Pandas copies columns changed over the past 8 years this significantly?
stackoverflow.com/questions/26350627 I'm impressed that we have this question and that it has 50k views. From OP's perspective it's an idiosyncratic debugging question, but for others it ends up providing an explanation of basic technique... I guess?