From 8e85adb71887d12badcb3089a63bf71744ca0a49 Mon Sep 17 00:00:00 2001 From: Takafumi Arakaki Date: Sun, 3 Mar 2013 15:19:34 +0100 Subject: [PATCH] Document Scope.get_defined_names --- jedi/parsing_representation.py | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/jedi/parsing_representation.py b/jedi/parsing_representation.py index 816087f9..ba201023 100644 --- a/jedi/parsing_representation.py +++ b/jedi/parsing_representation.py @@ -212,7 +212,7 @@ class Scope(Simple, IsScope): def get_set_vars(self): """ Get all the names, that are active and accessible in the current - scope. + scope. See :meth:`get_defined_names` for examples. :return: list of Name :rtype: list @@ -233,6 +233,26 @@ class Scope(Simple, IsScope): return n def get_defined_names(self): + """ + Get all defined names in this scope. + + >>> from jedi.parsing import Parser + >>> parser = Parser(''' + ... a = x + ... b = y + ... b.c = z + ... ''') + >>> parser.scope.get_defined_names() + [, ] + + Note that unlike :meth:`get_set_vars`, assignment to object + attribute does not change the result because it does not change + the defined names in this scope. + + >>> parser.scope.get_set_vars() + [, , ] + + """ return [n for n in self.get_set_vars() if isinstance(n, Import) or len(n) == 1]