Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Creating/Moving file
#4
(Mar-25-2022, 04:50 PM)DeadlyKnight Wrote: How do I code its input without knowing it?
You may not know the name, but your program does: it is in the variable input_1_5_1 (or one of the others ThiefOfTime proposed; just choose one). So you can open the file like this:
f = open(input_1_5_1, "w")
f.close()    # Make a habit of it to close everything you opened once you are ready with it.
Oh I see, you put them in functions so the variables are local and not accessible for other functions. So get rid of the functions. Functions are only useful in the following cases:
  • When you are building a large and complex program, you should split your program in parts that are not complex. These parts will be your functions.
  • When you notice you have to copy parts of your code again and again because certain procedures have to be repeated, you had better put this part in a function.
  • When your teacher requires you to use functions. Smile
So if you need to use functions, then make sure these functions return the values you need again. And use parameters to provide these values to the function.
Reply


Messages In This Thread
Creating/Moving file - by DeadlyKnight - Mar-22-2022, 03:39 PM
RE: Creating/Moving file - by ThiefOfTime - Mar-25-2022, 10:40 AM
RE: Creating/Moving file - by DeadlyKnight - Mar-25-2022, 04:50 PM
RE: Creating/Moving file - by ibreeden - Mar-25-2022, 06:25 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  creating dict out of CSV file without the headers ranbarr 6 2,724 May-09-2021, 08:26 PM
Last Post: ranbarr
  Creating Disassembler for a bin file(total beginner) SoulsKeeper 1 2,495 Sep-04-2018, 04:15 PM
Last Post: Larz60+
  Creating a file with variable name but distinct extension Moeniac 1 2,289 Nov-27-2017, 05:47 PM
Last Post: DeaD_EyE

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020