Skip to content

Instantly share code, notes, and snippets.

View ironpythonbot's full-sized avatar

ironpythonbot

View GitHub Profile
@ironpythonbot
ironpythonbot / itertest.py
Created September 28, 2013 00:55
CodePlex Issue #18412 Plain Text Attachments
class iterclass(object):
def __iter__(self):
for i in range(10):
yield i
print iter(iterclass)
@ironpythonbot
ironpythonbot / test.py
Created September 28, 2013 00:57
CodePlex Issue #18637 Plain Text Attachments
# -*- coding: utf-8 -*-
print u'ABCDE\u3042\u3044\u3046\u3048\u304a'
@ironpythonbot
ironpythonbot / deltest.py
Created September 28, 2013 00:57
CodePlex Issue #18722 Plain Text Attachments
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
@ironpythonbot
ironpythonbot / Script1.py
Created September 28, 2013 01:00
CodePlex Issue #19130 Plain Text Attachments
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 \
@ironpythonbot
ironpythonbot / Script3.py
Created September 28, 2013 01:01
CodePlex Issue #19257 Plain Text Attachments
import time
import sys
def Date(year,month,day):
return Timestamp(year,month,day,0,0,0)
def Timestamp(year,month,day,hour,minute,second):
return time.localtime(time.mktime((year,month,day,hour,minute,second,0,0,-1)))
def DateObjectToIsoFormatString(obj):
@ironpythonbot
ironpythonbot / timing.py
Created September 28, 2013 01:03
CodePlex Issue #19484 Plain Text Attachments
from timeit import Timer
class Timing:
def __init__(self, name, num, init, statement):
self.__timer = Timer(statement, init)
self.__num = num
self.name = name
self.statement = statement
self.__result = None
@ironpythonbot
ironpythonbot / noattr.py
Created September 28, 2013 01:08
CodePlex Issue #19821 Plain Text Attachments
import types
class cached_property(object):
no_value = object()
def __init__(self, fget):
self.fget = fget
self.name = '_' + fget.__name__
def __get__(self, obj, cls):
@ironpythonbot
ironpythonbot / pyexpat.py
Created September 28, 2013 01:09
CodePlex Issue #20023 Plain Text Attachments
# Copyright (c) 2005-2007 Seo Sanghyeon
# A chapter from Dan Wahlin's "XML for ASP.NET Developers" is useful
# for understanding this code. Posted to informit.com, 2002-02-22.
# http://www.informit.com/articles/article.asp?p=25485
# 2005-11-16 sanxiyn Created
# 2006-08-18 sanxiyn Merged changes from Mark Rees
# * Adapted to the new way to load .NET libraries
# * Handle empty elements
@ironpythonbot
ironpythonbot / test2_close.py
Created September 28, 2013 01:11
CodePlex Issue #20143 Plain Text Attachments
# test2_close.py
from __future__ import with_statement
import types
import itertools
# Patching itertools.chain:
class chain(object):
@ironpythonbot
ironpythonbot / test_ihooks.py
Created September 28, 2013 01:14
CodePlex Issue #20326 Plain Text Attachments
class Loader(object):
def load_module(self, fullname):
return None
class MetaImporter(object):
def find_module(self, fullname, path=None):
return Loader()
import sys
sys.meta_path.append(MetaImporter())