Skip to content

Latest commit

 

History

History
57 lines (48 loc) · 2.07 KB

Hour3.md

File metadata and controls

57 lines (48 loc) · 2.07 KB

#Hour Five! Three sir. Three! - More on lists, and we get into flow control

  • Concatenation (+) versus append() versus extend()
  • pop()
  • index() and in
  • reverse() and sort()
  • Comprehensions
heartylaugh = [x for x in 'abracadabra' if x not in 'abc']

Flow Control (through 4.5)

  • if and else
  • while
  • for
  • range() (Another Python 3 note)

Useful tools

setuptools (easy_install)

setuptools -> distribute -> setuptools
What is the difference?

easy_install (part of setuptools)-> pip

How to install pip on Windows
An Easy Guide to Install Python or Pip on Windows
pip can uninstall
But... easy_install works better on windows because it handles binaries.

Another option

pip for windows
What does it do?
Why use other options?

##Scope
Namespace, including main

###Scope Hierarchy (9.2 Only)
1.the innermost scope, which is searched first, contains the local names 2. the scopes of any enclosing functions, which are searched starting with the nearest enclosing scope, contains non-local, but also non-global names 3. the next-to-last scope contains the current module’s global names 4. the outermost scope (searched last) is the namespace containing built-in namesthe innermost scope, which is searched first, contains the local names

###The namespace script

a = 0
def myName():
    print "When called by a function in my namespace, my name is", __name__
def whatisa():
    a = 1
    print a
def whatisglobala():
    global a
    print a
print "Right now, my name is:", __name__