title: Pickle - Load variable if exists or create and save it
body: <p>Is there a better way to load a variable with <code>pickle</code> if it already exists or create it and dump it if it doesn't?</p>
  
  <pre><code>if os.path.isfile("var.pickle"):
      foo = pickle.load( open( "var.pickle", "rb" ) )
  else:
      foo = 3
      pickle.dump( foo, open( "var.pickle", "wb" ) )
  </code></pre>