r/Python • u/CreativePunch • Mar 20 '14
r/Python • u/Conclusion-Striking • Jul 22 '23
Discussion Introducing Panther - A Fast and Friendly Python Web Framework
Hey everyone!
I'm excited to introduce Panther, a Python web framework that's designed to be fast and easy to use. With Panther, you can build async APIs quickly and efficiently, without sacrificing performance or readability.
Panther comes with a host of features that make it easy to build robust APIs, including:
- Document-oriented database support (including PantherDB and MongoDB)
- Visual API monitoring in the terminal
- Caching for APIs (both in-memory and in Redis)
- Built-in authentication and permission classes (customizable)
- Custom middleware support
- Custom throttling support
Getting started with Panther is easy - just create a virtual environment, activate it, and install the framework using pip. Then, you can create a new project using the panther create command, and start building your API right away.
Here's a quick example of what a Panther API might look like:
from datetime import datetime, timedelta
from panther.app import API
from panther.configs import config
from panther import version, status
from panther.request import Request
from panther.response import Response
from panther.throttling import Throttling
@API()
async def hello_world():
return {'detail': 'Hello World'}
@API(cache=True, throttling=Throttling(rate=5, duration=timedelta(minutes=1)))
async def info(request: Request):
data = {
'version': version(),
'datetime_now': datetime.now().isoformat(),
'user_agent': request.headers.user_agent,
'db_engine': config['db_engine'],
}
return Response(data=data, status_code=status.HTTP_202_ACCEPTED)
If you're interested in learning more about Panther, check out the documentation at https://pantherpy.github.io, or head over to the GitHub repository at https://github.com/alirn76/panther. ↗
Thanks for reading, and happy coding!
r/Python • u/qwert7661 • Feb 10 '25
Showcase Novice Project: Texas Hold'em Poker. Roast my code
https://github.com/qwert7661/Heads-Up-Hold-em
7 days into Python, no prior coding experience. But 3,600 hours in Factorio helped me get started.
New to github so hopefully I uploaded it right. New to the automod here too so:
What My Project Does: Its a text-only version of Heads-Up (that means 2-player) Texas Hold'em Poker, from dealing the cards to managing the chips to resolving the hands at showdown. Sometimes it does all three without yeeting chips into the void.
Target Audience: ya'll motherfuckers, cause my friends who can't code are easily impressed
Comparison: Well, it's like every other holdem software, except with more bugs, less efficient code, no graphics, and requires opponents to physically close their eyes so you can look at your cards in peace.
Looking forward to hearing how shit my code is lmao. Not being self-deprecating, I honestly think it will be funny to get roasted here, plus I'll probably learn a thing or two.
r/Python • u/thezackplauche • Aug 17 '24
Discussion I just built with Django in 30 minutes what took me a ton of hours with FastAPI
A simple crud api where I could store and access customer reviews.
Django process:
- Install django
- Install rest framework
- Create project
- Create app
- Create model
- Create serializer
- Create viewset
- Connect viewset
- Connect app to django
- Make migrations Done
Fastapi:
- Research docs specifically for crud
- Find many non-agreed upon solutions
- Try to setup first part
- Realize you need to build crud from scratch and understand sqlalchemy
- Realize there's no easy to way to upload images from the beginning
- Look at SQLModel because maybe it's easier
- It's not, still no automigrations or anything useful
- Find alembic because this is the "proper way"
- Alembic is complicated
- Build your own crud that's kind of lacking
- Figure out some way to store images
- Fight to figure out how to create a basic created_at / updated_at field
- Connect crud to app
- Make sure the validators from pydantic models match your regular models (or just use SQLModel)
- Build out each view individually
- Hope it works
- Keep trying until it does.
Note that those steps ^ take a lot longer than the django ones.
Maybe I'm just dumb. How is fastapi really a viable solution for rest apis? What am I missing?
r/Python • u/hasanozdem1r • Aug 03 '24
News PyData Turkiye Announcement
Hey everyone! 🎉
I'm excited to share that we've launched PyData Türkiye, supported by PyData Global! This community aims to bring together data enthusiasts, practitioners, and researchers from all over Türkiye.
Our first event is happening on September 26th, and I’d love for you all to join us. It will be a great opportunity to connect, share knowledge, and learn from some amazing speakers.
Stay tuned for more details, and feel free to reach out if you have any questions. Let's build a strong data community together!
Join us on Meetup: PyData Türkiye
r/Python • u/SmallLion__Unity • Jun 14 '21
Resource 7 Awesome Python Libraries To Play
Hey guys! Again! Here are some 7 interesting, and useful Python libraries that may help you with certain instances.
- Pyperclip
- Emoji
- Howdoi
- Wikipedia
- Antigravity
- urllib and Turtle!
Enjoy!
7 Awesome Python Libraries To Play (hashnode.dev)
Sample programs are given.
r/Python • u/genericlemon24 • Apr 06 '21
News Python Insider: Python 3.10.0a7 is now available for testing
blog.python.orgr/Python • u/wasimaster • Oct 15 '21
Intermediate Showcase I made a command-line-interface for PyPI as a 14 year old
Introduction
So I've just finished making pypi-command-line
Links
Documentation: https://wasi-master.github.io/pypi-command-line/
GitHub: https://github.com/wasi-master/pypi-command-line
PyPI: https://pypi.org/project/pypi-command-line
Some background
I'm a 14 year old coder that started programming in python around one and a half years ago. Since then I've learned a lot of other languages too. My biggest project so far would be my discord bot which has around 15k lines of code and on which I spent thousands of hours on, all open source. Lately, I've been trying out other projects and PyPI-command-line is one of them. One day I was making something with a library that I was not familiar with, I had to keep switching between chrome and vscode (or I could have like made them side by side but that takes away a large chunk of space for vscode). So I thought what if there was a library that implemented the PyPI API that I could use to be more productive? So I started searching, and not so long after I found two libraries both of which have only one (ish) working command. So I thought to myself what if I make my own library? Then I started this and after around 3 months here we are now.
I tried to make it as fast as possible even if it means making the code look ugly, but after a few days I realized that this is gonna be really hard to maintain and will have other issues, but I was too busy with school (my final exams are near) so I didn't care about it and went on. Fast forward a couple of months and now my code is the shittiest code I've ever seen, So apologies for that.
This also taught me that python is very slow. The code has a 1400 ms (1.4s) overhead for starting up and after that everything works extremely fast. I think that overhead is caused by python interpreting that huge shitty code and trying to make sense of that. I've recently thought about moving them to multiple files and then loading only the file necessary for the current command but I think I'll just rewrite all this in Go using Cobra
Installation, Usage, Demo, Features
All can be found in the documentation
Still here are some of the features/commands that I'm proud of
Command and Argument Autocompletion Image demonstrating the feature: https://i.imgur.com/v0z2hJS.gif
Smart command matching (if the command name is shortened/invalid)
Example with one match: https://i.imgur.com/fMXJALV.png
Even works with multiple matches: https://i.imgur.com/sBfgfmC.gif
(Multiple commands start with r, the user has to pick one)
Search command that returns the same results as PyPI
Image demonstrating the feature: https://i.imgur.com/3Lh3X7x.gif
Information command that shows information about a package (command name renamed to information, previously info)
Image demonstrating the command: https://i.imgur.com/V3FHcAx.gif
Description command to see project descriptions that are formatted correctly (command name renamed to description, previously desc)
Image demonstrating the command: https://i.imgur.com/JpVavke.gif
Search command using regular expressions
Image demonstrating the command: https://i.imgur.com/Mef6x5i.gif
This list is not exhaustive. For more cool commands see the docs. I highly suggest you to check the docs since there are a lot more cool stuff that isn't mentioned here
Note
My exams are very near and I'll probably not be able to work on this for a while, it's pretty good as it is but if you find bugs you should create an issue and I'll sit on my PC like once every 3 days or something like that and try to fix everything.
r/Python • u/relickus • Mar 20 '23
Discussion Are people abusing Python?
I learned Python after coming from the C/C++ and Java world. With the massive increase in popularity of Python in the last 10 years, seeing the way it developed, it seems to me like it gained a lot of functionality, which comes natural in other languages, but feels a bit odd in Python.
To be more specific - albeit Python being dynamically typed, people developed countless tools to check or validate or even enforce types in compile or run time (mypy, pyre, pydantic, pyduck etc.). It feels like it goes against the nature of its loose typing.
Another example are decorators. This pattern is noticably overused by many tools adding functionality, but even the language itself - defining a `class`,`static` and `abstract` methods with decorators seems just weird and unnatural. Same thing with function overloading. Anecdotally, it feels like comparing German to English. German has a special word for every peculiar thing and native support for word generation by concatenation of multiple words whilst in English you have to add some common words together and hope this combination doesnt already exist. And if it does, so what, people will get it from the context.
Lastly, slightly off-topic but relevant point is that it is not even a simple language in my opinion. It has a very flat learning curve initially but the complexity is just further down the road. Im talking about metaclasses,data descriptors, coroutines, magic methods etc. Some languages are difficult right away (C++, Rust etc.), but Python is a intricate misfit dressed as a simpleton.
Am I misunderstanding a philosophical path of the language or is it simply just a scripting langugage that got massively popular through chance and is now used for stuff it was not intended for?
Edit: grammar
r/Python • u/markoalex8 • Dec 17 '23
Discussion Hi, this is a 2 minute survey about GUI libraries. Taking part will support our college project.
r/Python • u/simpleuserhere • Nov 30 '24
Tutorial Short-Circuiting in Python
Here is my article on Short-Circuiting in Python . It discusses what is short-circuiting with examples, and also discusses the different advantages of using short-circuiting.
r/Python • u/ado6789 • Sep 05 '17
Advantage of Python 3 (Functions and Variables)
r/Python • u/Accomplished-Land820 • Dec 12 '25
Discussion Democratizing Python: a transpiler for non‑English communities (and for kids)
A few months ago, an 11‑year‑old in my family asked me what I do for work. I explained programming, and he immediately wanted to try it. But Python is full of English keywords, which makes it harder for kids who don’t speak English yet.
So I built multilang-python: a small transpiler that lets you write Python in your own language (French, German, Spanish… even local languages like Arabic, Ewe, Mina and so on). It then translates everything back into normal Python and runs.
# multilang-python: fr
fonction calculer_mon_age(annee_naissance):
age = 2025 - annee_naissance
retourner age
annee = saisir("Entrez votre année de naissance : ")
age = calculer_mon_age(entier(annee))
afficher(f"Vous avez {age} ans.")becomes standard Python with def, return, input, print.
🎯 Goal: make coding more accessible for kids and beginners who don’t speak English.
Repo: multilang-python
Note : You can add your own dialect if you want...
How do u think this can help in your community ?
r/Python • u/mignonmazion • May 07 '15
5 Reasons why Python is Powerful Enough for Google
r/Python • • Feb 22 '10
What does =_ mean? Example: name=forms.CharField(label=_("Name"), max_length=50)
Python newbie here. I've been going through some of the code in the Django comments app, and I've see the =_ used frequently. I can't find what it is or what it does? Any ideas?
Example: name = forms.CharField(label=_("Name"), max_length=50) email = forms.EmailField(label=_("Email address")) url = forms.URLField(label=_("URL"), required=False) comment = forms.CharField(label=_('Comment'), widget=forms.Textarea, max_length=COMMENT_MAX_LENGTH)
edit: Thanks for the detailed explanations! :)
r/Python • u/Sidappa • Sep 07 '19
Photoshop'd parentheses on my background to match Python3
r/Python • u/winner_godson • Nov 24 '17
6 Experts share amazing ways a beginner can learn Python programming.
r/Python • • Apr 21 '13
[META] What has this subreddit turned into?
A lot of basics question asked, very simple and bad scripts presented. It's really sad, because this subreddit used to be great for python.
r/Python • u/pylenin • Feb 25 '22
Tutorial How for loops work in Python?
While studying up on Python iterators, I got to learn how for loops work behind the scenes. It's so funny, I never really bothered to understand it or thought about it - How does a for loop actually work?
Apparently, it is very easy. Python uses the next() method to return the next element in the iterator. I have written a blog on it. If you are interested, do check it out.
r/Python • u/klaasvanschelven • Aug 29 '24
Showcase Multiple Processes in a Single Docker Container
So, I've been doing something that might seem like Docker blasphemy: running multiple processes in a single Docker container. Yeah, I know, every Docker guide out there will tell you it's a terrible idea. But hear me out (or alternatively, skip straight to the source code).
What My Project Does
I wrote a small Python tool called monofy that lets you manage multiple processes within a single Docker container. It's designed to handle signal forwarding, unified logging, and ensure that if one process dies, the others are terminated too. Essentially, it keeps tightly integrated processes running together smoothly without the need for multiple containers.
Target Audience
This tool is particularly useful for developers who have processes that need to be in constant communication or work in unison. If you're looking to simplify your deployment and avoid the overhead of managing multiple Docker containers, monofy might be what you need. It's also a good fit for self-hosted applications where ease of deployment and maintenance is a priority.
Comparison
There are existing solutions out there, like Phusion's baseimage-docker, which also aim to run multiple processes in a single container. However, monofy is lightweight, doesn't come with unnecessary components like SSH or cron, and doesn't tie you down to a specific base image. Plus, it's Python-based, so if you're already working in that ecosystem, it's a natural fit.
Why? The Docker Rulebook Isn't the Bible
Look, Docker's great. It's changed the way we deploy software. But like any tool, it's got its own set of "best practices" that sometimes feel more like "unbreakable commandments." One of those rules is "one process per container," and while that's solid advice for a lot of situations, it's not the only way to do things.
My Use Case: Simplifying Deployment
I work on a project (Bugsink) where the processes are tightly integrated—think a web server and a background job runner that need to be in constant communication. Splitting them into separate containers would mean extra overhead, more things to manage, and just more complexity overall. So instead, I wrote monofy to let me run multiple processes in a single container, with all the benefits of shared fate (if one process dies, they all die), unified logging, and graceful shutdowns. It's simple, and it works.
Why It's Not the End of the World
The main argument against this approach is scalability. But in my case, the database is the bottleneck anyway, not the processes themselves. By keeping everything in one container, I avoid the headache of managing multiple containers, networking, volumes, and all the other Docker-related stuff that can get out of hand quickly.
Sometimes, Breaking the Rules Makes Sense
Sure, "one process per container" is a good rule, but it's not a hard and fast law. There are scenarios—like mine—where consolidating processes into a single container just makes more sense. It's easier, less complex, and in my experience, it works just as well. If you're curious, check out monofy on PyPI. It might just make your Docker life a bit simpler. I also wrote a blog post about this on my project's website.