Rookev/Reddit-Image-Scraper — pull request #1 by jjangsangy (2014-06-25 10:47:28+00:00)
Title: Conversion into Python Module

Hi

I saw your project from [reddit](http://www.reddit.com/r/learnpython/comments/28v2lh/reddit_image_scraper_my_first_project/ciet53y) and thought it was really neat.

I've seen a bunch of different image scrappers, but really liked the way you implemented yours. From reading through your code, and I can see you have some previous programming background, but maybe not particularly Python though, so I took the liberty of `Pythonizing` the module for you.

I'll walk you through some changes I've made.

Installation
--------------

### requirements.txt

* Rather than installing each module individually, I've added a `requirements,txt` at the root of the directory.

#### Install Requirements
``` bash
$ pip install -r requirements.txt
```

* This will install all the requirements in one go. Later, if dependencies change, you can just modify this file (it's just a list of modules) and not have to add any more details for others to change.

### setup.py

I've added a simple setup script in the `setup.py` module. This allows others to install your program and conveniently call it anywhere using `reddit_scrapper`. The `setuptools` module does all the work of installing it in the users environment so you don't need to go into the directory with `imagescrapper.py` to run.

It's also less typing!

#### To Install
``` bash
$ python setup.py install
```

#### To Uninstall
``` bash
$ pip uninstall Reddit-Image-Scrapper
```

## reddit_scrapper directory
* I've organized all the original code into a directory called `reddit_scrapper`. This is also conveniently the name of your console script **(Not to be confused with the name of the repo `Reddit-Image-Scrapper`)**.
* The `__init__.py` file is a python convention that lets the interpreter know we are dealing with a packaged module. It will now treat files in the directory as a single package rather than an assortment of scripts/files.
* Advantages are that you can separate your concerns into logical units and have each file be aware of it's other members, very useful when you want to add features or debug issues.
* I had to modify some of the original code, but almost all of it is exactly the same. The things I changed were mostly conventions dealing with modules and packaging.
* Changed name of `imagescraper.py` to `__main__.py`. This lets python know where the single entry point of the program is. If you're going to implement **argument parsing**, I would do it in this file.
* `__version__.py` contains your version info. Updating this file will update the version number everywhere.

## Docs
* I saw that you've actually written some good documentation already within your program, so I implemented `Sphinx` in the `docs` directory to extract your docstrings and then generate a html website with all the info. This means, you can do all the documentation in one place, and `Sphinx` will update the necessary fields for you.
* You can automate this feature even more by utilizing services like [ReadTheDocs](https://readthedocs.org/), which will check your github repo for pushes and generate/host your documentation so everything is up to date. I've gone ahead and set it up for my fork, so you can see an example.

http://reddit-image-scrapper.readthedocs.org/

Let me know if you have any questions!