Serhiy Storchaka <storchaka+cpyt...@gmail.com> added the comment:

Other problem is that the repr looks like an evaluable expression, but 
evaluating it will always produce error.

>>> st = os.stat('/dev/null')
>>> st
os.stat_result(st_mode=8630, st_ino=6, st_dev=6, st_nlink=1, st_uid=0, 
st_gid=0, st_size=0, st_atime=1602523313, st_mtime=1602523313, 
st_ctime=1602523313)
>>> os.stat_result(st_mode=8630, st_ino=6, st_dev=6, st_nlink=1, st_uid=0, 
>>> st_gid=0, st_size=0, st_atime=1602523313, st_mtime=1602523313, 
>>> st_ctime=1602523313)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: structseq() takes at most 2 keyword arguments (10 given)

os.stat_result() accepts only two arguments: a tuple for indexable elements and 
a dict for non-indexable elements.

>>> os.stat_result((8630, 6, 6, 1, 0, 0, 0, 1602523313, 1602523313, 
>>> 1602523313), {'st_atime': 1602523313.282834, 'st_mtime': 1602523313.282834, 
>>> 'st_ctime': 1602523313.282834, 'st_atime_ns': 1602523313282834115, 
>>> 'st_mtime_ns': 1602523313282834115, 'st_ctime_ns': 1602523313282834115, 
>>> 'st_blksize': 4096, 'st_blocks': 0, 'st_rdev': 259})
os.stat_result(st_mode=8630, st_ino=6, st_dev=6, st_nlink=1, st_uid=0, 
st_gid=0, st_size=0, st_atime=1602523313, st_mtime=1602523313, 
st_ctime=1602523313)

But such form looks not very readable, because it lacks names for indexable 
elements.

To solve this we can use an angular form in the repr:

<os.stat_result ...>

----------
nosy: +serhiy.storchaka

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue11698>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to