Global accessors for things like settings. This could be used across applications and modules to share data.
This utility is to help easily share values across multiple modules and libraries without having to pass values around.
Example
Simple example.
# settings.py
import pyglobal
pyglobal.set('abc', 123)
pyglobal.default('qwerty', '')
pyglobal.set('Hello', 'World!')
pyglobal.default('SECRET_KEY', '!!!CHANGE!!!') # Warning: Any library using pyglobal could then look for this value.
pyglobal.set('DATABASE_URL', 'http://') # Warning: Any library using pyglobal could then look for this value.
Then use the settings in another part of the project
# main.py
import pyglobal
import settings # Set pyglobal values before using in other modules
import db
app = App(SECRET_KEY=pyglobal.get('SECRET_KEY'))
The sub module db.py doesn’t have to know anything about settings.py and can be nested down packages.
# db.py
import pyglobal
db = Database(pyglobal.get('DATABASE_URL'))
Avoiding clashes with other projects
Avoid clashes and add some small amount of security to your app with a scope
# settings.py
import pyglobal
import uuid
app_scope = 'MYAPP=' + str(uuid.uuid4())
def scope_get(key, default=None):
return pyglobal.get(key, default, app_scope)
def scope_set(key, value)
return pyglobal.set(key, value, app_scope)
pyglobal.scope_get = scope_get
pyglobal.scope_set = scope_set
pyglobal.set('SECRET_KEY', '!! Change !!', scope=app_scope)
scope_set('DATABASE_URL', 'http://')
Once again you can use in other files, but you would also need the scope to access.
# main.py
import pyglobal
import settings
secret = pyglobal.scope_get('SECRET_KEY')
db_url = pyglobal.get('DATABASE_URL', scope=settings.app_scope)
At some point code can always be disassembled, so this isn’t really secure. All scopes are is another level of obfuscation and a way to avoid global names from clashing with other projects.
Metadata
Release files for pyglobal 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 | |
|---|---|---|---|
| pyglobal-0.0.1.tar.gz | 7.5 kB | Details |
Built distributions (wheels)
| File | Reset | |||
|---|---|---|---|---|
| pyglobal-0.0.1-cp38-cp38-win_amd64.whl | CPython 3.8 | CPython 3.8 | Windows x86-64 | Details |
| pyglobal-0.0.1-cp38-cp38-win32.whl | CPython 3.8 | CPython 3.8 | Windows x86-32 | Details |
| pyglobal-0.0.1-cp37-cp37m-win_amd64.whl | CPython 3.7 | CPython 3.7 pymalloc | Windows x86-64 | Details |
| pyglobal-0.0.1-cp37-cp37m-win32.whl | CPython 3.7 | CPython 3.7 pymalloc | Windows x86-32 | Details |
| pyglobal-0.0.1-cp36-cp36m-win_amd64.whl | CPython 3.6 | CPython 3.6 pymalloc | Windows x86-64 | Details |
| pyglobal-0.0.1-cp36-cp36m-win32.whl | CPython 3.6 | CPython 3.6 pymalloc | Windows x86-32 | Details |
| pyglobal-0.0.1-cp34-cp34m-win_amd64.whl | CPython 3.4 | CPython 3.4 pymalloc | Windows x86-64 | Details |
| pyglobal-0.0.1-cp34-cp34m-win32.whl | CPython 3.4 | CPython 3.4 pymalloc | Windows x86-32 | Details |
Total release size: 320.8 kB
Release files / pyglobal-0.0.1.tar.gz
| Download URL | pyglobal-0.0.1.tar.gz |
|---|---|
| Size | 7.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
59d07da0d555e76ab512db305fa91d14c3a540c1b03b797dbd06a5cc1e29fc92
|
|
BLAKE2b-256 checksum How to use checksums |
7321c61da59073afe14a82d18c0afae397458c709b06999dc8179d6326d2ed9d
|
| 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/40.8.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.1
|
Release files / pyglobal-0.0.1-cp38-cp38-win_amd64.whl
| Download URL | pyglobal-0.0.1-cp38-cp38-win_amd64.whl |
|---|---|
| Size | 20.7 kB |
| Tags | CPython 3.8 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
97a7511916df379f2d77df45b183b91fe8824d6c0973711c678f4c380e0fc3b0
|
|
BLAKE2b-256 checksum How to use checksums |
863902ecbe6872f0e5838720ea8440748406ca2bc7010548db4b30aa02284a93
|
| 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/40.8.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.1
|
Release files / pyglobal-0.0.1-cp38-cp38-win32.whl
| Download URL | pyglobal-0.0.1-cp38-cp38-win32.whl |
|---|---|
| Size | 26.1 kB |
| Tags | CPython 3.8 Windows x86-32 |
|
SHA-256 checksum How to use checksums |
7f500597665271bbf5dc81cfe264ac4abe47b978a67d1643ed06e3586ba10ee5
|
|
BLAKE2b-256 checksum How to use checksums |
ad74c50da6e38e2f0250b9724ae91803e25e195bba2a27887739cce61e49967e
|
| 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/40.8.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.1
|
Release files / pyglobal-0.0.1-cp37-cp37m-win_amd64.whl
| Download URL | pyglobal-0.0.1-cp37-cp37m-win_amd64.whl |
|---|---|
| Size | 32.0 kB |
| Tags | CPython 3.7 CPython 3.7 pymalloc Windows x86-64 |
|
SHA-256 checksum How to use checksums |
733283f6ad279d5b19a400319b97cb19689a411f2ffe34864f216a1b615ec53d
|
|
BLAKE2b-256 checksum How to use checksums |
ef728ef191646ce91c02d053b98e4588a2a916e8c70172f20280736fe56e9564
|
| 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/40.8.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.1
|
Release files / pyglobal-0.0.1-cp37-cp37m-win32.whl
| Download URL | pyglobal-0.0.1-cp37-cp37m-win32.whl |
|---|---|
| Size | 37.3 kB |
| Tags | CPython 3.7 CPython 3.7 pymalloc Windows x86-32 |
|
SHA-256 checksum How to use checksums |
e93fbc686fc5522ffef85e0314b2bbb24e9586fe19491685b4266af301baf7b7
|
|
BLAKE2b-256 checksum How to use checksums |
b83f1c4fdab39520cada5024ab20b5d672d2f2ed4ba164b9d87f29f7d6d786de
|
| 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/40.8.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.1
|
Release files / pyglobal-0.0.1-cp36-cp36m-win_amd64.whl
| Download URL | pyglobal-0.0.1-cp36-cp36m-win_amd64.whl |
|---|---|
| Size | 43.3 kB |
| Tags | CPython 3.6 CPython 3.6 pymalloc Windows x86-64 |
|
SHA-256 checksum How to use checksums |
0f023eb5aa4eb9cce01e23431ac5220b07a8d869805949028cf0b9ef19355a74
|
|
BLAKE2b-256 checksum How to use checksums |
5085568f072d0b843b207346d11f55202b12ea9f743ec8557b01e4df232396f5
|
| 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/40.8.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.1
|
Release files / pyglobal-0.0.1-cp36-cp36m-win32.whl
| Download URL | pyglobal-0.0.1-cp36-cp36m-win32.whl |
|---|---|
| Size | 48.6 kB |
| Tags | CPython 3.6 CPython 3.6 pymalloc Windows x86-32 |
|
SHA-256 checksum How to use checksums |
85f8a1fbf5b9caf684561b2af201f3e07fb893ccefbaf7df76fd4c4904803765
|
|
BLAKE2b-256 checksum How to use checksums |
eeb263f46dd7a762cbcd6ab51b6bff1c33189eafe5d1f224942bf6941ca5700d
|
| 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/40.8.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.1
|
Release files / pyglobal-0.0.1-cp34-cp34m-win_amd64.whl
| Download URL | pyglobal-0.0.1-cp34-cp34m-win_amd64.whl |
|---|---|
| Size | 52.6 kB |
| Tags | CPython 3.4 CPython 3.4 pymalloc Windows x86-64 |
|
SHA-256 checksum How to use checksums |
7a7d4664abfa97f3f150d8fffab4d262fcd73b37f8e30ca4ea60e5cf2777f27a
|
|
BLAKE2b-256 checksum How to use checksums |
92d464fd220d54a351f41732484373420c709f56f030be213da82f0560d8021c
|
| 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/40.8.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.1
|
Release files / pyglobal-0.0.1-cp34-cp34m-win32.whl
| Download URL | pyglobal-0.0.1-cp34-cp34m-win32.whl |
|---|---|
| Size | 52.6 kB |
| Tags | CPython 3.4 CPython 3.4 pymalloc Windows x86-32 |
|
SHA-256 checksum How to use checksums |
89df9e8c8783ab9fefa77f582dce0816056c89a21e0144ba5f890c336e32e9af
|
|
BLAKE2b-256 checksum How to use checksums |
21b92e67164651ad90c96d98f1db02db5e5c47257b60b66aec31116e1118540b
|
| 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/40.8.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.1
|