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
#ROTurn | |
#Decode a ROT13'ed block of text. | |
#Python version of Perl script by Jay Kominek | |
#By Robin Wellner (gvx) | |
#I hereby waive copyright and related or neighboring rights to this work | |
#See the Creative Commons Zero Waiver at <http://creativecommons.org/publicdomain/zero/1.0/> | |
""" | |
"I recently wrote a Perl script, which, using letter frequency, attempts | |
to guess whether a given block of text has been ROT13ed or not. I've found |
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
#By Robin Wellner (gvx) | |
#I hereby waive copyright and related or neighboring rights to this work | |
#See the Creative Commons Zero Waiver at <http://creativecommons.org/publicdomain/zero/1.0/> | |
def rename(oldname, newname, scope): | |
scope[newname] = scope[oldname] | |
if hasattr(scope[newname], '__name__'): scope[newname].__name__ = newname | |
del scope[oldname] |
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 | |
#By Robin Wellner (gvx) | |
#I hereby waive copyright and related or neighboring rights to this work | |
#See the Creative Commons Zero Waiver at <http://creativecommons.org/publicdomain/zero/1.0/> | |
#Simulation of modules containing one or more function/class/object. | |
#Warning: modules are named differently than what you would expect. | |
def namespace(name): | |
class namespace: |
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
#Listtools 0.1 | |
#By Robin Wellner (gvx) | |
#Functions for lists | |
#I hereby waive copyright and related or neighboring rights to this work | |
#See the Creative Commons Zero Waiver at <http://creativecommons.org/publicdomain/zero/1.0/> | |
def append(lst, object): | |
"listtools.append(lst, object) -- append object to end" | |
lst.append(object) |
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
#By Robin Wellner (gvx) | |
#I hereby waive copyright and related or neighboring rights to this work | |
#See the Creative Commons Zero Waiver at <http://creativecommons.org/publicdomain/zero/1.0/> | |
import sys | |
diff_file = sys.stdin.read().split('\n') | |
if len(sys.argv) > 1: | |
filename = sys.argv[1] | |
else: |
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
#By Robin Wellner (gvx) | |
#I hereby waive copyright and related or neighboring rights to this work | |
#See the Creative Commons Zero Waiver at <http://creativecommons.org/publicdomain/zero/1.0/> | |
import sys | |
import subprocess | |
f = open (sys.argv[1], "r") | |
r = f.readline()[:-1] | |
f.close() |
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
#By Robin Wellner (gvx) | |
#I hereby waive copyright and related or neighboring rights to this work | |
#See the Creative Commons Zero Waiver at <http://creativecommons.org/publicdomain/zero/1.0/> | |
#a simple way to create one object without having to maintain it's class | |
#only works in Python 3.x | |
@apply | |
class oneObject: | |
x = 6 |
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 collections import OrderedDict | |
from inspect import Parameter, signature | |
from itertools import chain, starmap | |
from operator import itemgetter | |
__all__ = ['namedtuple'] | |
dict_property = property(lambda self: OrderedDict(zip(self._fields, self)), | |
doc='dictionary for instance variables (if defined)') |
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 doc(f): | |
newdoc = f.__doc__ and [f.__doc__, ''] or [] | |
c = f.__code__ | |
ann = f.__annotations__ | |
max_i = c.co_argcount + c.co_kwonlyargcount | |
for arg_index in range(max_i): | |
name = c.co_varnames[arg_index] | |
if name in ann: | |
newdoc.append(name + ': ' + str(ann[name])) | |
else: |
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
func some function: | |
a test | |
catch handler: | |
some mistake | |
if this is wrong: | |
tell me why | |
elseif this should not fail: | |
hello | |
if hi: | |
bye |