#!/usr/bin/env python import hello #world = hello.world() world = hello.world('Hello') print(world.get()) world = hello.world(1, 2) print(hello.abstract().value())
import os print(os.getcwd()) # Ensure that your current working directory is the folder in which the module scripts are stored. # os.chdir('/users/david/documents/github/exercises/Py_testModule') import hello hello.world() hello.spiel() from hello import noHello noHello() # Note that it doesn't work to attempt to import a module that is in a sub-folder of the current working directory import secretModule secretModule.secretFunction( ) # doesn't work (and you'll have to kill the terminal) # For modules in sub-folders, the working directory needs to be changed os.getcwd() os.chdir( '/users/david/documents/github/References-and-Illustrations/Py_testModule/secretModule' ) import secretModule secretModule.secretFunction( ) # This works fine (after a fresh terminal opened)
def test_hello(): assert hello.world() == 'hello world'
def test_hello(self): self.assertEquals('Hello', world())
# import hello module import hello # Call function hello.world(); # Print variable print(hello.shark); # Call class jesse = hello.Octopus("Jesse", "orange"); jesse.tell_me_about_the_octopus();
import hello #import our custom hello module hello.world() #run the world() function within the hello module
#!/usr/bin/python3 import sys; sys.path.append('/home/srm/aa/PYTHON/PROJECTS'); from hello import world world();
#!/usr/bin/python3 import sys sys.path.append('/home/srm/aa/PYTHON/PROJECTS') from hello import world world()
# Import hello module import hello # Call function print(hello.world()) # Print variable print("---------->", hello.ant) # Call class the_machine = hello.Car("Ford Mustang", "1967 Fastback", "night blue") the_machine.tell_me_about_the_car() print(the_machine.color)
def test_hello_world(): assert hello.world() == "Hello, World!"
def test_world(self): self.assertEquals(hello.world("Hello, World!"), "Hello, World!")