forked from VimPlug/jedi
rearranged builtin mixins
This commit is contained in:
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user