A python module to help with meta classes
Project description
A helper class to programaticly build a Meta Class
Install
git clone https://gitlab.com/craigukaea/class-maker.git
cd class-builder
./Install
Use
To build a class equivelent to the following:
class Foo:
def bar():
print("Hello world")
Use:
maker = ClassMaker()
maker.setClassName('Foo')
maker.addFunction('bar', lambda : print("Hello World!"))
#make the class
foo = maker.makeClass()
##test the functions
foo.__init__()
foo.bar()
Example
from ClassMaker import ClassMaker
if __name__ == "__main__":
maker = ClassMaker()
maker.setClassName('Foo')
maker.addFunction('bar', lambda : print("Hello World!"))
maker.addVariable('baz', 5)
maker.addFunctionToInitialiser(lambda : print("Initialising"))
maker.addFunctionToInitialiser(lambda : print("!"))
foo = maker.makeClass()
foo.__init__()
foo.bar()
print(foo.baz)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
ClassMaker-0.1.tar.gz
(2.1 kB
view details)
Built Distribution
File details
Details for the file ClassMaker-0.1.tar.gz
.
File metadata
- Download URL: ClassMaker-0.1.tar.gz
- Upload date:
- Size: 2.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.6.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7b7e1725be135f6b6c5cb86e7fd4c6750f6d8305aa9f2663666815f5fdc34551 |
|
MD5 | c4f88c0e0cd905e0cea9ca532da23bc4 |
|
BLAKE2b-256 | be99a4b116a700d212ca620f2aa0c9bde95f5c6e95c09ed6cf87ec95b981babc |
File details
Details for the file ClassMaker-0.1-py3-none-any.whl
.
File metadata
- Download URL: ClassMaker-0.1-py3-none-any.whl
- Upload date:
- Size: 2.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.6.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d8a51ef52a752aeec372c91362e09913980e2694613b80598c78ac537b1aa219 |
|
MD5 | f39d51f4ea46f026bfa25dd470a0b4fb |
|
BLAKE2b-256 | 52679687e57d35f7c56ec70bbf307a6b7df6414f7d59d662c68a61966c5123f7 |