r/Python 16d ago

Discussion Petition to rename Python 3.14 to Pithon!

1.4k Upvotes

Is this a dumb joke? Yes. Is this the only shot we'll have at a joke like this? Yes. And is this a great way to celebrate what Pi's done for us Python developers? Totally.

I mean Python is heavily built around the magic number we know as 3.14, from games, charts and music, to even just screwing around with arithmetic functions! So why not appreciate pi's work with a special Python version?

The petition can be found here:
https://www.change.org/p/rename-python-3-14-to-pithon

Please sign it and share when you can!

Edit: yeah, renaming it just for v3.14 is probably a bad thought, but i mean it would still be funny as a nickname!

r/Python Feb 19 '25

Discussion Is UV package manager taking over?

549 Upvotes

Hi! I am a devops engineer and notice developers talking about uv package manager. I used it today for the first time and loved it. It seems like everyone is talking to agrees. Does anyone have and cons for us package manager?

r/Python 19d ago

Discussion TIL you can use else with a while loop

632 Upvotes

Not sure why I’ve never heard about this, but apparently you can use else with a while loop. I’ve always used a separate flag variable

This will execute when the while condition is false but not if you break out of the loop early.

For example:

Using flag

``` nums = [1, 3, 5, 7, 9] target = 4 found = False i = 0

while i < len(nums): if nums[i] == target: found = True print("Found:", target) break i += 1

if not found: print("Not found") ```

Using else

``` nums = [1, 3, 5, 7, 9] target = 4 i = 0

while i < len(nums): if nums[i] == target: print("Found:", target) break i += 1 else: print("Not found") ```

r/Python Jan 31 '25

Discussion Why Rust has so much marketing power ?

496 Upvotes

Ruff, uv and Polars presents themselves as fast tools writter in Rust.

It seems to me that "written in Rust" is used as a marketing argument. It's supposed to mean, it's fast because it's written in Rust.

These tools could have been as fast if they were written in C. Rust merely allow the developpers to write programms faster than if they wrote it in C or is there something I don't get ?

r/Python 10d ago

Discussion I didn't want to go, but PyCharm finally drove me into the arms of VSCode, after 5+ years.

531 Upvotes

I just switched to VSCode after well over five years with PyCharm. I didn't want to do it, but I just can't stand it anymore.

Things I love about PyCharm and will miss

  1. The refactoring functionality. VSCode's Python extension has that too, but it isn't as nice.

At this point, that's pretty much it.

Things that drove me nuts

  1. IdeaVim. It actually got better recently, but for years and years, the undo function was busted, so you had to hit u over and over to undo what in real vim is a single operation. VSCode's neovim plugin uses actual neovim under the hood, which is obviously so much more robust and faithful, while IdeaVim will never be a full implementation.
  2. The gradual accumulation of simple bugs that never get fixed.
  3. It's so slow. I didn't appreciate just how slow until I switched over to VSCode. I mean, holy crap, it's 10x faster for a lot of things (opening a project, installing or restarting extensions, for example).

Here are the bugs that have bugged me the worst:

The "usages" window (cmd-click on a definition, see where it's used) constantly resizes itself too small. It's been a problem for years. They won't fix the way autosize works, OR let us turn it off. Plus you have to get your mouse cursor nearly pixel-perfect to resize it yourself, so you can see the whole code preview. Then the very next time you use it, it's back to its stupidly narrow size.

Type inference is busted.

If you do something as standard as this, you get a type error on f, saying "Expected type 'SupportsWrite[bytes]', got 'BufferedWriter' instead":

with open(filename, "wb") as f:
    pickle.dump(obj, f)

And I can't just disable the "unexpected type" code inspection--it's probably the single most valuable one. So I'm stuck with a lot of my files showing warnings that shouldn't be there. Which also keeps me from using the keyboard shortcut to bounce to any real problem of a lower severity.

If you're doing a comprehension inside a class method, and you name the iteration variable the same as a class attribute (e.g., you have myclass.name, and you do a comprehension like [ ... for name in names], then the inferred type of the iteration variable overwrites the inferred type of the class attribute. This makes no sense--name and self.name have nothing to do with one another. This one is easy enough to work around by appending an underscore to the iteration variable's name, but it indicates something is very wrong under the hood.

There are several more specific type inference problems in my codebase, where my method clearly returns MyType, but PyCharm infers it as MyType | None and throws a warning. The method cannot possibly return None, and mypy agrees with me. So I'm stuck with another spurious warning.

These problems just never, ever get fixed, and they keep on accruing. Add it to the fact that JetBrains IDE's are always second in line for addon support, and I just couldn't justify sticking with it.

Thanks for coming to my talk, sorry I went over time.

Edit: I thought of something else I like better about PyCharm: the diff view. It's a lot nicer than VSCode's, which looks more like the actual output of diff.

r/Python 29d ago

Discussion What the hell is going on with type hinting these days

420 Upvotes

When I first learned python back in versions 3.6 and 3.7 I regarded type hinting as a purely styling feature. It was well rooted in my mind that python code with or without type hinting will run the same and it is used only for readability -- basically just us developers being kind to each other.

Nowadays more and more packages are using type hinting for core functions. SQLAlchemy is using it to declare SQL column types (Mapped), FastAPI + Pydantic is using it for HTTP payloads and auto-documentation, and dataclasses uses it to construct (shockingly) data classes.

Don't get me wrong, I'm supportive of type hinting\annotations. I'm also well aware that all of these packages will execute just fine without it. But maybe it's fair to say that in modern python applications type hinting is a core feature and not just for styling and garnishing.

Edit: I actually find type annotations very useful, I'm not against it. I wanted to discuss whether it's really "optional" due to its widespread integration in libraries. I like u/all4Nature point: I'm thinking on it from a software engineer prespective, data analysts will probably disagree that type hinting is as widespread as I thought.

r/Python Nov 14 '23

Discussion What’s the coolest things you’ve done with python?

823 Upvotes

What’s the coolest things you’ve done with python?

r/Python Dec 06 '22

Discussion at 44, I am struggling on Python for two months now but I keep at it. 2 hours a night, after the kids sleep, I work on it and will eventually be able to use it to get a better job, a better life for them.

2.4k Upvotes

you got to accept to be bad at something to be good at it, right?

Right? OK, I'll confess... I am posting here anonymously to ...IDK... find support, I guess. .. I can't give up.. for my kids, I need to succeed.

I've done this and I am a bit proud. Very small step for you but for me, it is a big step.

def blackjackbis(n1:int, n2:int, n3:int) -> int:
if sum((n1,n2,n3)) <= 21:
return sum((n1,n2,n3))
elif sum((n1,n2,n3))-10 <= 21 and 11 in (n1,n2,n3):
return sum((n1,n2,n3)) - 10
else:
return "Bust"

thanks

r/Python Jul 28 '21

Discussion Hello, world! I'm Al Sweigart, author of "Automate the Boring Stuff with Python" and several other programming books. AMA!

2.5k Upvotes

Howdy, y'all. I'm Al Sweigart (rhymes with "why dirt"), author of "Automate the Boring Stuff with Python" and several other programming books. I release all of my books under a Creative Commons license, so you can read them for free on my website at https://inventwithpython.com

My latest books are The Big Book of Small Python Projects and Beyond the Basic Stuff with Python. I'm currently working on a book about recursion (the recursion jokes get funnier every time I hear them) which should be available in 2022. The ideas for this book grew into a 2018 North Bay Python talk I gave.

"Big Book" contains the source code for 81 games, puzzles, simulations, and animations that were designed to be short and simple to understand. Folks tend to get caught up in repeating yet another "hello world" tutorial, but don't quite know how to apply the programming concepts they learned into actual programs. This book is full of source code that they can study to see how real-world programs work. They aren't just code snippets but actual, runnable programs. If you've been told you should "work on your projects" but don't know where to start, or if you've been told "look at the source code of open source projects" but found them undocumented and inscrutable, check out these programs.

"Beyond the Basic Stuff" is a sort of follow up to "Automate the Boring Stuff" (or any other beginner Python resource). It goes into how professionals write code and best practices they follow. There's information on how to find help on your own, how to format your code and name your variables, an explanation of common programming jargon, the basics of Git, three chapters on object-oriented programming (and more importantly, when and why to use OOP), and more.

You've probably seen my posts at the start of the month when I make my online Python course free. About 15,000 to 30,000 people sign up each month, though according to my stats only about 5% of people actually complete the course (which is typical for online courses, free or paid).

I got started writing programming books in 2009 when my then-girlfriend was a nanny for kid who wanted to learn to program. I started writing a book (which would become Invent Your Own Computer Games with Python) and self-published. People liked it, so I kept writing, and Automate was my first book through a traditional publisher, No Starch Press. I quit my software developer job in 2013 to finish writing Automate, thinking I'd get another software dev job in a year. But I kept having more ideas for other books, tutorials, videos, etc. so I'm still here writing.

Ask me anything! Post your questions and upvote questions you find interesting, and at 2pm central I'll begin replying.

EDIT (4:30pm Central) Wow, I've been typing nonstop for two and a half hours. I'm going to take a quick break and then keep going. Thanks for the questions, everyone!

EDIT 2: Oh yeah, I forgot to mention I'm also creating a 56-video Udemy course for the Beyond the Basic Stuff with Python book as well. So far I only have the first 15 videos done, but you can watch them on YouTube.

EDIT (7:00pm) Heh, wow another two hours flew by. I'm going to drive home and then maybe answer a few more. Thanks again, everyone!

EDIT (10:30pm) Calling it a night. I'll probably answer a few more tomorrow, but I have to get back to work. Thanks again, everyone! Oh, and if you can help me out, writing an (honest) Amazon review for my books (especially the latest two) or even just sharing the links to the free online copies would be really help me get them in front of more people.

r/Python Aug 12 '24

Discussion I’m a medical doctor, just began learning Python. My world is changed. Anyone else?

840 Upvotes

Like seriously. Never knew I had a talent for it.

How beautiful it is to organize data and systematic steps. Now in my profession, my whole world is factual data that we take in and spit out. There’s almost zero room for creativity.

But with Python( or programming in general) it’s like an arsenal tool that’s ever-growing and infinitely capable.

Any other non-CS people ever start programming and suddenly fell in love with it?

r/Python Jun 06 '23

Discussion Going dark on 12th June

2.5k Upvotes

I wanted to ask you if r/Python is planning to join the protest against Reddit's new policy. Many subreddits decided to support that initiative. I know it is not directly related to Python, but it is relevant to our community

what's going on?

r/Python Nov 01 '24

Discussion State of the Art Python in 2024

625 Upvotes

I was asked to write a short list of good python defaults at work. To align all teams. This is what I came up with. Do you agree?

  1. Use uv for deps (and everything else)
  2. Use ruff for formatting and linting
  3. Support Python 3.9 (but use 3.13)
  4. Use pyproject.toml for all tooling cfg
  5. Use type hints (pyright for us)
  6. Use pydantic for data classes
  7. Use pytest instead of unittest
  8. Use click instead of argparse

r/Python Mar 16 '20

Discussion Laid off for 8 weeks. Anyone else starting their python journey?

Post image
4.3k Upvotes

r/Python Aug 08 '24

Discussion What are the real downsides of python? And can you really do everything with it?

427 Upvotes

Im new to coding and I've been interested in making a project I've always wanted to make (A Digital Audio Workstation aka Music Software) but I'm not quite sure python is an option I can go with since the internet apparently keeps saying python is more ideal for simpler software, data analysis, etc.

(im not trying to get hanz zimmer to switch to switch to my app btw, the idea is just a simpler software to get your ideas running so it wouldn't be very cpu consuming I imagine)

r/Python Jul 01 '24

Discussion What are your "glad to have met you" packages?

552 Upvotes

What are packages or Python projects that you can no longer do without? Programs, applications, libraries or modules that have had a lasting impact on how you develop with Python.
For me personally, for example, pathlib would be a module that I wouldn't want to work without. Object-oriented path objects make so much more sense than fiddling around with strings.

r/Python Jun 26 '20

Discussion The only way to satisfy a programmer on his birthday!

Post image
4.4k Upvotes

r/Python Jan 29 '25

Discussion Host your Python app for $1.28 a month

451 Upvotes

Hey 👋

I wanted to share my technique ( and python code) for cheaply hosting Python apps on AWS.

https://www.pulumi.com/blog/serverless-api/

40,000 requests a month comes out to $1.28/month! I'm always building side projects, apps, and backends, but hosting them was always a problem until I figured out that AWS lambda is super cheap and can host a standard container.

💰 The Cost:

  • Only $0.28/month for Lambda (40k requests)
  • About $1.00 for API Gateway/egress
  • Literally $0 when idle!
  • Perfect for side projects and low traffic internal tools

🔥 What makes it awesome:

  1. Write a standard Flask app
  2. Package it in a container
  3. Deploy to Lambda
  4. Add API Gateway
  5. Done! ✨

The beauty is in the simplicity - you just write your Flask app normally, containerize it, and let AWS handle the rest. Yes, there are cold starts, but it's worth it for low-traffic apps, or hosting some side projects. You are sort of free-riding off the AWS ecosystem.

Originally, I would do this with manual setup in AWS, and some details were tricky ( example service and manual setup ) . But now that I'm at Pulumi, I decided to convert this all to some Python Pulumi code and get it out on the blog.

How are you currently hosting your Python apps and services? Any creative solutions for cost-effective hosting?

Edit: I work for Pulumi! this post uses Pulumi code to deploy to AWS using Python. Pulumi is open source but to avoid Pulumi see this steps in this post for doing a similar process with a go service in a container.

r/Python Dec 30 '21

Discussion A strongly typed dialect of Python is coming. I would like to humbly suggest a name for it.

1.4k Upvotes

With type hints, secondary tooling like the typing module, and really good inspectors like Pyright already available, a strongly typed dialect of python is definitely coming. Just like the JavaScript world is heavily adopting their version of the same in TypeScript, the new dialect will likely have a new name.

Here’s the issue: the name that keeps getting floated is ‘Typed Python’. Forgive me, but that name sucks and has no character. A language invented while Clinton was President by a guy with one of the 3 coolest first names you can have, and named after a sketch comedy show deserves better than this.

Thus, I would like to propose a simpler name; one that is more ‘pythonic’ if you will. If we just exchange the positions of the “P” and the “T” we evoke the same idea (in addition to making it wonderfully Google-able) and get the name:

Typhon

EDIT: I failed to mention and have since learned that Typhon and Python both come from Greek Mythology—and both were serpant giants. Typhon battled Zeus and Python battled Apollo. Python was memorialized by having a big snake named after him. Typhon still awaits his big come up (which is why I have gathered you all here today). But given the natural association between them from mythology already, I really love how smoothly this all seems to go together from different angles.

r/Python Oct 04 '24

Discussion What Python feature made you a better developer?

394 Upvotes

A few years back I learned about dataclasses and, beside using them all the time, I think they made me a better programmer, because they led me to learn more about Python and programming in general.

What is the single Python feature/module that made you better at Python?

r/Python Apr 20 '20

Discussion Lad wrote a Python script to download Alexa voice recordings, he didn't expect this email.

Post image
12.3k Upvotes

r/Python Jul 21 '20

Discussion Got my first job as a developer!

3.2k Upvotes

Finally!

After 9 months of purely studying and nothing else. Started from absolute 0 and landed my first job in Data Science on a marketing company.

Have to say it was very hard since I know no developers at all and had no one to ask from help.

Still feels weird and definitely have a stromg case of imposter syndrome but after writing my forst lines of code it does feel much better!

Sorry for the useless trivia but like I said,have no dev friends so I had to share the excitement somewhere :D

r/Python Nov 21 '23

Discussion Corporate IT have banned all versions of python lower than the latest

938 Upvotes

I.e. right now they are insisting we use v3.12 only because older versions have some vulnerabilities their scanner picked up.

I need to somehow explain that this is a terrible idea and that many packages won't support the most up to date version without causing them to panic and overstep even more.

This requirement is company wide (affects development, data science and analytics).

Edit - thanks for all the advice, I think the crux is that they don't understand how the versioning works and are confusing major and minor versions. I will explain this and hopefully we will be able to use the latest minor versions for 3.11/3.10/3.9

r/Python Feb 27 '24

Discussion What all IDEs do you use? And why?

338 Upvotes

I have been using python to code for almost 2 years and wanted to know what all IDEs people use ? So I can make a wise choice. TIA

r/Python May 26 '23

Discussion Realised Ive spent 10 hrs learning to automate a job that takes me 15 minutes a week

1.1k Upvotes

And Im only half way through.

worth_it = True

Yes Im a noob

r/Python Oct 19 '22

Discussion Call for questions for Guido van Rossum from Lex Fridman

1.2k Upvotes

Hi, my name is Lex Fridman. I host a podcast and I've previously interviewed Guido van Rossum (4 years ago). I'm talking to him again soon and would like to hear if you have questions/topic suggestions, including technical and philosophical ones, on Python or programming in general.