It's actually much worse than making obviously buggy code pass silently. It
can also make uncommon bugs almost impossible to detect.

Some code looks like `mystring.format(**values)`. Whether values contains
the needed keys can vary at runtime now. It might be fine under most code
paths, but fail in other cases.

That's already somewhat hard to catch, but the proposed change of passing
silently disguises even the intermittent glimpse into the error.

On Thu, Apr 27, 2023, 9:05 AM Matthias Görgens <matthias.goerg...@gmail.com>
wrote:

> What is the use case for this?
>
> Does it have any use case that's not already served by functools.partial?
>
> As far as I can tell, this proposal would turn buggy code that currently
> throws an obvious exception into code that silently does the wrong thing.
>
> This seems more appropriate for PHP or JavaScript (or C) than for Python.
>
>
> On Sat, 22 Apr 2023, 06:23 Samuel Muldoon, <muldoonsam...@gmail.com>
> wrote:
>
>> Consider the following string:
>>
>> x = r"\mathjax{{color}}{{text}}"
>>
>> string `x` contains two parameters named `color` and the other named `
>> text`.
>>
>> Currently, python requires that the string class method `str.format` contain
>> key-word arguments for *all *parameters, not just *one* parameter
>>
>> result = r"\mathjax{{color}}{{text}}".format(color = "blue" , text = 
>> "Spanish")
>>
>> result = "\mathjax{blue}{Spanish}"
>>
>> Can we change str.format so that it is possible to change only one string 
>> parameter, but leave the other parameters alone?
>>
>> # pfr is partially_formatted_result
>>
>> pfr    = r"\mathjax{{color}}{{text}}".format(color = "blue")   # ERROR! 
>> missing parameter `text`
>>
>> result = r"\mathjax{{color}}{{text}}".format(text = "Spanish") # ERROR! 
>> missing parameter `color`
>>
>> The implementation requires fewer than ten lines of code in python, probably 
>> less than fifty lines in C, or a different implementation language.
>>
>> class str:
>>     def format(self, **kwargs):
>>         for key in kwargs:
>>             x = "{"+key+"}"
>>             ostr   = kwargs[key].join(self.split(x))
>>         return ostr # output string
>>
>> As an example, everywhere a string contained `{text}` it will now say 
>> `*Spanish*` .
>>
>>
>> *Samuel Muldoon*
>>
>> *(720) 653 -2408*
>>
>> *muldoonsam...@gmail.com <muldoonsam...@gmail.com>*
>>
>>
>>
>> _______________________________________________
>> Python-ideas mailing list -- python-ideas@python.org
>> To unsubscribe send an email to python-ideas-le...@python.org
>> https://mail.python.org/mailman3/lists/python-ideas.python.org/
>> Message archived at
>> https://mail.python.org/archives/list/python-ideas@python.org/message/2A6RTXKQ3LCMKDGDIPOX525O52KYQJS7/
>> Code of Conduct: http://python.org/psf/codeofconduct/
>>
> _______________________________________________
> Python-ideas mailing list -- python-ideas@python.org
> To unsubscribe send an email to python-ideas-le...@python.org
> https://mail.python.org/mailman3/lists/python-ideas.python.org/
> Message archived at
> https://mail.python.org/archives/list/python-ideas@python.org/message/3HHUQV35HQMU6AZWS2NIMFHFEJW3W3LO/
> Code of Conduct: http://python.org/psf/codeofconduct/
>
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/AEFUTF7GTMHAGHF5G4BX7GIYBNQ6REBI/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to