title: Python: How to deal with non-subscriptable objects?
body: <p>I've read <a href="https://stackoverflow.com/questions/216972/in-python-what-does-it-mean-if-an-object-is-subscriptable-or-not">a thread on what a (non)subscriptable object is</a> but it doesn't tell me what i can do about it.</p>
  
  <p>I have a code calling a <code>mypost</code> private module. The aim is to set up mail accounts and to do this i create <code>MailAccounts()</code> objects defined in the <code>mypost</code> module. Quantity of accounts and their respective details are described in a configuration file. When the application starts, it collects account information and stores it in a dictionary, the structure of which is: <code>accounts = {service : { &lt;MailAccounts Object at xxxxx&gt; : {username : myusername, password : mypassword}}}</code> where <code>service</code> can be "gmail" and where <code>MailAccounts</code> is the class defined in the <code>mypost</code> module.
  So far so good. When however i want to setup the account, i need to call its method: <code>MailAccounts.setupAccount(username, password)</code>. I do this by iterating each MailAccount object of the dictionary and ask to run the method:</p>
  
  <pre><code>for service in accounts:
          for account in accounts[service]:
              account.setupAccount(account['username'], account['password'])
  </code></pre>
  
  <p>But as you may have guessed it didn't work, Python returns:</p>
  
  <p><code>TypeError: 'MailAccount' object is not subscriptable</code></p>
  
  <p>If i create the same account manually however it works:</p>
  
  <pre><code>account = MailAccount()
  account.setupAccount('myusername', 'mypassword')
  </code></pre>
  
  <p>Now i believe it has something to do with the fact that my <code>&lt;MailAccount Object at xxxx&gt;</code> is a dictionary key right? That makes it non-subscriptable (whatever that may mean)?</p>
  
  <p>No what exactly does this mean to be non-subscriptable? What does it imply in this example? And of course: how can i solve / bypass this in this case?</p>
  
  <p>Thanks,
  Benjamin :)</p>