A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2004-September/048859.html below:

[Python-Dev] Re: AlternativeImplementationforPEP292:SimpleString Substitutions

[Python-Dev] Re: AlternativeImplementationforPEP292:SimpleString SubstitutionsBarry Warsaw barry at python.org
Mon Sep 13 17:24:19 CEST 2004
On Mon, 2004-09-13 at 10:50, Moore, Paul wrote:
> From: Barry Warsaw
> > What I was worried about was if you providing 'mapping' positionally,
> > and kwds contained a 'mapping' key, you'll get a TypeError.  I'm going
> > to change the positional argument to '__mapping' so collisions of that
> > kind are less likely, and will document it in libstring.tex.
> 
> Can't you do something like
> 
>     def substitute(self, *args, **kwds):
>         if len(args) > 1:
>             raise TypeError # mild hack...
>         if len(args) == 1:
>             mapping = args[0]
>             mapping.update(kwds)
>         else:
>             mapping = kwds
> 
>         # etc...
> 
> This avoids the use of a strangely-named positional argument, at the cost
> of a check for too many positional arguments (because the interpreter no
> longer does it)

Nice.  That's a better hack IMO than the crappy argument name hack.

Thanks,
-Barry

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 307 bytes
Desc: This is a digitally signed message part
Url : http://mail.python.org/pipermail/python-dev/attachments/20040913/0ba5d82b/attachment.pgp
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4