kiddouk / redisco

A Python Library for Simple Models and Containers Persisted in Redis
MIT License
438 stars 78 forks source link

A better way to add data to containers. #7

Closed jeloou closed 12 years ago

jeloou commented 12 years ago

This allows to add multiple values to containers in a easier way.

Sets:

from redisco.containers import Set
s = Set('s')
s.add('bananas', 'tomatoes')
s.add(['blackberries', 'strawberries'])
print s.members # -> set(['blackberries', 'strawberries', 'tomatoes', 'bananas'])
s.remove('bananas', 'blackberries') # -> True
print s.members # -> set(['strawberries',  'tomatoes'])

Lists:

from redisco.containers import List
l = List('l')
l.append('a')
l.append(['b', 'c'])
l.append('d', 'e', 'f')
print l # -> ['a', 'b', 'c', 'd', 'e', 'f']

Sorted set:

from redisco.containers import SortedSet 
z = SortedSet('z')
z.add('a', 1)
z.add({'f' : 200, 'e' : 201})
print z.members # -> ['a', 'f', 'e'] 
travisbot commented 12 years ago

This pull request passes (merged ee73e307 into 46c165f3).

kiddouk commented 12 years ago

This reminds me that the doc really need some love now.