[Subversion] / AddOns / README.txt  

Diff of /AddOns/README.txt

Parent Directory | Revision Log

version 2727, Fri Apr 3 23:33:46 2015 UTC version 2728, Fri Apr 3 23:43:33 2015 UTC
Line 34 
Line 34 
     ...         self.saved = False      ...         self.saved = False
     ...     def save_if_needed(self):      ...     def save_if_needed(self):
     ...         if not self.saved:      ...         if not self.saved:
     ...             print "saving"      ...             print("saving")
     ...             self.saved = True      ...             self.saved = True
   
     >>> class Thing: pass      >>> class Thing: pass
Line 139 
Line 139 
   
     >>> something = Thing()      >>> something = Thing()
     >>> Index(something, "x>y")["a"] = "b"      >>> Index(something, "x>y")["a"] = "b"
     >>> dir(something)      >>> [key for key in something.__dict__ if not isinstance(key, str)]
     ['__doc__', '__module__', (<class 'Index'>, 'x>y')]      [(<class 'Index'>, 'x>y')]
   
     >>> "a" in Index(something, "z<22")      >>> "a" in Index(something, "z<22")
     False      False
Line 151 
Line 151 
     >>> Index(something, "x>y").expression      >>> Index(something, "x>y").expression
     'x>y'      'x>y'
   
     >>> dir(something)      >>> keys = [key for key in something.__dict__ if not isinstance(key, str)]
     ['__doc__', '__module__', (<class 'Index'>, 'x>y'), (<class 'Index'>, 'z<22')]      >>> keys.sort()
       >>> keys
       [(<class 'Index'>, 'x>y'), (<class 'Index'>, 'z<22')]
   
     >>> Index.exists_for(something, 'x>y')      >>> Index.exists_for(something, 'x>y')
     True      True
Line 187 
Line 189 
     >>> Leech(something, 42)      >>> Leech(something, 42)
     Traceback (most recent call last):      Traceback (most recent call last):
       ...        ...
     TypeError: addon_key() takes exactly 1 argument (2 given)      TypeError: addon_key() takes exactly 1 ...argument (2 given)
   
 Naturally, your ``addon_key()`` and ``__init__()`` (and/or ``__new__()``)  Naturally, your ``addon_key()`` and ``__init__()`` (and/or ``__new__()``)
 methods should also agree on how many arguments there can be, and what they  methods should also agree on how many arguments there can be, and what they
Line 252 
Line 254 
 usually be deleted as soon as the subject is::  usually be deleted as soon as the subject is::
   
     >>> def deleting(r):      >>> def deleting(r):
     ...     print "deleting", r      ...     print("deleting "+str(r))
   
     >>> from weakref import ref      >>> from weakref import ref
   
Line 370 
Line 372 
   
     >>> class SpecialMethodRegistry(ClassAddOn):      >>> class SpecialMethodRegistry(ClassAddOn):
     ...     def __init__(self, subject):      ...     def __init__(self, subject):
     ...         print "init called for", subject      ...         print("init called for "+str(subject))
     ...         self.special_methods = {}      ...         self.special_methods = {}
     ...         super(SpecialMethodRegistry, self).__init__(subject)      ...         super(SpecialMethodRegistry, self).__init__(subject)
     ...      ...
     ...     def created_for(self, cls):      ...     def created_for(self, cls):
     ...         print "created for", cls.__name__      ...         print("created for "+cls.__name__)
   
     >>> class Demo:      >>> class Demo:
     ...     def dummy(self, foo):      ...     def dummy(self, foo):
Line 391 
Line 393 
 the subject is not ``None``::  the subject is not ``None``::
   
     >>> SpecialMethodRegistry(float)      >>> SpecialMethodRegistry(float)
     init called for <type 'float'>      init called for <... 'float'>
     created for float      created for float
     <SpecialMethodRegistry object at ...>      <SpecialMethodRegistry object at ...>
   
Line 644 
Line 646 
     ...         from threading import RLock      ...         from threading import RLock
     ...         self.lock = RLock()      ...         self.lock = RLock()
     ...     def acquire(self):      ...     def acquire(self):
     ...         print "acquiring"      ...         print("acquiring")
     ...         self.lock.acquire()      ...         self.lock.acquire()
     ...     def release(self):      ...     def release(self):
     ...         self.lock.release()      ...         self.lock.release()
     ...         print "released"      ...         print("released")
   
     >>> def synchronized(func):      >>> def synchronized(func):
     ...     def wrapper(self, *__args,**__kw):      ...     def wrapper(self, *__args,**__kw):
Line 663 
Line 665 
   
     >>> class AnotherThing:      >>> class AnotherThing:
     ...     def ping(self):      ...     def ping(self):
     ...         print "ping"      ...         print("ping")
     ...     ping = synchronized(ping)      ...     ping = synchronized(ping)
   
     >>> AnotherThing().ping()      >>> AnotherThing().ping()


Generate output suitable for use with a patch program
Legend:
Removed from v.2727  
changed lines
  Added in v.2728

cvs-admin@eby-sarna.com

Powered by ViewCVS 1.0-dev

ViewCVS and CVS Help