Rookev/Reddit-Image-Scraper — pull request #3 by jjangsangy (2014-08-26 00:53:00+00:00)
Title: implemented argument parsing and updated docs

Hi

So I was playing with your code over the weekend and implemented argument parsing using the `argparse` module over hard coding argv within a try block.

Most of the semantics in the rest of the modules are the same, but I did modify certain blocks to be more idiomatic and easier to work with later. Some of the things in particular are as follows.

## String Formatting
I see you using a lot of `+` concatenation. Overloading the `+` operator is still very easy , but for longer and more complicated strings, you may want to try out the `str.format()` method instead.

```python
# Using +
print("User '" + username + "' does not exist!")

# Using str.format()
print('User {name} does not exist!'.format(name=username))
```

## Building Filesystem Paths

- Normalize into string with `os.path.normpath()`
- Assemble your path components using `os.path.join()`

```python
import os

home = os.enviorn.get('HOME')
some_path = os.path.normpath(os.path.join(home, 'Documents', 'folder'))

```

This has the added benefit of not having the worry about concatenating path separators into your code and is inherently backslash escapes windows paths for you.

* **Windows**

>>> print(some_path)
C:\\Users\\jjangsangy\\Documents\\folder

* **Linux**

>>> print(some_path)
/home/jjangsangy/Documents/folder

* **OS X**

>>> print(some_path)
/Volumes/Users/jjangsangy/Documents/folder

## Using `__all__` to export a function

You can use the `__all__` variable which is a list of strings at the top of a `.py` file to specify which functions are public.

In your `downloader.py` file, I added this

```python
__all__ = [
'process_direct_link',
'process_normal_link',
'process_album',
'format_url',
]
```

That way, you can just import the entire file into your `__init__.py` and it will only see those 4 functions.

```python
# __init__.py
from downloader import *
```