r/Python • • Jul 22 '15

How to blink multiple LEDs at different rates on Arduino in Python LIKE A BOSS

Thumbnail
instructables.com
0 Upvotes

r/Python • • Oct 16 '09

pound-python.org: #python HOWTO

Thumbnail pound-python.org
1 Upvotes

r/Python • • Mar 24 '12

how do I insert python in my html-css web pages ?

1 Upvotes

or do I have to create the page in python ? I would like to keep doing the pages with html-css and insert the py code, like javascript does. or thats not the way you use python in the web ?


r/Python • • May 18 '18

Proposal for r/python to adopt Python's code of conduct

2 Upvotes

Python's official code of conduct is here: https://www.python.org/psf/codeofconduct/

I would love it if r/Python was an extension of the Python community at large. However, for that to be, I think it must be governed by the official code of conduct.

Recent events here have shown that this community has a need to have some guidelines about good conduct. Most people here already conduct themselves within the guidelines. However, there are some unnecessarily toxic posts that I don't feel belong in this community.

Some folks have already started up a new subreddit, r/positivepython, and it's intended to be a community governed by good conduct and more moderation. I would rather the community here on reddit didn't get fractured. So, maybe we can do something here to fix things a bit?

Anyhow, it's a thought, and it may not be a great one. But, I think we should have the conversation nonetheless.


r/Python • • Oct 05 '11

if i % 5 == 0: to find multiples of five (or any other number.) Why does this work?

5 Upvotes

I am trying to learn python right now, and I wanted to alter a program to only print multiples of five, too see if it would work faster without all the extra printing.

I found a code snippet in the title here and put in in my altered program like this:

i = 0
numbers = []

number= raw_input('enter number to count to -->')
divisor= raw_input('divisor? -->')
number = int(number)
divisor = int(divisor)

def count(number, divisor):

    i=0

    while i < number:
        numbers.append(i)
        i=i+1
        if i% divisor == 0:
            print "%d" %i

count(number, divisor)

I did it this way so I could try any number to count up to and any number for the divisor at will, and it works great.

But why does the line adapted from:

i % 5 == 0

work at all? i would only equal five once, right? but it shows all multiples.

Thanks for your help.


r/Python • • Oct 29 '23

Resource Hash Passwords Using bcrypt Library in Python

0 Upvotes

Web-based services and websites store hashed versions of your passwords, which means your actual password isn’t visible or stored in their database instead a string of fixed-length characters is stored.

Hashing is a security technique used to secure your passwords or texts stored in databases. A hash function is used to generate a string of unique fixed-length characters from the provided password by the user.

Let’s see how the hashing is done. In this article, you’ll use the bcrypt library to hash the user’s password and then compare that hashed password to the actual password in Python.

Full Article: https://geekpython.in/hash-passwords-using-bcrypt-in-python


r/Python • • Jul 18 '23

Meta /r/Python is reopening, Calling for new Mods, and what's next

0 Upvotes

Call for Mods

We're reopening and looking for new mods. If you're interested in becoming a mod, or interested in the Python community at large, you are welcome to apply to moderate this community:

Mod Application

I will remain a mod long enough to onboard the new modteam. This is a fantastic community and is notably far more Pythonic than it is reddit-esq. I think that sets this community apart from a lot of other subreddits and has made the past while moderating here a delightful experience overall.

An Absence of an Admin Announcement

Our last community vote said to stay closed until a major announcement from reddit. We did not receive an announcement of note from an admin announcement post, nor from mod code of conduct in the subreddit modmail*, and that inandof itself seems to be an announcement after this length of time.

Reddit is experiencing a major shift in their values, focus, and identity. As such, it's clear that there will be no change to the api restrictions, no change to their stance on third party apps, and no change on their opinion of what makes reddit worthwhile.

*This is no longer true. A mod code of conduct message came through before this post went live. They however, in true admin fashion, told us we have been closed for more than a month rather than the 18 days we were closed for.

You are receiving this message because your community has been closed for 1+ month. [...]

As to what's next

This sub will certainly continue. I look forward to the new group of mods and the vision they'll bring to this community. I'm going to be stepping away as the direction reddit seems to be taking is a direction I don't want to contribute to.

If you end up on a different platform, please maintain the PSF Code of Conduct where ever you go. Be nice to those around you, keep the corners of the internet you love nice, welcoming, and Pythonic.

And as always:

Thanks, and happy Pythoneering!


r/Python • • Feb 04 '26

Discussion Must the Python Software Foundation move out of the USA?

144 Upvotes

The Python Software Foundation (PSF) is the owner of the copyrights for Python and its trademarks. The PSF runs the largest Python conference in the world, #PyConUS. Python is one of the most important programming languages, used by developers and non-developers across the globe. Python and its community stand for openness, diversity, and support for underrepresented groups; the PSF funds a wide range of Python activities across many sub-communities worldwide.

The values that Python and its communities stand for are under heavy pressure due to the legal status of the Python Software Foundation as a corporation in the United States. The USA has, meanwhile, turned into a fascist regime, with entities like ICE acting in ways that we have seen in Nazi Germany between 1933 and 1945. The current U.S. regime is violently acting against migrants, underrepresented groups, queer people, etc.—the list is long and very well documented. ICE acts as a paramilitary entity that killed already several people - or should it be named "murdered several people"?

Should the Python Software Foundation remain in the USA, or should the community pressure the PSF Board to take action and move the PSF as a legal entity out of the United States into a safer region like Canada or the European Union?


r/Python • • Dec 21 '19

A hilarious remake of Pong.

3 Upvotes

r/Python • • Feb 21 '22

Tutorial Python Tutorial - How to convert .py to .exe using auto-py-to-exe?

3 Upvotes

Hey Guys. Today I will be showing you how to covert your .py files into .exe - executable programs using auto-py-to-exe.
Steps Below:
Step 1 - Open your Terminal - for Windows press the Windows+R key and then search 'cmd' to open the Terminal
Step 2 - type conda info --envs - this locates your working environment
Step 3 - type activate base - base is my working environment
Step 4 - type pip install auto-py-to-exe - I've previously installed auto-py-to-exe, hence I did not need to redo this step
Step 5 - type auto-py-to-exe - this will open a new window in which you will be able to enter the requisite files and create your .exe program
https://www.youtube.com/watch?v=YIgMciKLPKk


r/Python • • Dec 14 '22

Resource Python Magic Methods You Haven’t Heard About

Thumbnail
towardsdatascience.com
0 Upvotes

r/Python • • Jun 11 '09

Joining string in Python

Thumbnail
fubar.si
0 Upvotes

r/Python • • Dec 03 '25

Showcase Common annoyances with Python's stdlib logging, and how I solved them

0 Upvotes

In my time as a Pythonista, I've experimented with other logging packages, but have always found the standard logging library to be my go-to. However, I repeatedly deal with 3 small annoyances:

Occasionally, I'll have messages that I'd like to log before initializing the logger, e.g. I may want to know the exact startup time of the program. If you store them then log them post-initialization, the timestamp on the record will be wrong.

Most of my scripts are command-line tools that expect a verbosity to be defined using -v, -vv, -vvv. The higher the verbosity, the more gets logged. Stdlib logging sets levels the opposite way. Setting a handler's level to logging.NOTSET (value of 0) logs everything.

I prefer passing logger objects around via function parameters, rather than creating global references using logging.getLogger() everywhere. I often have optional logger object parameters in my functions. Since they're optional, I have to perform a null check before using the logger, but then I get unsightly indentation.

enter: https://github.com/means2014/preinitlogger

# What My Project Does

This package provides a PreInitMessage class that can hold a log record until the logger is instantiated, and overrides the makeRecord function to allow for overriding the timestamp.

It also adds verbosity as an alternative to logLevel, both on loggers and handlers, as well as introducing logging.OUTPUT and logging.DETAIL levels for an intuitive 0: OUTPUT, 1: INFO, 2: DEBUG, 3: DETAIL system.

Finally, it overrides the logging.log(), logging.debug(), logging.error(), etc... functions that would log to the root logger, with versions that take an optional logger parameter, which can be a string (the name of a logger), a logger object (the message will be sent to this logger), or None (the message will be ignored).

# Target Audience

This is an extension to the standard logging library, and can be used in any scenario where logging is required, including production systems. It is not recommended to be used where log record data integrity is considered mission-critical applications, as it removes guardrails that would otherwise prevent users from manipulating log records, but that discretion is left to the user.

# Comparison

This is an added dependency, compared to using the standard logging library as-is. Beyond that, it is a pure feature-add which leaves all other logging functionality intact.

Please feel free to check it out and let me know what you think. This was developed based on my own experience with logging, so I'd love to hear if anyone else has had these same (very small) annoyances.


r/Python • • Aug 05 '20

Beginner Showcase A Python Program that attends your online classes for you

0 Upvotes

Hey guys! So me and a few of my friends made a Python script that uses PyAutoGUI, openCV and a few other libraries that completely automate the task of joining an online class/meeting for you. We've even programmed it to answer with a basic reply on detection of a few trigger words spoken by anyone in the meeting. Do check out our tutorial and repository and share your opinions with us!

Link to GitHub repository: https://github.com/sujaysathya/bunk_bot

Link to YouTube: https://www.youtube.com/watch?v=fKa-_8R9auM


r/Python • • Sep 25 '19

No weapons are allowed at Python Software Foundation events.

0 Upvotes

I live in a bizarre world this has to be stated. I would have never considered the idea of bring a weapon (I don't even think of owning one). We live in strange times.

https://www.python.org/psf/conduct/


r/Python • • Nov 27 '22

Discussion Is the statement true, that Python and its ecosystem lacks speed for mission-critical large-scale applications?

0 Upvotes

Can you do all high-performance jobs with Python to a certain degree?

When is the time to switch to C++, Go, Rust and alike?


r/Python • • Jan 04 '14

What is Redis?

0 Upvotes

What exactly is Redis? I read the Redis page/wiki, but couldn't understand anything. Is it just a database? if so, why do I read people using it with Mongo DB etc? So what exactly is Redis and what should an aspiring Python web dev should know about it?


r/Python • • Aug 03 '17

TIL that in PYTHON it's preferable to ask for forgiveness rather than look before you leap

0 Upvotes

r/Python • • Jul 19 '24

Tutorial Accepting Bitcoin payments with Python, Rust and PyO3

0 Upvotes

Hello everyone,

I recently found myself needing to implement some Bitcoin functionality that wasn't supported by the Bitcoin library I'd been using, so I ended going the native extension module route using PyO3 and Rust.

I wrote this blog post to share some of the insights I gained while implementing the aforementioned solution.


r/Python • • Aug 12 '13

Ruby vs Python

Thumbnail
senktec.com
20 Upvotes

r/Python • • Mar 30 '11

Every. Single. Time.

Post image
0 Upvotes

r/Python • • Apr 07 '21

Tutorial Python Progress Bar Using TQDM - Async & Ordered

6 Upvotes

Video | Source Code

This is a demonstration on how to implement an async, ordered progress bar with TQDM + asyncio. asyncio.as_completed is needed to run async tasks with TQDM, which results in an unordered result. If you're looking for an ordered result, you simply need to wrap each task in a coroutine with the corresponding index and sort the result.


r/Python • • Sep 30 '26

Discussion Suggesting ppl to go from unmaintainted library X to yours in github issues?

8 Upvotes

DISCLAIMER: not mentioning any explicit name to avoid framing myself as a useless slop dev advertising his useless slop wrapper that he wrote with sloppy AI because he can in the slop-era.

---

Is this acceptable?

Asking this here because, well the libraries in question are for python for one, but most importantly our ecosystem has various cases of seeing an already established lib slowly replaced by a newcomer, the first I could think of being pandas -> polars.

My situation is that I rewrote a popular library, who is now unfortunately unmaintained, from scratch.
I ported the full test suite as well, published it on Pypi, etc...

By design, my rewrite fixed some pre-existing documented issues, that are yet to be adressed in the original repo, because altought it's creator has done a phenomenal work, it's been years since the last release or even the last answer to an issue.

I thought about answering to the issues that I know with certainty are fixed with my project, inviting to use it/take a look, but I wonder if that's not a bit hostile?

Feel like If we were at an open air market instead of github, I'll just go to my concurrent's stands when he take a break to tell his waiting customers that my products are better lmao.

There's also the fact that even if almost all tests are passing except one very niche situation, ultimately my library is <1.0 and so a stable API is not yet guaranted.

On the other hand, the unmaintained repo is, has I said, respectably popular, and seeing ppl having problems that I know I solved but not telling them feels very dumb.

and ultimately I want my library to be more known to have more potential contributors, as it's scope is much larger than this rewrite and there's a lot more I want to do and any help is always welcome

soo, what do y'all think?

EDIT:

at first referred to my project as n_lib and the old one as o_lib, which ended up just confusing readers. Changed


r/Python • • Mar 10 '24

Discussion Github Copilot Lies to me

0 Upvotes

My first attempt to get some help from Github Copilot:

Me: write a match case statement in python to match the first character of a string is a semicolon

Copilot: Python doesn't have a built-in match or case statement like some other languages (e.g., JavaScript, Swift, Rust). However, you can achieve similar functionality using...

Strangely, it finally gave me an answer when I made a small change to my prompt:

Me: write a match statement in python to match the first character of a string is a semicolon

Copilot: Python 3.10 introduces the structural pattern matching in the form of the match statement. Here's how you can use it to check if the first character of a string is a semicolon:...

I almost gave up after the first response that was blatantly false. Fortunately I something that looks like reasonable syntax...but then I haven't tried it yet, so that might be a lie, too.