From ec2e0b28cf8b310ecc738cb5898675fcc6d0e542 Mon Sep 17 00:00:00 2001 From: David Halter Date: Thu, 3 May 2012 23:00:02 +0200 Subject: [PATCH] iter replaces __iter__ calls --- evaluate.py | 10 ++++++---- parsetest.py | 36 ++++++++++++++++++------------------ parsing.py | 4 ++-- test/completion/functions.py | 10 ++++++++++ 4 files changed, 36 insertions(+), 24 deletions(-) diff --git a/evaluate.py b/evaluate.py index 70afc225..86f0b9a6 100644 --- a/evaluate.py +++ b/evaluate.py @@ -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] diff --git a/parsetest.py b/parsetest.py index 7c3b714f..9a5df0e9 100644 --- a/parsetest.py +++ b/parsetest.py @@ -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 diff --git a/parsing.py b/parsing.py index 0dfb761e..597b7efe 100644 --- a/parsing.py +++ b/parsing.py @@ -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: diff --git a/test/completion/functions.py b/test/completion/functions.py index 03bea797..cb37d9df 100644 --- a/test/completion/functions.py +++ b/test/completion/functions.py @@ -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