Skip to main content

Get an object by name or dotted path, import if it necessary.

Project description

Get an object by name or dotted path, import if it necessary.

Install

pip install object_by_name

Usage

>>> from object_by_name import object_by_name
>>> object_by_name('test_package')
<module 'test_package' from ...>
>>> object_by_name('test_package.test_module')
<module 'test_package.test_module' from ...>
>>> object_by_name('test_package.test_module.TestClass')
<class 'test_package.test_module.TestClass'>
>>> object_by_name('test_package.test_module.instance')
<test_package.test_module.TestClass object at 0x...>
>>> object_by_name('test_package.test_module.instance.method')
<bound method TestClass.method of <test_package.test_module.TestClass ...>>

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

object_by_name-0.0.1.tar.gz (1.8 kB view hashes)

Uploaded Source

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