Re: [Python-Dev] f-strings

2017-12-15 Thread Wagner Herculano
Hi,
Thank you all for your time.
In fact I'm really a newbie and I need to study so hard (including English) to 
become someone like you all. I don't know if is possible, but I need to try.
Once again, thank you all for your time and I'm sorry if I'm bother both of you.

Kind regards,
   Wagner Herculano.


From: Chris Barker - NOAA Federal <chris.bar...@noaa.gov>
Sent: Friday, December 15, 2017 2:49:08 PM
To: Mariatta Wijaya
Cc: Wagner Herculano; Python Dev
Subject: Re: [Python-Dev] f-strings




That's covered under "format specifiers" I think.
The PEP mentions this: 
https://www.python.org/dev/peps/pep-0498/#format-specifiers

I can see how a newbie might not realize that that means that f-strings use the 
same formatting language as the .format() method, and or where to find 
documentation for it.

So somewhere in the docs making that really clear, with a link to the 
formatting spec documentation would be good.

Not sure where though — a PEP is not designed to be user documentation.

-CHB


That specific example is not mentioned in the docs, but there other examples of 
using format specifiers with f-strings.
https://docs.python.org/3/reference/lexical_analysis.html#formatted-string-literals


On Dec 15, 2017 7:39 AM, "Wagner Herculano" 
<waghercul...@hotmail.com<mailto:waghercul...@hotmail.com>> wrote:
Good evening,
I'm Wagner Herculano from Brazil.
I was trying to do a table exercise with number 5 and tried formatting spaces 
and did not find it in PEP 498 documentation.
Finally I found a way, if possible, include this example in the documentation 
please.

Below is my script with the desired formatting about table of 5.

n = 5
for i in range(1,11):
print(f'{n} x {i:>2} = {n*i:>2}')

Result
5 x  1 =  5
5 x  2 = 10
5 x  3 = 15
5 x  4 = 20
5 x  5 = 25
5 x  6 = 30
5 x  7 = 35
5 x  8 = 40
5 x  9 = 45
5 x 10 = 50
---
Sorry my English, I needed to use Google Translate

Best Regards,
Wagner Herculano

___
Python-Dev mailing list
Python-Dev@python.org<mailto:Python-Dev@python.org>
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/mariatta.wijaya%40gmail.com

___
Python-Dev mailing list
Python-Dev@python.org<mailto:Python-Dev@python.org>
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/chris.barker%40noaa.gov
___
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


[Python-Dev] f-strings

2017-12-15 Thread Wagner Herculano
Good evening,
I'm Wagner Herculano from Brazil.
I was trying to do a table exercise with number 5 and tried formatting spaces 
and did not find it in PEP 498 documentation.
Finally I found a way, if possible, include this example in the documentation 
please.

Below is my script with the desired formatting about table of 5.

n = 5
for i in range(1,11):
print(f'{n} x {i:>2} = {n*i:>2}')

Result
5 x  1 =  5
5 x  2 = 10
5 x  3 = 15
5 x  4 = 20
5 x  5 = 25
5 x  6 = 30
5 x  7 = 35
5 x  8 = 40
5 x  9 = 45
5 x 10 = 50
---
Sorry my English, I needed to use Google Translate

Best Regards,
Wagner Herculano
___
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com