Skip to content

Instantly share code, notes, and snippets.

@bryjbrown
Created April 8, 2015 20:38
Show Gist options
  • Save bryjbrown/8625cbdbf137a9a83a23 to your computer and use it in GitHub Desktop.
Save bryjbrown/8625cbdbf137a9a83a23 to your computer and use it in GitHub Desktop.
A summary of the Wednesday@2PM Python Code Club meeting from 4/8/2015

#A summary of the Wednesday@2PM Python Code Club meeting from 4/8/2015 Session guide: Bryan Brown Note taker: Bryan Brown

##Pre-meeting questions:

  • Most of the group uses either Mac or Linux, so demos using the bash shell would work.
  • More group members are familiar with Python 2 than Python3.
  • Group is generally agnostic about MARC/PyMARC, mainly interested in Python in general.

##Python in general:

  • Learning by doing is best way to get familiar with Python.
  • Know the difference between Python 2 and 3.
    • Check your version with python --version and python3 --version.
    • Python 2 has print 'foo' while Python 3 has print('foo').
    • Python 2 is for legacy projects, Python 3 is the future and has better stuff (see https://docs.python.org/3.0/whatsnew/3.0.html).
    • Basically use Python 2 when a project demands it, use Python 3 for anything new.
  • Run files by calling the interpreter (python3 test.py to execute the file 'test.py').
  • Learn the interpreter's options to do cool stuff (python3 -c "print('foo')" to execute a one line print statement).
  • Learn to use the built-in interactive Python shell to explore the language (see https://docs.python.org/3/tutorial/interpreter.html).

##IPython:

  • IPython (http://en.wikipedia.org/wiki/IPython) is like the built-in interactive Python shell on steroids.
  • IPython doesn't come with the standard Python installation, you must install it separately with sudo pip3 install ipython.
  • All input and output are saved to the named arrays 'In' and 'Out'.
    • For example, to get the input from line 4, call 'In[4]'. The prompt shows this on each line.
  • IPython recognizes standard UNIX navigation commands like ls and cd. No need to leave the environment to move.
  • Hit to autocomplete variable and method names, or to see what methods are available for an object.
  • Add '?' to a variable to get information about it, or put it at the end of a method (i.e., x.append?) to find out what the method does.
  • IPython has a lot of crazy features you may never need (like running several CPU cores at once), but its cool to know you could.

##Anaconda:

  • Like a Linux distrubution that has the Linux kernal at its core but different sets of default packages, Anaconda has Python (2 or 3!) at its core and some really top notch built-in third-party libraries like IPython (mentioned above), NLTK (Natural Language Processing Toolkit), NumPy & Pandas (data analysis libraries) and lxml (super fast XML processing).
  • Anaconda is easy to install, just go to http://continuum.io/downloads and select version 2 or 3 and the platform you want to run it on.
  • Anaconda can be installed in your home directory, so you don't need sudo priviliges. Run it anywhere!

##Postmeeting discussion:

  • Bryan mentioned using Python in a project that scrapes OJS sites to create Islandora metadata batches(https://github.com/fsulib/ojsh, ignore the README.md for now).
  • Phil is mostly interested in XML data processing applications of Python as opposed to web/MARC stuff.
  • Mark mentioned using Mark Phillips' (https://github.com/vphill) Python code for OAI-PMH processing, Bryan says FSU does this too.
  • Some group members left for meetings at 3:00 sharp (everybody, its fine to leave early if you have meetings. we understand).
  • Ann asked if we should have a note taker for sessions like the other Python Code Club group, Bryan, Mark and Phil agree we should.
  • Bryan agreed to type up the notes for this session (hi!), Ann agreed to add a "Note taker" field or something to the group schedule spreadsheet.
  • Remainder of group disbanded at 3:15ish.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment