Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > re best way to enumerate something in Python

Reply
Thread Tools

re best way to enumerate something in Python

 
 
David Stockwell
Guest
Posts: n/a
 
      05-26-2004
I'm going to try using the range function.

as in:

ID_COL, ANIMAL_COL, HOUSING_COL = range(3)

This appears to assign assign those vars as 'constants' with values of 0,1,2


David Stockwell
-------
Cell: http://cellphone.duneram.com/index.html
Cam: http://www.duneram.com/cam/index.html
Tax: http://www.duneram.com/index.html

__________________________________________________ _______________
Stop worrying about overloading your inbox - get MSN Hotmail Extra Storage!
http://join.msn.click-url.com/go/onm...ave/direct/01/


 
Reply With Quote
 
 
 
 
Yermat
Guest
Posts: n/a
 
      05-26-2004
David Stockwell wrote:
> I'm going to try using the range function.
>
> as in:
>
> ID_COL, ANIMAL_COL, HOUSING_COL = range(3)
>
> This appears to assign assign those vars as 'constants' with values of
> 0,1,2


You should get an eye on
http://www.python.org/cgi-bin/moinmo...ionProgramming
It may give you some ideas...

--
Yermat

 
Reply With Quote
 
 
 
 
Michael Geary
Guest
Posts: n/a
 
      05-26-2004
David Stockwell wrote:
> I'm going to try using the range function.
>
> as in:
>
> ID_COL, ANIMAL_COL, HOUSING_COL = range(3)
>
> This appears to assign assign those vars as 'constants' with values of

0,1,2

Yes, this is exactly the same as if you'd written:

ID_COL = 0
ANIMAL_COL = 1
HOUSING_COL = 2

Earlier in the thread you asked:

> In the os.stat there is aparrently a list of things you can refer to eg:
> ST_SIZE, ST_ATIME, etc.
>
> How are these defined? They appear to be related to 0,1,2,3,.... some
> sort of enumeration.


It's easy to answer a question like that by searching the Python
installation directory (at least if the names are defined in Python source
code, not C code). You can either do a search, or since these are defined in
the stat module (not os.stat), you can look in stat.py, where you'll find:

# Indices for stat struct members in tuple returned by os.stat()

ST_MODE = 0
ST_INO = 1
ST_DEV = 2
ST_NLINK = 3
ST_UID = 4
ST_GID = 5
ST_SIZE = 6
ST_ATIME = 7
ST_MTIME = 8
ST_CTIME = 9

-Mike


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Best way to enumerate classes in a module Дамјан Георгиевски Python 5 06-26-2009 09:56 AM
Re: Best way to enumerate something in python David Stockwell Python 1 05-27-2004 05:50 PM
Re: Best way to enumerate something in python David Stockwell Python 3 05-27-2004 05:31 PM
Best way to enumerate something in python David Stockwell Python 2 05-26-2004 05:40 PM
ruby way to enumerate users Robert K. Ruby 9 02-02-2004 04:17 PM



Advertisments