what_next.asciidoc 10 KB

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