Note to Self: For programming and Python Jupyter Notebook νBs, who are wondering what they are getting themselves into:

Programming Dos and Don'ts: A Running List...

  1. Do restart your kernel and run cells up to your current working point every fifteen minutes or so. Yes, it takes a little time. But if you don't, sooner or later the machine's namespace will get confused, and then you will get confused about the state of the machine's namespace, and by assuming things about it that are false you will lose hours and hours...

  2. Do reload the page when restarting the kernel does not seem to do the job...

  3. Do edit code cells by copying them below your current version and then working on the copy: when you break everything in the current cell (as you will), you can then go back to the old cell and start fresh...

  4. Do exercise agile development practices: if there is a line of code that you have not tested, test it. The best way to test is to ask the machine to echo back to you the thing you have just created in its namespace to make sure that it is what you want it to be. Only after you are certain that your namespace contains what you think it does should you write the next line of code. And then you should immediately test it...

  5. Do take screenshots of your error messages...

  6. Do google your error messages: Ms. Google is your best friend here...

  7. Do not confuse assignment ("=") and test for equality ("=="). In general, if there is an "if" anywhere nearby, you should be testing for equality. If there is not, you should be assignment a variable in your namespace to a value. Do curse the mathematicians 500 years ago who did not realize that in the twenty-first century it would be very convenient if we had different and not confusable symbols for equals-as-assignment and equals-as-test...

  8. Do expect things to go wrong: it's not the end of the world, or even a threat to your soul. Back up to a stage where things were working as expected, and then try to figure out why things diverged from your expectations. Here, for example, we have Gandalf the Grey, Python νB, confronting unexpected behavior from a Python pandas.DataFrame:
    Tools Data Science and Python MRE key

    Yes, he is going to have to upgrade his entire system and reboot. But in the end he will be fine...

 


#berkeley #datascience #jupytger #notebook #programming #python #teaching

Comments