LibCST
CPython
LibCST | CPython | |
---|---|---|
9 | 1,327 | |
1,448 | 60,420 | |
2.1% | 1.3% | |
8.6 | 10.0 | |
2 days ago | 1 day ago | |
Python | Python | |
GNU General Public License v3.0 or later | GNU General Public License v3.0 or later |
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
LibCST
- Show HN: Codemodder – A new codemod library for Java and Python
-
Package that graphs and exports jpeg of CST/AST?
LibCST: Seems to only show in terminal.
-
How to approach modifying source code programmatically?
While you can do this using ANTLR or any other lexing/parsing tool, it's honestly a bit of a pain. Whitespace and comments can go almost anywhere, even in the middle of expressions, so the grammar ends up becoming fairly messy. So, I'd recommend using a library that handles this for you, if at all possible. For example, if I wanted to code-mod Python I'd prob just use the LibCST library.
-
ruff is a fast Python linter written in Rust
I recommend https://github.com/Instagram/LibCST (which is currently implementing rust bindings)
-
How to handle line endings when writing files depending on OS?
I've been roughly copying some of the logic from the LibCST project. This struct in particular- https://github.com/Instagram/LibCST/blob/main/native/libcst/src/tokenizer/text_position/char_width.rs does a good job of normalizing the line endings of a str. The long way around you could mimic this construct, transform the str to normalized line endings, and then split on "\n" or make a somewhat more complicated transformer which turns a large str into a Vec (or Vec).
-
We're the core team behind the popular Python autoformatter: Black. AMA!
I myself am working on upgrading LibCST's parser engine to support the new syntax, and then am hoping we can rewrite Black's formatting rules in terms of LibCST's API. That's not a small amount of work, which is why we can't confidently say that's going to be the way forward.
-
Our Engineering Team Used Python's AST to Patch 100,000s of Lines of Code
Never used it but it appears that Facebook/Instagram have a format preserving CST library for Python: https://github.com/Instagram/LibCST
CPython
-
How to shuffle a virtual deck of cards?
python has random.shuffle() and random.sample() with an MT Mersenne Twister PRNG for random. https://docs.python.org/3/library/random.html#random.shuffle Modules/_randommodule.c: https://github.com/python/cpython/blob/main/Modules/_randomm... , Library/random.py: https://github.com/python/cpython/blob/main/Lib/random.py#L3...
From "Uniting the Linux random-number devices" (2022) https://news.ycombinator.com/item?id=30377944 :
> > In 2020, the Linux kernel version 5.6 /dev/random only blocks when the CPRNG hasn't initialized. Once initialized, /dev/random and /dev/urandom behave the same. [17]
From https://news.ycombinator.com/item?id=37712506 :
> "lock-free concurrency" [...] "Ask HN: Why don't PCs have better entropy sources?" [for generating txids/uuids] https://news.ycombinator.com/item?id=30877296
> "100-Gbit/s Integrated Quantum Random Number Generator Based on Vacuum Fluctuations" https://link.aps.org/doi/10.1103/PRXQuantum.4.010330
-
Awesome List
Python
-
Python Bytecode: A Beginner’s Guide
Python bytecode is like a secret language that Python uses behind the scenes. When you write your Python code, it doesn’t run directly. Instead, Python translates your code into bytecode, a set of instructions that the Python interpreter can understand and execute.
-
Python Development in VSCode: Setting Up and Best Practices
Ensure you have Python installed on your system. You can download it from the official Python website. Verify the installation by running:
-
Help test Python 3.13!
We strongly encourage maintainers of third-party Python projects to test with 3.13 during the beta phase and report issues found to the Python bug tracker as soon as possible. While the release is planned to be feature complete entering the beta phase, it is possible that features may be modified or, in rare cases, deleted up until the start of the release candidate phase (Tuesday 2024-07-30). Our goal is to have no ABI changes after beta 4 and as few code changes as possible after 3.13.0rc1, the first release candidate. To achieve that, it will be extremely important to get as much exposure for 3.13 as possible during the beta phase.
- Guido van Rossum drops ownership of the core Python interpreter code
-
Introduction to GUI Programming with Tkinter
Before diving into Tkinter, ensure that you have Python installed on your computer. Visit the official Python website (https://www.python.org) and download the latest version suitable for your operating system.
-
Casino Terminal Game
1. Download the files: "CasinoGame.py" and "MainDriverSection.py" 2. Make sure Python is installed: https://www.python.org/ 3. Open a terminal for command prompt 3.1 Navigate to the directory containing the files 3.2 Run the game with "python3
-
Easy CSV Handling with Python: A Beginner's Guide (Bite-size Article)
Let's install Python on your computer by downloading it from the official Python website.
-
The new REPL in Python 3.13
I think there's a bit of a misunderstanding regarding exit. exit is not a keyword or a REPL command; it's actually a function exposed in the builtin package. you can run "import builtins; builtins.exit()"
To clarify, there are two things here: why exit exists in the REPL, and why it's a function. The exit() function is available only in the REPL, and it appears built-in, but it isn't part of the built-in namespace. Instead, exit is loaded automatically by the site module.
Heres is the code with the function site.main that is doing it: https://github.com/python/cpython/blob/8af84b503d0b62a3db0d8...
The line builtins.exit = _sitebuiltins.Quitter('exit', eof) shows that exit is set as a function. The Quitter class, which exit is an instance of, has a __call__ method, making it callable, so it as a function.
I don't believe you're wrong not understanding it; it's just that the process isn’t typically explained in detail, especially what happens when you start the REPL. This is why the message "Use exit() instead..." exists in the REPL: it needs that clarification.
In a nutshell, exit is a function loaded into the built-ins by the site.py module, which automatically activates when the REPL starts. This automatic loading is what makes exit, help, __copyright__ and others available only in the interactive sessions.
What are some alternatives?
RedBaron - Bottom-up approach to refactoring in python
RustPython - A Python Interpreter written in Rust
Bowler - Safe code refactoring for modern Python.
ipython - Official repository for IPython itself. Other repos in the IPython organization contain things like the website, documentation builds, etc.
black - The uncompromising Python code formatter
Vulpix - Fast, unopinionated, minimalist web framework for .NET core inspired by express.js
pasta - Library to refactor python code through AST manipulation.
Visual Studio Code - Visual Studio Code
ufmt - Safe, atomic formatting with black and µsort
Automatic-Udemy-Course-Enroller-GET-PAID-UDEMY-COURSES-for-FREE - Do you want to LEARN NEW STUFF for FREE? Don't worry, with the power of web-scraping and automation, this script will find the necessary Udemy coupons & enroll you for PAID UDEMY COURSES, ABSOLUTELY FREE!
instaviz - Instant visualization of Python AST and Code Objects
Pandas - Flexible and powerful data analysis / manipulation library for Python, providing labeled data structures similar to R data.frame objects, statistical functions, and much more