Re: Simple Object assignment giving me errors

2014-02-12 Thread Nir
Thank you Jerry. And thank you to the rest of you. You all have been tremendously helpful. PS Chris, next time I will do just that. -- https://mail.python.org/mailman/listinfo/python-list

Re: Simple Object assignment giving me errors

2014-02-12 Thread Jerry Hill
On Wed, Feb 12, 2014 at 4:42 PM, Nir wrote: > If this makes sense to you, great. I am trying to break it down so that I can > make sense of it. As you mentioned self["name"] = filename doesn't work > unless I built a class to handle it. I guess my question then, is how is the > class handling i

Re: Simple Object assignment giving me errors

2014-02-12 Thread Chris Angelico
On Thu, Feb 13, 2014 at 8:42 AM, Nir wrote: > Also, UserDict is a built in module. I just typed it out so as to give > reference or any clue as to why I cant instantiate jeez. Recommendation for next time: Don't type it out, copy and paste it. Show the actual code you ran, and the actual error m

Re: Simple Object assignment giving me errors

2014-02-12 Thread Nir
Those two classes are from this code here(pasted below). Quite frankly, I don't understand this code. Also, UserDict is a built in module. I just typed it out so as to give reference or any clue as to why I cant instantiate jeez.

Simple Object assignment giving me errors

2014-02-12 Thread Nir
This is from the book 'dive into python'. I am trying to define jeez as being an instance of FileInfo. class UserDict(object): def __init__(self, dict = None): self.data = {} if dict is not None: self.update(dict) class FileInfo(UserDict): def __in

Re: Simple Object assignment giving me errors

2014-02-12 Thread Chris Angelico
On Thu, Feb 13, 2014 at 8:18 AM, Nir wrote: > class FileInfo(UserDict): > def __init__(self, filename=None): > UserDict.__init__(self) > self["name"] = filename > > I get a TypeError: 'FileInfo' object doesn't support item assignment . > > Am I missing somet