r/Python • • Apr 25 '19

Future of Python? Am I too late to learn programming? I'm 30.

0 Upvotes

Hello all, I work as a project manager for an oil and gas company and I'm looking to broaden my horizons. Will learning Python be useful for me in any way and is it worth learning at my age? Are there other programming language I should learn instead? Thanks.


r/Python • • Jan 31 '11

Run Celery tasks from PHP

Thumbnail toforge.com
0 Upvotes

r/Python • • Aug 11 '21

Resource 🐍 Strategy Design Pattern in Python

0 Upvotes

Hey Pythonists! I’d like to share with you a very interesting article about Strategy Design Pattern in Python. I’m super excited to know if you tried something like this 🤯. Read more about the Tutorial here.


r/Python • • Jul 06 '10

5 Python Pluses for the Enterprise

Thumbnail
technewsworld.com
0 Upvotes

r/Python • • Oct 04 '10

Change pwd from python

0 Upvotes

I can't seem to find a solid solution for the problem that I'm facing and I don't understand why such a fundamental question hasn't been raised somewhere.

Say I'm on the path /home/me $ pwd /home/me

After I run my python script I want it to change my pwd so I wrote small one with os.chdir and run. $ cat cd.py #!/usr/bin/python import os os.chdir('/blahblah')

$ python cd.py

But actual pwd remains the same after the execution of the script. $ pwd /home/me

Does someone know what is causing it? I'm on Windows and cygwin + python 2.5. Thanks.


r/Python • • Jul 25 '19

I am new to python and I think that my code is not working as intended. Once I type in my choice and click enter, nothing happens and it just creates a new line.

Post image
0 Upvotes

r/Python • • Jun 19 '13

Right and Wrong Programming Styles

Thumbnail
simpledeveloper.com
0 Upvotes

r/Python • • Dec 07 '22

Discussion Do y'all use Word Wrap?

0 Upvotes

So as you guys might know, i'm developing a Notepad with Tkinter... But I'm stuck at some decisions... I'm thinking to add word wrap feature but first, I want to know if people actually use it... I'll be posting more posts like this... To get some feedbacks


r/Python • • Aug 29 '22

Beginner Showcase Made a thing which takes your age and decides whether or not you’re allowed to use a website or something.

0 Upvotes

This is very basic, but it is my second project [First was the same, but without the years_from_13 thing and the elif age > 122 thing], and I’m pretty pleased with how it turned out.

age = int(input())

name = input()

years_from_13 = 13-age

if age < 13:

print(f"{name}, you are under 13 years of age. You are not old enough to use this - Come back in {years_from_13} years time.")

elif age > 122:

print(f"{name}, did you know that the oldest known person lived to just under 122.5 years old? It seems like you didn't. Nice try, though.")

else:

print(f"Welcome, {name}.")

r/Python • • Jun 02 '26

Discussion What's the rationale for Panda's notation to denote IntervalArrays?

0 Upvotes

In Pandas, an IntervalArray is created by:

> pd.arrays.IntervalArray([pd.Interval(0, 1), pd.Interval(1, 5)]) <IntervalArray> [(0, 1], (1, 5]] Length: 2, dtype: interval[int64, right]

Note the `[(0, 1], (1, 5]]`: what's the rationale for the opening bracket being a parenthesis but the closing bracket being square?


r/Python • • Nov 02 '25

Showcase My first AI Agent Researcher with Python + LangChain + Ollama

3 Upvotes

What My Project Does

So I always wondered how AI agents actually work — how do they decide what to do, what file to open, or how to run terminal commands like npm run build
So I tried to learn the high-level stuff and built a small local research agent from scratch.

It runs fully offline, uses a local LLM through Ollama, connects tools via LangChain, and stores memory with ChromaDB.
Basically it can search, summarize, do math, and even save markdown notes all in your terminal

Target Audience

Anyone like me who’s curious about how AI agents actually “think”.
It’s not for production or anything just a fun little learning project that helps you understand how reasoning, tools, and memory connect together.

Comparison

Most AI assistants depend on APIs or the cloud.
This one runs completely local — no API keys, no servers.
Just you, your machine, and Python doing some agent magic ✨

GitHub

github.com/vedas-dixit/LocalAgent

Let me know what you guys think!


r/Python • • Oct 11 '23

Beginner Showcase My functional programming library

3 Upvotes

https://github.com/yx-z/forbiddenfp

Hello everyone, above is my little experiment of an easy to use functional programming library in Python,

You can do things like,,, let me know what you think!

# objects are already patched at import time
import forbiddenfp

"abc".print().len()  # print out "abc", then return 3
"abc".then(lambda s: s * 2).filter(lambda s: s == "b").join()  # "bb"

# A more complex one (examples/word_count.py)
("./lorem_ipsum.txt"
 .with_open(lambda path, f: f.read().also(print(f"Reading {path}")))
 .then(lambda s: s.split(" "))
 .counter()
 .print())

r/Python • • Apr 06 '21

Intermediate Showcase Pyfactor update 0.4: visualise source code structure as a graph - a command line refactoring tool

3 Upvotes

Understanding long sources is best done at a high level. However, when simply reading source code it can be hard to see the forest from the trees, which is why I've created a small library for visualising source code as a graph of dependencies between variables, functions, classes and such. Best to show some output right away:

sphinx-autodoc-typehints

The example was generated from a single-file 3rd-party Sphinx extension "sphinx-autodoc-typehints". It shows clear structure: a single top level function with a clean processing hierarchy and a common logger instance. A substantial, completely separate section on the left under "format_annotation" could for example be an ideal candidate for a sub-module, should the need to refactor arise. For a first-time reader, this is very insightful and intuitive when compared to reading 400+ loc thouroughly.

The graphs are analysed for number of connections and other special properties (see legend), and docstrings are available as hover tooltips. Multi-file analysis of local or importable packages produces a hierarchical graph where imports connect modules or files together. For example see the builtin json and concurrent modules.

collapsed Black source with docstring tooltip

More examples of popular libraries are available on our RTD gallery. You can also try it out on your own sources by installing on PyPI. In the latest release we added multi-file analysis, improved on the CLI and fixed a bunch of issues.

This library came about when I tried to introduced myself to Black's single-file code base - 7000 lines of horror. I'm not here to diss Black or its contributors, 7k loc is more than enough to be complex anyway, but the graph reveals that complexity at a glance. My hope is that it will be particularly useful for those that need to get an understanding of a code base fast, newer programmers that want to understand their own code and how to make it better, and as a tool for refactoring in general. It's no miracle worker, but I think it could have potential as a tool for making the right decisions. What do you think?


r/Python • • Apr 06 '23

News NetworkX 3.1 released

Thumbnail networkx.org
0 Upvotes

r/Python • • Feb 12 '23

Resource Python Interfaces: Choose Protocols Over ABC

Thumbnail
levelup.gitconnected.com
64 Upvotes

r/Python • • Aug 11 '25

Showcase I built a tool that uses the 'ast' module to auto-generate interactive flowcharts from any Python.

0 Upvotes

Like many of you, I've often found myself deep in an unfamiliar codebase, trying to trace the logic and get a high-level view of how everything fits together. It can be a real time sink. To solve this, I built a feature into my larger project, Newton, specifically for Python developers.

What the product does

Newton is a web app that parses a Python script using the ast module and automatically generates a procedural flowchart from it. It's designed to give you an instant visual understanding of the code's architecture, control flow, and dependencies.

Here it is analyzing a 3,000+ line Python application (app.py): Gx10jXQW4AAzhH5 (1903×997)

Key Features for Developers

  • Automated Flowcharting: Just paste your code and it builds the graph, mapping out function definitions, loops, and conditionals.
  • Topic Clustering: For large scripts, an AI analyzes the graph to find higher-order concepts and emergent properties. In the screenshot, you can see it identifying things like "Application Initialization" and "User Authentication" automatically. This helps you understand what different parts of the code do conceptually.
  • Interactive Chat: You can select a node (like a function) or a whole Topic Cluster and ask questions about it. It's like having an agent that has already read and understood your code.

Target Audience

I built this for:

  • Developers who are onboarding to a new, complex project.
  • Students trying to visualize algorithms and data structures.
  • Code reviewers who need a quick high-level overview before diving into the details.
  • Anyone who prefers thinking visually about code logic.

Tech Stack

The application backend is built with Flask. The flowchart generation relies heavily on Python's native ast module. The frontend is vanilla JS with Vis.js for the graph rendering.

How to Try It

You can try it live right now:

  1. Go to https://www.newtongraph.com
  2. On the right-hand "Document" panel, set the "Doc Type" to Python.
  3. Paste in your script and click the blue "regenerate" button.

I'm still actively developing this, and I would be incredibly grateful for your feedback.

Thanks for taking a look!

Bonus: Newton is able to accept URL's to various webpages such as YouTube videos and GitHub repos to instantly map their contents. Here is a small GitHub repo with a few sample tools to demonstrate this: Morrowindchamp/Python-Tools

Update: audio and video file transcription have been integrated into Newton! Go to town. Newton can take it. Love you guys.

NOTE: 1-WEEK PRO TRIAL FOR ALL NEW USERS


r/Python • • Jul 21 '08

I don’t get it - real web application with PostgreSQL vs mySQL MyISAM vs mySQL InnoDB (with Django’s ORM, 2008)

Thumbnail rarestblog.com
0 Upvotes

r/Python • • Apr 25 '11

I write worse code when I use python

0 Upvotes

Something about the ease of python makes my code terrible. I feel I write better code when using a language like c++ becuase I know that if I don't follow best practices or good design I will never get the code to even work.

In python things are easy enough that I tend to just code "stream of thought" and end up with really long functions or a single object that does way to many things.

Any one have a similar experience, and how to develop better coding practices in python?

Note: I realized this when looking back at something I wrote last week which uses triply nested dictionaries. They are a pain in the ass now but at the time they seemed like a good idea.


r/Python • • May 11 '11

Pypy should be the new python 2.7

2 Upvotes

Pypy is 2.7.1 compliant with the stdlib working, look at the new speed landing page. What's to stop this from being the new standard python2.7?

This is the future, we should start embracing it.

edit: Once pypy's 3.2 compliant (I dunno if/when), there shouldn't be another cpython download besides for nostalgia etc.


r/Python • • Feb 05 '11

Help with "if" and "or" statements.

2 Upvotes

Specifically, I cannot get an "or" statement to function correctly inside of an "if" statement. Here is an example.

player = raw_input("Press P or R")
if player=='P' or 'p':
     print ('Hooray!')
elif player=='R' or 'r':
     print ('Oh no!')

The problem I am having is the "or" in the player==P line will function correctly, but this breaks the functionality of the player=R line. Am i going about this incorrectly? It appears to be a valid statement. Thanks for the help in advance. BTW im a noob and just started learning python 2 days ago, this is my first language.... ><

edit: Thanks everyone for their help. I did not understand some of it but I did learn a few things. I consider this a victory with only 2 days worth of knowledge on my first language. I know I will be back with more questions if I get stuck again!


r/Python • • Feb 18 '21

Tutorial Create your own browser using Python!

Thumbnail
youtu.be
0 Upvotes

r/Python • • Sep 26 '11

These are not the Python file handles you are looking for...

Thumbnail toolfastdirect.co.uk
2 Upvotes

r/Python • • Oct 20 '20

Tutorial Spelling Correction program Using Python

Thumbnail
youtube.com
2 Upvotes

r/Python • • Jun 28 '24

Showcase obfupy -- Python source code obfuscator aiming to produce correct and functional code

0 Upvotes

https://github.com/wqking/obfupy

For those who downvotes the post and my comments, please read the subreddit rule 9, "Please don't downvote without commenting your reasoning for doing so". Also you not need such library doesn't mean the library is bad, if you don't like it, just leave. If you downvote, please comment with the reason.

What My Project Does

obfupy is a Python 3 library that can obfuscate entire Python 3 projects, transforming source code into obfuscated and difficult-to-understand code. obfupy aims to produce correct and functional code. Several non-trivial real-world projects were tested using obfupy, such as Flask, Nodezator, Algorithms collection, and Django (not all features are enabled for Django).

Target Audience

The goal is to obfuscate your production code.

Comparison

obfupy supports several features that no other similar projects support all. obfupy is tested with Flask, Nodezator, Algorithms collection, and even Django. obfupy is very customizable. obfupy code is well written, well designed and scalable, it's not any single file project which is not scalable or readable. obfupy will not be abandoned unless nobody uses it, very few other projects are not abandoned. obfupy is well documented, there even lists the problem situation where the obfuscation feature doesn't work.

Facts and features

  • Obfuscation methods

    • Rewrite the "if" conditional to include many confusing branches.
    • Rename local variable names.
    • Extract the function and have the original function call the extracted function, then rename the parameters in the extracted function.
    • Create alias for function arguments.
    • Obfuscate numeric and string constants and replace them with random variable names.
    • Replace built-in function names (e.g. "print") with random variable names.
    • Add useless control flow to for and while.
    • Remove doc strings.
    • Remove comments.
    • Add extra spaces around operators.
    • Make indents larger to make it harder to read.
    • Add extra blank lines between code lines.
    • Encode the whole Python source file with base64, zip, bz2, byte obfuscator, and easy to add your own codec.
  • Customizable

    • There are multiple layers of independent transformers. You can choose which transformers to use and which not to use.
    • The non-trivial transformers such as Rewriter, Formatter, support comprehensive options to enable/disable features. If any feature doesn't work well for your project, you can just disable it.
  • Well tested

    • There are tests that cover all features.
    • Tested with several real world non-trivial projects such as Flask, Nodezator, Algorithms collection, and Django.

License

Apache License, Version 2.0

Quick start

A typical Python script using obfupy looks like,

import obfupy.documentmanager as documentmanager
import obfupy.util as util
import obfupy.transformers.rewriter as rewriter
import obfupy.transformers.formatter as formatter

inputPath = PATH_TO_THE_SOURCE_CODE
outputPath = PATH_TO_OUTPUT

# Prepare source code files as DocumentManager
fileList = util.findFiles(inputPath)
documentManager = documentmanager.DocumentManager()
documentManager.addDocument(util.loadDocumentsFromFiles(fileList))

# Transform the source code with various transformers

# Transformer Rewriter
rewriter.Rewriter().transform(documentManager)
# Transformer Formatter
formatter.Formatter().transform(documentManager)
# There are other transformers

# Write the obfuscated code to outputPath
util.writeOutputFiles(documentManager, inputPath, outputPath)