Hour 24. Taking the Next Steps with Python


What You’ll Learn in This Hour:

Image What other projects might interest you

Image What you’ll get from attending conferences

Image How to learn more about Linux

Image How to contribute to the Python community

Image What other programming languages you might try

Image What reading and website resources are available


In this last hour, we won’t be doing any coding. You’ve spent the past 23 hours learning about Python, the parts of coding, advanced concepts, and building applications. Although you may still struggle now and then, you have the tools to go out and do some great things. This hour is dedicated to helping you find additional resources.

Interesting Projects

What now? This is the question that many new coders have after learning the basics of their first language. Nearly every developer has closed their textbook and felt befuddled. What should they do now? Let’s go over some resources for various projects that may interest you.

Creating Websites and Web Applications

In Hour 20, “Developing for the Web with Flask,” you learned how to use Flask to create a website. Flask is hardly the only option when it comes to web development, however. Also, you may want to learn more about getting your website off of your computer and onto an actual server, where other people can see it.

Frameworks and Applications

The Python community maintains a page of currently maintained frameworks here: http://wiki.python.org/moin/WebFrameworks. Let’s take a few minutes to go over some of the more popular options.

Django (https://www.djangoproject.com/) is a popular Python web framework that is lauded for its power and its flexibility. It also has amazing documentation as well as a large and active community. If you need something a bit more powerful than Flask, this would be a good place to start.

Web2py (http://www.web2py.com/) is another lightweight framework. It doesn’t require installation, like most other frameworks, so you can run it anywhere that Python can run. You can even run it off of a USB stick!

Plone (http://plone.org/) is a fully featured content-management system (CMS). Unlike a framework, it comes with a fully working website, with tons of functionality, right out of the box. Hundreds of Plone extensions and themes are available at http://plone.org/products.

Managed Service Providers

As stated before, there’s a huge difference between developing a website on your laptop and running it on a server. If you don’t want to learn about running a server, a good middle ground is finding a managed service provider. There are dozens of these, ranging from ones that are used mostly for casual sites, to those that run websites for large companies.

Because new services are popping up all the time, the best way to find one is to search for your framework’s name plus “hosting.” Look for either forum posts in the past year or the actual host’s site.

One interesting option is Python Anywhere (http://learncss.tutsplus.com/). There, you can get a free account that allows you to create one web app. You can create an app in Django, Flask, web2py, or Bottle (another web framework written in Python). You can edit files through a web interface, and the tutorial helps walk you through editing, restarting your server, and updating other files.

Creating Desktop Applications

Python comes with a library for creating graphical user interfaces (GUIs) called Tkinter. The Python community maintains a list of tutorials for Tkinter at http://wiki.python.org/moin/TkInter. Just because Python includes a library for creating a GUI, though, doesn’t mean that others haven’t stepped in to create third-party applications.

Pyjs (also known as Pyjamas) is a framework that not only works for the Web, but can be used to create desktop applications as well. Pyjs can be found at http://pyjs.org/.

PyGUI is another toolkit for creating desktop applications, with the advantage that you don’t have to be well versed in desktop toolkits to understand the documentation. You can find PyGUI here: http://www.cosc.canterbury.ac.nz/greg.ewing/python_gui/.

Finally, wxPython offers a simple framework and also offers a tutorial to help users get started with creating desktop applications. You can find out more about wxPython at http://www.wxpython.org/.

Creating Android and iOS Applications

If you want to create applications for Android and iOS, Kivy is an excellent option. It’s free, and it also allows you to build applications for Mac OS and Windows. It supports multitouch, and makes it easy to create various interface elements. Kivy can be found at http://kivy.org.

Game Creation Competitions

We’ve already gone over how to create games in Python, but there’s a competition run several times a year called PyWeek you might want to know about. PyWeek is free to enter, and you can work either alone or in a team. You have one week to code a game. Although you can plan before the week starts and gather artwork, all coding must be done that week. PyWeek can be found at http://pyweek.org.

If you prefer working under less of a time crunch, check out the yearly Interactive Text Competition. Any language is allowed, and you can even make a game that’s hosted online. The Interactive Text Competition can be found at http://ifcomp.org.

Python in Science and Math

Python has a strong following in the scientific and mathematical fields, so there are more than a few top-notch third-party libraries. SciPy consists of a number of science- and math-based modules, including:

Image NumPy— A package for dealing with large matrices and arrays

Image SymPy— A package for symbolic mathematics

Image SciPy Library— A library for scientific computing

Image Matplotlib— A library for 2D plotting

Image pandas— A library for data structure and analysis

SciPy, and links to all of the individual modules, can be found at http://www.scipy.org/.

Making a Better Working Environment

One of the first things an experienced developer will do when starting a new project is to put it in a sandbox. A sandbox is a place where a project can exist without affecting any other project on that system, whether it’s on a laptop or a server. The habit of using a sandbox is so ingrained that developers often do this on a server that will only be up an hour, and will only have one project.

The most popular way to sandbox in Python is to use virtualenv and virtualenvwrapper. virtualenv is the application that does the actual sandboxing, whereas virtualenvwrapper provides a number of helper functions, such as quickly moving to your environment, easily setting up an environment, and making it easier to execute custom commands every time your sandbox is started up or exited.

virtualenv can be found at http://www.virtualenv.org/en/latest/, and virtualenvwrapper can be found at http://virtualenvwrapper.readthedocs.org/en/latest/.

Attending Conferences

The Python community is one that likes to get together. Often. Not only does the Python community hold dozens of conferences a year, but the most significant projects hold yearly conferences.

Pains are taken so that conferences are useful for everyone in the community. There are talks geared toward every type of Python developer. There are talks for (and by!) beginners to programming in Python alongside talks for more experienced developers. Besides seeing talks, conferences provide an excellent chance to meet fellow developers face to face and, if you stay for the sprints, contribute to open source projects.

A list of conferences can be found at http://pycon.org/, and it doesn’t hurt to do a search for conferences about your favorite framework. Also, don’t feel shy about asking about any upcoming conferences in that framework’s Freenode channel.

Not every Python event requires you to leave town. Every January and July, the Python community holds an event called Julython. Developers are encouraged to work on personal projects, either alone or in a team, for a little bit every day. People team up locally to compete against other cities. You can find more information about Julython at http://www.julython.org/.

Working with Linux

Nearly every developer, at some point, touches an operating system called Linux. There are many flavors of Linux, but all are open source, and most are free. They can even run on your computer alongside its current operating system. Here are some advantages to working on Linux:

Image It’s better suited to coding. Installing a new library is often as easy as typing one command into the command line. Had this book been written for Linux users, it would have been about 30 pages shorter.

Image Not only is the OS free, but there are hundreds of free (and high-quality) tools available for it.

Image There are many different flavors of Linux. Distributions have been made for enterprise environments, educators, children, people who like customization, and people who like a robust out-of-the-box experience.

Image Because many developers are running a version of Linux, that’s what they’ve written their documentation for. You will almost always find install instructions for Linux. Finding the same quality of instructions for Windows is much rarer.

Image If you want to do web development, you will eventually want to touch a server. That server, almost every time, will be running a Linux-based operating system.

Dozens of different distributions of Linux are available, but I tend to encourage new users to try out one called Ubuntu (see Figure 24.1). There’s even an online tour you can go through that lets you explore Ubuntu’s features. You can find the tour at http://www.ubuntu.com/desktop/take-the-tour.

Image

FIGURE 24.1 Ubuntu’s Desktop (from the guided tour at http://www.ubuntu.com/tour/en/).

You can use Ubuntu alongside another operating system in one of two ways: through dual-booting or by using it in a sandboxing application called Virtualbox. Ubuntu has documentation covering both options here:

Image Virtualbox and Ubuntu: https://help.ubuntu.com/community/VirtualBox

Image Windows dual-booting: https://help.ubuntu.com/community/WindowsDualBoot

Image Mac OS dual-booting: https://help.ubuntu.com/community/DualBoot/MacOSX

To find out more about Ubuntu, go to http://www.ubuntu.com. There, you’ll be able to download the install files, read about more of the features of Ubuntu, and meet other people who are using and developing Ubuntu.

If you want to learn more about the command line, I highly recommend The Linux Command Line, by William E. Shotts, Jr. Getting familiar with the terminal makes your life so much easier when coding on your local machine, and is vital when you move to a server.

Contributing to Python

Many developers assume they need a decade or more of experience before they can contribute back to the Python community. This couldn’t be further from the truth! Python (as well as the many projects that use it) is always looking for contributors.

To find the current list of bugs in Python, go to http://bugs.python.org/. Some may be too high level for you right now, but there’s some low-hanging fruit that almost anyone can fix. For example, as of this writing, there’s a ticket about some of the documentation being worded poorly. This is something nearly anyone with a bit of knowledge about Python can help fix!

To learn more about contributing to Python, go to http://docs.python.org/devguide/.

Contributing to Other Projects

You don’t have to limit yourself to contributing to Python. If you have a project you’ve discovered that you like, you can contribute to it. Most open source projects are always looking for people to help out—from bug fixes, to documentation, to new features!

To contribute to a project, search for the project home or see if it has a repository on GitHub. Make sure to look over its documentation to see if it has any guidelines for contribution before you start submitting fixes. Also, join its channel on IRC and see if there’s anywhere in particular you can help out.

Learning Another Language

You’ve just spent 24 hours learning one language, and now I’m suggesting you learn another one? Yes! There are many languages that complement Python.

Once you learn one language, learning a new language becomes much easier. With every new language, you often need less and less time to get up to speed. When I first started coding, it took what seemed like forever to get comfortable with a new language. Now, I do a quick skim to see how the language is set up. How do I declare a variable? What’s the syntax for a function? Anything cool I should know about? I can usually start coding within a week or so, given enough documentation and time to hunker down and focus.

If you’re interested in web development, I highly recommend picking up JavaScript and jQuery. These two languages are vital to making dynamic web pages. jQuery, a library built off of JavaScript, is actively maintained, free to use, and is cross-browser compliant. Codecademy (http://www.codecademy.com/tracks/) has free classes in both JavaScript and jQuery that can teach you the basics of both.

Also, if you’re going to do web development, you should learn about HTML and CSS. HTML is the language used for documents on the Web, and CSS is used to style the Web. Codecademy also has a track for HTML and CSS called Web Fundamentals. The site 30 Days to Learn HTML & CSS (http://learncss.tutsplus.com/) offers 30 days of lessons that are video based.

If you like game development, you might want to pick up C, which is the mother of Python. C is extremely fast and is perfect for intensive operations where your CPU might get bogged down. A great place to start is Learn-C.org (http://www.learn-c.org/), where they have an interactive, online tutorial.

Looking Forward to Python 3

Python 3 is coming along quickly, and although Python 2.7 will be around for a long time, it’s a good idea to check out what’s changing. Though it can feel scary to move to a new major release, lots of tools are out there to help get you up to speed and, better yet, help convert any code you want to port to Python 3.

A good place to start is at Python’s What’s New page (http://docs.python.org/3/whatsnew/3.0.html). Here, you can read over what has been removed, what has been changed, and what has been added to the language.

If you want to move some of your code over to Python 3, you should read the how-to guide at http://docs.python.org/dev/howto/pyporting.html. There, you can decide if you want to use one of the automated tools, such as 3to2, or if you’re going to need to adopt a more nuanced approach.

Recommended Reading

There is no shortage of books on Python. Here are some of the ones that are highly regarded by the community.

The Python Standard Library by Example, by Doug Hellmann, is one book that is never far from me. It takes a deep, yet accessible, dive into the standard library, showing how each module works and adding caveats where necessary. The content is also available at Hellmann’s blog (http://pymotw.com/), but I highly recommend the book for leafing through and exploring.

Learn Python the Hard Way, by Zed Shaw, helps you develop an attention to detail through repetition and careful observation. The course is available at http://learnpythonthehardway.org/.

Invent Your Own Computer Games with Python, by Al Sweigart, teaches Python through games, and although the earlier chapters may repeat what we’ve gone over in these past 24 hours, the later chapters delve much more deeply into game development.

Python Cookbook, by Alex Martelli, Anna Ravenscroft, and David Ascher, goes over common tasks you encounter when coding, and it reviews which ways are the most efficient or less error-prone, and why. There is also a later edition, written by David Beazley and Brian K. Jones, for Python 3.

Recommended Websites

You’ve probably already been to Python’s official website, http://python.org/, but it’s most certainly worth returning to, now that you have a better background in Python. Of particular interest is the documentation. You can browse the documentation online, or you can download it for offline reading.

If you want to see what kind of talks are at various Python conferences, you should go to PyVideo (http://pyvideo.org/). Almost all Python conferences are recorded, and the topics cover everything from beginner material to in-depth looks into how Python works. Speakers also talk on topics outside of Python, such as design and education.

Learn Python (http://www.learnpython.org/) is a great site for not only reviewing the topics we’ve covered in this book, but also to look into other concepts that we didn’t have time for in these 24 hours. For example, we only skimmed over decorators in the Flask hour, but this site has a page dedicated to how you would use decorators, and why.

If you like reading blog posts about what other people are doing in Python, Planet Python (http://planet.python.org/) offers an RSS feed (or a web display) of all the latest writings about Python. Posts come from all over the Python community and cover topics from all kinds of libraries, projects, and conferences.

Finally, The Hitchhiker’s Guide to Python (http://docs.python-guide.org/en/latest/) is a great resource for not only learning more about coding in Python but also learning about writing clean code and choosing the right tool for the project.

Summary

During this hour, you learned about other projects you can get involved with. You also learned about other resources for developing Python. Finally, you learned about where you can discover other languages that complement Python, as well as learned about how to move to Python 3.

Q&A

Q. But I still don’t have any ideas! Where can I go now for inspiration?

A. This is a common problem among new developers, and you are not alone! My first suggestion to every new developer is to think about what annoyances you have in your day-to-day life. Many of these can be solved through Python. For example, I hated remembering to give my children their allowance, so I built a web application to do this for me.

It only took a few hours, but it was far more effective than what I was already doing (giving my kids apologies and IOUs). Their allowance was deposited in a fake “bank” where they could set goals for themselves and check on their balance.

Q. I really, really don’t have any ideas. Is there anywhere else I can go?

A. Happens to the best of us. I recommend checking out coding challenges. Practicing coding often gives you ideas. The Open Knowledge Foundation hosts a number of coding challenges at http://wiki.okfn.org/Get_The_Data_Challenge. Another great site is CodingBat (http://codingbat.com/), where you can do warm-ups and then take on progressively more difficult challenges.

Workshop

The Workshop contains quiz questions and exercises to help you solidify your understanding of the material covered. Try to answer all questions before looking at the answers that follow.

Quiz

1. What are a few things you can do with Python?

2. What operating system do most servers run, especially where Python is concerned?

3. What other programming and markup languages complement Python?

Answers

1. You can create websites, games, desktop applications, and apps for your phone as well as perform scientific computing.

2. Most servers run a version of Linux.

3. C complements Python when speed is important. HTML, CSS, JavaScript, and jQuery are important in web development.

Exercises

1. If you haven’t yet, it’s now time to try out Ubuntu. Go to the online tour (http://www.ubuntu.com/desktop/take-the-tour) and do the following:

Image Find the Ubuntu Software Center.

Image Find the spreadsheet program.

Image Find the Dash home.

2. Still have no ideas about what you want to do with Python? It’s time to brainstorm. Take out a piece of paper and write down 20 things you wish you could automate. Think about tasks involved with areas such as the following:

Image Work

Image Home management

Image Planning trips and holidays

Image Hobbies

Image Communicating with others

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.129.148.210