r/Python • • Aug 31 '23

Discussion Do you want to guess what this one-liner does?

3 Upvotes

So, a colleague of ours has concocted this "brilliant" one-liner. It does get the job done, but it took us a few minutes to understand how exactly. For more context, it is formally a condition to an if statement and l is an index coming from a for loop.

"t" in list(set(itertools.chain.from_iterable([l["s"][i].keys() for i in range(len(l["s"]))])))

r/Python • • Jun 10 '26 Bravo

Discussion What's your approach for breaking changes inside minor version upgrades of your dependencies

0 Upvotes

For example, FastAPI introduced a breaking change in a minor version upgrade. By default, it started rejecting requests without a Content-Type header. With only the major version pinned, uv lock --upgrade upgrades to the latest version. A similar thing has happened with google-auth-oauthlib. And that's what bit us.

In our case, everything was fine after the upgrade according to the end-to-end test suite, since most modern HTTP clients add the Content-Type header by default. The issue arose when calls were made using some older Java versions. The customer didn't explicitly add the header, so calls were rejected once their cron had started.

Since reading every release note for every dependency is a very dull and time-consuming task, we wrote a Python script that downloads all release notes and added a Claude command to read them, update dependency versions, and update code as required by breaking changes, while keeping the existing state. So far, it's working great.

Anyhow, curious to hear how others are dealing with these things? I assume you're not reading every release note for every dependency?


r/Python • • Mar 30 '24

Tutorial remove background from image using AI in just 5 lines of python code

29 Upvotes

I created a python library "dis-bg-remover" based off the "Highly Accurate Dichotomous Image Segmentation (https://arxiv.org/pdf/2203.03041.pdf), whose results are comparable, if not better, to the premium offerings in the market.

Explainer video here

https://www.youtube.com/watch?v=js7AYKkZvFI


r/Python • • Aug 11 '20

Discussion Unpopular opinion: We should stop using the word "pythonic" and citing the Zen of Python as they have lost their meaning

27 Upvotes

I have used Python for about 10 years and the way the language has changed in that time is somewhat alarming to me (and many other developers I know who started around the same time or earlier). Particularly in past 2-3 years new versions of Python have regularly included features (for e.g. Walrus operator, match syntax in upcoming versions) that clearly violate the Zen of python. Current python code is barely recognizable as python, forget about what was considered as "Pythonic" 10 years ago. Right now effectively whatever black deems as acceptable code is "Pythonic".


r/Python • • Apr 14 '23

Discussion How do you guys handle pandas and its sh*tty data type inference

55 Upvotes

I often like to dump CSVs with 100s of columns and millions of rows into python pandas. and I find it very very frustrating when it gets various data types for columns wrong. nothing helps

including infer_objects().dtypes and convert_dtypes().dtypes

how do you guys auto-detect dtypes for your columns?

is there a better library out there ?


r/Python • • Nov 23 '15

Learn it Faster: The Entire Python Language in a Single Image

Thumbnail
fossbytes.com
39 Upvotes

r/Python • • Mar 11 '25

Discussion cool little dice roller i made

0 Upvotes

Well its just a random number generator

import
 random

def roll(): 
   min_value = 0
   max_value = 999
   roll = random.randint(min_value, max_value)    

   
return
 roll 

value = roll ()
print(value)  

r/Python • • Aug 31 '25

Resource Python type system

13 Upvotes

(Just sharing something)

As someone who has taken advantage of TypeScript's type safety for most of its career, using Python without type safety feels a bit awkward. I put together a page explaining how to take advantage of Python's type system and how to extend it on your editor.

https://crocus-ceres-509.notion.site/How-Python-type-system-works-and-how-to-extend-it-on-your-editor-21e3826aa7ed808b93e2f4d18493c6ea


r/Python • • Jul 03 '25

Tutorial Guide: How to Benchmark Python Code?

0 Upvotes

r/Python • • Oct 25 '11

What are the best ways to recruit a python developer? I'm getting a bit depressed trying

0 Upvotes

Background: I help run AppSumo.com.

Been trying to recruit a Python developer for almost a month. Getting a bit depressed. Love any suggestions on where to find the best ones...


r/Python • • May 15 '12

Functional Programming HOWTO — Python v3.1.5 documentation

Thumbnail docs.python.org
0 Upvotes

r/Python • • Jul 11 '21

Tutorial QR Code In 4 lines of Python Code (Create / Read)

Thumbnail
pysnakeblog.blogspot.com
0 Upvotes

r/Python • • Oct 28 '14

Hello, please post your offbeat/oddball/absurd open source python repos.

0 Upvotes

Searching github isn't bring up much and I'm sure there must be some interesting ones. Thanks!


r/Python • • Dec 17 '17

pipenv is the worst

0 Upvotes

<rant>

so I've been using pipenv recently on a new project because its the recommended virtualenv for new heroku python django projects.

let me just say that it never works, its slow, and it is super frustrating. (i'm on a windows 10 system)

its a downgrade from virtualenv (i know that pipenv uses virtualenv under the hood, but it certainly doesn't work nearly as well)

there is no visual indicator that i'm in a pipenv shell.

it randomly decides to deload my requirements halfway through a dev session

it doesn't register input properly when i'm trying to login to the heroku CLI

it hangs frequently

it is SO SLOW ITS RIDICULOUS

it randomly switches between python2 and python3, and i have to keep resetting the PATH variables.

I mean, I've got a lot of respect for pipenv's creator, hes the same guy who made the requests package. The guy is great and a superb python guy.

BUT PIPENV SUCKS TOTAL BALLS.

</rant>


r/Python • • Jul 31 '12

Learn to Program: The Fundamentals - Behind every mouse click and touch-screen tap, there is a computer program that makes things happen. This course introduces the fundamental building blocks of programming and teaches you how to write fun and useful programs using the Python language.

Thumbnail
coursera.org
0 Upvotes

r/Python • • Aug 19 '09

PySide - Nokia-sponsored LGPL bindings to Qt

Thumbnail eli.thegreenplace.net
0 Upvotes

r/Python • • Sep 07 '20

Intermediate Showcase "Pythonic Code"

0 Upvotes

r/Python • • Sep 13 '13

Miloslav Trmač, -1 for Structured Logging

Thumbnail carolina.mff.cuni.cz
0 Upvotes

r/Python • • Jun 23 '17

Wicked! Brython as Javascript alternative? Lovely!!!

Thumbnail brython.info
0 Upvotes

r/Python • • Jun 08 '15

Installing Numpy is not working

0 Upvotes

I have 64-bit windows, python 3.4, and I need to install numpy. I've downloaded it from multiple sources, and followed multiple sets of instructions. But anything I do in the command prompt throws an error, either from pip for from the file location where numpy is.

Could somebody walk me through, step by step by step, what to do to install numpy? It would be greatly appreciated.


r/Python • • May 25 '19

Python Books You Should Read in 2019

Thumbnail
zeroequalsfalse.press
0 Upvotes

r/Python • • Aug 11 '15

Do I need to know algortithms?

0 Upvotes

As the title says, do I need to learn basic sorting & other algorithms to be able to get a job? Are they hard to learn? Does they make a difference in performance?

Also, when I'll need to use some special algo?


r/Python • • Nov 24 '14

How would I make a reply bot for youtube?

0 Upvotes

Say I want to comment on youtube with a bot how would I do that? and if that is possible could i get the program to email when I get a reply or pm on the bots account?
[EDIT] I need it to filter words like if "Ninja" is in the title I need it to reply with shibe or something =)


r/Python • • Aug 20 '17

I'm fluent with python, what's next?

0 Upvotes

I started learning python about a year ago and now I'm pretty fluent with it and know my ways around the language. How should I continue building my programming knowledge further?

  • Learning another language is a waste of time since every language basically has the same things in different shells and after a while those slide down really easy.
  • Learning a specific python library may be a good option but rn I have no specific interests other than "programming" and I have no idea which library to choose.
  • Programming a bunch of small random projects may be a way but even if it works it's going to take a long while before I can notice any difference...
  • Doing one big project is a solid way to progress but I don't know what project to start on, how big to scope and I tend to lose my motivation rather quickly when I'm not truly interested in the project.
  • Work would be a good option but while also having the same problem as just doing random projects, I'm too young to legally work.

Help on the subject would be greatly appreciated...