iter replaces __iter__ calls

This commit is contained in:
David Halter
2012-05-03 23:00:02 +02:00
parent 9f8e0f46f6
commit ec2e0b28cf
4 changed files with 36 additions and 24 deletions

View File

@@ -9,6 +9,7 @@ TODO nonlocal statement
TODO doc
TODO list comprehensions, priority?
TODO care for *args **kwargs
TODO annotations
"""
from _compatibility import next
@@ -85,7 +86,8 @@ class Executable(object):
result.append(self_name)
# There may be calls, which don't fit all the params, this just ignores
# it.
for i, value in enumerate(self.params, offset):
param_iterator = iter(self.params)
for i, value in enumerate(param_iterator, offset):
try:
param = self.func.params[i]
except IndexError:
@@ -98,7 +100,7 @@ class Executable(object):
new_param._assignment_calls = calls
name = copy.copy(param.get_name())
name.parent = new_param
#print 'insert', i, name, calls.values, value, self.func.params
print 'insert', i, name, calls.values, value, self.func.params
result.append(name)
return result
@@ -455,7 +457,7 @@ def get_scopes_for_name(scope, name_str, position=None, search_global=False):
names = get_defined_names_for_position(scope, position)
else:
names = scope.get_defined_names()
scope_generator = [(scope, names)].__iter__()
scope_generator = iter([(scope, names)])
#print ' ln', position
return remove_statements(filter_name(scope_generator))
@@ -674,7 +676,7 @@ def follow_import(_import):
scope, rest = modules.find_module(loaded_in, ns_list)
if rest:
scopes = follow_path(rest.__iter__(), scope)
scopes = follow_path(iter(rest), scope)
else:
scopes = [scope]

View File

@@ -158,23 +158,23 @@ a = 3; b = ""
b,a=a,b
a.
class SuperClass(object):
super_class = 3
def __init__(self):
self.super_var = ''
def super_method(self)
self.super_var2 = list
class Mixin(SuperClass):
def super_method(self):
return int
class SubClass(Mixin, SuperClass):
sub_class = 3
def __init__(self):
self.sub_var = ''
def sub_method(self):
self.sub_var2 = list
return tuple
instance = SubClass()
SubClass.
def args_func(arg1, *args):
return args
#? ['real']
args_func(1,"")[0].real

View File

@@ -848,9 +848,9 @@ class Array(Call):
def __iter__(self):
if self.type == self.DICT:
return self.values.items().__iter__()
return iter(self.values.items())
else:
return self.values.__iter__()
return iter(self.values)
def __repr__(self):
if self.type == self.NOARRAY:

View File

@@ -67,3 +67,13 @@ def a():
func_b
#? ['real']
l.real
# -----------------
# *args / ** kwargs
# -----------------
def args_func(*args):
return args
#? ['real']
args_func(1)[0].real