It is a method to create and use your own module with Colaboratory.
First, create a folder for module in Google Drive. The name is chokozainerRL. Create an empty file \ _ \ _ init__.py in chokozainerRL. I made a file with VSCode and uploaded it. Next, create a test.py file like the one below and upload it.
test.py
class Test:
def sayStr(self, str):
print(str)
In the chokozainer folder
__test__.py
test.py
The notebook looks like the following.
import google.colab.drive
google.colab.drive.mount('gdrive')
!ln -s gdrive/My\ Drive mydrive
!ln -s gdrive/My\ Drive/chokozainer chokozainer
from chokozainerRL import test
a=test.Test()
a.sayStr("Hello Papa")
As the program grows, it becomes more convenient to create your own module.
Recommended Posts