Skip to content
← Back to Community
Importing files as modules
Profile icon
Electrosolt

How do I import a python file (One that I created through replit) as a module for my main program? I want to be able to categorize my code and use it for other programs without having to make a mess, being able to use functions from a file to make stuff easier. Any idea how I can do this?
Example: https://repl.it/@Electrosolt/File-Module-Test

Answered by AllAwesome497 [earned 5 cycles]
View Answer
Voters
Profile icon
ChristianLam
Profile icon
grsample
Profile icon
AnangoPrabhat
Profile icon
Electrosolt
Comments
hotnewtop
Profile icon
AllAwesome497

import <filename without extension>
here is an example: https://repl.it/@AllAwesome497/Business-Man-6

Profile icon
Electrosolt

@AllAwesome497 Thanks for the clarification, turns out I was being bad and wrapped the thing in a class instead of just leaving it as normal. :)

Profile icon
michael2008

On a Python or JavaScript repl, you can search for a package to install by clicking on the icon on the sidebar in the workspace. Simply search for the package you want and select it to install the package or to view its documentation. Clicking on the Add Package icon will put it in a spec file and a lock file.