Ask coding questions

← Back to all posts
Main.py, how do I change the name
TheHappyCow

How do I change the main.py to something else?

Answered by PattanAhmed [earned 5 cycles]
View Answer
Voters
AB321
TheHappyCow
Comments
hotnewtop
PattanAhmed

@TheHappyCow Hi,
I think you can't do it but if you really want that feature, You can post it in the Repl.it Feedback Section.
You can go to Repl.it Feeedback Section from here
I hope that the community will accept your wish.

Hope this helps
Please mark my answer if this helps

TheHappyCow

Thanks for the help! I didn't expect so many people would answer so quickly. I appreciate it! Have a good day!

PattanAhmed

@TheHappyCow Welcome!

Muffinlavania

You cant change main.py into anything else, but you can still import it, like this

Main.py is like a special file, it cant be renamed properly. its name when importing is __main__ two underscores on each side

JustA6

@Muffinlavania I cant access any of my funcs

Muffinlavania

@JustA6 do this

this will make it so that you can access stuff like variables and functions normally

JustA6

@Muffinlavania i STILL cant use any of my funcs

Muffinlavania

@JustA6 really? if you put a function in main.py, you can access it by doing from __main__ import * then just functionname(). if its in another file do from [filename] import *

JustA6

@Muffinlavania yeah, theres just some weird funcs i didnt def

Muffinlavania

@JustA6 lol ok then define them i guess and it should work

JustA6
JustA6

@JustA6 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

JustA6

@JustA6 Def appears 10 times

Muffinlavania

@JustA6 ??? do you need help? i can help you with these functions if its really that hard to you

JustA6

@Muffinlavania not with the funcs just that my funcs work in main.py but not second_file.py

Muffinlavania

@JustA6 here can you share me into the repl

JustA6

@Muffinlavania nah, but im pretty sure its a thing with main.py so https://repl.it/@JustA6/example#main.py

Muffinlavania

@JustA6 ?? what are you using you can just import the other files to run them can you make a copy of what your working on and share me into it?

JustA6

@Muffinlavania look at the code of main.py and test.py The problem is right there

Muffinlavania

@JustA6 i have no clue what you are using for the system('duiwadniawnd') whatever is this the code you are working on?

JustA6

@Muffinlavania I can’t believe you Don’t know that but it runs test.py

JustA6

@JustA6 its a bash thingy

JustA6

@JustA6 or cmd if your on windows

Muffinlavania

@JustA6 you cant use bash in python...

JustA6

@Muffinlavania Yeah but It RUNS A BASH TERMINAL

JustA6

@Muffinlavania it’s a built in Module, The python creators can do whatever they want

Muffinlavania

@JustA6 ok ok youve got me very confused, you are trying to run text.py right? 1)


2)
you can just import the file and it will run the file, or you can do from test import * to be able to get all the variables and functions inside of a file.
How to make a function (quickly)

JustA6

@Muffinlavania it does run it though because that’s the bash cmd For running python files, there’s a reason why I am not importing it, Second it doesn’t actually work and all my functions give a error saying they don’t exist

JustA6

@JustA6 besides we’re talking about main.py, it’s a problem with that not test

JustA6

@JustA6 from test import * works just fine infact

Muffinlavania

@JustA6 im sharing you into a python repl, can you just show me what you are doing

Coder100

Sorry, that file is pinned and cannot be edited. You can use a hacky method to rename it, however.
Hit ctrl+shift+s:

However, then you will have to configure how the repl is run in order to make the repl work. Create a .replit file:

InvisibleOne

You can't rename the main.py.