Main( ) in a file in my library?

How to run code from a file in my library without copying it to main()-file?

def add(a,b):
  return a+b
def main():
  print(add(4+5))
if __name__ == '__main__':
  print("HEJ")
    main()

Hey @beahus, welcome to the forums!

Just click the next to “Files” then click “Show hidden files”. Next click on the .replit file and finally you can change the entrypoint to whatever file you want to run.

Images

Dots

Show hidden files

edited

You should also see the docs on how to configure a Repl: https://docs.replit.com/programming-ide/configuring-repl

And if you want to run the last edited file, take a look at this post:

Hope this helps!
If this answers your question, you can mark this post as a Solution.

1 Like

Welcome to Ask! You can change the file to run as NateDhaliwal suggested or you can import and run other Py files in the same way you would a library.

1 Like