Skip to main content

A Python module methods decorator

Project description

import export

A Python package methods decorator

Lines of code Downloads Statistic GitHub

Let me show here

1. install

pip install -U import-export

2. use

"""mypack.py"""
import export

def fee():
    return 'twee'
	
@export
def moo():
    return 'moow'
    
@export
class C(object):
    pass
> from mypack import *
> print(fee())
NameError: name 'fee' is not defined
> print(moo())
moow
> print(C())
<mypack.C object at 0x00********>

NB:

> import mypack
> print(mypack.fee())
twee

How it work

  • just add decorated resource name to the tuple module.__all__

Implementation features

  • no requirements, but sys only
  • uses some hack from sys import modules and so won't leave beta
  • does not store itself in module variables
  • runs for all version python

License

  • It's free software, see the LICENSE for more details.

Credits

TODO

  • export(None) == raise Exception('doesn't work')
  • may be implement private() public() etc decorator to classes as new version of competing library
  • next part coming soon!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

import-export-0.3.1.tar.gz (5.1 kB view details)

Uploaded Source

File details

Details for the file import-export-0.3.1.tar.gz.

File metadata

  • Download URL: import-export-0.3.1.tar.gz
  • Upload date:
  • Size: 5.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.6

File hashes

Hashes for import-export-0.3.1.tar.gz
Algorithm Hash digest
SHA256 1e47906ef2cb35bedaf5082e37ead4f332f35757005a7eff85bf9aef85ea6a7b
MD5 d46d1d4560d79618ef2c579166ecb157
BLAKE2b-256 d0cd1a8c0719058ad9869758a3b4b2417519241c2c9f57ebc074730dbf664adf

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page