This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
print u'ABCDE\u3042\u3044\u3046\u3048\u304a' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from System import GC | |
class C(object): | |
_instance = None | |
def __new__(cls): | |
if C._instance is None: | |
C._instance = object.__new__(cls) | |
return C._instance |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
types = ['int', 'float', 'complex', 'long', 'str', 'dict', 'list', 'bool', | |
'tuple', 'unicode', 'bytearray', 'buffer', 'xrange', 'set', | |
'frozenset', 'file', 'memoryview', 'method-wrapper', 'type', | |
'builtin_function_or_method', 'NoneType'] | |
methods = dir(object) | |
def recurse(obj, path, depth): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import datetime | |
types = ['int', 'float', 'complex', 'long', 'str', 'dict', 'list', 'bool', | |
'tuple', 'unicode', 'bytearray', 'buffer', 'xrange', 'set', | |
'frozenset', 'file', 'memoryview', 'method-wrapper', | |
'builtin_function_or_method', 'NoneType', 'wrapper_descriptor'] | |
methods = dir(object) | |
methods.extend(dir(type)) | |
methods.append('__objclass__') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import clr | |
clr.AddReference("Microsoft.Scripting.Core") | |
clr.AddReference("Microsoft.Scripting") | |
clr.AddReference("IronPython") | |
import System | |
import Microsoft.Scripting | |
import Microsoft.Scripting.Hosting | |
from System.Scripting import SourceCodeKind | |
from Microsoft.Scripting.Hosting import ErrorListener, ScriptRuntime |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from Cheetah.Template import Template | |
templateDef = """ | |
#import sys | |
<HTML> | |
<HEAD><TITLE>$title</TITLE></HEAD> | |
<BODY> | |
$contents | |
## this is a single-line Cheetah comment and won't appear in the output | |
#* This is a multi-line comment and won't appear in the output | |
blah, blah, blah |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def fib(n): | |
if n < 2: | |
return n | |
else: | |
return fib(n-1) + fib(n-2) | |
code = ''' | |
def execfib(n): | |
if n < 2: | |
return n |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
import datetime | |
import sys | |
_ordinal_1899_12_31=datetime.date(1899,12,31).toordinal()-1 | |
def COMDateFromTuple(YMDHMSmsTuple): | |
d = datetime.date(YMDHMSmsTuple[0],YMDHMSmsTuple[1],YMDHMSmsTuple[2]) | |
integerPart = d.toordinal() - _ordinal_1899_12_31 | |
ms = ((YMDHMSmsTuple[3]*60 \ | |
+YMDHMSmsTuple[4])*60 \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
import datetime | |
import sys | |
print sys.version | |
def Timestamp(year,month,day,hour,minute,second): | |
return time.localtime(time.mktime((year,month,day,hour,minute,second,0,0,-1))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class N(object): | |
def __float__(self): | |
print 'float' | |
return 0.001 | |
def __long__(self): | |
print 'long' | |
return 0L | |
from math import log, log10 |
OlderNewer