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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:05:46+00:00 2026-05-27T21:05:46+00:00

When I put this python code into the REPL for python (the interactive shell),

  • 0

When I put this python code into the REPL for python (the interactive shell), it works as expected:

>>> def get_header():
...     return (None,None,None)
... 
>>> get_header()
(None, None, None)

Note that the return statement is indented by four spaces, and I have checked to ensure there are no extraneous spaces.

when I put the exact same code into a python script file and execute it, I get the following error:

./test.py: line 1: syntax error near unexpected token `('
./test.py: line 1: `def get_header():'

WHY?

EDIT: this is the exact contents of test.py, white spaces and all:

def get_header():
    return (None,None,None)

get_header()

I have verified that the above script (test.py) does yield the above error as it above stands.

  • 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-05-27T21:05:46+00:00Added an answer on May 27, 2026 at 9:05 pm

    The reason this is not working is that you don’t have anything telling bash that this is a Python script, so it tries to execute it as a shell script, then throws an error when the syntax isn’t right.

    What you need is to start the file with a shebang line, telling it what it should be run with. So your file becomes:

    #!/usr/bin/env python
    
    def get_header():
        return (None, None, None)
    
    print get_header()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In Python 2.5 I stored data using this code: def GLWriter(file_name, string): import cPickle
This simple Python method I put together just checks to see if Tomcat is
The batch file is something like this, I put the python in some directory
Edit: I put this snippet of code in jsbin: http://jsbin.com/eneru I am trying to
It's hard to put this into the title, so let me explain. I have
[Rails] Where to put this code? I have a user1 and when another registered
I am trying to translate the VBA code found in this link into IronPython.
simple bit of code, just prints out a list of urls I put into
I'm considering integrating some C code into a Python system (Django), and I was
In my Apache webserver I put this: <Directory /var/www/MYDOMAIN.com/htdocs> SetHandler mod_python PythonHandler mod_python.publisher PythonDebug

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.