[infinispan-issues] [JBoss JIRA] Created: (ISPN-1045) Python client should have dictionary-like syntactic sugar

Manik Surtani (JIRA) jira-events at lists.jboss.org
Thu Apr 14 09:43:33 EDT 2011


Python client should have dictionary-like syntactic sugar
---------------------------------------------------------

                 Key: ISPN-1045
                 URL: https://issues.jboss.org/browse/ISPN-1045
             Project: Infinispan
          Issue Type: Enhancement
          Components: Hot Rod Client - Python
    Affects Versions: 4.2.1.FINAL
            Reporter: Manik Surtani
            Assignee: Manik Surtani
             Fix For: 4.2.2.BETA1


The Python Cache class uses Java Map-style put(), get(), remove() and contains().  Which is fine, but we should also offer Python-style syntactic sugar, so that we can do:

{code} 
cache['key'] = 'value'
print cache['key']
if 'key' in cache:
  print 'Key exists!'
for e in cache:
  print e
{code}

etc.  Have a look at the implementation of a Python map for more details, or one of the many custom map-like classes available for Python.

This is usually implemented by defining internal methods, such as:

{code}
def __getitem__(self, key):
  return self.get(key)

def __setitem__(self, key, value):
  self.put(key, value)
{code}

etc.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira


More information about the infinispan-issues mailing list