[issue45165] alighment format for nullable values

2021-09-10 Thread Anthony Sottile


Anthony Sottile  added the comment:

alignment was the only one I found which was applicable and didn't work

`!s` "works" but it's kind of a hack (of course I want string formatting, I'm 
making a string!) -- then I would want to write `!s` everywhere which is 
cumbersome and ugly

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45165] alighment format for nullable values

2021-09-10 Thread Eric V. Smith


Change by Eric V. Smith :


--
type: behavior -> enhancement
versions:  -Python 3.10

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45165] alighment format for nullable values

2021-09-10 Thread Eric V. Smith


Eric V. Smith  added the comment:

Why would you only want alignment, and not all string formatting options?

And if that's the case, just convert it to a string: 

>>> f'{None!s:>8} {1:>8}'
'None1'

--
nosy: +eric.smith

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45165] alighment format for nullable values

2021-09-10 Thread Anthony Sottile


New submission from Anthony Sottile :

currently this works correctly:

```
>>> '%8s %8s' % (None, 1)
'None1'
```

but conversion to f-string fails:

```
>>> f'{None:>8} {1:>8}'
Traceback (most recent call last):
  File "", line 1, in 
TypeError: unsupported format string passed to NoneType.__format__
```

my proposal is to implement alignment `__format__` for `None` following the 
same as for `str` for alignment specifiers

--
components: Interpreter Core
messages: 401582
nosy: Anthony Sottile
priority: normal
severity: normal
status: open
title: alighment format for nullable values
type: behavior
versions: Python 3.10, Python 3.11

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com