title: Python Pickle File Permissions
body: <p>I'm new to python and am trying to write a program that keeps track of an amount of money, numbers or whatever. You can add or subtract to your amount and it is saved to a file, or check the amount you currently have. I had it working using this code</p>
  
  <pre><code>  import pickle
  
    num = 0
    toDo = input("would you like to load or add/subtract? ")
  
    if toDo == "add":
      a = float(input("How much do you want to add? "))
      pickle_in = open("Python", "rb")
      newNum = pickle.load(pickle_in)
      newNum = newNum + a
      print("Current balance:", newNum)
      pickle_out = open("Python","wb")
      pickle.dump(newNum, pickle_out)
      pickle_out.close()
  
    if toDo == "subtract":
      a = float(input("How much do you want to subtract? "))
      pickle_in = open("Python", "rb")
      newNum = pickle.load(pickle_in)
      newNum = newNum - a
      print("Current balance:", newNum)
      pickle_out = open("Python","wb")
      pickle.dump(newNum, pickle_out)
      pickle_out.close()
  
  
    if toDo == "load":
      pickle_in = open("Python", "rb")
      newNum = pickle.load(pickle_in)
      print("Current balance:", newNum)
  </code></pre>
  
  <p>This was working fine, the file was loading properly, everything was good, until today (about 24 hours later) when I tried to run this program again, attempting to load the current amount, and it gave me this error:</p>
  
  <pre><code>Traceback (most recent call last):
    File "C:\Users\Dom\Desktop\amount.py", line 34, in &lt;module&gt;
      pickle_in = open("Python", "rb")
  PermissionError: [Errno 13] Permission denied: 'Python'
  </code></pre>
  
  <p>I then tried using the os.chmod function but I'm not 100% sure I used it properly. </p>
  
  <pre><code>import pickle
  import os, sys, stat
  
  
  
  num = 0
  toDo = input("would you like to load or add/subtract? ")
  
  if toDo == "add":
    a = float(input("How much do you want to add? "))
    pickle_in = os.chmod("Python", "rb")
    newNum = pickle.load(pickle_in)
    newNum = newNum + a
    print("Current balance:", newNum)
    pickle_out = open("Python","wb")
    pickle.dump(newNum, pickle_out)
    pickle_out.close()
  
  
  if toDo == "subtract":
    a = float(input("How much do you want to subtract? "))
    pickle_in = os.chmod("Python", "rb")
    newNum = pickle.load(pickle_in)
    newNum = newNum - a
    print("Current balance:", newNum)
    pickle_out = open("Python","wb")
    pickle.dump(newNum, pickle_out)
    pickle_out.close()
  
  
  if toDo == "load":
    pickle_in = os.chmod("Python", "rb")
    newNum = pickle.load(pickle_in)
    print("Current balance:", newNum)
  </code></pre>
  
  <p>it seemed i got past the permission problem using chmod, but then i got this error when trying to load, add or subtract.</p>
  
  <pre><code>Traceback (most recent call last):
    File "C:\Users\Dom\Desktop\amount.py", line 11, in &lt;module&gt;
      pickle_in = os.chmod("Python", "rb")
  TypeError: an integer is required (got type str)
  </code></pre>
  
  <p>Not sure if i'm not using the chmod function properly or what. Could anyone tell me how to fix this and/or why it stopped working?</p>