2 1095
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
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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Daniel Pryde |
last post by:
Hi everyone.
I was wondering if anyone might be able to help me out here. I'm currently
looking to find the quickest way to find a best fit match in a large array.
My problem is that I have an array of, say, 600*400, which contains a value
at each point, and I need to find the value in that array which is closest
to the input value. It's basically some euclidean distances that I've
calculated, and I need to be able to find the best matches...
|
by: David Stockwell |
last post by:
Hi Everyone,
I'm wondering about the best way to enumerate something.
I have a list of columnames for a db and I decided to put them in a giant
tuple list for two reasons:
1) its unchangeable
2) I was hoping that creating an enumeration of those names would be easy
In the os.stat there is aparrently a list of things you can refer to eg:
|
by: Pekka Niiranen |
last post by:
Hi,
I have Perl code looping thru lines in the file:
line: while (<INFILE>) {
...
$_ = do something
...
if (/#START/) {
# Start inner loop
|
by: smichr |
last post by:
I see that there is a thread of a similar topic that was posted
recently ( enumerate with a start index ) but thought I would start a
new thread since what I am suggesting is a little different.
I posted a very similar item to python-dev, but they said to post it
here. Tutor also said that if anything is to be considered as PEP
worthy, it should be run through here first. So...here goes.
Whenever I use enumerate, I am doing so...
|
by: andrewfelch |
last post by:
I write a lot of code that looks like this:
for myElement, elementIndex in zip( elementList,
range(len(elementList))):
print "myElement ", myElement, " at index: ",elementIndex
My question is, is there a better, cleaner, or easier way to get at the
element in a list AND the index of a loop than this?
| |
by: John Salerno |
last post by:
If I want to make a list of four items, e.g. L = ,
and then figure out if a certain element precedes another element, what
would be the best way to do that?
Looking at the built-in list functions, I thought I could do something like:
if L.index('A') < L.index('D'):
# do some stuff
But I didn't know if maybe there was a preferred method for this type of
|
by: eight02645999 |
last post by:
hi,
i am using python 2.1. Can i use the code below to simulate the
enumerate() function in 2.3? If not, how to simulate in 2.1?
thanks
from __future__ import generators
def enumerate(sequence):
index = 0
for item in sequence:
yield index, item
|
by: James Stroud |
last post by:
I think that it would be handy for enumerate to behave as such:
def enumerate(itrbl, start=0, step=1):
i = start
for it in itrbl:
yield (i, it)
i += step
This allows much more flexibility than in the current enumerate,
tightens up code in many cases, and seems that it would break no
|
by: Debajit Adhikary |
last post by:
I'm writing this little Python program which will pull values from a
database and generate some XHTML.
I'm generating a <tablewhere I would like the alternate <tr>'s to be
<tr class="Even">
and
<tr class="Odd">
What is the best way to do this?
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |