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
possible for the auto completion.
"""
def next(iterator, default=None):
if hasattr("next"):
return iterator.next()
@@ -12,6 +14,16 @@ def next(iterator, default=None):
return default
def iter(collection, sentinel=None):
if sentinel:
yield collection()
else:
yield next(collection)
#--------------------------------------------------------
# descriptors
#--------------------------------------------------------
class property():
def __init__(self, fget, fset=None, fdel=None, doc=None):
self.fget = fget
@@ -59,6 +71,9 @@ class classmethod():
return _method
#--------------------------------------------------------
# array stuff
#--------------------------------------------------------
class list():
def __init__(self, iterable=[]):
self.iterable = []
@@ -94,17 +109,14 @@ class set():
return self
def iter(collection, sentinel=None):
if sentinel:
yield collection()
else:
yield next(collection)
#--------------------------------------------------------
# basic types
#--------------------------------------------------------
class int():
def __init__(self, x, base=None):
self.x = x
class str():
def __init__(self, obj):
self.obj = obj