Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8228271
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T16:24:37+00:00 2026-06-07T16:24:37+00:00

In researching the answer to this question here on stackoverflow, I’ve learned a lot

  • 0

In researching the answer to this question here on stackoverflow, I’ve learned a lot of new things, but have so far been unable to close the deal.

My python process will be receiving one line of input via stdin, e.g.

[{'name':'ry', 'age':28}, {'name':'bo', 'age':11}, {'name':'ed', 'age':99}]

…and I’d like to be able to store this line directly to a list object that I can then iterate over, e.g.

for i in list:
    print i['age'], i['name']

…but I just cannot get this to work, whether I use sys.stdin() or the fileinput module. For example, even when I explicitly create a list with x = list(stdin.readline()) it ends up making each character a separate item in the list, not parsing the text in the way I want it to. Anyway.. back to searching. (Thanks for reading.)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T16:24:39+00:00Added an answer on June 7, 2026 at 4:24 pm

    A bad way is to use input. However this is unsafe and the function has been removed in Python 3 (the function called input in Python 3 does the same as Python 2’s raw_input).

    A better way is to use ast.literal_eval.

    import ast
    x = ast.literal_eval(stdin.readline())
    

    See it working online: ideone

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been researching this for a while but got no convinced answer. From
I am beyond frustrated. I have been researching an answer to this for hours
I've been researching this a bit but haven't come across an answer -- is
I've been researching this for a while but I have to ask: isn't it
I have been Google-ing and researching for an answer on how to do a
I've been researching this for a while now and cant get a straight answer.
When researching an answer to a question (based on this answer ) I tried
I've been researching this one and found references to similar problems here and there,
First sorry for posting this here.I just got no answer to this question on
I've been researching this all day and can't seem to find an answer so

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.