Dark Python
Patch python built-in functions and libraries!
Create your own python!
Do dangerous things in python you've never dreamed of!
What it does
- patch built-in function
$ dpython config beautify.py
# beautify.py
from pprint import pprint
print = pprint
and just use $ dpython as python command line for the rest of your life, every print is guaranteed to be pretty.
- patch any package, built-in or not
$ dpython config troll_packages/random
random
└── __init__.py
#__init__.py
def randint(a,b):
return a
And now ssh into some production server. $ sudo alias python3=dpython and watch the world burn.
Use case
Combined with the forbidden fruit. You can do anything, including:
-
Customize your python however you like. Are you a data scientist who find it impossible to do anything with python vanilla list? No problem! Extend built-in list with numpy array functionality!
-
Patch a shit ton of python code without doing any refactoring
-
Create python patch package for other packages
How to use
pip install dpython
By default, pip creates command line shortcut $ dpython. If it does not work, (You're using stupid Windows or something), you can always use > python -m dpython
dpython by itself works exactly the same as python command line.
e.g.:
$ dpython test.py runs test.py
$ dpython opens interactive shell
$ dpython -m my_module runs folder my_module as a python module
dpython only has one reserved sub-command which is different from python: 'config'. You can supply the following instructions:
$ dpython config [something.py|folder]. Register either a single .py file or a folder containing a python package.
- In the case of
pyfile. The supplied file will effectively be executed prior to future$ dpythoncalls. You can call it a startup script. - In the case of a package, imports in other code will use the supplied package instead of ones with duplicate names.
- You can register as many as packages as you like. But only one
.pystartup script.
$ dpython config inspect-script Print the saved startup script
$ dpython config clear-script Reset the saved startup script
$ dpython config inspect-package Print registered packages
# example output
patch packages:
random
numpy
argparse
$ dpython config clear-package Clear registered packages, won't delete real file.
# example output
random removed
numpy removed
argparse removed
$ dpython -h|--help to print help
More Examples
-
example 1
# leEtH4ck3r.py oldprint = print def print(*args, **kwargs): oldprint('Pwned by Dark Python!!!') oldprint(*args, **kwargs)
$ dpython register leEtH4ck3r.py -
example 2
# ilovetqdm.py from tqdm import trange range = trange
$ dpython register ilovetqdm.py
My Stupid Fantasies (todos)
-
Write a package called
gwrapthat internally usesdpythonto extend built-inargparse.$ gwrap any_cmd_utility.pyAs long as the script uses
argparse, gwrap will create a GUI, with check boxes replacing boolean arguments. Drop down menus replacing argument choices. Hovering tooltips for argument help. And store command history for autocompletion. -
Install
dpythonon my coworkers computer, screw up the most usual functions likerange(),list(). Alias python=dpython just for fun.
Metadata
Release files for dpython 1.0.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| dpython-1.0.5.tar.gz | 7.4 kB | Without provenance | Details for dpython-1.0.5.tar.gz |
Release files / dpython-1.0.5.tar.gz
| Download URL | dpython-1.0.5.tar.gz |
|---|---|
| Size | 7.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
859cd892f76cf28c3a0540900cae9cdef511dbf3fb83e46e6b195b441175bf88
|
|
BLAKE2b-256 checksum How to use checksums |
ad3bf7bebe215f7ab39e88ccc999d2b6672c64dc28cfbb490c5c824cfef14f2c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.6.8
|
Security for dpython 1.0.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.