unknown's Articles
How to Traverse a Directory Tree in Python – Guide to os.walk
When you use a scripting language like Python, one thing you will find yourself doing over and over again is walking a directory tree, and processing files. While there are many ways to do this, Python offers a built-in function that makes this process a breeze. What is the os.walk() Function? The walk function is […]
Read MorePython Unicode: Encode and Decode Strings (in Python 2.x)
Strings are among the most commonly used data types in Python, and there might be times when you want to (or have to) work with strings containing or entirely made up of characters outside of the standard ASCII set (e.g. characters with accents or other markings). Python 2.x provides a data type called a Unicode […]
Read MoreIPython Introduction: An Enhanced Python Interpreter
Simply put, IPython lets you do all sorts of really powerful stuff. It’s very popular amongst scientists and mathematicians, and has a lot of features that they seem to really appreciate. It also has a lot of features that are really useful to everyone else who uses Python. IPython offers lots of simple hooks for […]
Read MoreHow to Install Virtualenv (Python)
Note: Edited comments about the –no-site-packages argument now being default, thanks to @dideler on Twitter. Python is a very powerful scripting language. The language has lots of Python packages you can install and use in your projects. Sometimes, you may have different projects that need different versions of the same package/module. For example, let’s say […]
Read MorePython Beautiful Soup Example: Yahoo Finance Scraper
Python offers a lot of powerful and easy to use tools for scraping websites. One of Python’s useful modules to scrape websites is known as Beautiful Soup. In this example we’ll provide you with a Beautiful Soup example, known as a ‘web scraper’. This will get data from a Yahoo Finance page about stock options. […]
Read MoreHow to Run a Python Script via a File or the Shell
If you can’t execute or run a Python script, then programming is pointless. When you run a Python script, the interpreter converts a Python program into something that that the computer can understand. Executing a Python program can be done in two ways: calling the Python interpreter with a shebang line, and using the interactive […]
Read MoreObject Oriented Programming in Python
Object orientation is a central concept in Python, as well as many other languages. Understanding the concept, and applying it well, will enable you to build much more elegant and manageable software. What is Object Oriented Programming in Python? You’ll often hear it said that, in Python, everything’s an object. It’s pretty much true, with […]
Read More