[Python-checkins] r53925 - sandbox/trunk/pep362/pep362.py

brett.cannon python-checkins at python.org
Sun Feb 25 23:59:40 CET 2007


Author: brett.cannon
Date: Sun Feb 25 23:59:37 2007
New Revision: 53925
Modified:
 sandbox/trunk/pep362/pep362.py
Log:
Remove __str__ support.
Modified: sandbox/trunk/pep362/pep362.py
==============================================================================
--- sandbox/trunk/pep362/pep362.py	(original)
+++ sandbox/trunk/pep362/pep362.py	Sun Feb 25 23:59:37 2007
@@ -49,27 +49,6 @@
 self.has_annotation = True
 self.annotation = annotation
 
- def _tuple2param(self, tuple_):
- if not isinstance(tuple_, tuple):
- return str(tuple_)
- elif len(tuple_) == 1:
- return "(" + str(tuple_[0]) +",)"
- else:
- return ('(' +
- ', '.join(self._tuple2param(x) for x in tuple_) +
- ')')
-
- def __str__(self):
- """Return the string representation of the parameter as it would look
- in a function's signature."""
- if isinstance(self.name, tuple):
- result = self._tuple2param(self.name)
- else:
- result = self.name
- if self.has_default:
- result+= "=" + str(self.default_value)
- return result
-
 
 class Signature(object):
 
@@ -92,7 +71,8 @@
 keyword_only_count = func_code.co_kwonlyargcount
 else:
 keyword_only_count = 0
- positional = func_code.co_varnames[:pos_count]
+ #positional = func_code.co_varnames[:pos_count]
+ positional = argspec[0]
 keyword_only = func_code.co_varnames[pos_count:keyword_only_count]
 if func.func_defaults:
 pos_default_count = len(func.func_defaults)
@@ -178,22 +158,6 @@
 else:
 return tuple(cls._list2tuple(x) for x in list_)
 
- def __str__(self):
- """String representation of a signature as one might write it in source
- code."""
- result = "%s(" % self.name
- result += ", ".join(str(param) for param in self.parameters)
- if self.var_args:
- if self.parameters:
- result +=", "
- result += "*%s" % self.var_args
- if self.var_kw_args:
- if self.parameters or self.var_args:
- result += ", "
- result += "**%s" % self.var_kw_args
- result += ")"
- return result
-
 def bind(self, *args, **kwargs):
 """Return a dictionary mapping function arguments to their parameter
 variables, if possible.


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /