The PEAK Developers' Center   Diff for "PEAK-Rules/Predicates" UserPreferences
 
HelpContents Search Diffs Info Edit Subscribe XML Print View Up
Ignore changes in the amount of whitespace

Differences between version dated 2010-08-17 19:59:15 and 2011-08-31 21:12:05

Deletions are marked like this.
Additions are marked like this.

calls where the second argument is a constant, and ``type(x) is y`` expressions
where `y` is a constant::
 
    >>> from peak.rules.criteria import Test, Signature, Classes
    >>> from peak.rules.criteria import Test, Signature, Conjunction
 
    >>> pe('isinstance(x,int)')
    Test(IsInstance(Local('x')), Class(<type 'int'>, True))

    Test(IsInstance(Local('x')), istype(<type 'str'>, False))
 
    >>> pe('not isinstance(x,(int,(str,unicode)))') == Test(
    ... IsInstance(Local('x')), Classes([
    ... IsInstance(Local('x')), Conjunction([
    ... Class(unicode, False), Class(int, False), Class(str, False)])
    ... )
    True

    True
 
    >>> pe('not issubclass(x,(int,(str,unicode)))') == Test(
    ... IsSubclass(Local('x')), Classes([
    ... IsSubclass(Local('x')), Conjunction([
    ... Class(unicode, False), Class(int, False), Class(str, False)])
    ... )
    True

    ... lambda expr: Test(None, expr.value)
    ... )
    <function <lambda> ...>
 
    >>> expressionSignature(Const(priority(3)))
    Test(None, 3)
 
    
Okay, let's try out our new condition::
 

PythonPowered
ShowText of this page
EditText of this page
FindPage by browsing, title search , text search or an index
Or try one of these actions: AttachFile, DeletePage, LikePages, LocalSiteMap, SpellCheck