Skip to content
Sign upLog in
← Back to Community

Main.py, how do I change the name

Profile icon
TheHappyCow

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

Answered by PattanAhmed [earned 5 cycles]
View Answer
Voters
Profile icon
AB321
Profile icon
TheHappyCow
Comments
hotnewtop
Profile icon
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

Profile icon
Muffinlavania

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

#In any other file import __main__

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

Profile icon
JustA6

@Muffinlavania
I cant access any of my funcs

Profile icon
Muffinlavania

@JustA6
do this

from __main__ import *

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

Profile icon
JustA6

@Muffinlavania
i STILL cant use any of my funcs

Profile icon
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 *

Profile icon
JustA6

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

Profile icon
Muffinlavania

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

Profile icon
JustA6

@Muffinlavania
but

Profile icon
JustA6

@JustA6
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

Profile icon
JustA6

@JustA6
Def appears 10 times

Profile icon
Muffinlavania

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

Profile icon
JustA6

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

Profile icon
Muffinlavania

@JustA6
here can you share me into the repl

Profile icon
JustA6

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

Profile icon
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?

Profile icon
JustA6

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

Profile icon
Muffinlavania

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

Profile icon
JustA6

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

Profile icon
JustA6

@JustA6
its a bash thingy

Profile icon
JustA6

@JustA6
or cmd if your on windows

Profile icon
Muffinlavania

@JustA6
you cant use bash in python...

Profile icon
JustA6

@Muffinlavania
Yeah but It RUNS A BASH TERMINAL

Profile icon
JustA6

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

Profile icon
Muffinlavania

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

image


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)

def functionname(): #must have parenthesis print("Put stuff here, idk") functionname() #Calling the function
Profile icon
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

Profile icon
JustA6

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

Profile icon
JustA6

@JustA6
from test import * works just fine infact

Profile icon
Muffinlavania

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

Profile icon
TheHappyCow

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

Profile icon
PattanAhmed

@TheHappyCow
Welcome!

Profile icon
Coder100

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

rename main.py [new file].py

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

run="python [new file].py"
Profile icon
InvisibleOne

You can't rename the main.py.