no_toplevel_code
Package to wrap a piece of python code in a function and function call, to avoid running code at the top level of a script.
Example
E.g., if you have a script that looks like this:
import numpy as np
import matplotlib.pyplot as plt
x = np.linspace(0, 2*np.pi, 100)
y = np.sin(x)
plt.plot(x, y)
plt.show()
no_toplevel_code converts it to this:
import numpy as np
import matplotlib.pyplot as plt
def _main():
x = np.linspace(0, 2*np.pi, 100)
y = np.sin(x)
plt.plot(x, y)
plt.show()
_main()
Interface
This package provides two functions: wrap_code and unwrap_code as well as their equivalent functions
wrap_ast and unwrap_ast. The former functions take a string as input, while the latter functions
take an AST (Abstract Syntax Tree) as input.
Metadata
Release files for no-toplevel-code 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| no-toplevel-code-1.0.0.tar.gz | 2.9 kB | Details |
Release files / no-toplevel-code-1.0.0.tar.gz
| Download URL | no-toplevel-code-1.0.0.tar.gz |
|---|---|
| Size | 2.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1e7d33fa2f4567aba616b4b2a7cf069e8902c3c826afe8268e003a0351aa66a8
|
|
BLAKE2b-256 checksum How to use checksums |
4cd580b10e7ec7676a2d25ae1890dff817effa913c33b2345538fc3e3961e254
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.65.0 CPython/3.8.8
|