Skip to main content

Home/ Python Programming/ Group items tagged oop

Rss Feed Group items tagged

anonymous

Guide to Python introspection - 5 views

  • Objects that represent potential behavior (functions and methods) can be invoked, or called. We can test an object's callability with the callable() function:
anonymous

Intermediate and Advanced Software Carpentry in Python - 4 views

  • try: import psyco psyco.full() except ImportError: pass
  • >>> def simple_cache(fn): ... cache = {} ... ... def new_fn(n): ... if n in cache: ... print 'FOUND IN CACHE; RETURNING' ... return cache[n] ... ... # otherwise, call function & record value ... val = fn(n) ... cache[n] = val ... return val ... ... return new_fn
1 - 2 of 2
Showing 20 items per page