On Sun, Aug 27, 2023, at 17:19, Rob Cliffe via Python-list wrote:
> I understand that this is an error: I'm telling the f-string to expect
> an integer when in fact I'm giving it a Decimal.
> And indeed f"{x:3}" gives ' 42' whether x is an int or a Decimal.
> However, to my mind it is not the form
Roel Schroeven wrote:
Op 6/06/2023 om 16:08 schreef Chris Angelico:
On Wed, 7 Jun 2023 at 00:06, Neal Becker wrote:
>
> The following f-string does not parse and gives syntax error on 3.11.3:
>
> f'thruput/{"user" if opt.return else "cell"} vs. elevation\n'
>
> However this expression, which is
Op 6/06/2023 om 16:48 schreef Chris Angelico via Python-list:
On Wed, 7 Jun 2023 at 00:42, Roel Schroeven wrote:
> (Recently there has been an effort to provide clearer and more useful
> error messages; this seems to be a case where there is still room for
> improvement: "SyntaxError: invalid sy
On Wed, 7 Jun 2023 at 00:42, Roel Schroeven wrote:
> (Recently there has been an effort to provide clearer and more useful
> error messages; this seems to be a case where there is still room for
> improvement: "SyntaxError: invalid syntax" doesn't immediately remind me
> of that fact that 'return'
Op 6/06/2023 om 16:41 schreef Roel Schroeven:
'return' being a keyowrd is definitely going to be the problem.
*keyword
--
"Don't Panic."
-- Douglas Adams, The Hitchhiker's Guide to the Galaxy
--
https://mail.python.org/mailman/listinfo/python-list
Op 6/06/2023 om 16:08 schreef Chris Angelico:
On Wed, 7 Jun 2023 at 00:06, Neal Becker wrote:
>
> The following f-string does not parse and gives syntax error on 3.11.3:
>
> f'thruput/{"user" if opt.return else "cell"} vs. elevation\n'
>
> However this expression, which is similar does parse cor
On Wed, 7 Jun 2023 at 00:06, Neal Becker wrote:
>
> The following f-string does not parse and gives syntax error on 3.11.3:
>
> f'thruput/{"user" if opt.return else "cell"} vs. elevation\n'
>
> However this expression, which is similar does parse correctly:
>
> f'thruput/{"user" if True else "cell
On 25May2022 00:13, Kevin M. Wilson wrote:
>Cameron, I have a misunderstanding here, the 'f-string' is used when
>the str() is not...isn't it!
No, f-strings (format strings) are just a convenient way to embed values
in a string. The result is a string.
In days of yore the common formatting met
On 24May2022 21:14, Kevin M. Wilson wrote:
>future_value = 0
>for i in range(years):
># for i in range(months):
> future_value += monthly_investment
> future_value = round(future_value, 2)
> # monthly_interest_amount = future_value * monthly_interest_rate
> # future_value += monthly_intere
On 5/24/22 15:14, Kevin M. Wilson via Python-list wrote:
> future_value = 0
> for i in range(years):
> # for i in range(months):
>future_value += monthly_investment
>future_value = round(future_value, 2)
># monthly_interest_amount = future_value * monthly_interest_rate
># future_val
Try something like:
print(f"Year = {years}, Future value = {future_value}")
On Tue, 2022-05-24 at 21:14 +, Kevin M. Wilson via Python-list
wrote:
> future_value = 0
> for i in range(years):
> # for i in range(months):
> future_value += monthly_investment
> future_value = round(future_va
On 2022-05-24 22:14, Kevin M. Wilson via Python-list wrote:
future_value = 0
for i in range(years):
# for i in range(months):
future_value += monthly_investment
future_value = round(future_value, 2)
# monthly_interest_amount = future_value * monthly_interest_rate
# future_value +=
The string library is a utility set of functions with common string
operations and that documentation is about the specific library, not the
concept of strings or their syntax and other features in the language
itself. For more about f-strings and other string behaviors, read the
documentation on s
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
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
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
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)
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:
>>
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
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]
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
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:
On Tue, Dec 5, 2017 at 6:37 PM, Ned Batchelder wrote:
> On 12/5/17 7:16 PM, Steve D'Aprano wrote:
>> compile('f"{spam} {eggs}"', '', 'single')
>
> $ python3.6
> Python 3.6.3 (default, Octâ 4 2017, 06:03:25)
> [GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.37)] on darwin
> Typ
On Wed, 6 Dec 2017 11:54 am, John Pote wrote:
[...]
> Ran above test file and got,
> >>python36 compiletest.py
> at 0x02120E40, file "", line 1>
>
>
> SPAM scrambled
Thanks everyone, that's what I wanted to see.
--
Steve
â £Cheer up,â Ø they said, â £things could be worse.â Ø So I ch
On Wed, Dec 6, 2017 at 8:24 PM, Steve D'Aprano
wrote:
> On Wed, 6 Dec 2017 12:21 pm, Chris Angelico wrote:
>
>> On Wed, Dec 6, 2017 at 11:54 AM, John Pote
>> wrote:
>>>
>>> On 06/12/2017 00:16, Steve D'Aprano wrote:
Anyone got a handy copy of Python 3.6 available to test something for m
On Wed, 6 Dec 2017 12:21 pm, Chris Angelico wrote:
> On Wed, Dec 6, 2017 at 11:54 AM, John Pote
> wrote:
>>
>> On 06/12/2017 00:16, Steve D'Aprano wrote:
>>>
>>> Anyone got a handy copy of Python 3.6 available to test something for me?
>>>
>>> What does compile('f"{spam} {eggs}"', '', 'single') r
On 06/12/2017 00:16, Steve D'Aprano wrote:
> Anyone got a handy copy of Python 3.6 available to test something for me?
>
> What does compile('f"{spam} {eggs}"', '', 'single') return?
>
> What does eval()'ing the above compiled object do? If necessary, you may have
> to define spam and eggs first.
On 12/5/17 7:16 PM, Steve D'Aprano wrote:
> compile('f"{spam} {eggs}"', '', 'single')
$ python3.6
Python 3.6.3 (default, Octâ 4 2017, 06:03:25)
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.37)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
On 2017-12-06 00:16, Steve D'Aprano wrote:
> Anyone got a handy copy of Python 3.6 available to test something for me?
>
> What does compile('f"{spam} {eggs}"', '', 'single') return?
>
> What does eval()'ing the above compiled object do? If necessary, you may have
> to define spam and eggs first.
>
On Wed, Dec 6, 2017 at 11:54 AM, John Pote wrote:
>
> On 06/12/2017 00:16, Steve D'Aprano wrote:
>>
>> Anyone got a handy copy of Python 3.6 available to test something for me?
>>
>> What does compile('f"{spam} {eggs}"', '', 'single') return?
>>
>> What does eval()'ing the above compiled object do
On Wed, Dec 6, 2017 at 11:16 AM, Steve D'Aprano
wrote:
> Anyone got a handy copy of Python 3.6 available to test something for me?
>
> What does compile('f"{spam} {eggs}"', '', 'single') return?
>
> What does eval()'ing the above compiled object do? If necessary, you may have
> to define spam and
On Wed, Dec 6, 2017 at 8:24 PM, Steve D'Aprano
wrote:
> On Wed, 6 Dec 2017 12:21 pm, Chris Angelico wrote:
>
>> On Wed, Dec 6, 2017 at 11:54 AM, John Pote
>> wrote:
>>>
>>> On 06/12/2017 00:16, Steve D'Aprano wrote:
Anyone got a handy copy of Python 3.6 available to test something for m
On Wed, 6 Dec 2017 12:21 pm, Chris Angelico wrote:
> On Wed, Dec 6, 2017 at 11:54 AM, John Pote
> wrote:
>>
>> On 06/12/2017 00:16, Steve D'Aprano wrote:
>>>
>>> Anyone got a handy copy of Python 3.6 available to test something for me?
>>>
>>> What does compile('f"{spam} {eggs}"', '', 'single') r
On Wed, 6 Dec 2017 11:54 am, John Pote wrote:
[...]
> Ran above test file and got,
> >>python36 compiletest.py
> at 0x02120E40, file "", line 1>
>
>
> SPAM scrambled
Thanks everyone, that's what I wanted to see.
--
Steve
“Cheer up,” they said, “things could be worse.” So I cheered
On Wed, Dec 6, 2017 at 11:54 AM, John Pote wrote:
>
> On 06/12/2017 00:16, Steve D'Aprano wrote:
>>
>> Anyone got a handy copy of Python 3.6 available to test something for me?
>>
>> What does compile('f"{spam} {eggs}"', '', 'single') return?
>>
>> What does eval()'ing the above compiled object do
On 06/12/2017 00:16, Steve D'Aprano wrote:
Anyone got a handy copy of Python 3.6 available to test something for me?
What does compile('f"{spam} {eggs}"', '', 'single') return?
What does eval()'ing the above compiled object do? If necessary, you may have
to define spam and eggs first.
Thanks
On Wed, Dec 6, 2017 at 11:16 AM, Steve D'Aprano
wrote:
> Anyone got a handy copy of Python 3.6 available to test something for me?
>
> What does compile('f"{spam} {eggs}"', '', 'single') return?
>
> What does eval()'ing the above compiled object do? If necessary, you may have
> to define spam and
On 12/5/17 7:16 PM, Steve D'Aprano wrote:
compile('f"{spam} {eggs}"', '', 'single')
$ python3.6
Python 3.6.3 (default, Oct 4 2017, 06:03:25)
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.37)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
On 2017-12-06 00:16, Steve D'Aprano wrote:
Anyone got a handy copy of Python 3.6 available to test something for me?
What does compile('f"{spam} {eggs}"', '', 'single') return?
What does eval()'ing the above compiled object do? If necessary, you may have
to define spam and eggs first.
Thanks
39 matches
Mail list logo