22 |
22 |
23 This version is a re-implementation of rlcompleter with |
23 This version is a re-implementation of rlcompleter with |
24 selectable namespace. |
24 selectable namespace. |
25 |
25 |
26 The problem with rlcompleter is that it's hardwired to work with |
26 The problem with rlcompleter is that it's hardwired to work with |
27 __main__.__dict__, and in some cases one may have 'sandboxed' namespaces. So |
27 __main__.__dict__, and in some cases one may have 'sandboxed' namespaces. |
28 this class is a ripoff of rlcompleter, with the namespace to work in as an |
28 So this class is a ripoff of rlcompleter, with the namespace to work in as |
29 optional parameter. |
29 an optional parameter. |
30 |
30 |
31 This class can be used just like rlcompleter, but the Completer class now has |
31 This class can be used just like rlcompleter, but the Completer class now |
32 a constructor with the optional 'namespace' parameter. |
32 has a constructor with the optional 'namespace' parameter. |
33 |
33 |
34 A patch has been submitted to Python@sourceforge for these changes to go in |
34 A patch has been submitted to Python@sourceforge for these changes to go in |
35 the standard Python distribution. |
35 the standard Python distribution. |
36 |
36 |
37 |
37 |
175 n = len(text) |
175 n = len(text) |
176 for list in [keyword.kwlist, |
176 for list in [keyword.kwlist, |
177 __builtin__.__dict__.keys(), |
177 __builtin__.__dict__.keys(), |
178 self.namespace.keys()]: |
178 self.namespace.keys()]: |
179 for word in list: |
179 for word in list: |
180 if word[:n] == text and word != "__builtins__" and not word in matches: |
180 if word[:n] == text and \ |
|
181 word != "__builtins__" and \ |
|
182 not word in matches: |
181 matches.append(word) |
183 matches.append(word) |
182 return matches |
184 return matches |
183 |
185 |
184 def attr_matches(self, text): |
186 def attr_matches(self, text): |
185 """ |
187 """ |