Giter VIP home page Giter VIP logo

autoxinit's Introduction

autoXinit - lazy importing

This package extends the the py-package 'automodinit' with the option also to import classes and functions inside a module.

If classes/functions have the same name as modules they will override them. This is useful if the 'one class/function per file' principle is used.

autoXinit is listed in the Python Package Index. You can install it typing:

pip install autoxinit

To init your package with autoXinit add the following to your __init__.py:

__all__ = []
# Don't modify the line above, or this line!
from autoxinit import autoxinit
autoxinit(__name__, __file__, globals())
del autoxinit

If you want to exclude modules, functions and or classes add accordingly:

import_modules=False,
import_classes=False,
import_functions=False

as keyword argument to the autoxinit() function above.

If you want to exclude classes/functionc from specific modules from the import add:

AUTOXINIT_IMPORT_MEMBERS = False

somewhere in the corresponding module.

autoXinit also provides a test package. Importing this module via:

from autoxinit import test
  1. Execute the test environment
  2. Imports all modules AND all included (dummy) functions/classes. If a function/class share the same same with its parent module calling the modules name leeds to the function/class.

File structure of the test package:

  • testClass.py
    • class testClass
  • testFunction.py
    • def testFunction
  • testModule.py
    • class testModuleClass
    • def testModuleFunction

Instead of typing:

from test.testClass import testClass
from test.testFunction import testFunction

You can import your classes/functions directly via:

from test import testClass
from test import testFunction

As written before the imported names are only overridden if the name of a class/function is identical to the name of the module. That's why you can still access:

from test import testModule
from testModule import testModuleClass
from testModule import testModuleFunction

autoxinit's People

Contributors

radjkarl avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.