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

    pyfnc 0.1.1

    Download button

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

    License / Price:

    Last Updated:

    Category:
    Jean-Lou Dupont | More programs
    Other/Proprietary Li... / FREE
    February 13th, 2012, 03:15 GMT
    ROOT / Programming / Libraries

     Read user reviews (0)  Refer to a friend  Subscribe

    pyfnc description

    Python decorators for pattern matching function dispatch



    For more information, visit http://www.systemical.com/doc/opensource/pyfnc

    Examples

    Dictionary class 'dic' with 'return self' functionality:

     >>> d=dic({"k2":"v2"})
     >>> dr=d.update({"k1":"v1"})
     >>> self.assertEqual(d, dr)


    List class 'liste' with 'return self' functionality and integrated 'map', 'reduce' and 'filter' functions:

     >>> l=liste()
     >>> lr=l.extend([1,2,3])
     >>> self.assertEqual(len(l), 3)
     >>> self.assertEqual(l, lr)

     >>> f=lambda x:x+10

     >>> lm=l.map(f)
     >>> self.assertEqual(lm, [11, 12, 13])
     >>> self.assertEqual(l, [11, 12, 13])


    Erlang style function dispatch:

     >>> @pattern('male', str)
     ... def greet_male(p1, p2):
     ... return "Hello M. %s!" % p2

     >>> @pattern('female', str)
     ... def greet_female(p1, p2):
     ... return "Hello Mrs. %s!" % p2

     >>> @patterned
     ... def greet(p1, p2):
     ... pass

     >>> print greet("male", "Dupont")
     "Hello M. Dupont!"

     >>> print greet("female", "Corriveau")
     "Hello Mrs. Corriveau!"


    Tests


    Tests can be performed using nosetests in the root directory.


    Product's homepage

    Requirements:

    · Python

      


    TAGS:

    Python decorators | pattern matching | Python | decorators | pattern

    Go to top

    WindowsGamesDriversMacLinuxScriptsMobileHandheldNews

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