Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Issue w/ "With Open"
#3
@praveencqr: there is no need to open and close file on every write to file. In that sense @vman44 code is correct - open the file and write rows.

Alternatively one can use print for writing into file and advantage of this is that you don't need to worry about newline:

with open(dbfileA, 'a') as writer:
    for in_val in userinputs:
        print(in_val, file=writer)
vman44 likes this post
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


Messages In This Thread
Issue w/ "With Open" - by vman44 - Dec-23-2022, 06:59 AM
RE: Issue w/ "With Open" - by praveencqr - Dec-23-2022, 07:30 AM
RE: Issue w/ "With Open" - by perfringo - Dec-23-2022, 10:32 AM
RE: Issue w/ "With Open" - by snippsat - Dec-23-2022, 02:35 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Issue when using open() in converted exe skakalpes 2 1,749 Feb-02-2022, 02:42 PM
Last Post: snippsat

Forum Jump:

User Panel Messages

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