1
0
forked from VimPlug/jedi

rearranged builtin mixins

This commit is contained in:
David Halter
2012-08-06 20:54:35 +02:00
parent c154bdad0e
commit 6ae98ba2f6

View File

@@ -4,6 +4,8 @@ This code is not going to be executed anywhere.
These implementations are not always correct, but should work as good as These implementations are not always correct, but should work as good as
possible for the auto completion. possible for the auto completion.
""" """
def next(iterator, default=None): def next(iterator, default=None):
if hasattr("next"): if hasattr("next"):
return iterator.next() return iterator.next()
@@ -12,6 +14,16 @@ def next(iterator, default=None):
return default return default
def iter(collection, sentinel=None):
if sentinel:
yield collection()
else:
yield next(collection)
#--------------------------------------------------------
# descriptors
#--------------------------------------------------------
class property(): class property():
def __init__(self, fget, fset=None, fdel=None, doc=None): def __init__(self, fget, fset=None, fdel=None, doc=None):
self.fget = fget self.fget = fget
@@ -59,6 +71,9 @@ class classmethod():
return _method return _method
#--------------------------------------------------------
# array stuff
#--------------------------------------------------------
class list(): class list():
def __init__(self, iterable=[]): def __init__(self, iterable=[]):
self.iterable = [] self.iterable = []
@@ -94,17 +109,14 @@ class set():
return self return self
def iter(collection, sentinel=None): #--------------------------------------------------------
if sentinel:
yield collection()
else:
yield next(collection)
# basic types # basic types
#--------------------------------------------------------
class int(): class int():
def __init__(self, x, base=None): def __init__(self, x, base=None):
self.x = x self.x = x
class str(): class str():
def __init__(self, obj): def __init__(self, obj):
self.obj = obj self.obj = obj