stupidity.py - toolkit for stupid Python code
Installation
pip install stupidity
Switch statement
Ever miss the classic switch statement in Python?
from stupidity import switch
for case in switch('b'):
if case('a'):
print('this is not printed')
if case('b'):
print('this is printed')
if case('c'):
print('fallthrough is also supported')
break
if case('d'):
print('this is not printed either')
print('default value at bottom, but this is not reached')
Think if-statements are stupid? We've got you covered!
from stupidity import switch
for case in switch('b'):
with case('a'):
print('this is not printed')
with case('b'):
print('this is printed')
with case('c'):
print('fallthrough is also supported')
break
with case('d'):
print('this is not printed either')
print('default value at bottom, but this is not reached')
Think for-loops are stupid too? We can get rid of those as well:
from stupidity import switch
with switch('b') as case:
with case('a'):
print('this is not printed')
with case('b'):
print('this is printed')
with case('c'):
print('fallthrough is also supported')
BREAK # NOTE: We have to yell here
with case('d'):
print('this is not printed either')
print('default value at bottom, but this is not reached')
Dealing with closure variables
Ever get annoyed at those pesky variables inside closures that are seemingly just outside your reach? Fear no more!
from stupidity import replace_closure_variables
def foo():
x = 42
def f():
return x
return f
f = foo()
f() # 42
replace_closure_variables(f, x=123)
f() # 123
Braces
Everyone knows that importing braces from __future__ fails miserably:
from __future__ import braces
# File "<stdin>", line 1
# SyntaxError: not a chance
Luckily, we provide a working implementation:
from stupidity import braces
x = 42;
if (x == 123): {
print('nope')
}
elif (x == 42): {
print('yep')
}
# prints 'yep'
Metadata
Release files for stupidity 0.0.1
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 |
|---|---|---|---|---|
| stupidity-0.0.1.tar.gz | 4.5 kB | Without provenance | Details for stupidity-0.0.1.tar.gz |
Release files / stupidity-0.0.1.tar.gz
| Download URL | stupidity-0.0.1.tar.gz |
|---|---|
| Size | 4.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fd40770018815e061b22a8ca994459638a01cf1d9edb1426853ca3e4462f07f8
|
|
BLAKE2b-256 checksum How to use checksums |
e20a390b447e4b6f5f21cd607229c6b564a912dae7105e6c32204e2561296fd2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.2
|
Security for stupidity 0.0.1
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.