oh, that’s a good idea.
what i’m actually working on is an inventory for my game. the initial script upon starting the game creates an inv.txt file.
example:
file = open("inv.txt", "w")
file.write("test")
file.write("
")
file.close()
generally it’d be empty, but the ‘test’ text is there because i want to be able to find and edit it in the next script.
there would be a script for when an item is picked up. say, a gun.
file = open("inv.txt", "a")
file.write("gun")
file.write("
")
file.close()
works well enough. then the next script (the problem script) is run if, say, something happens to remove the item ‘test’ from the inventory.
pseudo code:
file = open("inv.txt", "a")
find "test" (first line found with the word used)
remove "test" (where found)
file.close()
i’m familiar with php and using it with mysql, so i know how to pull mysql info into php, edit it, and resave it. or, which i’d prefer to do with python 3, edit the content directly (such as when using php to edit via mysql syntaxes).
i’d like to do something similar.
i can’t use a dictionary because it only works within a single script. i attempted the use of global variables, but python 3 isn’t recognizing any (even if assigned as global) within a separate script.
i realize learning python 3 is of course important, but i cannot learn the syntax if i can’t find it, or examples of it. yes, i’ve read every link you’ve provided Zeff, but none of them are showing anything like what i need to do. not that i can find. learning python 3 isn’t really an issue. i can learn it pretty fast because thus far it’s a very basic, simple language. the problem is the syntax. how to find the appropriate terms to use in order to say “find this in the file” and “edit this in the file”.