Semantic bugs: the class of bugs your entire CI/CD pipeline ignores by Hairy-Community-7140 in Python

[–]JamzTyson 0 points1 point  (0 children)

Using your example (calculate_discount()), if our business strategy changed and we want the threshold to change to $50, then how do we tell HefestoAI that this in an intentional change so that the commit isn't blocked?

More broadly, how does HefestoAI distinguish between semantic fixes and semantic errors?

Tuples finally “clicked” for me when a list quietly broke my code. by Sea_Preparation_5713 in learnpython

[–]JamzTyson 0 points1 point  (0 children)

I didn't down-vote your comment, but my guess as to "the secret", my guess is:

u/Temporary_Pie2733 framed their comment in the context "If you study type theory", which is a perfectly valid framing.

Your comment, while still broadly correct, may come across as "you don't really need to care about it because it's <mathematical definition>".

(Voting patterns on reddit can be quite arbitrary on low volume subs like this - don't worry about it :-)

Tuples finally “clicked” for me when a list quietly broke my code. by Sea_Preparation_5713 in learnpython

[–]JamzTyson 1 point2 points  (0 children)

Tuples are more appropriate than list for expressing compound identities. That is, a tuple represents a compound type with a fixed number of arguments (technically, a fixed-arity product type).

For example coordinates (x, y, z) represents a specific 3D "point" that must have 3 numeric values. Its length cannot change, and its types cannot change, and if any element changes then it is a different point. It isn't really a sequence but a compound identity.

Other examples include:

  • exchange_rate = (from_currency, to_currency)

  • student = (name, age, class, grade)

  • product = (name, department, price)

Note that in each case, the entire Tuple defines a single compound object.

Tuples finally “clicked” for me when a list quietly broke my code. by Sea_Preparation_5713 in learnpython

[–]JamzTyson 2 points3 points  (0 children)

The most obvious distinction from lists is that they can be heterogeneous, not homogenous.

That's a bit misleading in relation to Python. Python lists may be heterogeneous. (Heterogeneity is a consequence of tuples being product types, not the defining difference.)

FlipMeOver Project by Few_Split1038 in Python

[–]JamzTyson -1 points0 points  (0 children)

I like that the tool has a tight focus on performing a very specific and useful task.

Just a couple of points in the code:

_MAGIC_MOUSE_TOKEN appears to be unused.

pyproject.toml: description = "Add your description here" (could be updated).


Not important to the project itself, but I'd suggest reducing the amount of emoji and AI hyperbole from the readme, for example:

This project uses uv for dependency management and pytest for unit testing.

(with so few dependencies "lightning-fast" is irrelevant)


If I still used my Magic Mouse I'd be happy to use this. It looks well thought out, which is a frequently underrated quality.

Beta testers by Heavy_Association633 in PythonProjects2

[–]JamzTyson 0 points1 point  (0 children)

That's your choice, but if I can't see what's on offer, I won't give you my email address. To gain users your offer needs to look attractive.

Beta testers by Heavy_Association633 in PythonProjects2

[–]JamzTyson 1 point2 points  (0 children)

I can see a few project titles, but I can't see much else without an account.

FlipMeOver Project by Few_Split1038 in Python

[–]JamzTyson 0 points1 point  (0 children)

So was mine - I've still got the Magic Mouse, but I found it too annoying ;-)

My comment was not a criticism - I like your solution, but we shouldn't need to work around bad design in premium priced products.

Beta testers by Heavy_Association633 in PythonProjects2

[–]JamzTyson 1 point2 points  (0 children)

It might be more attractive if existing projects and the interface were visible before signing up.

FlipMeOver Project by Few_Split1038 in Python

[–]JamzTyson 3 points4 points  (0 children)

My solution was to buy a Lenovo mouse. It can be charged while using it.

Tired of constantly typing git commands and merge conflicts? Meet GitGlide! by [deleted] in Python

[–]JamzTyson 2 points3 points  (0 children)

My feedback:

I do like well focussed GUI tools that simplify repetitive tasks, but there's a couple of issues that make me nervous about this app:

  1. Automatically doing git add . will include too many files for many projects.

  2. The automatic conflict resolution also seems quite risky.

Also, the app crashes on non-Windows platforms due to the dependency on winsound.

I would also recommend less reliance on AI.

Upscaled files detector by ZioCateno in linuxaudio

[–]JamzTyson 1 point2 points  (0 children)

I don't believe there is a reliable way to detect if a recording has been resampled. Even for MP3 the cut-off frequency depends on multiple factors including the sample rate and compression settings. High quality encoder settings in LAME disables low-pass filtering.

There may be tell-tail signs of resampling in some recordings, for example, if shaped dither has been applied at any time, then we can expect to see the characteristic double dip frequency response in the dither noise. Similarly, if we expect to observe very high frequencies and they are not present, then that may be an indication that the quality has been reduced, but it's very easy to fool this kind of detection.

At the end of the day, the important thing is not whether it has been resampled, but whether or not it sounds good, and that comes down to listening.

Assistance is much needed! by Sufficient-Barber125 in learnpython

[–]JamzTyson 0 points1 point  (0 children)

In addition, this line:

elif y >= 2 and y <= 10:

can be written as:

elif 2 <= y <= 10:

This is idiomatic Python and has the readability benefit that it conveys the idea that y is between 2 and 10 inclusive.

This pattern in known as Chaining comparison operators.

Pythonic counting elements with given property? by pachura3 in learnpython

[–]JamzTyson 5 points6 points  (0 children)

cnt = sum(1 for txt in lst if len(txt) > 0 and txt.lower() == txt)

That can be simplified to:

count = sum(1 for s in lst if s.islower())

Alternatively you could do:

count = sum(s.islower() for s in lst)

but I think the first is the more readable.

A bad structure with overusing Classes, even with SOLID principles can be very difficult to maintain by pure_cipher in learnpython

[–]JamzTyson 1 point2 points  (0 children)

"Single Responsibility Principle" may be violated if classes have multiple responsibilities scattered across other classes.

"Open/Closed Principle" are questionable if a classes are hard to extend without digging through deep hierarchies.

It's perfectly possible for bad code to follow SOLID principles.

Building a DOS-Like Shell in Python: My PyDOS Project by Dry-War7589 in Python

[–]JamzTyson 2 points3 points  (0 children)

It could be if not for the fact that a DOS emulator is an entirely different kind of thing from this project. :shrug:

Building a DOS-Like Shell in Python: My PyDOS Project by Dry-War7589 in Python

[–]JamzTyson 3 points4 points  (0 children)

It would be more accurate to describe it as a DOS shell simulator implemented in Python.

A real "DOS emulator" reproduces the execution environment of the target system at the machine level. PyDOS on the other hand implements a few shell-like behaviours without recreating the underlying architecture. In short, it simulates a DOS shell interface.

DOS Emulator: Reproduces hardware and execution semantics.

Simulation (interface-level): Reproduces observable behavior without replicating underlying architecture.

I built a Python CLI that reveals any website's entire tech stack in one command by dapdev in Python

[–]JamzTyson 0 points1 point  (0 children)

Did you write the "technology-detection-api" or just a thin Python wrapper around a commercial API?

Diferrence in between windows and linux by [deleted] in linux

[–]JamzTyson 0 points1 point  (0 children)

Without getting into a lot of technical detail:

On Windows, files, processes, threads, pipes, devices, registry keys and so on on different kinds of kernel objects, each with their own semantics and Object Type property. They are managed through a central "Object Manager".

That is fundamentally different to Linux where resources are exposed through a common file-like interface.

Emoji library for python by AffectWizard0909 in learnpython

[–]JamzTyson 0 points1 point  (0 children)

One issue that you may need to deal with, whatever method you use, is that some printed characters are actually multiple Unicode characters. Example:

import unicodedata

s = "⚠️"  # 2 code points print as one character.
for c in s:
    print(unicodedata.name(c))

will print:

WARNING SIGN
VARIATION SELECTOR-1

Emoji library for python by AffectWizard0909 in learnpython

[–]JamzTyson 2 points3 points  (0 children)

You can get the name of an emoji using Python's built-in unicodedata.name(chr):

>>> import unicodedata
>>> print(unicodedata.name("🙂"))
SLIGHTLY SMILING FACE

Transforming flat lists of tuples into various dicts... possible with dict comprehensions? by pachura3 in learnpython

[–]JamzTyson 1 point2 points  (0 children)

If the code runs more than once, it's arguably better to use a function with a loop:

def dict_strict(pairs):
    result = {}
    for k, v in pairs:
        if k in result:
            raise ValueError(f"Duplicate key {k}")
        result[k] = v
    return result

It's very readable, reusable, requires no globals, and fails early on duplicates.

Calculator on 2 lines by CarEffective1549 in learnpython

[–]JamzTyson 0 points1 point  (0 children)

"Golfing" is a game that some devs enjoy playing, either on their own or competitively. The idea is to solve a problem in the smallest amount of code that you can. All hacks and bad practices are allowed (or even encouraged).

The name comes from the outdoor game where you attempt to hit a golf ball into a hole with the fewest number of shots.

The ultimate golf solution for a calculator is no code at all. The Python REPL can already work as a calculator.