This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description
#########
staticargs
#########
**A clean way to work around mutable default arguments in python functions**

Get staticargs
=============

staticargs supports Python 2 and 3. Tests are run for 2.7 and 3.4

.. code-block:: shell

pip install staticargs

Run the tests
=============
You must install tox, then run:

.. code-block:: shell

git clone https://github.com/HurricaneLabs/staticargs.git
cd staticargs
tox

Example
--------

First view the problem we are going to solve:

.. code-block:: python

>>> def append_cat(cats=[]):
... cats.append("cat")
... return cats
...
>>> print(append_cat())
['cat']
>>> print(append_cat())
['cat', 'cat']
>>> print(append_cat())
['cat', 'cat', 'cat']
>>>

Well that's not good! Notice how even though we are appending "cat" only once, the number of items in the list returned gets bigger each time. Learn more about this problem and some other Python gotchas by watching this amazing presentation from PyCon 2015 (this specific problem is discussed at 8:04): https://youtu.be/sH4XF6pKKmk

staticargs solves this problem for you:

.. code-block:: python

>>> from staticargs import staticargs
>>> import random
>>>
>>> @staticargs
... def append_cat(cats=[]):
... #I love cats
... cats.append("cat")
... return cats
...
>>> print(append_cat())
['cat']
>>> print(append_cat())
['cat']
>>> print(append_cat())
['cat']
>>>
>>> @staticargs
... def store_dog(dogs={}):
... #Dogs are OK I guess
... dog_name = random.choice(["rufus", "muffins", "scooby"])
... dogs[dog_name] = "good boy"
... return dogs
...
>>> print(store_dog())
{'muffins': 'good boy'}
>>> print(store_dog())
{'scooby': 'good boy'}
>>> print(store_dog())
{'rufus': 'good boy'}
>>>
Release History

Release History

1.0.0rc3

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

1.0.0rc2

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
staticargs-1.0.0rc3.tar.gz (2.7 kB) Copy SHA256 Checksum SHA256 Source Apr 12, 2015

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS HPE HPE Development Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting