Finds a python-thing, like a class, a function or a variable by string and loads it
Project description
find_class
This little package finds and loads a class by fully qualified string.
Let's assume there is a file in package/sub/animal.py
with
class Animal:
def say_somthing(self):
return 'wau'
def a_little_function():
return 'wuff'
a_tone = 'wiiiiii'
Then, you can use find_class
to get from a string to the python-thing:
a = find_class('package.sub.animal.Animal')().say_something()
b = find_class('package.sub.animal.a_little_function')()
c = find_class('package.sub.animal.a_tone')
assert a == 'wau'
assert b == 'wuff'
assert c == 'wiiiiii'
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
find_class-0.0.1.tar.gz
(6.0 kB
view hashes)
Built Distribution
Close
Hashes for find_class-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0581c85c549237f6455036fa99c4b2fa5c8000f0163adc0256f2aa707ff0994b |
|
MD5 | d4a8fea28979461194adb41957587900 |
|
BLAKE2b-256 | 21a522a71c01b064519af4c1ff77217a573db38b514ea7bf32657cd15cd72b7d |