Help with Dictionaries and Classes requested please.
Ben Finney
bignose+hates-spam at benfinney.id.au
Thu Aug 9 09:29:35 EDT 2007
"special_dragonfly" <Dominic at PLEASEASK.co.uk> writes:
> I've managed to solve the problem, I really was just being a
> dunce.
Doubtful; but at this stage we can't tell, because we still don't know
what it is you're actually trying to *do*.
> Here's how incase anyone is wondering:
>
> class MyClass:
> def __init__(self):
> name=""
> dict={}
> dict[0]=[]
> dict[0].append(MyClass())
> dict[0][0].name="Hello"
> print dict[0][0].name
It's not clear why you are using the value 0 for a dictionary key
here; nor why you're assigning an attribute to an object after
creating the object. Neither of them are errors, but without context
it's hard to know what advice to give.
--
\ "When we call others dogmatic, what we really object to is |
`\ their holding dogmas that are different from our own." -- |
_o__) Charles Issawi |
Ben Finney
More information about the Python-list
mailing list