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 8195029
In Process

The Archive Base Latest Questions

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

I am writing some code and need the user to input a file for

  • 0

I am writing some code and need the user to input a file for use in the program:

file=input('input file name')

however, whenever you then input a file name (or anything for that matter) an error pops up saything that whatever has just been input is not defined and ends the program. What is causing this to happen?

Thanks

  • 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-07T05:00:01+00:00Added an answer on June 7, 2026 at 5:00 am

    This is important:

    input([prompt]) -> value
    Equivalent to eval(raw_input(prompt)).
    

    Input will try to eval your input

    Check this

    In [38]: l =  input("enter filename: ")
    enter filename: dummy_file
    ---------------------------------------------------------------------------
    NameError                                 Traceback (most recent call last)
    C:\Python27\<ipython-input-37-b74d50e2a058> in <module>()
    ----> 1 l =  input("enter filename: ")
    
    C:\Python27\<string> in <module>()
    
    NameError: name 'dummy_file' is not defined
    
    
    In [39]: input /?
    Type:       builtin_function_or_method
    Base Class: <type 'builtin_function_or_method'>
    String Form:<built-in function input>
    Namespace:  Python builtin
    Docstring:
    input([prompt]) -> value
    
    Equivalent to eval(raw_input(prompt)).
    
    In [40]: file = raw_input("filename: ")
    filename: dummy_file
    
    In [41]: file
    Out[41]: 'dummy_file'
    

    using raw_input has it’s disadvantages though.

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

Sidebar

Related Questions

I am writing some code that will go through a file, edit it as
I'm writing some code in which I need to use my own HttpResponse object
I am working on writing some code to scrub user input to my ASP.NET
I'm writing a program that calculates input a user gives, simple numbers. 2, 4,
I am writing some code in which i need to get a line from
I am writing some Ruby code, not Rails, and I need to handle something
I'm writing some terrible, terrible code, and I need a way to put a
I'm writing some code that will take a screenshot of another application, given its'
I'm writing some code (just for fun so far) in Python that will store
I'm writing some quick code to try and extract data from an mp3 file

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.