Skip to content

print converts to string object automatically, but write to file doesn't and additional function needs to be called (on prettytable) #92437

@ghost

Description

pepe@pepe-MS-7C90:~$ python3
Python 3.10.4 (main, Apr 2 2022, 09:04:19) [GCC 11.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.

import prettytable
x = PrettyTable()
Traceback (most recent call last):
File "", line 1, in
NameError: name 'PrettyTable' is not defined. Did you mean: 'prettytable'?
x = prettytable.PrettyTable()
print(x)
++
||
++
++
f=open("yo.txt","wt")
f.write(x)
Traceback (most recent call last):
File "", line 1, in
TypeError: write() argument must be str, not PrettyTable
f.write(x.get_string())
11

Screenshot from 2022-05-07 21-56-10

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-featureA feature request or enhancement

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions