Use the new string formatting method in io.ascii.write
See original GitHub issueAs far as I can see the formats
parameter in io.ascii.write
still uses the old string formatting.
The new method should be used instead.
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (7 by maintainers)
Top Results From Across the Web
Writing Tables — Astropy v5.2
The write() function provides a way to write a data table as a formatted ASCII table.
Read more >Writing tables — Astropy v0.4.2
The write() function provides a way to write a data table as a formatted ASCII table. For example: >>> >>> import numpy as...
Read more >Formatting with astropy.io.ascii - python - Stack Overflow
I do this fairly often. To stay close to what you've written: df = data['ra', 'dec'] ascii.write(df, 'temp.dat', overwrite=True, ...
Read more >Writing tables — Astropy v0.2.dev2728
The write() function provides a way to write a data table as a formatted ASCII table. For example: >>> from astropy.io import ascii...
Read more >A Guide to the Newer Python String Format Techniques
Since f-strings are comparably new to the Python language, it's good for you to be ... Now, you can use Python's string .format()...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Takeaway: feel free to change any examples or code from old style (e.g.
format='%12.1f'
) to new style (e.g.12.1f
), which is the preferred idiom. This usesformat(val, fmt)
to actually do the formatting.Note that is NOT the same as
{:12.1f}
, which usesfmt.format(val)
.There was some recent discussion on performance implications of the different format options in context of
logging
which might be of interest here as well (the on-demand evaluation probably is not, since everything is written here anyway).