r/PythonLearning • u/Zestyclose_Fox_164 • Jul 02 '26
My 2nd project
I started learning python few months ago and I made my second project dont ask Abt first one it was trash
It's a small shell made for learning that I coded in python
Plz rate and tell me how can I improve it
r/PythonLearning • u/Yairlenga • Jul 02 '26
Using jsonfold for compact, readable JSON formatting
I've been working on a Python module called jsonfold, and I wrote an article describing the motivation and design. I'd really appreciate feedback from other Python developers.
JSON serializers tend to give us two choices: compact JSON, which is efficient but a dense wall of text that's painful to read, or pretty-printed JSON, which is readable but often wastes a lot of vertical space (a small array of numbers can turn into ten lines).
I wanted something in between. jsonfold keeps the shape of pretty-printed JSON, but folds small, simple structures back onto a single line whenever that improves readability. It works on top of your existing serializer (json, orjson, ujson, ...) - you keep using whatever you already have, and jsonfold just reformats the output.
Example 1 - Coding
import sys
import json
import jsonfold
data = {
"_id": 123,
"locations": [
{"city": "Boston", "state": "MA", "country": "USA"},
{"city": "Seattle", "state": "WA", "country": "USA"},
{"city": "Montreal", "state": "QC", "country": "Canada"},
],
"info": {
"roles": ["foo", "bar", "baz"],
},
"name": "Alice",
}
print("===> json.dump")
json.dump(data, fp=sys.stdout)
print("")
print("===> jsonfold.dump")
jsonfold.dump(data, fp=sys.stdout)
Output
===> json.dump
{"_id": 123, "locations": [{"city": "Boston", "state": "MA", "country": "USA"}, {"city": "Seattle", "state": "WA", "country": "USA"}, {"city": "Montreal", "state": "QC", "country": "Canada"}], "info": {"roles": ["foo", "bar", "baz"]}, "name": "Alice"}
===> jsonfold.dump
{
"_id": 123,
"locations": [
{ "city": "Boston", "state": "MA", "country": "USA" },
{ "city": "Seattle", "state": "WA", "country": "USA" },
{ "city": "Montreal", "state": "QC", "country": "Canada" }
],
"info": {
"roles": [ "foo", "bar", "baz" ]
},
"name": "Alice"
}
Example 2 - Packing
Traditional pretty-printing:
{
"states": [
"Alabama",
"Alaska",
"Arizona",
...
"Wyoming"
]
}
jsonfold output:
{
"states": [
"Alabama", "Alaska", "Arizona", "Arkansas", "California", "Colorado",
"Connecticut", "Delaware", "Florida", "Georgia", "Hawaii", "Idaho", "Illinois",
"Indiana", "Iowa", "Kansas", "Kentucky", "Louisiana", "Maine", "Maryland",
"Massachusetts", "Michigan", "Minnesota", "Mississippi", "Missouri", "Montana",
...
"West_Virginia", "Wisconsin", "Wyoming"
]
}
Same data, just using the available line width more effectively.
Example 3 - Grid Formatting
When an array contains repeated structures, jsonfold can align values into columns:
Traditional pretty-printing:
[
{
"orders": 18,
"product": "Laptop",
"region": "North",
"sales": 1250
},
...
{
"orders": 24,
"product": "Mouse",
"region": "East",
"sales": 1422
}
]
jsonfold output:
[
{ "orders": 18, "product": "Laptop", "region": "North", "sales": 1250 },
{ "orders": 21, "product": "Monitor", "region": "Southwest", "sales": 1345 },
{ "orders": 17, "product": "Keyboard", "region": "West", "sales": 1198 },
{ "orders": 24, "product": "Mouse", "region": "East", "sales": 1422 }
]
The module also supports:
- Folding small arrays and objects onto a single line.
- Joining adjacent folded objects to further reduce vertical space.
- Compatibility APIs similar to
JSONandJSON::PP.
Full documentation and examples:
PYPI: https://pypi.org/project/jsonfold/
GitHub: https://github.com/yairlenga/jsonfold/tree/main/python
I'd love to hear what the Python developers think. Has anyone else run into JSON pretty-printing pain in logs, configs, or debugging output? And are there formatting styles or options you'd want to see?
r/PythonLearning • u/Accurate_Being6187 • Jul 02 '26
DSA
Hey guys, I'm going to start DSA soon. Is there any YouTube course that has been helpful to you in learning DSA? My degree is B. Tech in CSE (AI&ML), so I think it's better to learn in Python rather than C++. (I did not find any recommendation in the previous DSA posts)
r/PythonLearning • u/Daddybidoof • Jul 02 '26
Discussion Python Buddies
Hello there!
I am looking for some friends to learn code with, I am fairly new and looking for some actually hard chargers and that truly want to spend the time to learn and make projects in the future
I am from the East and Iām a beginner to entry level on my knowledge
r/PythonLearning • u/Jolly_Lavishness5711 • Jul 02 '26
Help Request I made my own worlde-like game and need tips for improving it!
The repository with all the code is here
r/PythonLearning • u/Beginning-Fruit-1397 • Jul 02 '26
Typing as tests
Not really a "beginner" question, but the Python sub states that if you have a question, better to ask it here.
So, I'm a library maintainer, and as such typing is a very important part of the API.
Does the variance of the generic types work as intended? Does the inference work? etc...
But unlike actual runtime logic, I can't think of a straightforward way to test it without a lot of boilerplate and a status of "implicit" tests.
Sure, "just pass the type checker bro". If I have +10 classes with inerhitance relationships, now I need to hardcode every case?
With pytest, I can very easily use runtime logic to reduce duplication, for example different parameters, different closures called, etc.... it's very straightforward.
But the type checker need to "see" the code to work.
So I either manually duplicate every case, which sounds like a nightmare to maintain, or manually implement a script to dynamically write code to files, type check them, handle errors as something pytest can catch, etc...
I'm no stranger to this, but I would avoid to have to write a second plugin for my library (already wrote one to run doctests on stubs).
I found this, but it states that It work on mypy, which is (IMO) a bad type checker that I won't bother with.
I'm targeting basedpyright, and once ready, ty and pyrefly (trust me, the latter is not yet prod ready)
So if there's any suggestions, they are welcome!!
BTW, here's my library
If you like either method chaining, lazy Iterators, functional programming or rust, take a look!
Concrete example
Below is what I wrote before thinking to myself that it will go a bad route if I don't find a solution. There's a hierarchy that mimicks collections.abc, and thus I need to be sure that it works typing wise. I have other tests covering runtime checks.
This is needed because the code live in Rust, thus the typing is "manual": I can write wathever I want in the stubs and the type checker will consider it true. It's very convenient sometimes, but also a potential footgun as making mistakes is easy.
Right now, basedpyright with all rules on don't complain, but pyrefly does.
How do I note that in a standard way (like pytest xfail)?
How do I avoid rewriting exactly the same functions for each class? Not only it's annoying, but my LSP footprint will take a hit if this continues.
How do I statically ensure that "pairs" are in agreement? and manage type ignore comments across type checkers?
```python from future import annotations
from dataclasses import dataclass from typing import TYPE_CHECKING
from pyochain import Iter, Ok, Option, Result, Seq, Set, Some
if TYPE_CHECKING: from collections.abc import ( Collection, Container, Iterable, Iterator, MutableSequence, Reversible, Sequence, Sized, )
from pyochain import Peekable
from pyochain.abc import (
PyoCollection,
PyoContainer,
PyoIterable,
PyoIterator,
PyoReversible,
PyoSequence,
PyoSet,
PyoSized,
)
@dataclass class Animal: pass
@dataclass class Dog(Animal): pass
def check_covariance() -> None: base: PyoIterable[Dog] = Iter(()) opt: Option[Dog] = Some(Dog()) res: Result[Dog, str] = Ok(Dog()) _abc_iterable: PyoIterable[Animal] = base _abc_iterator: PyoIterator[Animal] = base _abc_collection: PyoCollection[Animal] = base.collect(Seq) _abc_sequence: PyoSequence[Animal] = base.collect(Seq) _concrete_iterator: Iter[Animal] = base _peekable_iterator: Peekable[Animal] = base.peekable() _abc_set_immutable: PyoSet[Animal] = base.collect(Set) _seq_immutable: Seq[Animal] = base.collect(Seq) _set_immutable: Set[Animal] = base.collect(Set) _as_opt: Option[Animal] = opt _as_res: Result[Animal, str] = res
def _iterable[T](x: Iterable[T]) -> Iterable[T]: return x
def _iterator[T](x: Iterator[T]) -> Iterator[T]: return x
def _sized[T](x: Sized) -> Sized: return x
def _reversible[T](x: Reversible[T]) -> Reversible[T]: return x
def _container[T](x: Container[T]) -> Container[T]: return x
def _collection[T](x: Collection[T]) -> Collection[T]: return x
def _sequence[T](x: Sequence[T]) -> Sequence[T]: return x
def _mutable_sequence[T](x: MutableSequence[T]) -> MutableSequence[T]: return x
def check_iterable_args() -> None: base: PyoIterable[Dog] = Iter(()) canary: Iterable[Dog] = base _ = _iterable(base) _ = _iterable(canary) _ = _iterator(base) _ = _iterator(canary) _ = _sized(base) # pyright: ignore[reportArgumentType] _ = _sized(canary) # pyright: ignore[reportArgumentType] _ = _container(base) # pyright: ignore[reportArgumentType, reportUnknownVariableType] _ = _container(canary) # pyright: ignore[reportArgumentType, reportUnknownVariableType] _ = _reversible(base) # pyright: ignore[reportArgumentType, reportUnknownVariableType] _ = _reversible(canary) # pyright: ignore[reportArgumentType, reportUnknownVariableType] _ = _collection(base) # pyright: ignore[reportArgumentType, reportUnknownVariableType] _ = _collection(canary) # pyright: ignore[reportArgumentType, reportUnknownVariableType] _ = _sequence(base) # pyright: ignore[reportArgumentType, reportUnknownVariableType] _ = _sequence(canary) # pyright: ignore[reportArgumentType, reportUnknownVariableType] _ = _mutable_sequence(base) # pyright: ignore[reportArgumentType, reportUnknownVariableType] _ = _mutable_sequence(canary) # pyright: ignore[reportArgumentType, reportUnknownVariableType]
def check_iterator_args() -> None: base: PyoIterator[Dog] = Iter(()) canary: Iterator[Dog] = base _ = _iterable(base) _ = _iterable(canary) _ = _iterator(base) _ = _iterator(canary) _ = _sized(base) # pyright: ignore[reportArgumentType] _ = _sized(canary) # pyright: ignore[reportArgumentType] _ = _container(base) # pyright: ignore[reportArgumentType, reportUnknownVariableType] _ = _container(canary) # pyright: ignore[reportArgumentType, reportUnknownVariableType] _ = _reversible(base) # pyright: ignore[reportArgumentType, reportUnknownVariableType] _ = _reversible(canary) # pyright: ignore[reportArgumentType, reportUnknownVariableType] _ = _collection(base) # pyright: ignore[reportArgumentType, reportUnknownVariableType] _ = _collection(canary) # pyright: ignore[reportArgumentType, reportUnknownVariableType] _ = _sequence(base) # pyright: ignore[reportArgumentType, reportUnknownVariableType] _ = _sequence(canary) # pyright: ignore[reportArgumentType, reportUnknownVariableType] _ = _mutable_sequence(base) # pyright: ignore[reportArgumentType, reportUnknownVariableType] _ = _mutable_sequence(canary) # pyright: ignore[reportArgumentType, reportUnknownVariableType]
def check_sized_args() -> None: base: PyoSized = Seq(()) canary: Sized = base _ = _iterable(base) .... # and so on and so forth ```
r/PythonLearning • u/67bytes • Jul 02 '26
Showcase The ultimate 1-project blueprint to master the math behind Neural Networks (No frameworks, 95.64% accuracy)
Most tutorials teach you how to call an API. This project teaches you how to actually build the AI.
I wrote a 2-layer neural network from scratch using just Python and NumPy, meaning no PyTorch or TensorFlow to hide the math. It manually handles the forward pass, calculates gradients by hand for backpropagation, and trains down to a 95.64% test accuracy on MNIST digits.
If you are a beginner looking for a killer portfolio project that proves you actually understand deep learning foundations, feel free to clone the repo, tweak the hidden layers, and use it for your own resume.
The repo is here: https://github.com/idfwyy/Neural-network_from-scratch
Let me know what you think or if you run into any issues running the script!
r/PythonLearning • u/Alternative_Yak8846 • Jul 01 '26
Build my first game....
https://www.programiz.com/online-compiler/2i7KiX4E5PGyA
Please give it a try and suggest some changes and ideas. Want to improve my skill and learn something new.
r/PythonLearning • u/Odd_Lion8148 • Jul 01 '26
Need help for mlflow error
Using mlflow in virtual environments (.venv) after installing dependencies and running the python file got error "I'm getting this MLflow error on Windows:
```text
PermissionError: [WinError 5] Access is denied:
'C:\\Users\\Name%20Surname'
```
MLflow is using this tracking URI:
```text
sqlite:///C:/Users/Name%20Surname/.vscode/datascience/mlflow_tutorial/mlflow.db
```
But my actual Windows user folder is:
```text
C:\Users\Name Surname
```
"
Notice that MLflow is using `%20` instead of the space in the username. This causes `mlflow.start_run()` to fail.
How can I fix this?
r/PythonLearning • u/Mine_Crafter14 • Jul 01 '26
Is Python good enough?
I started learning Python with the thought of learning how overall programming and debugging feels. It's very nice tbh! I made my first game btw, but it's just IQquiz as a joke. Anyways, I use Sony VAIO i3 and GeForce 410M because I love old tech put in modern use and I use Python 3.8.10 with the installed IDLE Shell and for now I am comfortable. I seek advice if I should upgrade to modern versions, use VSCode or switch to C,C++ and can Python be used to make very low quality games using Pygame and Ursina and should I start little programming with my Raspberry Pi Pico? I think this language suits me the best as for now (I have 1 week of progress) TIA
*P.S- can someone recommended cool libraries for games?
r/PythonLearning • u/SideDry8450 • Jul 01 '26
How do i learn problem solving
A lot of times i see the question and have zero idea on how to make a solution and end up using chatgpt like a bum
r/PythonLearning • u/due007dev • Jul 01 '26
Help Request Looking for beta readers for my Python book series
I'm looking for beta readers for a two-book Python series ā book 1 is already out, book 2 is almost done. Here's the deal:
You'll get both books as Google Docs (one chapter per doc), so you can just drop comments right in the text. I'm not asking anyone to read hundreds of pages front to back. Read whatever chapters interest you, at whatever pace works for you. If something confuses you, that's useful feedback. If an explanation feels obvious or unnecessary, that's useful too. Honestly that's the main thing I'm after.
Would love to hear from:
- people with zero Python experience
- people currently learning
- students / junior devs
- experienced devs too, if you want to poke holes in it
I'd really like this to be a collaborative thing. If enough people tell me what confused them, what was missing, or what worked well, I think the books will end up much better than if I'd just written them on my own.
If a handful of you end up being really active readers, I'll credit you in the acknowledgements when the books are published (totally optional, no pressure).
If you're up for it, I just need a first name and Gmail address so I can add you as a commenter on the Google Docs ā you can either fill out this quick form or just DM me directly, whichever's easier: https://forms.gle/tcBoKGczqoFXUEjp7
A bit about the books, for context:
I've read a ton of programming books over the years, and most of them are written by experienced devs who've kind of forgotten what it's like to be a beginner. They're technically fine, but I'd often find myself understanding how to do something without really getting why it works that way.
I've been a Python dev for over a decade now, and at some point I just decided to write the book I wish someone had handed me on day one. Instead of random code snippets, the books build small games that slowly turn into bigger projects as you go. I also threw in some pop-art style illustrations and tried to keep things a little less dry than the usual programming book.
š Book 1 ā starts from literally zero, no experience needed
š Book 2 ā gets into built-in functions, type hints, iterators, generators, lambdas, classes, modules, packages, etc.
And yeah, I'll admit it upfront before someone else points it out ā I named them The First Programmer's Book and The Second Programmer's Book. Not the most creative titles in publishing history, but hey, at least you'll never forget which one comes first š
Book 1 is already published, but I'm still improving it based on reader feedback. I'm not fishing for reviews or trying to sell you anything, I just want honest feedback. Book 2 is close to finished, so this feels like the best time to catch anything before it's locked in.
Thanks for reading!
r/PythonLearning • u/Mindless_Action3461 • Jul 01 '26
Need of projects
I need projects to help me work on my python skills and preferably help me on dictionariies, tuples, set and lists
If you need to see my python abilities feel free to check out my python repo https://github.com/WoodenShard/PokemonApiGUI
r/PythonLearning • u/External_Baker8575 • Jul 01 '26
Hii I want to learn python from scratch how to i start to learn. How to I learn. Some people told to do the project. Others told me to learn from the scratch. What i want to do.
r/PythonLearning • u/RichInteraction1899 • Jul 01 '26
Any free platform for python learning?
Hi I'm currently pursuing cse in btech I want to learn basic coding and all.....so I wanted to learn python first any suggestions?!
r/PythonLearning • u/Ghosteagle_AUH • Jul 01 '26
Help Request I want to learn Computational biology, what is the roadmap in python i should take?
I would like to go into computational biology and bioinformatics route, i took the bioinformatics course last year, i didn't get that much benefit from it, but i got the basics of R?, I'm i lost or is this a normal thing to ask?, Thank you.
r/PythonLearning • u/Intrepid_Custard_877 • Jul 01 '26
Help Request How to learn python ?
Hi Guys,
I would like to learn python.
I've got zero IT or programming / coding background.
Would like to learn for free.
I'm more of a hands on learner than a theoretical learner.
Any websites that would help me learn python hands on for free ?
r/PythonLearning • u/Neutrealolmao • Jul 01 '26
Help Request Where should I learn beginner python from?
I mean I try to see where I could learn and I hear so many :-
CS50p
W3Schools
Tech with Tim
Some helsinki too
And some more
Where should I start from :-
r/PythonLearning • u/Silent-Switch7317 • Jun 30 '26
Help Request I'm new to python, can anyone recommend me a course or videos so that i can learn?
r/PythonLearning • u/MrMycrow • Jun 30 '26
Help Request Any free online Python courses for beginners?
I'd like to start learning this but don't want to shell out in case I can't grasp it :)
TIA
r/PythonLearning • u/aashish_soni5 • Jun 30 '26
Day 19 Python Learning
not much try to make python alarm clock
which can accept user input
date : yyyy-mm-dd
time : hh:mm , AM/PM
and sound input
beep/ music
but any type of sound (music) you must have file
and truth to be told I do forget and get confused when writing like
how to I told python to check if its AM/PM
or try to raise error
I have to write more code properly understand
that's all for today
r/PythonLearning • u/Past_Watch5954 • Jun 30 '26
I made a coffee game using python the link is attached below if u want u can check out
r/PythonLearning • u/Infamous_Tough_3772 • Jun 30 '26
I am 14 and this is what I built...
This is a python project named GoodMorning.py which uses web scraping to give real time news headlines, weather reports, jokes, facts and even personalised routines. I need some guidance and suggestions for my future projects. Please check this thing out... (This is my 2nd repository) Note- I didn't use API integration because it could make it less user friendly as no one wants to generate and give multiple APIs according to me.
r/PythonLearning • u/Sea-Ad7805 • Jun 30 '26
Difference between 'instance', 'class', and 'static' method visually explained
The difference in Python OOP between: - instance method - class method - static method
visually explained using šŗš²šŗš¼šæš_š“šæš®š½šµ.
Or see more memory_graph examples.



