<commit_before>#Optimizely Python Client

##Getting Started
Optimizely's Python client library is an interface to its [REST API](http://developers.optimizely.com/rest/).

The `optimizely` Python module can be installed via `pip` using the command `pip install git+git://github.com/optimizely/optimizely-client-python.git`.

###Authentication
Every API request needs to be authenticated. To authenticate, use a token generated from [optimizely.com/tokens](https://www.optimizely.com/tokens), then pass it to the Optimizely client object.

In the following examples, `client` refers to a `Client` object created using the code below.

```python
>>> import optimizely
>>> client = optimizely.Client('abcdefghijklmnopqrstuvwxyz:123456')
```

###Exceptions
If you make a call and it succeeds, data will be included in the returned object(s) (except in the case of deletions, where a `None` response indicates success).

If the call fails, we'll raise one of the following exceptions:

* `BadRequestError` can happen if your request was not sent in valid JSON. The error may reference specific fields that were invalid.

* `UnauthorizedError` if your API token was missing.

* `ForbiddenError` if you provided an API token but it was invalid or revoked, or if you don't have read/write access to the entity you're trying to view/edit.

* `NotFoundError` if the id used in the call was inaccurate or you didn't have permission to view/edit it.

* `TooManyRequestsError` if you hit a rate limit for the API. If you receive this response, we recommend waiting at least 60 seconds before re-attempting the call.

* `ServiceUnavailableError` if the API is overloaded or down for maintenance. If you receive this response, we recommend waiting at least 60 seconds before re-attempting the call.

All of these Exceptions inherit from the `OptimizelyError` class.

##Projects
A project is a collection of experiments, goals, and audiences. Each project has an associated Javascript file to include on the page.

###Read a Project
Get metadata for a single project.

See [the Optimizely REST API documentation](http://developers.optimizely.com/rest/#read-a-project) for response attribute definitions.

####Example Python
```python
>>> project = client.Projects.get(1234) # get Project by Id
>>> project.__dict__
# {
#   'id': 1234,
#   'account_id': 123456789,
#   'code_revision': 12,
#   'project_name': 'My even newer project name',
#   'project_status': 'Active',
#   'created': '2014-04-16T21:33:34.408430Z',
#   'last_modified': '2014-06-10T22:12:21.707170Z',
#   'library': 'jquery-1.6.4-trim',
#   'include_jquery': False,
#   'js_file_size': 23693,
#   'project_javascript': 'someFunction = function () {\n //Do cool reusable stuff \n}'
#   'enable_force_variation': False,
#   'exclude_disabled_experiments': False,
#   'exclude_names': None,
#   'ip_anonymization': False,
#   'ip_filter': '1.2.3.4'
# }
>>> client.Projects.get([1234, 5678])   # get multiple Projects by Id
# [<optimizely.resource.Project object at 0x000000000>, <optimizely.resource.Project object at 0x000000010>]
```

###Create a Project<commit_msg>include client in __dict__ for a project and associated object<commit_after>#Optimizely Python Client

##Getting Started
Optimizely's Python client library is an interface to its [REST API](http://developers.optimizely.com/rest/).

The `optimizely` Python module can be installed via `pip` using the command `pip install git+git://github.com/optimizely/optimizely-client-python.git`.

###Authentication
Every API request needs to be authenticated. To authenticate, use a token generated from [optimizely.com/tokens](https://www.optimizely.com/tokens), then pass it to the Optimizely client object.

In the following examples, `client` refers to a `Client` object created using the code below.

```python
>>> import optimizely
>>> client = optimizely.Client('abcdefghijklmnopqrstuvwxyz:123456')
```

###Exceptions
If you make a call and it succeeds, data will be included in the returned object(s) (except in the case of deletions, where a `None` response indicates success).

If the call fails, we'll raise one of the following exceptions:

* `BadRequestError` can happen if your request was not sent in valid JSON. The error may reference specific fields that were invalid.

* `UnauthorizedError` if your API token was missing.

* `ForbiddenError` if you provided an API token but it was invalid or revoked, or if you don't have read/write access to the entity you're trying to view/edit.

* `NotFoundError` if the id used in the call was inaccurate or you didn't have permission to view/edit it.

* `TooManyRequestsError` if you hit a rate limit for the API. If you receive this response, we recommend waiting at least 60 seconds before re-attempting the call.

* `ServiceUnavailableError` if the API is overloaded or down for maintenance. If you receive this response, we recommend waiting at least 60 seconds before re-attempting the call.

All of these Exceptions inherit from the `OptimizelyError` class.

##Projects
A project is a collection of experiments, goals, and audiences. Each project has an associated Javascript file to include on the page.

###Read a Project
Get metadata for a single project.

See [the Optimizely REST API documentation](http://developers.optimizely.com/rest/#read-a-project) for response attribute definitions.

####Example Python
```python
>>> project = client.Projects.get(1234) # get Project by Id
>>> project.__dict__
# {
#   'id': 1234,
#   'account_id': 123456789,
#   'client': <optimizely.client.Client object at 0x7c11e6fa7090>,
#   'code_revision': 12,
#   'project_name': 'My even newer project name',
#   'project_status': 'Active',
#   'created': '2014-04-16T21:33:34.408430Z',
#   'last_modified': '2014-06-10T22:12:21.707170Z',
#   'library': 'jquery-1.6.4-trim',
#   'include_jquery': False,
#   'js_file_size': 23693,
#   'project_javascript': 'someFunction = function () {\n //Do cool reusable stuff \n}'
#   'enable_force_variation': False,
#   'exclude_disabled_experiments': False,
#   'exclude_names': None,
#   'ip_anonymization': False,
#   'ip_filter': '1.2.3.4'
# }
>>> client.Projects.get([1234, 5678])   # get multiple Projects by Id
# [<optimizely.resource.Project object at 0x000000000>, <optimizely.resource.Project object at 0x000000010>]
```

###Create a Project
{'fraction_non_alphanumeric': 0.10601764335223693, 'fraction_numerical': 0.03575929426591052, 'mean_word_length': 4.824770642201835, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 38, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 4, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4275351', 'n_tokens_mistral': 2065, 'n_tokens_neox': 1854, 'n_words': 737}