Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Introduction to Python and Web Programming


Published on

Slides created for the San Diego Python Users Group to teach our "Intro To Python" class. We have held the class twice already and will continue to do so as there continues to be interest in learning Python.

Introduction to Python and Web Programming

  1. 1. Intro to Python & Web Programming For Beginners San Diego Python Users Group Kendall Chuang, David Fischer, Trey Hunner, David NeissMonday, January 28, 13
  2. 2. Introductions • Your name • Your Python experience and software background • What you would like to do with Python? This helps us better focus the training for the next iterationMonday, January 28, 13
  3. 3. Thanks to Sponsors: • Ansir Innovation Center = big thanks for the space • Python Software Foundation = $ for food • San Diego Python Users Group = volunteersMonday, January 28, 13
  4. 4. SD Python Users Group • Started by Kendall Chuang and David Fischer • Appx 300 people • Free, monthly meet-ups. Usually last Thursday • 7:30, appx 1.5 hours, @Ansir • Usually one or two speakers • All experience levels • Listed on and • (optional) after meeting @ pubMonday, January 28, 13
  5. 5. Today’s Overview • Morning learn & do • Lunch break around 12 • Afternoon, learn & do • Do project • Bathroom locations, wifi login/pw, parking reminderMonday, January 28, 13
  6. 6. Today’s Goals 1. Breadth (not depth) coverage of Python 2. Reading Python, but not necessarily writing it 3. Learn how to figure out Python for yourself: a. try it in the Python shell b. help() in the Python shell c. google “The Python Tutorial” in Python docs d. google/stack overflowMonday, January 28, 13
  7. 7. The Python Interpreter • The “python” executable • Compiles Python source code into Python byte codes (the .pyc files you will see in your dirs) • Can be used to run entire programs or interactively (the “shell” mode)Monday, January 28, 13
  8. 8. Python Shell • Fosters “exploratory/interactive programming” • Prints expression values automatically • >>> is the shell prompt • help() - enters into a help mode • dir() - prints names in module’s namespace • Use up arrow to retrieve last command • Can be used as a calculator, for example, 1*2*3*4*5 to compute 5! • quit via exit()Monday, January 28, 13
  9. 9. Do • Startup the Python shell • help() to enter the help system • Type “list” to get help on Python’s Lists • “quit” to exit help mode • Alternatively, you can just type help(list) • dir() to get a dump of names in current scope • quit() or CTRL-D to exit the shell • print ‘hello world’ to print the string “hello world” • Compute the number of seconds in a day using the shell interactive modeMonday, January 28, 13
  10. 10. Print Statement • Before we do anything, we need a way to look at values using the print command. • print <expression> • <expression> can be a literal, variable, or expression: print “hello world” # this is a literal print 1+1 # 1+1 is an expression myTeam = “Chargers” # myTeam is a variable print myTeam # print out the value of myTeamMonday, January 28, 13
  11. 11. Print Formatting • For string literals, you can use single or double quotes • For substitutions into a string, use %s for strings and ints # Dynamic HTML generation in Python! print “<title>%s</title>” % “MyWebSite” print “size=%d” % 10 • For multiple values, surround with parenthesis (called a tuple) print ‘<img src=”%s” alt=”%s”>’ % (“”, “A picture”)Monday, January 28, 13
  12. 12. Do • Print your name • Print your name and house number using print formatting string “I am %s, and my house address number is %s” and a tupleMonday, January 28, 13
  13. 13. User Input • raw_input() is a built in function • Use raw_input(“user prompt”) • Prints the “user prompt” and then waits for user input followed by return key • raw_input() returns what user entered • Assign raw_input() to a variable, val = raw_input()Monday, January 28, 13
  14. 14. Do • Ask the user to enter their name, by typing the following into the Python shell, raw_input(“Hi sexy, what’s your name?”) • Next, print “Hey <yourName>, you are kinda cute” and substitute the user input for <yourName>.Monday, January 28, 13
  15. 15. Variables • Created using an arbitrary name (certain rules apply, must start with a letter, case sensitive, not be a reserved word,...) For example, “tweet” or “this_URL” or “jsonData” • Dynamically bound to objects of specific data types at assignment time. For example, errCode=404 (an int), url=‘’ (a string), pi=3.1415 (a float) • No need to declare types. type is inferred from object. In the previous case, we would have an int, string, and float type • Type can be determined using type(variable)Monday, January 28, 13
  16. 16. Variables... • When a variable isn’t bound to anything, its type is “NoneType” • If you assign a variable to a function that has no return value, you get None • to test a variable for “none-ness”, use “var is None”, which is a bool expressionMonday, January 28, 13
  17. 17. Do • Create a variable using your name and assign an integer of your birth month to it • Print the variable and print its type • Assign a string of your birth month to the same variable • Now print the variable and print its type • Notice that the type of the variable changes with the dataMonday, January 28, 13
  18. 18. Boolean (bool) • two values, True or False • case sensitive • “and” does boolean AND operation. Only True of both are True • “or” does boolean OR operation. True if either are True • “not” does boolean inversion. not True == False • == for comparison (not single equals, that’s assignment)Monday, January 28, 13
  19. 19. Integers and Floats • Usual operators +, -, *, /, ** • +=, *=, /=, -= shortened forms. No ++ or -- operators as in C/Java • Integers have arbitrary precision(!), try 2**1000. Floats don’t (try 2.1**1000) • Floating point number must have decimal point • Note difference between 5/2 and 5.0/2 • use int(value) and float(value) to convert into that typeMonday, January 28, 13
  20. 20. Strings • Use quotes around text • Single or double quotes, but must match • If string must contain quotes, escape it with backslash. For instance “he said ”Wow!”” • Immutable • len() for length • type() == str • Use str() to convert a type to a string. str(2) == “2” • Use triple quoting to continue text after an end-of-line (which normally terminates a line)Monday, January 28, 13
  21. 21. String Operations • Concatenation via +, returns new string combining both • Concatenation via *, repeats string N times • string.upper(), converts string to upper case • string.swapcase(), swaps case of chars in string • string.split(), splits string and returns list of words • string.strip(), removes leading and trailing white space, returns new string • string.count(“whatToCount”) • string.replace(“this”, ”withThat”), returns new string with changes • string.find(“whatToFind”, fromIndex) - returns index of whatToFind in string starting at position fromIndex, -1 if not found • Many more, look in docsMonday, January 28, 13
  22. 22. Do • Create two variables, one assigned to “http://www.” and another to “” • Concatenate (join) the two into a third variable so you get a complete URL • Create another variable with the complete URL repeated 10 times, but with a comma between the URLs • Split the string “<h1> This is an HTML header </h1>” into its space delimited words • Count the number of occurrences of “jpg” in this string “a.jpg, b.gif, c.jpg, d.png” • From the URL string “” create a new string and replacing “facebook” with “twitter”.Monday, January 28, 13
  23. 23. Splicing • 0 indexed/based - as per C/Java/C# • Examples: • S = ‘hello world’ • S[0] = ‘h’ • S[1] = ‘e’ • S[-1] = ‘d’ • S[1:3] = ‘el’ • S[:-2] = ‘hello wor’ • S[2:] = ‘llo world’Monday, January 28, 13
  24. 24. Do • Crate a string contain the following JSON encoded information: [ {color : ”red” , value : ”#f00” } ] • Use .replace(this,withThat) to remove all whitespace from the string • Find the index to the first quote, use .find(“””) • Find the index to the second quote, use .find(“””,firstIndex+1) • Extract the value mapped to color (in this case red) which is between the first two quotes, using the splicing operator and the indexes found in the 2 previous stepsMonday, January 28, 13
  25. 25. Lists • Create a new list with [ ] or list() • Lists are arrays that can change size, elements can be changed, added or removed • Elements or a list can be of mixed types, including other lists • Supports splice operations • For example rssTags = [“<channel>”,”<title>”,”<pubDate>”, ”<rss>”] print type(rssTags) # type is ‘list’ print rssTags[1:3] # supports slicing rssTags[0] = “<link>” # mutable print len(rssTags) # returns length of listMonday, January 28, 13
  26. 26. Lists... • list.sort() # sorts the list in place (doesn’t return sorted list) • list.reverse() #reverses list in place • list.append(item) # appends item to end of list • list.remove(item) # removes item from list • list.count(item) # counts number of items in list • del list[index] # removes elements, can use splice indexing • bounds checked, throws exceptionMonday, January 28, 13
  27. 27. Do • Create a list of 5 strings of URLs • Using splicing, print the second and third elements of the list • Print the length of the list • Sort the list • Reverse the list • Remove the first entry in the list • Append the number 100 to the list. Notice that the list contains strings and numbers. • Try to access the 100th element in the list and explain what happenedMonday, January 28, 13
  28. 28. Dictionaries • Can be created via dict(), {}, or {key1:val1, key2:val2, ...} • A set of key:value pairs • Unordered - probably should really be called a map not a dictionary (actual ordering is based on hash of key, so key must be hashable and constant) • Can grow and shrink • Specific values are accessed via [key] • Add new values via [newKey] = newValue • Remove values via del dict[key] • Use dict.has_key(key) (or, “key in dict”) to determine if key is contained • Accessing undefined values generates an exception • len() returns number of key/value pairs in dictMonday, January 28, 13
  29. 29. Do • Create an empty dictionary to keep track of user preferences as key/value pairs • Add in 3 key/value pairs mapping a user preference string to a value for the following pairs, “userName”-> some string, “autoLogout” -> a bool, and “maxLoginTime” -> any integer • Print the contents of the dictionary. What order are the entries? Why? • Add in a new key/value pair “homePage” -> “” • Query the dict to return the value for the key “userName” • Change the value associated with “userName” to a different name • Delete the “homePage” key/value pair from the dictMonday, January 28, 13
  30. 30. Sets • Contains a set of data where there are no duplicates • Created by or {values,...} or set([1,2,3]) (but not {}, which creates an empty dict) • Supports union, intersection, difference operations • set.add(value) to add a value • set.remove(value) to remove value • set.intersection(anotherSet) to find the elements in common to both • set.union(anotherSet) to combine anotherSet into this set, removes duplicates • set.difference(anotherSet) removes anotherSet members from this set • element in set - in operator tests for inclusion in setMonday, January 28, 13
  31. 31. Do • Create two small sets of URLs you visited today and yesterday • Check if “” is in either set • Create a union of the two sets. Are there are duplicates in the union? Why not? • Lets say you visited “” today. Add that to your set representing today’s URLs • Print the set of all the URLs that you visited on both days (the union) • Print only the URLs that you visited on both today and yesterday (the intersection) • Print only the URLs that you visited today but not yesterday (the difference) • See how handy sets can be?Monday, January 28, 13
  32. 32. Aliasing • Variables refer to underlying objects • Assigning one variable to another makes both point to the same object • If both point to same object, one can appear to change the other a = [1,2,3] b = a id(a) == id(b) # true a[0] = 99 print b # notice that b got changed • Use copy operations to make copies/deep copies b = a[:] id(a) == id(b) # false a = [1, [2,3], 4] b = copy.deepcopy(a) # import copy first id(a[1]) == id(b[1]) # falseMonday, January 28, 13
  33. 33. if/elif/else statements • Used to conditionally perform operations • Formatted as “if expression:” • Note the trailing colon which is required - will trip up C/C++ programmers • Conditional block must be indented, either spaces or tabs. All code in block must have same indentation For example: a = 11 if a > 10: print “a is greater than 10” elif a>= 10 and a <= 20: print “a is between 10 and 20” else: print “a is greater than 20”Monday, January 28, 13
  34. 34. for loops • Used to iterate over a sequence, such as a list or set for searchTerm in [“PERL”,”Python”,”C”]: googleFor(searchTerm) • Use range(low, high, step) to generate a range of numbers to iterate over for b in range(1,10,2): print b # odd numbers from 1 to 9Monday, January 28, 13
  35. 35. for loops • continue - continues with the next cycle of the loop., skipping rest of code in block. For example: for i in range(1,1000): if someSpecialCondition(i): continue doSomethingWith(i) • break - breaks out of the innermost loop. For example: while True: if someCondition(): breakMonday, January 28, 13
  36. 36. Do Compute the product of all numbers that are a multiple of 5 between 5 and 100, inclusive (e.g., 5, 10, 15,.... 100)Monday, January 28, 13
  37. 37. Functions • why? abstraction, program decomposition, code reuse/ reduce duplication • declare functions with “def name(argList):” • function name must follow naming rules (and not use a reserved word as its name) • function body (line following def) must be indented • end the function with a return statement if you are returning a value; otherwise, no return statement is necessary. Note that function doesn’t declare its return type. Functions that dont have return values effectively return “None”Monday, January 28, 13
  38. 38. Arguments • argList is a comma separated list of argument names. You select the argument names that make sense for the function • as usual in Python, argument types are not declared explicitly • arguments are passed “by reference”, so a function could change their values (if they are mutable types) • If you don’t want function to change values passed in by reference, make deep/copy or use immutable type (tuple) • Advanced - Python supports default argument values, named arguments, and variable number of argumentsMonday, January 28, 13
  39. 39. Variable scopes • Variables defined outside a function are global to that file • Variables defined within a function are local to that function • Objects can be returned from the function via the “return” statement • Variables, functions, classes in other modules may be accessed in multiple ways (will be discussed in upcoming Modules slides)Monday, January 28, 13
  40. 40. Example • Create a function that accepts a list of URL strings and return a dictionary mapping the URL to the number of times it was visited sites = ["","","", "","", ""] def countVisits(sitesVisited): numVisited = dict() for site in sitesVisited: if numVisited.has_key(site): numVisited[site] = numVisited[site] + 1 else: numVisited[site] = 1 return numVisited; print countVisits(sites)Monday, January 28, 13
  41. 41. Do • Write a function that accepts a string containing the name of a site and returns a proper HTTP URL for that site For example for “yelp”, return “http://”, so prefix it with “http:// www.” and suffix it with “.com”Monday, January 28, 13
  42. 42. Exceptions • Exceptions indicate an error condition • “throw” means that the exception has occurred • Python can throw exceptions or you can throw them • Used to simplify error handling since error handing need not be locally coded • An advanced topic, but not complicatedMonday, January 28, 13
  43. 43. Exceptions... • coded as try/except blocks: try: . . doSomethingThatCouldThrowException() if somethingBad: raise anException() . . except typeOfExceptionToCatch: handleException()Monday, January 28, 13
  44. 44. Classes • Objects must be allocated via className(argList) • Allocation may include additional arguments used to initialize the object • Methods (or member functions) may be invoked using dotted notation • Objects can be deleted with del() or simply by overwriting the reference • For instance: from datetime import date date1 = date(2001,1,1) # allocate instance and supply construction arguments type(date1) # type, user-defined type date2 = date(2013,1,1) delta = date2 - date1 # notice use of difference operator on user-defined types print delta.total_seconds() # invoke member function total_seconds to compute secondsMonday, January 28, 13
  45. 45. Modules & Python Program Structure • Python files run from top to bottom • Import statements run their imported files (modules) • Imported files may import their own set of filesMonday, January 28, 13
  46. 46. Modules • Modules allow for decomposition of programs into packages of code & data, to facilitate • Code reuse • System namespace partitioning • Each file is a module, which defines a namespace • Modules import other modules to access the names they defineMonday, January 28, 13
  47. 47. Modules... • import modName - lets a client fetch a module as a whole. Inserts into local namespace as modName.XXX • from modName import foo - allows clients to fetch particular names from a module into this namespace as foo • imp.reload modName - provides a way to reload a module w/o restarting pythonMonday, January 28, 13
  48. 48. Python Program Structure • import statements • function and class definitions • module scope variables and code • Code executes from top to bottom of file (as opposed to main() )Monday, January 28, 13
  49. 49. Python program structure... def foo(): import a print “foo” file: • Running does nothing except declare the foo function • When B is run, A’s foo is imported as • Running prints “foo”Monday, January 28, 13
  50. 50. File I/O • The File type object is actually built into the language as a type • You can only get an instance with the open(fileName,”r +”) method. “r+” = read and write. • returns whole file as a string • f.readlines() returns a list of strings, one for each line in file • f.write(data) to write data to file • f.close() to close file when finishedMonday, January 28, 13
  51. 51. Do • Create a file named “test”, open it, and write “hello worldn” and then “i love pythonn” into it and close it • Open the file, read its contents and close it • From outside the Python shell, verify that file named “test” was created and contains the two strings on separate linesMonday, January 28, 13
  52. 52. The Python Standard Library • Included with Python (no need to download 3rd party libs) • What follows is a small subset • Selected to help pique your interestMonday, January 28, 13
  53. 53. CSV Files • CSV = Comma Separated Values • Common format for spreadsheets and databases • Python includes a csv module to make reading and writing of CSV files easier • Handles different “dialects” of file formatsMonday, January 28, 13
  54. 54. csv Module • To write: f = file(“myData.csv”,”r+”) myWriter = csv.writer(f) myWriter.writerow([“”, ”news”, ”hourly”]) myWriter.writerow([“”, ”reviews”, ”daily”]) f.close() • Could use .writerows(arg) if arg is a list of lists • To read: f = file(“myData.csv”,”r”) myReader = csv.reader(f) for rowAsList in myReader: print rowAsListMonday, January 28, 13
  55. 55. Do • Create several rows of data with each row having a name string, and address string, and a zip code number as a list of lists. • Write all of the rows of data to a CSV file using .writerows() • Open the CSV file outside of Python and verify that all the rows were writtenMonday, January 28, 13
  56. 56. JSON Processing • JSON encoding is very popular on the web • has the spec, but looks similar to Python dicts • Can contain objects (maps) and lists of strings, numbers, booleans, null, or other maps and listsMonday, January 28, 13
  57. 57. json Module • To read/write JSON, use the json module • For input, parses JSON string into its value val=json.loads(jsonString) • For output, converts a value to a JSON encoded string jsonString=json.dumps(value)Monday, January 28, 13
  58. 58. Do {     "red":"#f00",     "green":"#0f0",     "blue":"#00f" } • Parse the above string using json.loads() into a dict. Once in the dict, change “green” to “#fff” and then encode back to JSON string using json.dumps() and print the resultant string.Monday, January 28, 13
  59. 59. datetime module • Captures date & time stamps • Allows manipulations (addition & subtraction of time, comparing time stamps, • class returns a datetime object with a date&time stamp when statement is run • class datetime.timedelta contains the difference between two datetime objectsMonday, January 28, 13
  60. 60. Do This program should print the time to write a file but has two bugs in it that prevent it from working correctly. Fix the bugs and make it run so that it prints the proper amount of time. How long did it take? import datetime def WriteToFile(fileName, textToWrite): f = open(fileName,”r”) f.write(textToWrite) f.close() timeBefore = WriteToFile(“testFile”,”hello world”); timeAfter = print timeBefore - timeAfterMonday, January 28, 13
  61. 61. random Module • Used to generate “pseudo” random numbers • random.randint(a,b) generates a random number between a and b inclusive, uniform distribution • random.choice(seq) randomly selects one of the elements in the seq • random.shuffle(seq) shuffles the sequenceMonday, January 28, 13
  62. 62. The following code is supposed to generate a deck of cards, shuffle them, and then print out the shuffled deck. One line is missing, causing it to fail. What is that one line? Add it and make it run. import random def UnshufledDeckOfCards(): deck = [] for num in range (1,11): for suit in ["hearts", "clubs", "diamonds", "spades"]: deck.append( str(num) + " of " + suit) deck = UnshuffledDeckOfCards() print "Unshuffled deck:" print deck random.shuffle(deck) print "Shuffled deck:" print deckMonday, January 28, 13
  63. 63. socket module • Provides low level networking interface called sockets • Normally, one uses the higher level networking abstracts, but this is available • Supports client and server modes • socket.socket(socket.AF_INET, socket.SOCK_STREAM) • socket.connect( (host, port) ) connects to server • socket.sendall(stuffToSend) sends message to server • socket.recv(NumBytesToRx) receives up to num bytesMonday, January 28, 13
  64. 64. Do Enter the following code and run it and look at the output. If it ran, you just talked to Google’s web server and fetched part of their home page! import socket sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.connect( ("",80) ) sock.sendall("GET / HTTP/1.0nrnr") httpResponse = sock.recv(1000) print httpResponseMonday, January 28, 13
  65. 65. telnetlib module • Supports the telnet protocol • Allows you to login to a telnet session and send and receive text • telnetlib.Telnet(host) connects to host via Telnet protocol, returns connection object • .write(text) sends text to server • .read_until(text) reads from server until finds “text” and returns all data readMonday, January 28, 13
  66. 66. Do Enter this code and run it. Look at the output. If successful, you just connected to the Villanova library’s Telnet server. import telnetlib # Villanova Law Library server HOST = "" tn = telnetlib.Telnet(HOST) print tn.read_until("DISCONNECT")Monday, January 28, 13
  67. 67. X/HTLM Parsing • Two models, stream based (SAX) or document based (DOM) • A simple stream based parser is available in the module HTMLParser • You must derive from the HTMLParser class and implement functions to receive callbacks for those parsing events • handle_starttag - <html> • handle_endtag - </html> • handle_data - for data between tags • Throws a HTMLParseError in the event that gets too confused to parseMonday, January 28, 13
  68. 68. Enter the following code, run it, and watch the output. Explain how you would modify it to extract just the text between the tags <h1> and </h1> from HTMLParser import HTMLParser # create a subclass and override the handler methods class MyHTMLParser(HTMLParser): def handle_starttag(self, tag, attrs): print "Encountered a start tag:", tag def handle_endtag(self, tag): print "Encountered an end tag :", tag def handle_data(self, data): print "Encountered some data :", data # instantiate the parser and fed it some HTML parser = MyHTMLParser() parser.feed(<html><head><title>Test</title></head> <body><h1>Parse me!</h1></body></html>)Monday, January 28, 13
  69. 69. Regular Expressions • RE (regular expressions) module allows you to do pattern matching • RE is a small language that defines rules for matching patterns in text • For instance, find a string followed by @ followed by a string followed by .com to find an email addresses in a string • Optimized for very fast executionMonday, January 28, 13
  70. 70. RE Example • The following is a Python script demonstrating a Python script, fetching an RSS feed, and searching for a RE in the received page • It is to be run via “python ‘re-expression’ “ • For example, “python Kardashians” • Fetches the People magazine headlines RSS feed • Searches for occurrences of the RE in the feed • If any were found, prints a message, otherwise indicates that none were foundMonday, January 28, 13
  71. 71. import re # regular expressions import urllib2 # URL access import sys # for argv # Use the first arg as RE search term whatToFind = sys.argv[1] # Fetch the headlines from People magazine response = urllib2.urlopen(" topheadlines/index.xml") if response.code == 200: strings = re.findall(whatToFind, if len(strings) == 0: print "Thankfully, another day without news" else: print "In the news again" else: print "Error fetching the URL”Monday, January 28, 13
  72. 72. Web Server • Python includes a library to implement a simple web server, SimpleHTTPServer • Serves files from the current directory and below, mapping the dir structure to HTTP requestsMonday, January 28, 13
  73. 73. Enter the following code into a file and run it. Fire up your browser and enter localhost:8000 as the URL. Your browser should talk to this Python server code, which should will a web page of the directory in which you started the Python interpreter in. Pretty cool! import SimpleHTTPServer import SocketServer PORT = 8000 Handler = SimpleHTTPServer.SimpleHTTPRequestHandler httpd = SocketServer.TCPServer(("", PORT), Handler) print "serving at port", PORT httpd.serve_forever()Monday, January 28, 13
  74. 74. Web Service Clients • Using HTTP to make requests of servers • Usually requires a 3rd party library not part of the Python standard library, such as SUDS • Client libraries like SUDS can read a WSDL file and generate what looks like a Python class with member functions which perform all communications with the server, making server communications look as simple as a regular function callMonday, January 28, 13
  75. 75. GUIs • There are several options here: • Tkinter • PyQT • wsPythonMonday, January 28, 13
  76. 76. Need more? • Look over the standard library docs at • PyPI - Python Package Index, http:// • Appx 30,000 packages in PyPI (!)Monday, January 28, 13
  77. 77. Python Twitter ProjectMonday, January 28, 13
  78. 78. Python Project • Using your browser, download the Twitter example and unzip the project on your computer from here: • exampleMonday, January 28, 13
  79. 79. Project Problem 1 • Run the command python • The response.json returns the JSON object as a Python data type. What data type is it? (e.g. , List, String, Dictionary, Tuple)Monday, January 28, 13
  80. 80. Project Problem 2 • Create a new output text file and write the response.json to the file • Open up the output file in another text editor and check the resultMonday, January 28, 13
  81. 81. Project Problem 3 • Print out the count of how many “tweets” there are in the results • For example • Tweet Count: nMonday, January 28, 13
  82. 82. Project Problem 4 • Create and print a new list of the tweet ‘text’ from the results of the searchMonday, January 28, 13
  83. 83. Project Problem 5 • Create and print a new list of the tweet ‘from_user’ from the results of the searchMonday, January 28, 13
  84. 84. Project Problem 6 • From the results, create and print a dictionary with the ‘from_user’ strings as the keys and the ‘text’ as the values of a Python dictionary.Monday, January 28, 13
  85. 85. Resources • • The official Python tutorial: http:// • Think Python: thinkcs/python/english2e/ • Learn Python with games: http://, January 28, 13
  86. 86. Resources • Udacity CS 101: overview/Course/cs101/CourseRev/apr2012 • Coursera: programming1 • Learn Python The Hard Way, 2nd Edition • (Free online) • Paperback book costs $15.99 • http://learncodethehardway.orgMonday, January 28, 13
  87. 87. Upcoming Events • PyLadies • Join the PyLadies group, encourage women to learn Python • Monthly Meeting January 24th • Meet our regular Python developers • Django Day February 23 • Learn to program a web app! • November 2-3, BrightScopeMonday, January 28, 13
  88. 88. Follow Us • • • • • @sandiegopythonMonday, January 28, 13