Softpedia
 


LINUX CATEGORIES:



GLOBAL PAGES >>
NEWS ARCHIVE >>
SOFTPEDIA REVIEWS >>
MEET THE EDITORS >>
WEEK'S BEST
  • Linux Kernel 3.9.3 / 3....
  • LibreOffice 3.6.6 / 4.0.3
  • MPlayer 1.1.1
  • systemd 204
  • Arch Linux 2013.05.01
  • Blender 2.67a
  • KDE Software Compilatio...
  • CrunchBang Linux Stable...
  • Elementary OS 0.1 / 0.2...
  • SystemRescueCd 3.6.0
  • Home > Linux > Programming > Libraries

    injector 0.6.1

    Download button

    No screenshots available
    Downloads: 207  Tell us about an update
    User Rating:
    Rated by:
    NOT RATED
    0 user(s)
    Developer:

    License / Price:

    Last Updated:

    Category:
    Alec Thomas | More programs
    BSD License / FREE
    April 18th, 2012, 19:47 GMT
    ROOT / Programming / Libraries

     Read user reviews (0)  Refer to a friend  Subscribe

    injector description

    Python dependency injection framework, inspired by Guice

    injector is a Python framework similar to snake-guice, but aims for simplification.

    While being inspired by Guice, it does not slavishly replicate its API. Providing a Pythonic API trumps faithful replication.

    An Example


    Here's a brief, completely contrived, example from the unit tests:

    from injector import Injector, Module, Key, injects, provides

    Weight = Key('Weight')
    Age = Key('Age')

    class MyModule(Module):
     @provides(Weight)
     def provide_weight(self):
     return 50.0

     @provides(Age)
     def provide_age(self):
     return 25

     # TODO(alec) Make provides/inject order independent.
     @provides(str)
     @inject(age=Age, weight=Weight)
     def provide_description(self, age, weight):
     return 'Bob is %d and weighs %0.1fkg' % (age, weight)

    assert_equal(Injector(MyModule()).get(str), 'Bob is 25 and weighs 50.0kg')



    Product's homepage

    Requirements:

    · Python

      


    TAGS:

    Python framework | dependency injection | injection framework | Python | framework | dependency

    Go to top

    WindowsGamesDriversMacLinuxScriptsMobileHandheldNews

    SUBMIT PROGRAM   |   ADVERTISE   |   GET HELP   |   SEND US FEEDBACK   |   RSS FEEDS   |   UPDATE YOUR SOFTWARE   |   ROMANIAN FORUM