Python Forum
Drop Dead Simple Interview Questions
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Drop Dead Simple Interview Questions
#6
Simple file reading?  I'm not sure if this is better than csv, or if just seeing the general way people handle resources is more important...

>>> text = '''
... hello, my name is
...     wait, who am i?
... '''
>>> text = text.split('\n')
>>> with open('saved_data.txt', 'w') as f:
...     for line in text:
...         print(line, file=f)
...
>>> text = "spam"
>>> # now we don't have any reference to the original text floating around
...
>>> with open('saved_data.txt') as f:
...     for line in f:
...         print(line.rstrip())
...

hello, my name is
   wait, who am i?

>>>
Reply


Messages In This Thread
Drop Dead Simple Interview Questions - by nilamo - Feb-13-2017, 05:56 PM
RE: Drop Dead Simple Interview Questions - by nilamo - Feb-13-2017, 08:04 PM
RE: Drop Dead Simple Interview Questions - by wavic - Feb-13-2017, 09:02 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Pipenv & Requests Author Kenneth Reitz Interview Evrone 1 2,172 Jan-28-2021, 02:16 PM
Last Post: elizabethlvova
Star Flask Creator Armin Ronacher Interview elizabethlvova 1 2,009 Dec-16-2020, 09:10 AM
Last Post: Evrone
  Becoming a Self-Taught Programmer: Cory Althoff Interview Evrone 0 1,953 Dec-16-2020, 08:49 AM
Last Post: Evrone
  PEP 594 -- Removing dead batteries from the standard library ichabod801 3 2,866 May-31-2019, 01:23 PM
Last Post: heiner55
  Best resource to learn and pass interview oryucouk 5 3,195 May-18-2019, 05:19 AM
Last Post: heiner55
  MIT Interview with Guido Larz60+ 3 3,449 Nov-27-2018, 10:45 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

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