Skip to content

Commit

Permalink
Merge pull request #2 from avelino/master
Browse files Browse the repository at this point in the history
Implementation PEP8 and Encode UTF-8
  • Loading branch information
vic committed Nov 24, 2011
2 parents 248966c + eab6626 commit 8492511
Show file tree
Hide file tree
Showing 19 changed files with 118 additions and 41 deletions.
4 changes: 3 additions & 1 deletion examples/builtins.py
@@ -1,4 +1,6 @@
"wat" # -*- coding: utf-8 -*-

"""wat"""
print __name__ print __name__
print __doc__ print __doc__
print object print object
12 changes: 12 additions & 0 deletions examples/classes.py
@@ -1,12 +1,24 @@
# -*- coding: utf-8 -*-

class BankAccount(object): class BankAccount(object):

def __init__(self, initial_balance=0): def __init__(self, initial_balance=0):

self.balance = initial_balance self.balance = initial_balance

def deposit(self, amount): def deposit(self, amount):

self.balance = self.balance + amount self.balance = self.balance + amount

def withdraw(self, amount): def withdraw(self, amount):

self.balance = self.balance - amount self.balance = self.balance - amount

def overdrawn(self): def overdrawn(self):

return self.balance < 0 return self.balance < 0


print BankAccount print BankAccount
my_account = BankAccount(15) my_account = BankAccount(15)
print my_account print my_account
Expand Down
22 changes: 14 additions & 8 deletions examples/decorators.py
@@ -1,14 +1,20 @@
# -*- coding: utf-8 -*-

class test(object): class test(object):
@staticmethod
def static(a,b,c): @staticmethod
print a, b, c def static(a,b,c):


@classmethod print a, b, c
def clsm(cls, a, b, c):
print cls, a, b, c @classmethod
def clsm(cls, a, b, c):

print cls, a, b, c



test.static(1,2,3) # => "1 2 3" test.static(1,2,3) # => "1 2 3"
test.clsm(1,2,3) # => "<type 'test'> 1 2 3" test.clsm(1,2,3) # => "<type 'test'> 1 2 3"


test().static(1,2,3) # => "1 2 3" test().static(1,2,3) # => "1 2 3"
test().clsm(1,2,3) # => "<type 'test'> 1 2 3" test().clsm(1,2,3) # => "<type 'test'> 1 2 3"
28 changes: 20 additions & 8 deletions examples/descriptors.py
@@ -1,16 +1,28 @@
# -*- coding: utf-8 -*-

class DataDesc(object): class DataDesc(object):
def __get__(self, obj, type):
print "datadesc", self, obj, type def __get__(self, obj, type):
def __set__(self, obj, val):
print "datadesc", self, obj, val print "datadesc", self, obj, type

def __set__(self, obj, val):

print "datadesc", self, obj, val



class Desc(object): class Desc(object):
def __get__(self, obj, type):
print "desc", self, obj, type def __get__(self, obj, type):

print "desc", self, obj, type



class test(object): class test(object):
dd = DataDesc()
d = Desc() dd = DataDesc()
d = Desc()



#__debugger__() #__debugger__()
test.dd test.dd
Expand Down
29 changes: 16 additions & 13 deletions examples/embed_func.py
@@ -1,18 +1,21 @@
# -*- coding: utf-8 -*-

z = 'watevah' z = 'watevah'


def blah(a,k='b'): def blah(a,k='b'):
def blorp(b):
print(b) #3 def blorp(b):
print(a) #4
print(z) #5 print(b) #3
print(__name__) #6 print(a) #4

print(z) #5
l = lambda x: x print(__name__) #6
#def l(x): return x

l = lambda x: x
print(l("zoom!")) #1 #def l(x): return x

print(l("zoom!")) #1
print(a,k) #2 print(a,k) #2
blorp("boom") blorp("boom")



blah("floom") blah("floom")
2 changes: 2 additions & 0 deletions examples/eval.py
@@ -1,3 +1,5 @@
# -*- coding: utf-8 -*-

a = 22 a = 22
b = eval("a * 33") b = eval("a * 33")
print b print b
9 changes: 7 additions & 2 deletions examples/foo/bar.py
@@ -1,4 +1,9 @@
"The Foo::Bar module" # -*- coding: utf-8 -*-

def bar(): def bar():
print "BAR" """The Foo::Bar module"""

print "BAR"


bar() bar()
4 changes: 4 additions & 0 deletions examples/from_import.py
@@ -1,2 +1,6 @@
# -*- coding: utf-8 -*-

from imported import foo from imported import foo


print foo() print foo()
4 changes: 4 additions & 0 deletions examples/from_import_as.py
@@ -1,2 +1,6 @@
# -*- coding: utf-8 -*-

from imported import foo as bar from imported import foo as bar


print bar() print bar()
5 changes: 5 additions & 0 deletions examples/func.py
@@ -1,9 +1,14 @@
# -*- coding: utf-8 -*-

def greet(name, wat, blorp = 'woop', zoop = 'noop'): def greet(name, wat, blorp = 'woop', zoop = 'noop'):

print '---' print '---'
print 'hello', name print 'hello', name
print 'wat:', wat print 'wat:', wat
print 'blorp:', blorp print 'blorp:', blorp
print 'zoop:', zoop print 'zoop:', zoop


greet('Jack', 'stuff') greet('Jack', 'stuff')
greet('Jill', 'cffuf', 'tuff') greet('Jill', 'cffuf', 'tuff')
greet('Bob', 'wat') greet('Bob', 'wat')
2 changes: 2 additions & 0 deletions examples/hello.py
@@ -1 +1,3 @@
# -*- coding: utf-8 -*-

print("hello world") print("hello world")
7 changes: 4 additions & 3 deletions examples/import.py
@@ -1,6 +1,7 @@
import imported # -*- coding: utf-8 -*-

print(imported.__doc__)


import imported
import foo.bar import foo.bar



print(imported.__doc__)
6 changes: 5 additions & 1 deletion examples/import_as.py
@@ -1,2 +1,6 @@
# -*- coding: utf-8 -*-

import imported as foo import imported as foo
print(foo.__name__) # => "imported"
# => "imported"
print(foo.__name__)
4 changes: 3 additions & 1 deletion examples/imported.py
@@ -1,6 +1,8 @@
"imported module" # -*- coding: utf-8 -*-


def foo(): def foo():
"""imported module"""
return "FOO" return "FOO"



print __name__ print __name__
2 changes: 2 additions & 0 deletions examples/literals.py
@@ -1,3 +1,5 @@
# -*- coding: utf-8 -*-

1 1
2.3 2.3
"a b c" "a b c"
Expand Down
5 changes: 4 additions & 1 deletion examples/numbers.py
@@ -1,7 +1,10 @@
# -*- coding: utf-8 -*-

print "boom" print "boom"


x = 1 x = 1
y = 100000*100000 # current parser blows up on long numbers. # current parser blows up on long numbers.
y = 100000*100000
z = 10000 z = 10000


#__debugger__() #__debugger__()
Expand Down
4 changes: 4 additions & 0 deletions examples/pass.py
@@ -1,3 +1,7 @@
# -*- coding: utf-8 -*-

def foo(): def foo():
pass pass


print foo() print foo()
6 changes: 4 additions & 2 deletions examples/ruby.py
@@ -1,6 +1,8 @@
from __ruby__ import require # -*- coding: utf-8 -*-


require('rbconfig') from __ruby__ import require
from __ruby__.Config.CONFIG import fetch as rb from __ruby__.Config.CONFIG import fetch as rb



require('rbconfig')
print rb("RUBY_INSTALL_NAME") # => rbx print rb("RUBY_INSTALL_NAME") # => rbx
4 changes: 3 additions & 1 deletion examples/singletons.py
@@ -1,4 +1,6 @@
# -*- coding: utf-8 -*-

print None print None
print None.__class__ print None.__class__
print NotImplemented print NotImplemented
print NotImplemented.__class__ print NotImplemented.__class__

0 comments on commit 8492511

Please sign in to comment.