https://github.com/willtheorangeguy/pytricks-archive
An archive of the 🐍PyTricks featured in Dan Badder's Real Python email newsletter.
https://github.com/willtheorangeguy/pytricks-archive
hacktoberfest python pytricks tips tricks
Last synced: 3 months ago
JSON representation
An archive of the 🐍PyTricks featured in Dan Badder's Real Python email newsletter.
- Host: GitHub
- URL: https://github.com/willtheorangeguy/pytricks-archive
- Owner: willtheorangeguy
- License: other
- Created: 2022-08-08T16:28:21.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2026-02-05T17:36:38.000Z (4 months ago)
- Last Synced: 2026-02-06T03:35:52.105Z (4 months ago)
- Topics: hacktoberfest, python, pytricks, tips, tricks
- Language: Python
- Homepage: https://willtheorangeguy.github.io/PyTricks-Archive/
- Size: 22.8 MB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE.md
- Code of conduct: CODE_OF_CONDUCT.md
- Security: SECURITY.md
Awesome Lists containing this project
README
PyTricks Archive
An archive of the 🐍PyTricks featured in Dan Badder's Real Python email newsletter.
Key Features •
Download •
How To Use •
Contributing •
Credits & Contributors

## Key Features
- Archive of all PyTricks.
- Table of contents available.
- Available as Python `.py` files, or on a website.
- Website links to specific PyTricks.
- Cross platform.
## Download
You can **[download](https://github.com/willtheorangeguy/PyTricks-Archive/archive/refs/heads/main.zip) the `main` branch archive** to view the Python `.py` files or **[download](https://github.com/willtheorangeguy/PyTricks-Archive/archive/refs/heads/gh-pages.zip) the `gh-pages` branch archive** run the website locally.
## How To Use
Each PyTrick has a name that relates to the title of the newsletter, and you can find all of the tricks in the [`PyTricks`](https://github.com/willtheorangeguy/PyTricks-Archive/tree/main/PyTricks) folder on the Python. They are also available [on the website](https://willtheorangeguy.github.io/PyTricks-Archive/)! Below is a table of contents (sorted alphabetically by file name), with links for each PyTrick.
### Table of Contents
| **Original Email Titles** | **Python** | **Web** |
| ---------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------- |
| [🐍PyTricks]: Peeking Behind The Bytecode Curtain | [Python](https://github.com/willtheorangeguy/PyTricks-Archive/blob/main/PyTricks/bytecodecurtain.py) | [Web](https://willtheorangeguy.github.io/PyTricks-Archive/#bytecodecurtain) |
| [🐍PyTricks]: Check if all elements in a list are equal | [Python](https://github.com/willtheorangeguy/PyTricks-Archive/blob/main/PyTricks/checkifallequal.py) | [Web](https://willtheorangeguy.github.io/PyTricks-Archive/#checkifallequal) |
| [🐍PyTricks]: Class inheritance and the issubclass() built-in | [Python](https://github.com/willtheorangeguy/PyTricks-Archive/blob/main/PyTricks/classinheritance.py) | [Web](https://willtheorangeguy.github.io/PyTricks-Archive/#classinheritance) |
| [🐍PyTricks]: contextlib.suppress | [Python](https://github.com/willtheorangeguy/PyTricks-Archive/blob/main/PyTricks/contextlib.suppress.py) | [Web](https://willtheorangeguy.github.io/PyTricks-Archive/#contextlib) |
| [🐍PyTricks]: CPython easter egg | [Python](https://github.com/willtheorangeguy/PyTricks-Archive/blob/main/PyTricks/cpythoneasteregg.py) | [Web](https://willtheorangeguy.github.io/PyTricks-Archive/#cpythoneasteregg) |
| [🐍PyTricks]: Emulate switch/case statements | [Python](https://github.com/willtheorangeguy/PyTricks-Archive/blob/main/PyTricks/emulateswitchcasestatements.py) | [Web](https://willtheorangeguy.github.io/PyTricks-Archive/#emulateswitchcasestatements) |
| [🐍PyTricks]: Python 3.3+ has a new "faulthandler" std lib module | [Python](https://github.com/willtheorangeguy/PyTricks-Archive/blob/main/PyTricks/faulthandler.py) | [Web](https://willtheorangeguy.github.io/PyTricks-Archive/#faulthandler) |
| [🐍PyTricks]: Finding the most common elements in an iterable | [Python](https://github.com/willtheorangeguy/PyTricks-Archive/blob/main/PyTricks/findmostcommonelement.py) | [Web](https://willtheorangeguy.github.io/PyTricks-Archive/#findmostcommonelement) |
| [🐍PyTricks]: "for" (and "while") loops can have an "else" branch?! | [Python](https://github.com/willtheorangeguy/PyTricks-Archive/blob/main/PyTricks/forandwhileelsebranch.py) | [Web](https://willtheorangeguy.github.io/PyTricks-Archive/#forandwhileelsebranch) |
| [🐍PyTricks]: Forced keyword-only parameters in Python 3.x | [Python](https://github.com/willtheorangeguy/PyTricks-Archive/blob/main/PyTricks/forcedkeywordparameters.py) | [Web](https://willtheorangeguy.github.io/PyTricks-Archive/#forcedkeywordparameters) |
| [🐍PyTricks]: Function argument unpacking in Python | [Python](https://github.com/willtheorangeguy/PyTricks-Archive/blob/main/PyTricks/functionargumentunpacking.py) | [Web](https://willtheorangeguy.github.io/PyTricks-Archive/#functionargumentunpacking) |
| [🐍PyTricks]: Python's built-in HTTP server | [Python](https://github.com/willtheorangeguy/PyTricks-Archive/blob/main/PyTricks/httpserver.py) | [Web](https://willtheorangeguy.github.io/PyTricks-Archive/#httpserver) |
| [🐍PyTricks]: Python's shorthand for in-place value swapping | [Python](https://github.com/willtheorangeguy/PyTricks-Archive/blob/main/PyTricks/inplacevalueswapping.py) | [Web](https://willtheorangeguy.github.io/PyTricks-Archive/#inplacevalueswapping) |
| [🐍PyTricks]: Working with IP addresses in Python 3 | [Python](https://github.com/willtheorangeguy/PyTricks-Archive/blob/main/PyTricks/ipaddresses.py) | [Web](https://willtheorangeguy.github.io/PyTricks-Archive/#ipaddresses) |
| [🐍PyTricks]: "is" vs "==" | [Python](https://github.com/willtheorangeguy/PyTricks-Archive/blob/main/PyTricks/isvsequals.py) | [Web](https://willtheorangeguy.github.io/PyTricks-Archive/#isvsequals) |
| [🐍PyTricks]: itertools.permutations() | [Python](https://github.com/willtheorangeguy/PyTricks-Archive/blob/main/PyTricks/itertools.permutations.py) | [Web](https://willtheorangeguy.github.io/PyTricks-Archive/#itertools) |
| [🐍PyTricks]: Lambda Functions | [Python](https://github.com/willtheorangeguy/PyTricks-Archive/blob/main/PyTricks/lambdafunctions.py) | [Web](https://willtheorangeguy.github.io/PyTricks-Archive/#lambdafunctions) |
| [🐍PyTricks]: Python's list comprehensions are awesome | [Python](https://github.com/willtheorangeguy/PyTricks-Archive/blob/main/PyTricks/listcomprehensions.py) | [Web](https://willtheorangeguy.github.io/PyTricks-Archive/#listcomprehensions) |
| [🐍PyTricks]: Python list slice syntax fun | [Python](https://github.com/willtheorangeguy/PyTricks-Archive/blob/main/PyTricks/listslice.py) | [Web](https://willtheorangeguy.github.io/PyTricks-Archive/#listslice) |
| [🐍PyTricks]: @classmethod vs @staticmethod vs "plain" methods | [Python](https://github.com/willtheorangeguy/PyTricks-Archive/blob/main/PyTricks/methodscomparison.py) | [Web](https://willtheorangeguy.github.io/PyTricks-Archive/#methodscomparison) |
| [🐍PyTricks]: Multiple sets of kwargs in Python 3.5+ | [Python](https://github.com/willtheorangeguy/PyTricks-Archive/blob/main/PyTricks/multiplekwargs.py) | [Web](https://willtheorangeguy.github.io/PyTricks-Archive/#multiplekwargs) |
| [🐍PyTricks]: Python's namedtuples can be a great alternative to defining a class manually | [Python](https://github.com/willtheorangeguy/PyTricks-Archive/blob/main/PyTricks/namedtuplealternative.py) | [Web](https://willtheorangeguy.github.io/PyTricks-Archive/#namedtuplealternative) |
| [🐍PyTricks]: You can use "json.dumps()" to pretty-print Python dicts | [Python](https://github.com/willtheorangeguy/PyTricks-Archive/blob/main/PyTricks/prettyprintdicts.py) | [Web](https://willtheorangeguy.github.io/PyTricks-Archive/#prettyprintdicts) |
| [🐍PyTricks]: The get() method on Python dicts and its "default" arg | [Python](https://github.com/willtheorangeguy/PyTricks-Archive/blob/main/PyTricks/pythondictgetmethod.py) | [Web](https://willtheorangeguy.github.io/PyTricks-Archive/#pythondictgetmethod) |
| [🐍PyTricks]: When To Use **repr**\_\_** vs **str\*\*? | [Python](https://github.com/willtheorangeguy/PyTricks-Archive/blob/main/PyTricks/reprvsstr.py) | [Web](https://willtheorangeguy.github.io/PyTricks-Archive/#reprvsstr) |
| [🐍PyTricks]: How to sort a Python dict by value | [Python](https://github.com/willtheorangeguy/PyTricks-Archive/blob/main/PyTricks/sortdictbyvalue.py) | [Web](https://willtheorangeguy.github.io/PyTricks-Archive/#sortdictbyvalue) |
| [🐍PyTricks]: Different ways to test multiple flags at once in Python | [Python](https://github.com/willtheorangeguy/PyTricks-Archive/blob/main/PyTricks/testmultipleflags.py) | [Web](https://willtheorangeguy.github.io/PyTricks-Archive/#testmultipleflags) |
| [🐍PyTricks]: Measure the execution time of small bits of Python code with the "timeit" module | [Python](https://github.com/willtheorangeguy/PyTricks-Archive/blob/main/PyTricks/timeit.py) | [Web](https://willtheorangeguy.github.io/PyTricks-Archive/#timeit) |
| [🐍PyTricks]: Python 3.5+ type annotations | [Python](https://github.com/willtheorangeguy/PyTricks-Archive/blob/main/PyTricks/typeannotations.py) | [Web](https://willtheorangeguy.github.io/PyTricks-Archive/#typeannotations) |
| [🐍PyTricks]: Python 3 allows unicode variable names | [Python](https://github.com/willtheorangeguy/PyTricks-Archive/blob/main/PyTricks/unicodevariablename.py) | [Web](https://willtheorangeguy.github.io/PyTricks-Archive/#unicodevariablename) |
| [🐍PyTricks]: Avoid version conflicts with Virtual Environments | [Python](https://github.com/willtheorangeguy/PyTricks-Archive/blob/main/PyTricks/virtualenvs.py) | [Web](https://willtheorangeguy.github.io/PyTricks-Archive/#virtualenvs) |
## Contributing
Please contribute using [GitHub Flow](https://guides.github.com/introduction/flow). Create a branch, add commits, and [open a pull request](https://github.com/willtheorangeguy/PyTricks-Archive/compare).
Please read [`CONTRIBUTING`](CONTRIBUTING.md) for details on our [`CODE OF CONDUCT`](CODE_OF_CONDUCT.md), and the process for submitting pull requests to us.
## Credits
This software uses the following open source packages, projects, services or websites:
GitHub
Real Python
Bunny Fonts
Simple Analytics
Web - Plans
Web
Web
Web - Plans
## Contributors
- [@willtheorangeguy](https://github.com/willtheorangeguy) - Sponsor on [PayPal](https://paypal.me/wvdg44?country.x=CA&locale.x=en_US)
## You may also like...
- [Running Calculator](https://github.com/willtheorangeguy/Running-Calculator) - A running speed calculator for any unit of distance.
- [Python Logo Widgets](https://github.com/willtheorangeguy/Python-Logo-Widgets) - Python Powered Logo widgets that can be added to any GUI project.
- [Random Lotto Number Chooser](https://github.com/willtheorangeguy/Random-Lotto-Number-Chooser) - Randomly pick lucky lotto numbers.
## License
My work on this project is released under the Creative Commons Attribution 4.0 International Public License, which can be found in the [`LICENSE`](LICENSE.md) file. The PyTricks are copyright [Dan Badder of Real Python](https://realpython.com/).