pythonwin closes unexpectedlyI

2007-06-02 Thread leegold
Hi,

I run a script in PythonWin and obviously some sort of an error occurs
in the script and PythonWin closes. No warning,  no error message just
closes. I definitely know the line of code that causes the problem and
will cite the code below.

Note:  I'm using ArcGIS 9.1 (Python 2.1 is bundled with it) and
trying:p to write a script. I know this works OK at work but on my
home system the problem occurs. I'm suspicious that maybe file sharing
permission problems are the cause. But I can't get any error messages
to even start figuring it out. Using WinXP.

When the 2nd raw_input box opens ( GP.workspace = raw_input('workspace
path: ')  and I enter the path and click Ok that's when PythonWin
closes.  Here's code:


import win32com.client, sys, os

GP = win32com.client.Dispatch("esriGeoprocessing.GpDispatch.1")

print 'I am in the program'# this works OK

test001 = raw_input('workspace path: ')

print test001 # this works OK

try:

GP.workspace = raw_input('workspace path: ')

except:

GP.AddMessage(GP.GetMessages(2))

print GP.GetMessages(2)

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


Re: pythonwin closes unexpectedlyI

2007-06-04 Thread leegold
snip...

Slight off-topic fix for anyone whose search comes here:

Recommend to patch ESRI application to newest update.

You might also see error message:   OLE error 0x80040212

http://support.esri.com/index.cfm?fa=knowledgebase.techarticles.articleShow&d=30524

gp.SetProduct("ArcView")  is fix


>
> Steps to try:
>
> 1. Add
> raise
> after the print statement.
> 2. Get pythonwin out of the equation; run your script from the command
> line.
> 3. If that doesn't give you a clue what the error is, remove the try/
> accept/GP.AddMessage.../print lines and run it again from the command
> line.
>
> HTH,
> John


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


Sort lines in a text file

2007-07-21 Thread leegold
say I have a text file:

zz3 uaa4a ss 7 uu
  zz 3 66 ppazz9
a0zz0

I want to sort the text file. I want the key to be the number after
the two "zz".  Or I guess a string of two zz then a numberSo
that's 3, 9, 0

I'm trying to say that I want to sort lines in a file based on a
regular expression. How could I do that in Python? I'm limited to
Python 2.1, I can't add any 2nd party newer tools.

Thanks
Lee G.

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


Re: Sort lines in a text file

2007-07-22 Thread leegold
...snip...
> To save anybody who's tempted to write the whole shebang for you,
> please specify which part(s) of the exercise you are having problems
> with:
> (a) reading lines from a file
> (b) extracting a sort key from a line [presuming "number" means
> "positive integer"; what do you want to do if multiple lines have the
> same number? what if no number at all"]
> (c) creating a list of tuples, where each tuple is (key,
> line_contents)
> (d) sorting the list
> (e) creating the output file from the sorted list.

Thanks, you've done more than enough right here!

(a) through (e) gives me a good start.

Again, thank you for this.

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


Re: Sort lines in a text file

2007-07-22 Thread leegold
...snip...
>
> Do your own homework.

Hush troll.

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