Re: f-string anomaly

2018-05-14 Thread Lele Gaifax
Ken Kundert writes: > Lele, > I am using Python3.6. d has to be an object of mydict. My bad, sorry, I completely missed the premise :-|. ciao, lele. -- nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri real: Emanuele Gaifas | comincerò ad aver paura di chi mi copia. l...@m

Re: f-string anomaly

2018-05-14 Thread Ken Kundert
Lele, I am using Python3.6. d has to be an object of mydict. Here is the code that exhibits the problem: import sys, os from inform import error, os_error class mydict(dict): def __format__(self, template): print('Template:', template) return

Re: f-string anomaly

2018-05-14 Thread MRAB
On 2018-05-14 20:24, Lele Gaifax wrote: Ken Kundert writes: Lele, I'm afraid I was unclear. The ... in the code snippet was intended to imply that these lines were appended to the end of the original code, where d was defined. Ok, but then I get a different behaviour: Python 3.6.5

Re: f-string anomaly

2018-05-14 Thread Lele Gaifax
Ken Kundert writes: > Lele, > I'm afraid I was unclear. The ... in the code snippet was intended > to imply that these lines were appended to the end of the original code, > where d was defined. Ok, but then I get a different behaviour: Python 3.6.5 (default, May 11 2018, 13:30:17)

Re: f-string anomaly

2018-05-14 Thread Ken Kundert
Lele, I'm afraid I was unclear. The ... in the code snippet was intended to imply that these lines were appended to the end of the original code, where d was defined. -Ken On 05/14/2018 12:30 AM, Lele Gaifax wrote: > Ken Kundert writes: > >> I tried adding k and v to the local namespace: >>

Re: f-string anomaly

2018-05-14 Thread Thomas Jollans
On 2018-05-14 04:08, Terry Reedy wrote: > On 5/13/2018 3:22 PM, Ken Kundert wrote: > > Please do not double post. > >> I am seeing an unexpected difference between the behavior of the string >> format method and f-strings. > > Read > https://docs.python.org/3/reference/lexical_analysis.html#form

Re: f-string anomaly

2018-05-14 Thread Lele Gaifax
Ken Kundert writes: > I tried adding k and v to the local namespace: > > ... > k = 6 > v = 9 > print(f'Email: {d:{{k}} {{v}}}') > > I still got: > > NameError: name 'k' is not defined This is not what I get: Python 3.6.5 (default, May 11 2018, 13:30:17) [GCC 7.3.0]

Re: f-string anomaly

2018-05-13 Thread Ken Kundert
Terry, Thanks for your response. I apologize about the double posting. I am well aware how doing so is bad form. My double posting was unintentional; it occurred when my news reader misbehaved. What I did in my code was to put double braces inside the format_spec, which the syntax specificati

Re: f-string anomaly

2018-05-13 Thread Terry Reedy
On 5/13/2018 3:22 PM, Ken Kundert wrote: Please do not double post. I am seeing an unexpected difference between the behavior of the string format method and f-strings. Read https://docs.python.org/3/reference/lexical_analysis.html#formatted-string-literals carefully. Here is an example:

f-string anomaly

2018-05-13 Thread Ken Kundert
I am seeing an unexpected difference between the behavior of the string format method and f-strings in Python3.6. Here is an example: import sys, os from inform import error, os_error class mydict(dict): def __format__(self, template): print('Template:', template)

f-string anomaly

2018-05-13 Thread Ken Kundert
I am seeing an unexpected difference between the behavior of the string format method and f-strings. Here is an example: import sys, os from inform import error, os_error class mydict(dict): def __format__(self, template): print('Template:', template)