Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
fixed width numbers
#11
Nwb's method is the proper one.
Reply
#12
(May-26-2019, 06:33 PM)Larz60+ Wrote: Nwb's method is the proper one.

how can i put an expression in that method? perfringo's method is obvious.
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply
#13
For example?
Do you mean like:
print(f'Number with leading zeroes{10:020}')
Reply
#14
no. can i do this?
print(f'foo is{numbers["foo"]**powers["bar"]:20}')
it doesn't work in any form in my older Python 3.5.2. was f'' added in 3.6 or 3.7 ?
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply
#15
(May-27-2019, 07:53 AM)Skaperen Wrote: was f'' added in 3.6 or 3.7 ?

Yep, you need 3.6 <= Python
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy

Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Reply
#16
then my only choice is your rjust() suggestion which i have already coded. i try to make my code work as far back as 3.3 if it's easy enough, else 3.4 or 3.5. but 3.5.2 is a must, partly because i have run into issues with Ubuntu 18.04 (sudo to root to run bash on amd64 arch fails to source .bashrc file ... it works OK on arm64).
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Python code to set column width 1418 11 943 Jan-20-2024, 07:20 AM
Last Post: Pedroski55
  How to do "fixed size" (wrapping) math in Python? AlexanderWulf 13 1,732 Jul-19-2023, 04:13 PM
Last Post: deanhystad
  Fixed colum width for rowLabels i Matplotlib pandabay 0 400 Jun-10-2023, 03:40 PM
Last Post: pandabay
  Encrypt and decrypt in python using own fixed key SriRajesh 3 4,625 Feb-20-2022, 01:18 PM
Last Post: dboxall123
  width of Unicode character Skaperen 6 2,648 Sep-27-2021, 12:41 AM
Last Post: Skaperen
  image.thumbnail(width, height) not working PCesarano 2 3,321 Apr-08-2021, 06:09 PM
Last Post: PCesarano
  Play fixed frequency sound in python 3 jpezz 2 2,723 Feb-07-2021, 08:21 PM
Last Post: jpezz
  Referencing a fixed cell Mark17 2 2,020 Dec-17-2020, 07:14 PM
Last Post: Mark17
  How can I get the width of a string in Python? aquerci 14 15,885 May-27-2019, 06:00 PM
Last Post: heiner55
  Print Numbers starting at 1 vertically with separator for output numbers Pleiades 3 3,667 May-09-2019, 12:19 PM
Last Post: Pleiades

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020