Contents:
  • Python FAQ
  • Installing Python on your own computer
  • Using your i-drive/Socweb/DCS
  • Connecting from a home computer
  • Some general Unix commands

    Python FAQ

  • I copied your code into UltraEdit/Notepad++ but it does not seem to work.
    Unix and PCs have different characters for line and file endings. Normally UltraEdit and Notepad can deal with that, but, if not, you may need to change your settings in these editors. In UltraEdit this can be done in "Advanced-Configuration-File Handling". Another possibility is to use dos2unix -c ISO filename on the command-line. Then open the file with nano and delete any control characters that may have been left.
  • Why do I not see any output when I execute a script whereas it works fine using the interpreter?
    The interpreter automatically prints results. For example, if you type "N(pi)" the interpreter prints the value of pi. If you do the same in a script, there will be no output. In order to see output from a script you need to print it ("print N(pi)").
  • Why are there funny characters on the screen?
    The command "sys.displayhook = pprint" uses UTF-8 characters to display mathematical formulas in a nicer format. Unfortunately, this does not always work perfectly when the client is on a PC and the server is Unix. To disable the display hook command temporarily, type
    sys.displayhook = sys.__displayhook__
    To disable the command permanently, delete that line from your .pythonstartup file.
  • Why are my commands for sets not working properly
    You'll need from sets import Set for the exercises to work properly. Otherwise, you would be using the sets module from SymPy, which is different from the one in Python.
  • Why is this code not working even though nothing seems wrong?
    Are you maybe reusing a name which is predefined by Python or by your program? You may not be getting a warning if you are overwriting a predefined name or if you are using the same name for a function and a variable, etc, but your code won't work.

    Installing Python on your own computer

    You can login to the university server remotely (see below). Therefore it should not be necessary for you to install Python on your own computer. If you do want to run it yourself, make sure that you have a version after 2.4 (for example, Python 2.6.4). I have not tested any code on Python 3 yet. Python is pre-installed on Mac OS X and Linux computers. For PCs you can get it from:
    Python downloads.
    You also need SymPy for most of the exercises.

    Using your i-drive/Socweb/DCS

  • General instructions on using Python on Socweb/DCS.
  • You can edit the files on the I:-drive using Notepad++ or UltraEdit because the I:-drive provides access to the same files as the ssh window. Don't use plain Notepad, Word or WordPad. If you do not have an I:-drive, you need to map it: Go to All Programs -> School of Computing -> Unix -> Map Unix drives.
  • Unix editor: nano
  • Arrow keys etc: Use the arrow keys to repeat a previous command. Use the tab key to complete a filename.
  • In nano, you can use Ctrl-K to delete/cut a line and Ctrl-U to get it back (paste). You can cut/uncut several adjacent lines in one go.

    Connecting from a home computer

    A secure shell (SSH) client is needed. On Linux and Mac OS X, such a client is usually pre-installed (type "ssh" at the command-line). For PCs there are several clients freely available for download, such as
    PuTTY or a GUI ftp client such as WinSCP. The address for the server is socweb8.napier.ac.uk.

    Some general Unix commands

    Change to mydirectorycd mydirectory
    Create newdirectorymkdir newdirectory
    Remove (delete) olddirrmdir olddir
    Move (rename) olddir to newdirmv -i olddir newdir
    Show name of current dir.pwd
    Allow others to read and execute files in current directory chmod go+rx .
    List files in current dir.ls
    List all (incl. hidden)files, with detailsls -la
    Show contents of myfile more myfile
    Move (rename) oldfile to newfilemv -i oldfile newfile
    Copy origfile to duplicatefilecp -i origfile duplicatefile
    Remove (delete) oldfile rm -i oldfile
    Allow others to read/change sharedfilechmod go+rw sharedfile
    Show the first few lines of largefile head largefile
    Show the last few lines of largefiletail largefile
    Edit a text filenano or emacs or vi or pico
    Find commands related to keywordman -k keyword
    Read manual for command man command
    Find true name of cmdwhich cmd
    Show environment variablesprintenv
    Change environvariablesetenv environvariable value