Ask coding questions

← Back to all posts
Can visitors create files?
DillonB07 (6)


I have a repl that uses Python 3.
I am worried that it won't work as from my testing when using code like this:

def logger():
    log = input(Fore.CYAN + Style.BRIGHT + '\nWould you like to save this character to the \'Characters/'+ name + '.txt\'file?\n' + Fore.RED + Style.BRIGHT + 'WARNING: This will overwrite any current data under the name \'Characters/' + name + '.txt\'. (y/n) ')
    if log == 'y':
      myFile = open('Characters/' + str(name) + '.txt', 'w')
      myFile.write('Name: ' + name)
      myFile.write('\nClass: ' + chosenClass)
      myFile.write('\nGender: ' + chosenGender)  
      myFile.write('\nStrength: ' + str(chosenStrength))
      myFile.write('\nMagic: ' + str(chosenMagic))
      myFile.write('\nDexterity: ' + str(chosenDexterity))
      myFile.write('\nSpecial Ability: ' + chosenAbilities)
      myFile = open('names.txt', 'a')
      myFile.write('\n' + name)
      print('Successfully saved into Characters/' + name + '.txt')
      from main import selector
    elif log == 'n':
      print('OK! This character is not being saved.')
      from main import selector
      print('Not a valid option. Try again.')

When somebody else runs the project, I think that it creates the file locally and then doesn't add it to the main project.

Please can somebody tell me if this is what happens or if there is a workaround? If there isn't a workaround then my entire project idea won't work.


Answered by ch1ck3n (2053) [earned 5 cycles]
View Answer
ch1ck3n (2053)

replit (for apparent security measures) doesn't save file changes made by the program. it will delete whatever the program file is making. sadly there is no workaround for this. i contacted some of the devs and they said they would have to redo their infrastructure to fix this.

DillonB07 (6)

@ch1ck3n Thanks for the reply.
I don't really want to say this, as I like replit, but are there other online free IDE's that I can use for this project?
I've spent a lot of time on it and don't want to abandon it.

ch1ck3n (2053)

@DillonB07 how about glitch

edit: glitch might not support file editing from the program

DillonB07 (6)

Thanks, I'll give it a go.

DillonB07 (6)

Thanks for the suggestion. does not officially support Python, but you can use it from the console.
However, other people can't run it.
Is your contact with the devs publically available to read/contribute to?
I'd like to see it.

ch1ck3n (2053)

@DillonB07 it's on discord from april 23rd i think? look in #off_topic

DillonB07 (6)

Oh. I don't have access to Discord.
I thought it might be a suggestion on Canny.
I will make it a suggestion there though!

DillonB07 (6)

Ah, ok.
Mine was a little more specific I think though.
And yours didn't come up in the similar questions.

Thanks, though