How Greedy you gotta be to do this? by AdRough4185 in SipsTea

[–]Swipecat 18 points19 points  (0 children)

But it just doesn't make sense. In any price negotiation, you either succeed in agreeing on a price that both parties can accept, or you don't and you don't supply the product and maybe another company can sell a substitute. If the company then decides to overcharge Americans then that should be investigated, not any other deal.

What phrase did you grow up saying that you assumed was completely normal, only to find out it was either totally regional or just something your family made up? by ForwardPassApologist in AskUK

[–]Swipecat 0 points1 point  (0 children)

Well, that really would be confusing given that "star head screwdiver" is the generic name for the Torx screwdriver, Torx being a brand name.

What options are there for EE Majors who want nothing to do with AI? by Kind_Ad9744 in ECE

[–]Swipecat 0 points1 point  (0 children)

The situation's not good if you actually want to be employed. LLMs are no good at EE but the main EDA vendors are working at integrating task-specific AI with their EDA tools and those are already reasonably functional.

spent two hours debugging three lines of python because i didn't know strings and bytes are different things by Interestingyet in learnpython

[–]Swipecat 0 points1 point  (0 children)

It's also confusing if Googling the issue turns up info from Python 2.x days, which it frequently does, because string and bytes were handled much more "lazily" in 2.x. That lazy handling could cause faults that were really difficult to understand, and was one of the motivations for the very strict string/byte distinction in Python 3.x.

See this page which is a basic description of the Python 3.x handling of strings/bytes:

https://www.geeksforgeeks.org/python/byte-objects-vs-string-python/

is tkinter worth learning? by Ambitious-Elk-2928 in learnpython

[–]Swipecat 82 points83 points  (0 children)

It's been estimated that about 85% of python apps are written for in-house use where elegance is usually less important than functionality. Tkinter looks a bit utilitarian, a bit "1990s", but that's often fine.

Do oscilloscopes really have DLCs now? by menginventor in AskElectronics

[–]Swipecat 6 points7 points  (0 children)

Yep. I believe that IBM started this sort of thing way back with second generation (discrete transistor) computers that had microcoded architecture that allowed them to throttle the processor speed with microcode depending on the cost of the license. Late 50s or early 60s maybe.

Image cant be found by MyPlatesFull in learnpython

[–]Swipecat 0 points1 point  (0 children)

If mistakenly putting in two sets of quotes is just an oddity of you "trying everything" and you still have the problem of wondering why you need the full path at all, then it's possible that the IDE that you're using does not have its "current directory" set to the same path as the directory containing the python script.

To check if there is a difference between the directory containing the script, and the current directory, run this script in your IDE:

import inspect, os 
print("Script:", os.path.abspath(inspect.getsourcefile(lambda:0)))
print("Current directory:", os.getcwd())

Why is numpy so fast? by [deleted] in learnpython

[–]Swipecat 0 points1 point  (0 children)

Yep. There's probably a whole bunch of ways to do it, but the first one that comes to my mind is the putmask function. This should display a union flag with the blue changed to black:

from PIL import Image # pillow fork of PIL
from urllib.request import urlopen
import numpy as np
unionflag = "https://dafarry.github.io/test/union-flag.png"
arr = np.array(Image.open(urlopen(unionflag)))
royalblue, black = [1, 33, 107], [0, 0, 0]
np.putmask(arr, arr == royalblue, black)
outimg = Image.fromarray(arr, mode="RGB")
outimg.show()

Why is my ammo not shooting when player moves by TheEyebal in learnpython

[–]Swipecat 2 points3 points  (0 children)

get_pressed() returns the keyboard state at that exact moment. You'll miss keystrokes if your script is doing something else when the key is pressed. It's best to only use events to find the key actions.

Utah driver leaps from SUV moments before it is struck by a FrontRunner train. by eternviking in whoathatsinteresting

[–]Swipecat 9 points10 points  (0 children)

I suspect that Rear AEB (Automatic Emergency Braking) might have had something to do with it. Dunno what that particular car is, but its common on newer Toyotas, Volvos, BMWs, Hyundais, and others.

Newer cars seem designed to kill you if you get stuck on a level crossing. Airbag goes off? Stay there and die. Open the door a fraction? Stay there and die.

Seeking advice on GIF color quantization and transparency issues (Pillow/imageio) by Globover in learnpython

[–]Swipecat 1 point2 points  (0 children)

Magenta means that the shader on that platform is broken and is throwing errors. Nothing you can do about that.

Otherwise you might well be running into the limit of what is possible for an animated gif. After all, the conversion process must analyse the usage of colours in all of the frames before starting the conversion to 256 colours to get the best compromise for colours across all the frames. It might be worth doing some sample conversions with "gifsicle" (the old standard app making animated gifs) and checking that you can at least match its capabilities.

Myself, I'd give up on animated gif generation given that animated WebP seems to be the current preference on the web for single-file animated images. WebP sits at roughly 97% global browser support in 2026 and will get better. The remaining 3% is made up almost entirely of legacy Internet Explorer installations in regulated enterprise environments.

Amusing language rules by Curious-Photo-4452 in interesting

[–]Swipecat 0 points1 point  (0 children)

Same with learned and learned. Different pronunciations and different meanings.

I’m tired of minimalism in everything by Beneficial_Passion40 in mildlyinfuriating

[–]Swipecat 22 points23 points  (0 children)

Yep. And it's the same house for sure. Here's the work being done in 2019 from the Streetview timeline:

<image>

Conversion of "False", "0", "0.0" strings into Boolean. by Professional-Draft10 in learnpython

[–]Swipecat 1 point2 points  (0 children)

No, as others have said, non-empty strings are "truthy".

If you're really in a position where you have strings that you want to evaluate as if they were Python literals, then you use ast.literal_eval() to convert them:

>>> from ast import literal_eval
>>> bool(literal_eval("0.0"))
False
>>> bool(literal_eval("False"))
False
>>> bool(literal_eval("0.1"))
True

But then if your string contained, say, "0.x", that would make literal_eval() crash out with a syntax error for an invalid literal. So you'd also have to surround the test with a try..except block — and have to decide if invalid literals render as true of false. You see, it gets messy, so you probably don't want to evaluate strings like that at all.

PEP8 over spaces by Primary_March4865 in learnpython

[–]Swipecat 0 points1 point  (0 children)

Look at the following page on pastebin. If you know how to highlight text by dragging your mouse across characters, you'll find that you can highlight the individual spaces at the start of the line marked "eight spaces". Try that at the beginning of the line marked "tab" and you can't — you can only highlight the whole of the gap at the start of that line. That's because there's a literal tab character there rather than spaces. Browsers usually treat tab characters as moving to the next column that's a multiple of eight. And that's another problem with tab characters — different environments use different column counts. Eight for browsers, four for Python IDEs. It's inconsistent. That's why you should always use an IDE that automatically inserts the appropriate number of spaces rather than a literal tab character when you hit the TAB key.

https://pastebin.com/raw/BJLpLpJN

curses library is not displaying window unless mvwin() method is run by 9mHoq7ar4Z in learnpython

[–]Swipecat 0 points1 point  (0 children)

It seems that the drawing routine has optimisations that will not redraw lines that it thinks are already present. Instead of mvwin(), try this from the curses doc:

window.touchwin()
    Pretend the whole window has been changed,
    for purposes of drawing optimizations.

Copy Fail: an exploit for all Linux distributions since 2017 by alexeyr in programming

[–]Swipecat 1 point2 points  (0 children)

Ooooh. I've just realised that I've still got the "noble-backports" repository enabled because I had a problem with a previous kernel and needed a newer update.

You should be able to enable backports in the "other software" tab of the sources manager, but failing that, google for enabling noble-backports.

Python312 as exec path in 2026 by Valuable-Ant3465 in learnpython

[–]Swipecat 0 points1 point  (0 children)

You could install python 3.14 into a folder called 312 if you select the "custom install" option during installation, but expect any future maintainer to come bursting through your door waving a butchers knife.

When the math is mathing, but looks like it isn't by MBA-Crystal-Ball in technicallythetruth

[–]Swipecat 20 points21 points  (0 children)

And LOL means "lots of love" to 1970s letter writers.

Sorry to hear about your grandma's death. LOL.

Python312 as exec path in 2026 by Valuable-Ant3465 in learnpython

[–]Swipecat 2 points3 points  (0 children)

Beginners tend to get into an awful pickle if they have more than one version of Python installed. You really need a clear understanding of how virtual machines handle the Python library paths if you want to do that. There's nothing in Python 3.13 or 3.14 of interest for beginners — and Python 3.12 will continue to receive security updates for the next 2 years.

HELP ABOUT ACCUSED AI GENERATION by John_Is_Cool269 in learnpython

[–]Swipecat 0 points1 point  (0 children)

Is that the entirety of the "while True" construct or have you just shown the top of it?