0

I'm new with Python and I created a method that clears the screen. Is it already saved somewhere in my computer so that everytime I call it in Python cmd I can use it?

Something to add: Should I learn Python 2 or 3 is fine enough?

J Roq
  • 171
  • 1
  • 8

2 Answers2

2

No. Each interactive session is separate. However, see this question for ways to save sessions if you want to.

Community
  • 1
  • 1
jtbandes
  • 115,675
  • 35
  • 233
  • 266
0

No, it will be gone when you start a new session. If you want to add your shortcut so that it's there every time you start python, you have a few options:

  • Add it in your sitecustomize.py file, this may be platform dependent but for my system it is located at /usr/lib/python2.7/sitecustomize.py.
  • Add it in your ipy_user_conf.py for ipython. On unix systems it should be under ~/.ipython/. I have actually already the same alias to clear the screen 3x on mine, by adding the line o.autoexec.append('alias c clear; clear; clear') under main() in ipy_user_conf.py
  • Define it in your own module, and autoimport this module at python startup (using sitecustomize, PYTHONPATH environment variable, or whatever..)

The adoption curve of python 3 is poor because many people are relying on packages that are still only supported properly by python 2.x. You should learn python 2 if you are going to use libraries that don't have good python 3 support yet, otherwise learn python 3 because it does have many significant improvements. The authors have a tool to convert 2 to 3 which can handle most syntax stuff automatically, for simple enough code.

wim
  • 338,267
  • 99
  • 616
  • 750