Skip to main content

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


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)

Uploaded Source

Built Distribution

find_class-0.0.1-py3-none-any.whl (6.2 kB view hashes)

Uploaded Python 3

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