Jim Valenza wrote:
Hello all - I'm new to the world of Python as I am a GIS guy who would like to broaden his horizons. I have a question about a script that we've been working on: The purpose of the code is to *Syncronize SDE DropBox with Regulatory Project working files. * I am looking for where the script dumps the domain list to a table and loops through the table? Is It necessary? Seems like you should be able to simply loop through the domain list. I was just trying to see if there was a more straitforward way. Thanks

The script is as follows:

[snip]

I've spotted a bug:

    P_Value = (P.strip(".mdb"))

The .strip() method DOESN'T strip off a string, it strips CHARACTERS off
BOTH ends.

P_Value will be P but with any number of the characters ".", "m", "d" or
"b" stripped off both ends, for example, if P == "my_database.mdb" then
P_Value will be "y_database".

You should do something like:

    if P.endswith(".mdb"):
        P_Value = P[ : -4]
    else:
        P_Value = P

Another point: you're recording the valid domains in a list and then
checking with:

    if P_Value in domainList:

This will perform a linear search of the list, which can be slow if the
list is long.

It would be much more efficient to put the domains in a set instead.
Checking for the presence of an item in a set is fast.

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to