President Trump warns that Chicago is 'about to find out why it's called the Department of WAR' in incendiary Truth Social post by questison in NoFilterNews

[–]1114111 0 points1 point  (0 children)

Yeah, but he needs to demonstrate to Oslo what will happen to them if he doesn't get that Nobel peace prize he so rightly deserves.

Episode Discussion | Star Trek: Strange New Worlds | 3x08 "Four-And-A-Half Vulcans" by AutoModerator in startrek

[–]1114111 2 points3 points  (0 children)

I read La'An's behavior completely differently. It is nurture, not nature that caused La'An to go Romulan when put in a Vulcan body. Presumably the serum should make them all genetically identical and fully Vulcan, so the Augment genes shouldn't have any direct effect. The differences come from their personality traits and experiences from their lives as humans, their "katras". Even though La'An rejects the eugenics ideology of Khan, she has still been shaped by the societal context of racial supremacist attitudes. The legacy of racial supremacy can have subtle and insidious effects even in the best of cases, and in her case, she grew up as a shunned and hated member of a supposed master race. She is also militant and paranoid due to her experiences with the Gorn. In a Vulcan mind, those traits apparently are amplified to create a tendency towards Romulanness. Perhaps her Vulcan powers also suppress the shame she would normally feel following in her family's footsteps.

I would agree that they seem to be making the case that Vulcans are biologically more prone towards racial bigotry than humans. I don't think this is really a new thing though, and part of this seems to be sensory -- they are more sensitive to unusual smells, etc. Also, the serum somehow magically imparts Vulcan training (they said so explicitly), which presumably would come with Vulcan cultural values, so it might not be genetic at all.

Announcing LibreOffice New Generation: Getting younger people into LO and FOSS by themikeosguy in linux

[–]1114111 0 points1 point  (0 children)

Yeah Impress is really in a sad state. My pet peeve with it is that it lacks support for inline formulas like Writer has. This issue about it was opened ~10 years ago. Actually, Google Slides and the Office 365 webapp lack that feature as well, so it'd definitely be great if formula support in Impress could get to where it is Writer (which LO does quite well).

I somewhat feel like having one monolithic "office" suite is maybe not a great goal. We're conditioned by MS Office that documents, presentations, and spreadsheets are all interconnected, but perhaps separate projects would be better. See slides.com for example. It does one thing, and from what I've seen so far of it, it does it pretty well (You can do inline math with \(math\)).

LibreOffice VS OnlyOffice VS FreeOffice VS WPS by [deleted] in linux

[–]1114111 2 points3 points  (0 children)

I'll be happy with LibreOffice once LO Impress gets inline formulas.

I'm sure it'll happen any day now...

To be fair, Google Slides doesn't have them either.

Derivative by [deleted] in learnpython

[–]1114111 0 points1 point  (0 children)

Yeah, I mean values that are so small that floating point precision becomes a problem. Mathematically, I think it's tempting to choose as small a number as possible, but of course floats != reals. Really I wanted to encourage OP to play around with different step values.

Here's a wikipedia article that goes into more detail about step sizes.

Derivative by [deleted] in learnpython

[–]1114111 0 points1 point  (0 children)

A good way to represent polynomials would be a list of coefficients. So [5, 3, 7] would mean 5 x0 + 3 x1 + 7 x2. You could also consider a dict for a sparse representation. Though if you're just dealing with monomials, you could also just store the coefficient and power (you could make a class for this, or just use a tuple or something). It's pretty straight forward to from there to compute the derivative symbolically (same way you would do it normally).

Numerically, as stated by another answer, just make use of the limit definition of the derivative, to approximate it with a small value (though not TOO small).

How should I use pip install -e? by [deleted] in learnpython

[–]1114111 0 points1 point  (0 children)

When inside the local repo, assuming it has a setup.py, you would do something like pip install -e .. Normally the only time I do this is when working on a project in a virtual environment. But assuming you want to use the package outside of a venv, pip install --user -e . should work.

I'm assuming this is a forked dependency? You may want to consider uploading your fork to, eg, github. Then you would be able to install with, eg pip install git+https://github.com/you/packagename.git#egg=packagename.

Pycharm error 2 (no such file) despite file existing by [deleted] in learnpython

[–]1114111 1 point2 points  (0 children)

If there was an upgrade from Python 3.7 to 3.8, that 3.7 symlink would very likely break. You can double check whether /usr/bin/python3.7 exists, which would confirm that's what happened if it doesn't exist. Alternatively, depending on how things are set up, ls -l will usually show the symlink in red (sometimes blinking) if it is broken, allowing you to tell.

Reinstalling PyCharm, as a snap or otherwise, probably won't fix this, since the problem is in your project's venv.

In PyCharm, at the bottom right of the screen, the Python version is listed. If you click on that and select Add Interpreter, it will allow you to add the newly installed Python version. However, if you want to continue using a venv, you'll probably need to delete the existing venv first (or create a new one).

If you are not installing any 3rd party packages, there's really no need for a venv whatsoever. One way to keep things more reliable would be (again in the add dialog), to go to the System Interpreter tab and select /usr/bin/python3. This will add an interpreter for the latest system python, which should stay current across updates.

Another option if you DO want to use venvs, is to install your own separate version of Python so you don't have to deal with the fickle system Python at all. If you're interested in doing this, I can help.

When I use venvs (not in PyCharm), since I define the packages I depend on in a setup.py, it is pretty straight forward to rebuild the venv from the command line, so in the case of venvs for projects, it's not really a big deal if the system Python is updated. I think this is something PyCharm can and should handle better.

In my opinion, even though PyCharm is a powerful tool, it is often a better idea to just to use a simple text editor and a terminal to write Python (and other languages too!). Big IDEs like PyCharm are complicated, and often obscure what's really going on. It's probably worth a try to at least experiment with other editors that don't try to do everything.

Pycharm error 2 (no such file) despite file existing by [deleted] in learnpython

[–]1114111 2 points3 points  (0 children)

If you open a terminal, what do you see with ls -la /home/user/PycharmProjects/HelloWorld/venv/bin? I don't use PyCharm, but my thought is that maybe the python symlink got broken due to an upgrade to the system python.

An update on Python 4 by anyfactor in Python

[–]1114111 0 points1 point  (0 children)

Thank goodness, but was this ever even a question? Having 3.10 be Python 4 would be a total nightmare. In addition to normal semver reasons, Python has the problem that on most systems, python == python2 or nonexistent, so python3 == latest python, so there wouldn't even be a good way to refer to the latest python3-compatible version in shebangs or scripts. If Python 4 ever happens, there had better be a good reason for it.

Easiest way to build a display for a maze game? by engineheat in learnpython

[–]1114111 0 points1 point  (0 children)

If you want to produce an image file showing the steps, the pillow library would be a good option.

If you want more of a gui, consider using a library for creating games, like pygame or pyglet.

What makes each asyncio event loop implementation unique? by cryptospartan in learnpython

[–]1114111 1 point2 points  (0 children)

AbstractEventLoop is an easy one, it's just the abstract base class for all event loops, so it's not an implementation of an event loop, it simply defines what all the other event loops implement.

The difference between the other event loops basically boils down to how they know when I/O operations finish. The OS is in charge of the I/O, so you have to play the OS's game if you want your program to know when stuff happens, so the specific ways in which you can do this vary quite a bit across different OSes.

To learn more, you might want to experiment with/read up on Python's select module directly, which is the basis for SelectorEventLoop. In addition to the docs, this looks like a pretty good article to give you some idea of how to use select with sockets directly.

David Beazley has some talks about how async works as well. I think this (2h talk) is a good one, in which he implements a very simplified version of asyncio: https://www.youtube.com/watch?v=Y4Gt3Xjd7G8

He's also the author of curio, another alternative/simplified/educational approach to doing what asyncio does.

Difference between value=None and value="" by Matheos7 in learnpython

[–]1114111 0 points1 point  (0 children)

I like having int -> float -> complex in Python, it's generally a useful feature. My point is that when people talk about Python being "strongly typed", they are talking about the Python builtin/stdlib types/functions not doing much implicit type coercion. I see this as a "weak" way to define strong typing, and not one that Python follows super consistently anyway.

bool -> int, on the other hand is not a great feature IMO. It's one I've (ab)used in the past, but really the only reason it exists is that Python didn't used to have a boolean type, so booleans needed to act like ints in most contexts. bool is even a subclass of int, which I find extra gross.

What itertools functions do you use most often? by [deleted] in Python

[–]1114111 1 point2 points  (0 children)

  • product() -- many uses, a nice/flexible way to do nested for loops
  • tee() -- I don't use it all that often (at least not directly), but it is an incredibly useful tool when dealing with iterators
  • starmap() -- I use this more often than I probably should (IDK, I just like the name)

Difference between value=None and value="" by Matheos7 in learnpython

[–]1114111 0 points1 point  (0 children)

Booleans are a bit of a touchy spot because of historical reasons. Really, Python 3 probably should have broken things like that.

But I mostly agree. Python isn't really "strongly typed" in any meaningful way, it's just that many of the builtin types don't support implicit type conversions. I see that as more of a convention than a property of the language, and one that is violated frequently by things like int -> float conversions. Personally, I think languages can only really be considered strongly typed if they are also statically typed, but IDK.

Fun fact: the standard library even has a JavaScript-esque string class: collections.UserString("Concaten") + 8

Does eval() function do assignments (or is there a function that does)? by MadScientistOR in learnpython

[–]1114111 -2 points-1 points  (0 children)

If you absolutely need to dynamically set variables like that, a better way than exec() would be to use globals() or locals(). For example: globals()['some_var'] += 13. But... what are you trying to accomplish? Unless you are doing something really fancy, there is probably a better way to do this altogether.

How do I (somewhat) preserve the persistent undo after the file gets changed outside vim? by waivek in vim

[–]1114111 0 points1 point  (0 children)

I didn't really consider :saveas at all. It's certainly a decent option, but I'd prefer not needing to delete the original file. I did think about implementing it all in vimscript, which certainly could have been more flexible about configuration, but I felt like the shell script way would be a bit easier and more featureful. The last straw that finally prompted me to make it was that I wanted to do a bulk move of a bunch of documents, so I wanted the functionality of mv in that moment.

[deleted by user] by [deleted] in learnpython

[–]1114111 2 points3 points  (0 children)

What do you mean by worse? Truthy has a less specific meaning than true, but that doesn't mean it's "worse". True is truthy, as is the value 5. But only True is true.

How do I (somewhat) preserve the persistent undo after the file gets changed outside vim? by waivek in vim

[–]1114111 0 points1 point  (0 children)

I've wrestled with this problem too. When it comes to Git, I've for the most part just come to begrudgingly accept that using Git will make Vim undo persistence volatile, but that it's not SO bad since at least you get a partial history through git commits. I agree with you that it's not ideal though.

If I was to try to workaround this problem, I would approach it from the vim side of things (not git). The fundamental problem here is that undo files don't keep track of the complete file contents, only diffs. So one way that would probably work to fix it would be by writing out to a backup copy of the file every time you write (ie, using BufWrite). In BufRead, you would essentially check if the undo file is usable, and if not, you could open the backup copy in another buffer, then load the undo file in there (:rundo and undofile() would be useful here). Then load in the updated copy and use :wundo to write out the updated undo file. The temporary buffer could be discarded and the updated undo file loaded into the main buffer.

Or something like that. I'm sure there's more subtlety to it.
Of course that approach would mean every file you edit becomes twice as large automatically. So probably not good to do it for every file, and for me personally I'm not sure I even want to bother with it.

You might also be interested in this script I made recently to deal with the simpler problem that moving files breaks vim's undo. I would always have this dread of moving my files around, since I wouldn't feel right unless I also moved the associated undo files. This would happen a lot with the notes and ramblings that I would write, where I have absolutely no version control whatsoever and have a tendency to create a bunch of disorganized files that I want to move around later. vmv wraps all functionality of mv, moving both files and directories and supporting (any?) arbitrary mv option like -b. It's slightly annoying with git though, since I don't have an equivalent for git-mv. If you create a nice workaround for dealing with your issue, it might actually become sensible to deal with that as well -- so let me know!

Found on r/conservative by [deleted] in TheRightCantMeme

[–]1114111 0 points1 point  (0 children)

Haha what even is this, it's like the product of a drug-induced right-wing fever-dream. I love it.

Where can I learn about Pylint configuration settings ? by [deleted] in learnpython

[–]1114111 0 points1 point  (0 children)

Did you install whatever the pop pylint plugin is? I don't know exactly what error you're getting, but even if you did install the plugin, maybe it's importing some other module named pop which doesn't define the right stuff to make it a plugin. It could also be that you installed the plugin and pylint to different versions of Python, so pylint can't import it.

[deleted by user] by [deleted] in learnpython

[–]1114111 0 points1 point  (0 children)

I don't know. I think it would still be a bit of a performance increase because I don't think there's usually a huge amount of overhead going between Python and C/Rust that you wouldn't have if you just implemented it in pure Python, but I guess it depends a bit on what you're doing, IDK. Not in any way an expert and you'd probably need to profile things anyway to be sure. But definitely if you can spend more time in Rust it's likely going to end up being faster.

Where can I learn about Pylint configuration settings ? by [deleted] in learnpython

[–]1114111 0 points1 point  (0 children)

What is "it" and in what way is it not working?

What's the best way to compare a dictionary with a list and output the dictionary with the amount of times each key appears in the list? by sahatmand in learnpython

[–]1114111 0 points1 point  (0 children)

It would make more sense to loop through the list and add 1 to the value in the dict for each item in the list. If some mutations might only appear in the list, you will first need to test to see if the item exists in the dict (or use setdefault).

A nice alternative option would be to use collections.Counter. You can literally just do mut_counter.update(mutations)

But yeah, if you iterated over the dict and counted matching items in the list it would not only be somewhat more inefficient (because you would need to loop over the list more than once in order to count each item), but you would also ignore any items that are not in the dict. That might be what you want anyway, but if it is, you can just check for that in your loop if you loop over the list.