Hint: You can adjust the default video playback speed in your account settings.
Hint: You can set the default subtitles language in your account settings.
Sorry! Looks like there’s an issue with video playback 🙁 This might be due to a temporary outage or because of a configuration issue with your browser. Please see our video player troubleshooting guide to resolve the issue.

Script Setup & Statements

Give Feedback

This lesson covers the best practices to follow when setting up a Python script. You saw that it is good idea to add a shebang statement at the top of your Python scripts. A shebang is useful when working with virtual environments that may contain third party applications.

You also learned how to specify the encoding of your script by adding this line to the top of your script:

# -*- coding: utf-8 -*-

This information is used by the Python parser to interpret the script using the given encoding. If no encoding is specified, ASCII is assumed. It is considered best practice to use UTF-8 since it has the added benefit of character support beyond ASCII-characters.

The last section of the lesson talks about the number of statements you should have on each line. Python supports writing multiple statements on a single line but this is considered bad practice. The pythonic way to write statements is to have each statement on its own line:


print 'Hello' ; print 'World'

if x == 1: print 'one'


print 'Hello' 
print 'World' 

if x == 1:
    print 'one' 

Become a Member to join the conversation.