Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(5)  |  Call(3)  |  Derive(0)  |  Import(2)
Determine if C{identifier} is a valid Python identifier.  This function never raises
any exceptions.  If C{identifier} is not a string, it simply returns C{False}.

@param identifier: identifier to determin if it is valid
@type  identifier: C{basestring}

@rtype:            C{bool}

        def is_valid_identifier (identifier):
    """
    Determine if C{identifier} is a valid Python identifier.  This function never raises
    any exceptions.  If C{identifier} is not a string, it simply returns C{False}.

    @param identifier: identifier to determin if it is valid
    @type  identifier: C{basestring}

    @rtype:            C{bool}
    """

    return (isinstance (identifier, StringType)
            and re.match ('^[_a-zA-Z][_a-zA-Z0-9]*$', identifier) is not None
            and not iskeyword (identifier))
        


src/p/y/py-notify-0.3.1/notify/base.py   py-notify(Download)
from notify.mediator import AbstractMediator
from notify.signal   import AbstractSignal, Signal
from notify.utils    import execute, is_callable, is_valid_identifier, mangle_identifier, \
                            raise_not_implemented_exception, StringType
 
        """
 
        if not is_valid_identifier (new_class_name):
            raise TypeError ("'%s' is not a valid Python identifier" % new_class_name)
 
        if 'object' in options:
            object = options['object']
            if not is_valid_identifier (object):
                raise ValueError ("'%s' is not a valid Python identifier" % object)
 
                    raise ValueError ("'property' option cannot be the same as 'object'")
 
                if not is_valid_identifier (property):
                    raise ValueError ("'%s' is not a valid Python identifier" % property)
 

src/p/y/py-notify-0.3.1/test/utils.py   py-notify(Download)
import unittest
 
from notify.utils import is_callable, is_valid_identifier, mangle_identifier, as_string, \
                         raise_not_implemented_exception, DummyReference