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
using System; | |
using System.Diagnostics; | |
using System.IO; | |
using System.Runtime.InteropServices; | |
using System.Security; | |
namespace MyConsole | |
{ | |
/// <summary> | |
/// Do ConsoleManager.Show() followed by Console.WritLine(), etc |
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
##################################################################################### | |
# | |
# Copyright (c) Microsoft Corporation. All rights reserved. | |
# | |
# This source code is subject to terms and conditions of the Microsoft Public License. A | |
# copy of the license can be found in the License.html file at the root of this distribution. If | |
# you cannot locate the Microsoft Public License, please send an email to | |
# ironpy@microsoft.com. By using this source code in any fashion, you are agreeing to be bound | |
# by the terms of the Microsoft Public License. | |
# |
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 subprocess import Popen, CREATE_NEW_PROCESS_GROUP | |
import ctypes | |
import signal | |
import sys | |
import time | |
def receive(): | |
def handler(signum, frame): |
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 functools import partial | |
class _MetaBaseObject(type): | |
def __init__(cls, name, bases, dct): | |
super(_MetaBaseObject, cls).__init__(name, bases, dct) | |
class Attr: | |
def __init__(self, **kwargs): | |
for k,v in kwargs.items(): | |
setattr(self,k,v) |
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 random | |
class Item: | |
def __init__(self, id): | |
self.Id = id | |
self.Value = random.random() * random.randint(5,100) | |
self.IsGood = random.random() < 0.9 # ~90% good | |
x = map(lambda i: Item(i), range(0, 1000)) |
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 unittest | |
import struct | |
import array | |
class StructTest(unittest.TestCase): | |
def test_unpack(self): | |
# test string format string | |
result = struct.pack(">HH", 1, 2) | |
self.assertEqual(result, b"\x00\x01\x00\x02") |
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 __future__ import with_statement | |
from codecs import BOM_UTF8 | |
with open('with_bom.txt', 'w') as f: | |
f.write(BOM_UTF8 + u'\xe4'.encode('UTF-8')) | |
with open('without_bom.txt', 'w') as f: | |
f.write(u'\xe4'.encode('UTF-8')) | |
with open('with_bom.txt') as f: |
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
namespace IPyImports | |
{ | |
using IronPython.Hosting; | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var e = Python.CreateEngine(); |
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
*** D:/Tmp/~/2/zipimport.cs Thu Oct 17 18:25:24 2013 | |
--- D:/Tmp/~/1/zipimport.cs Thu Nov 07 10:49:37 2013 | |
*************** | |
*** 212,224 **** | |
PythonContext pythonContext = PythonContext.GetContext(context); | |
PythonDictionary dict; | |
ScriptCode script = null; | |
! string code = GetModuleCode(context, fullname, out ispackage, out modpath); | |
if (code == null) { | |
return null; |
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 unittest, sys, traceback | |
class TestTraceback(unittest.TestCase): | |
def test_truncate_traceback_with_typeerror(self): | |
def task3(): | |
return (1, 2) + [3, 4] # TypeError | |
def task2(): | |
task3() |
NewerOlder