what_next.asciidoc 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. [[What Next]]
  2. If you have read this book thoroughly till now and practiced writing a lot of programs, then you
  3. must have become comfortable and familiar with Python. You have probably created some Python
  4. programs to try out stuff and to exercise your Python skills as well. If you have not done it
  5. already, you should. The question now is 'What Next?'.
  6. I would suggest that you tackle this problem:
  7. __________________________________________________
  8. Create your own command-line *address-book* program using which you can browse, add, modify, delete
  9. or search for your contacts such as friends, family and colleagues and their information such as
  10. email address and/or phone number. Details must be stored for later retrieval.
  11. __________________________________________________
  12. This is fairly easy if you think about it in terms of all the various stuff that we have come
  13. across till now. If you still want directions on how to proceed, then here's a hint
  14. footnote:[Create a class to represent the person's information. Use a dictionary to store person
  15. objects with their name as the key. Use the pickle module to store the objects persistently on your
  16. hard disk. Use the dictionary built-in methods to add, delete and modify the persons.].
  17. Once you are able to do this, you can claim to be a Python programmer. Now, immediately
  18. http://swaroopch.com/contact/[send me an email] thanking me for this great book ;-). This step is
  19. optional but recommended. Also, please consider http://swaroopch.com/buybook/[buying a printed
  20. copy] to support the continued development of this book.
  21. If you found that program easy, here's another one:
  22. __________________________________________________
  23. Implement the http://unixhelp.ed.ac.uk/CGI/man-cgi?replace[replace command]. This command will
  24. replace one string with another in the list of files provided.
  25. __________________________________________________
  26. The replace command can be as simple or as sophisticated as you wish, from simple string
  27. substitution to looking for patterns (regular expressions).
  28. === Next Projects
  29. If you found above programs easy to create, then look at this comprehensive list of projects and
  30. try writing your own programs: https://github.com/thekarangoel/Projects#numbers (the list is also
  31. at http://www.dreamincode.net/forums/topic/78802-martyr2s-mega-project-ideas-list/[Martyr2's Mega
  32. Project List]).
  33. Also see https://openhatch.org/wiki/Intermediate_Python_Workshop/Projects[Intermediate Python
  34. Projects].
  35. === Example Code
  36. The best way to learn a programming language is to write a lot of code and read a lot of code:
  37. - http://code.activestate.com/recipes/langs/python/[Python Cookbook] is an extremely valuable
  38. collection of recipes or tips on how to solve certain kinds of problems using Python. This is a
  39. must-read for every Python user.
  40. - http://pymotw.com/2/contents.html[Python Module of the Week] is another excellent must-read guide
  41. to the <<stdlib,Standard Library>>.
  42. === Advice
  43. - http://docs.python-guide.org/en/latest/[The Hitchhiker's Guide to Python!]
  44. - http://slott-softwarearchitect.blogspot.ca/2013/06/python-big-picture-whats-roadmap.html[Python Big Picture]
  45. - http://www.jeffknupp.com/writing-idiomatic-python-ebook/["Writing Idiomatic Python" ebook] (paid)
  46. === Videos
  47. - http://www.pyvideo.org[PyVideo]
  48. === Questions and Answers
  49. - http://docs.python.org/3/howto/doanddont.html[Official Python Dos and Don'ts]
  50. - http://www.python.org/doc/faq/general/[Official Python FAQ]
  51. - http://norvig.com/python-iaq.html[Norvig's list of Infrequently Asked Questions]
  52. - http://dev.fyicenter.com/Interview-Questions/Python/index.html[Python Interview Q & A]
  53. - http://stackoverflow.com/questions/tagged/python[StackOverflow questions tagged with python]
  54. === Tutorials
  55. - http://stackoverflow.com/q/101268/4869[Hidden features of Python]
  56. - http://www.reddit.com/r/Python/comments/19dir2/whats_the_one_code_snippetpython_tricketc_did_you/[What's the one code snippet/python trick/etc did you wish you knew when you learned python?]
  57. - http://www.awaretek.com/tutorials.html[Awaretek's comprehensive list of Python tutorials]
  58. === Discussion
  59. If you are stuck with a Python problem, and don't know whom to ask, then the
  60. http://mail.python.org/mailman/listinfo/tutor[python-tutor list] is the best place to ask your
  61. question.
  62. Make sure you do your homework by trying to solving the problem yourself first and
  63. http://catb.org/~esr/faqs/smart-questions.html[ask smart questions].
  64. === News
  65. If you want to learn what is the latest in the world of Python, then follow the
  66. http://planet.python.org[Official Python Planet].
  67. === Installing libraries
  68. There are a huge number of open source libraries at the http://pypi.python.org/pypi[Python Package
  69. Index] which you can use in your own programs.
  70. To install and use these libraries, you can use http://www.pip-installer.org/en/latest/[pip].
  71. === Creating a Website
  72. Learn http://flask.pocoo.org[Flask] to create your own website. Some resources to get started:
  73. - http://flask.pocoo.org/docs/quickstart/[Flask Official Quickstart]
  74. - http://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-i-hello-world[The Flask Mega-Tutorial]
  75. - https://github.com/mitsuhiko/flask/tree/master/examples[Example Flask Projects]
  76. === Graphical Software
  77. Suppose you want to create your own graphical programs using Python. This can be done using a GUI
  78. (Graphical User Interface) library with their Python bindings. Bindings are what allow you to write
  79. programs in Python and use the libraries which are themselves written in C or C++ or other
  80. languages.
  81. There are lots of choices for GUI using Python:
  82. Kivy ::
  83. http://kivy.org
  84. PyGTK ::
  85. This is the Python binding for the GTK+ toolkit which is the foundation upon which GNOME is
  86. built. GTK+ has many quirks in usage but once you become comfortable, you can create GUI apps
  87. fast. The Glade graphical interface designer is indispensable. The documentation is yet to
  88. improve. GTK+ works well on GNU/Linux but its port to Windows is incomplete. You can create both
  89. free as well as proprietary software using GTK+. To get started, read the
  90. http://www.pygtk.org/tutorial.html[PyGTK tutorial].
  91. PyQt ::
  92. This is the Python binding for the Qt toolkit which is the foundation upon which the KDE is
  93. built. Qt is extremely easy to use and very powerful especially due to the Qt Designer and the
  94. amazing Qt documentation. PyQt is free if you want to create open source (GPL'ed) software and you
  95. need to buy it if you want to create proprietary closed source software. Starting with Qt 4.5 you
  96. can use it to create non-GPL software as well. To get started, read about
  97. http://qt-project.org/wiki/PySide[PySide].
  98. wxPython ::
  99. This is the Python bindings for the wxWidgets toolkit. wxPython has a learning curve associated
  100. with it. However, it is very portable and runs on GNU/Linux, Windows, Mac and even embedded
  101. platforms. There are many IDEs available for wxPython which include GUI designers as well such as
  102. http://spe.pycs.net/[SPE (Stani's Python Editor)] and the http://wxglade.sourceforge.net/[wxGlade]
  103. GUI builder. You can create free as well as proprietary software using wxPython. To get started,
  104. read the http://zetcode.com/wxpython/[wxPython tutorial].
  105. === Summary of GUI Tools
  106. For more choices, see the http://www.python.org/cgi-bin/moinmoin/GuiProgramming[GuiProgramming wiki
  107. page at the official python website].
  108. Unfortunately, there is no one standard GUI tool for Python. I suggest that you choose one of the
  109. above tools depending on your situation. The first factor is whether you are willing to pay to use
  110. any of the GUI tools. The second factor is whether you want the program to run only on Windows or
  111. on Mac and GNU/Linux or all of them. The third factor, if GNU/Linux is a chosen platform, is
  112. whether you are a KDE or GNOME user on GNU/Linux.
  113. For a more detailed and comprehensive analysis, see Page 26 of the
  114. http://archive.pythonpapers.org/ThePythonPapersVolume3Issue1.pdf['The Python Papers, Volume 3, Issue 1'].
  115. === Various Implementations
  116. There are usually two parts a programming language - the language and the software. A language is
  117. _how_ you write something. The software is _what_ actually runs our programs.
  118. We have been using the _CPython_ software to run our programs. It is referred to as CPython because
  119. it is written in the C language and is the _Classical Python interpreter_.
  120. There are also other software that can run your Python programs:
  121. http://www.jython.org[Jython] ::
  122. A Python implementation that runs on the Java platform. This means you can use Java libraries and
  123. classes from within Python language and vice-versa.
  124. http://www.codeplex.com/Wiki/View.aspx?ProjectName=IronPython[IronPython] ::
  125. A Python implementation that runs on the .NET platform. This means you can use .NET libraries and
  126. classes from within Python language and vice-versa.
  127. http://codespeak.net/pypy/dist/pypy/doc/home.html[PyPy] ::
  128. A Python implementation written in Python! This is a research project to make it fast and easy to
  129. improve the interpreter since the interpreter itself is written in a dynamic language (as opposed
  130. to static languages such as C, Java or C# in the above three implementations)
  131. There are also others such as http://common-lisp.net/project/clpython/[CLPython] - a Python
  132. implementation written in Common Lisp and http://brython.info/[Brython] which is an implementation
  133. on top of a JavaScript interpreter which could mean that you can use Python (instead of JavaScript)
  134. to write your web-browser ("Ajax") programs.
  135. Each of these implementations have their specialized areas where they are useful.
  136. [[functional_programming]]
  137. === Functional Programming (for advanced readers)
  138. When you start writing larger programs, you should definitely learn more about a functional
  139. approach to programming as opposed to the class-based approach to programming that we learned in
  140. the <<oop,object oriented programming chapter>>:
  141. - http://docs.python.org/3/howto/functional.html[Functional Programming Howto by A.M. Kuchling]
  142. - http://www.diveintopython.net/functional_programming/index.html[Functional programming chapter in 'Dive Into Python' book]
  143. - http://ua.pycon.org/static/talks/kachayev/index.html[Functional Programming with Python presentation]
  144. === Summary
  145. We have now come to the end of this book but, as they say, this is the _the beginning of the
  146. end_!. You are now an avid Python user and you are no doubt ready to solve many problems using
  147. Python. You can start automating your computer to do all kinds of previously unimaginable things or
  148. write your own games and much much more. So, get started!