2

I am coming to Python from Ruby.

What is the equivalent statement of require in Python?

apaderno
  • 28,547
  • 16
  • 75
  • 90
abhishek
  • 41
  • 1
  • 1
  • 2

1 Answers1

5

The import statement.

Maybe it's advisable you follow a Python tutorial where much of the basics are explained

Ikke
  • 99,403
  • 23
  • 97
  • 120
  • 1
    There is a difference between import(Python) and require(Ruby). If i require in ruby (only require statement), File can be executed whereas having only import statement does not. For e.g. Suppose i have program(hello.rb) in ruby which has a line print "hello". I can execute this file by just doing this -> require "hello" – abhishek Sep 21 '10 at 12:32
  • 11
    @abhishek, this is completely wrong. A python module __is__ executed when it is imported! How else would the classes and functions which it contains be defined? – aaronasterling Sep 21 '10 at 12:48