New to Python: Do we have the concept of Hash in Python?

Brian Quinlan brian at sweetapp.com
Thu Jun 1 11:10:14 EDT 2006


A.M wrote:
> Is there any built-in Hash implementation in Python? I am looking for a 
> container that I can access to it's items by name. Something like this:
> 
> Print container["memeberName"]

d = {"memberName" : "some value"}
print d["memberName"]

> I am asking this because I learned that DB-API in Python doesn't offer 
> access to cursor columns by name. The only option is access by index. I hope 
> that I've got it wrong!
> 
> I learned Ruby perfectly supports that.

Python does not use column names by default because they are not 
portable across database implementations. That being said, you can get 
them easily, if you want. Look at the "description" attribute of your 
cursor instance.

Cheers,
Brian




More information about the Python-list mailing list