What is the equivalent of Ruby require?

10,405

The import statement.

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

Share:
10,405
abhishek
Author by

abhishek

Updated on June 04, 2022

Comments

  • abhishek
    abhishek almost 2 years

    I am coming to Python from Ruby.

    What is the equivalent statement of require in Python?

  • abhishek
    abhishek over 13 years
    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"
  • aaronasterling
    aaronasterling over 13 years
    @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?