Hello to all..... I want to know whether anyone knows how to display the refreshed plots on jupyter notebook using matplotlib.... Here is the code I have tried:
@AbhijeetPanwar Your question is perfect and looks good to me. The question belongs to Django framework. You can move to Django Chat room and discuss it there. Will help.
Hmm, having a hard time determining whether SOPython has a dupe target for Can you import another script from a variable?, because searching for "import" returns basically every question in the common questions list
I guess it depends on what you actually need to do with the objects. If you only need to create them, then you can subclass Canvas and write your own create_whatever method.
I actually have some ideas to subclass tk.Canvas, and make it OOP, with some sort of Model Hierarchy tree to group objects
I would like to discuss this with someone more experience and knowledgeable than I am; would that be something you would be willing to discuss with me to establish some sort of design guidelines - At a time convenient to you, that it.
I think I need a bit of reassurance that I am not completely off base in my analysis of how to do it.
You can of course reply later, and we could tentatively start a discussion just to see where that could lead to; no hard commitments to anything, just maybe bouncing off ideas
I would like in fact create canvas objects on which methods can be called on later. Something like `item = create_composite_item(canvas, ...)`, then later call canvas methods on it like `item.dothisandthat()`
doing away with tags and ids on the API/cliend side.
Hiding all that accounting machinery inside a canvas class
I wonder if it's even necessary to subclass Canvas. If you create a class for each kind of canvas item, then you can make each one of them responsible for handling their own "primitive" version of themselves
class Line:
def __init__(self, canvas, **options):
self.canvas = canvas
self.id = self.canvas.create_line(**options)
def delete(self):
self.canvas.delete(self.id)
#todo: implement other things that do this and that
Or, hmm, maybe it is a good idea to make a Canvas subclass, if you still want to use the tag system
Please sign my petition to encase all human settlements in enormous opaque domes, each one having an artificial sun that traverses the same arc in sync with every other dome's sun. Thus solving all time zone problems forever.
I was imagining the moon also tidelocked on the other side in a perpetual lunar eclipse. But I see that my imagination was running ahead of a earth tidelock reality
If we could figure out how to harness Earth's angular inertia, this could power humanity for a few 100,000s years... slowly slowing the rotation down until tide lock.
Fully expecting the reply to my comment to be "sorry, the line in question is ten layers deep in some code I just installed, I have no idea what it's doing"
@Kevin i dont have that example yet , i will try to recreate it , because sometimes this code works abs fine . will update here once i have the example code . thanks — Kiran7 mins ago
I'm divided between three different Metroid-likes on Switch right now. Iconoclasts, Hollow Knight, and Axiom Verge. No, I couldn't manage to finish one before buying the next.
High difficulty + plot line about a decaying world + rolling with iframes -> MetroidVaniaDarkSouls
I just finished Hyper Light Drifter, which is also a difficult game taking place in a decaying world where you have to master the dodging mechanic... Hmm, I sense a pattern
I've been writing a bit of go lately and since go formatting is opinionated (think PEP8 compliance or SyntaxError), the jetbrains editor - "GoLand" i.e. PyCharm for go - just formats it while you type.
I was using GVim for some quick hacks this week and realized "I used to love just loading up VI/VIM for some quick hacking but IDEs have ruined me"
hmm...I answer a question with three methods and explanation and no upvotes. Another person answers the question, with code that doesn't run at first (then doesn't actually answer question), and one upvote......people are mysteries
Looking at doing something on unix that I thought some people in this chatroom might know how to do. Anyone have any thoughts? unix.stackexchange.com/questions/460907/…
Hmm, thought it would give a preview. Anyway looking to start a root service from a GUI in a python application (linking in with dbus)
What to do when an answer arrives some years later, and it's not incorrect, but it's exactly the same as an already existing answer (on the same question)? Downvotable, or let it be?
@DonyorM Normally I'd suggest the subprocess module but I don't think you can use that in a non-root-privileged program to start a root privileged program
@wim So how would something like gparted work then? It inherently needs root access but equally needs a gui. My understanding was the best solution was to make a background service with root permissions and communicate to it from the low-priveliege gui program via dbus and authenticate with policy-kit. But I can't have my users starting the root service with CLI, I need to start that via a GUI too
Use the same model as windows -> "Hey, you want to do this thing which takes admin priv" -> Open non-bypassable message "Login as admin" or "enter admin password" -> then only use that permission for that act or set of actions and then return to previous permission setting & don't ever save the password
@wim Do Linux systems have a way to make an admin dialog? My understanding was something like gksudo or pkexec where the best, but those seem to be considered bad practice as well. I have found very little information online about this, hence the low-level questions. Trying to do this in a reasonably secure manner (and avoid the Dropbox phishing issue)
I know. That's why I'm looking for a better solution. Are you telling me that without the command line, there is no way to make a GUI administrative program?
It's kinda important if linux is to be used by anyone other than power users.
I shared this in a couple places besides here, if I don't get answer in a couple days I'll make a specific question on StackOverflow using MoxieBall's suggestion. I should be able to use sudo -S so long as I can get the password securely.
@DonyorM btw. a lot of people (I mean I just saw someone fired for this like this month) get in trouble for messing with WindowsIdentity or PrincipalPermission within a Windows environment so there's a reason they (other OSs) make it harder
@JGreenwell that makes sense. I'm asking this question because I want to do it right. At this time I have the program running as root as GUI, but that's terrible security practice and won't work at all in Wayland. I just have yet to find a good article or tutorial explaining what the alternative is an I'm utterly confused.
@DonyorM I would downvote your question, but I don't have the rep on unix stack exchange. You didn't even specify what privileges the program needs, and why.
How do you expect useful advice other than "don't do that" if the question is basically "I want GUI program to run with root"
What does it do, which parts need a privilege escalation and why, is it a temporary once-off escalation, these are important details
Also relevant: how/by whom/where is the daemon and/or GUI installed
As an example, the last time I had to do that (load something with non-admin but elevated permissions in Win), I did a Process.Start(otherprogram.exe -WorkingDirectory path_needed -Credential ($credentials)). User didn't even notice anything except they had to provide the credentials and GUI didn't touch the stuff that needed elevated perms - to their perspective it was all the GUI
@wim Thanks for asking specific questions. I'm sorry I'm having trouble articulating what I need, but I honestly have no clue what would be helpful because I have no experience with this. I'll edit the answer, but here's the quick answer to your question. It needs escalation for disk partitioning and filesystem formatting, once it has done this it's simply a backup program copying files with rsync.
The program is a normal program presumably installed as an administrator via a package manager of some sort (pip at the moment, but hopefully distribution package managers in the future)
@JGreenwell that would work, but under Linux systems apparently even making a dialog to receive a root password is considered bad security (if I understand what I've read elsewhere, wim seems to agree). Otherwise I could probably do that.
yeah, following those steps for admin/root, and saving passwords & full credentials, was what led to the whole DropBox incident. Hence Linux is smarter than MS and is telling you for a reason to avoid this :)
@wim on that answer: I'd vote for (and am) just downvoting - he copied you and didn't even write correct code (hence not really "copied") let him just reap the downvotes since we don't have a flag for "Its just wrong"
@JGreenwell yeah, just MS (apparently the dropbox issue was on Mac too, which is closer to linux in this case I think) has UAC when you need to do one or two things with root. I haven't found a linux equivalent. Apparently the best way is to run a daemon from start-up, but unless I misunderstand daemons (which is very possible), this seems like a waste of resources for something that won't be run frequently.
Cabbage. We didn't have named functions in the 1st dialect of Basic that I learned, just gosub. And of course there were no statement labels, just mandatory line numbers.
Basic was ok, back in the day. I probably used around 20 different dialects over the years. One of the nicest was on the Amstrad, I vaguely remember it having pretty advanced graphics capabilities for the era, and its graphics system was well-designed.
@piRSquared I'd use getrandbits(1) rather than messing around with floats.
I should've written GOSUB in that earlier message. Everything was uppercase. I didn't see a system that had lowercase chars until I'd been programming for over 10 years.
getrandbits is cool. And it's efficient. IIRC, all the random number functions eventually get their bits from it (or more precisely, from the underlying C function), so it makes sense to call getrandbits when appropriate.
I'm a little surprised that I got the top score on that Physics question. I was the 2nd to post an answer, and the answer that now has the 2nd-highest score was the winner until we got to the 20 upvotes mark. I guess the HNQ crowd just liked mine better.
I suppose I should create a nice ray-traced diagram for that answer. I wrote some POV-ray stuff about 15 years ago that does very accurate catenaries, given 2 points on the curve & the length. E.g., i.sstatic.net/osoqn.png
Actually, the curves themselves are perfect, but I don't bother ensuring that each link of a chain is perfectly following the law of gravity. That would be rather tricky!
duplicatepd.read_csv(..., index_col='year') explicitly says to drop 'year' as a column and use it for row-indices [doc]. What to do with the latest asking?
@user3483203 No, I said near-duplicate in my comment on the question. Questions on pd.read_csv(..., index_col) are pretty garbled. Not sure want to make this one the primary target either, because the pd.read_csv(..., index_col) may be unnecessary; the OP's intent and answers may sidestep it. See my edit to the code. (Do we answer the OP's stated question as-is, or the intent of their code? If the latter, it is not a good primary target for index_col)
@Arne the dataclass decorator also has the same "feature"
so it not clear to me which you're saying you prefer, 1 or 2?
this is kind of annoying imo. We don't allow a shortcut to call a function foo(kw1=1, kw2=2) like just foo so why should the case of a decorator-maker be any different?
Also, pd.read_csv(..., index_col) has been accepting string or list-of-string for some time, but the doc has never been updated to say that. Also a docbug.
If a question title is badly inaccurate, should we fix it to reflect the actual question or leave it like this so it may help some other user that uses the wrong but same terminology?
@OlivierMelançon I think the title should always be made as exact as possible. The onus should be on people searching for answers to correctly learn the terminology of what they seek.
@wim It shouldn't be. And the stdlib doesn't do stuff like that, afaik. E.g., you have to write @lru_cache(None) even though None is the most common arg.
@OlivierMelançon If the question is active, encourage the OP to fix the title, offering suggestions if necessary. We want to train OPs to do the right thing themself, not to expect us to clean up their messes.
@AndrasDeak A simple decorator takes one arg: the function (or class) that it's decorating. Fancy decorators that take parameters are more like decorator factories that return the real decorator that does the actual decorating. So having a decorator that can be written either with or without args is confusing. It looks like a simple decorator, but it really isn't.
@OlivierMelançon Ah. :) Incidentally, when I first saw that question I was just going to educate the OP about the difference between "array" & "list". But I got caught up in commenting on the answers instead.
@AndrasDeak a) I already showed the 1658(!) pandas questions mentioning index_col In sorting and triaging those there will be dupe target material. b) In my comment on the question I said near-duplicate, which it certainly is. I don't know what tag I'm supposed to use here in chat: discussion,possible-duplicate...? c) and I read multiple versions of pandas source and doc, then filed a pandas docbug
@OlivierMelançon No worries. I'm on my phone, so it's a bit painful to write answers, but it's nice to be able to offer suggestions. Although some people tend to delete their answers rather than improve them. I guess that makes sense if you realise that the only way to fix your code will turn it into a clone of an existing answer.
@AndrasDeak saying that something is wrong without saying what the right alternative is, is equally suboptimal. "No tag" seems suboptimal as the transcript cannot efficiently be searched.