Ejemplo n.º 1
0
# doStuff( lambda x=1: print( "slartibartfast %r" % x ) )

# overwrite a method name with another method... wtf... woah... careful
method1()
method1 = method2
method1()

# Enums !!
# from enum import Enum ### don't forget the import as our enum Color is derived from Enum
class Color( Enum ):
    red = 1
    green = 2
    blue = 3

print( "Color: %r" % Color.red )  # NOTE: Python 3+ prints the enum class, name and ordinal

# printing without newline
sys.stdout.write( "this is" )
sys.stdout.write( " on the same line" )
print( "" )

division = 5 / 2
print( "5/2   = %r" % division )

division = 5 / 2.0
print( "5/2.0 = %r" % division )

matchingSymbolString = "{.{.}.}.{.}"
matchingSymbolPos = StrUtl.findMatchingSymbol( matchingSymbolString, "{", "}" )
print( "MatchingSymbolPos: [%r]='%r'" % ( matchingSymbolPos, matchingSymbolString[matchingSymbolPos] ) )