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

Fredrik Lundh fredrik at pythonware.com
Thu Jun 1 18:09:32 CEST 2006


"A.M" wrote:

> I am new to Python, with C#/Java background

that's not really much of an excuse for not reading *any* Python tutorial before
you jump in...

> 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!

several people have already told you how to deal with this in Python.  please see
the followups to your earlier post.

> I learned Ruby perfectly supports that.

Ruby's DB interface, perhaps.  Python's standard DB-API doesn't support this
by default, for portability and performance reasons.  that doesn't mean that Python
don't have "hashes", just that the DB-API doesn't provide dictionary-style access
to columns.

see the followups to your earlier post for more details, and ways to handle this.

(a much better way to deal with this is of course to *name* the variables in your
select statements, so 1) the database engine can spot errors early on, and 2) it
won't have to fetch data that you don't really need).

</F> 






More information about the Python-list mailing list