User Profile

Collapse

Profile Sidebar

Collapse
dshimer
dshimer
Last Activity: Mar 2 '11, 09:55 PM
Joined: Dec 19 '06
Location: Central Ohio, USA
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • dshimer
    replied to Help with Barcode
    I don't have any experience with anything I am about to say so take it for what it is worth, but if you want to interact directly with the usb interface you may start by searching for python+usb in google, there are so many references that you would need to dig a little.

    Sometimes however it seems like barcode scanners just send the text just like it was being typed from a keyboard. If this is the case the very first thing I would...
    See more | Go to post

    Leave a comment:


  • dshimer
    replied to Help with Barcode
    What is the interface between the reader and the computer? Serial, USB?
    See more | Go to post

    Leave a comment:


  • dshimer
    replied to Help writing a loop
    This almost seems to simplistic but how about something like this.

    Note that the range values and results are truncated and don't exactly match your requirements, just used the original example loop to show the general idea.

    Code:
    for i in range(65,70):
    	for j in range(65,70):
    		for k in range(65,70):
    			print chr(i),chr(j),chr(k)
    ... 			
    A A A
    A A B
    A A C
    A
    ...
    See more | Go to post

    Leave a comment:


  • dshimer
    replied to I Need A Good Python Book
    If you like code examples the "Python Cookbook" offers a fairly diverse set.
    See more | Go to post

    Leave a comment:


  • dshimer
    replied to While Loop problem
    I'm not 100% sure I follow, but it sounds like you are looking for something similar to a C getch().
    Check this out and see if there is anything useful.
    http://aspn.activestate.com/ASPN/Coo.../Recipe/134892...
    See more | Go to post

    Leave a comment:


  • dshimer
    replied to How can I start?
    Also check out all the posts in this thread.
    http://www.thescripts.com/forum/thread581370.html...
    See more | Go to post

    Leave a comment:


  • Not really looking over your code but just answering the simple question, how about just test for the existence of the file like this using the + operator to add the extra characters.

    I have two trash files on my system called /tmp/test.txt and /tmp/test.txt.xml, I am setting name explicitely but in your code it would come from the list
    Code:
    name='/tmp/test.txt'
    if os.path.isfile(name):
    	 if os.path.isfile(name+'.xml'):
    ...
    See more | Go to post

    Leave a comment:


  • dshimer
    replied to i need some help
    If it is just an external file of values in some kind of table, you may be getting too complicated with the data structure on the way in, would it be easier to just read in a line then check it's values on the way through the file. Along with bvdet's idea of a function to check the ranges. If I have a file that has id, height, width, length and looks something like.
    a 1 2 3
    b 3 4 5
    c 5 6 7
    reading and parsing the data could...
    See more | Go to post

    Leave a comment:


  • dshimer
    replied to Problem with Python String
    Nothing original here, and you may have found it, but a search revealed the following
    Code:
    >>> s='\\x02\\x06\\x0b\\x01$\\x00'
    >>> eval("'%s'" % s)
    '\x02\x06\x0b\x01$\x00'
    >>> new=eval("'%s'" % s)
    >>> new
    '\x02\x06\x0b\x01$\x00'
    at the following
    http://mail.python.org/pipermail/pyt...ly/268855.html...
    See more | Go to post

    Leave a comment:


  • dshimer
    replied to File Processing in Python
    How about processing each answer as it comes using string formatting, by replacing the code above with this.
    Code:
    outfile.write('%s %s\n'%(name, capital))
    print '%s %s\n'%(name, capital)
    ...
    See more | Go to post

    Leave a comment:


  • dshimer
    replied to Concatenation
    And don't forget Code tags.

    My favorite way (because there are several) is using string formatting.
    Code:
    >>> num = raw_input("Pick a number: ")
    >>> num = int(num)
    >>> print "Your number times 5 is %d."%(num * 5)
    Your number times 5 is 30.
    You could also move the int() call to tighten the code a little.
    Code:
    >>> num = int(raw_input("Pick a number: "))
    ...
    See more | Go to post

    Leave a comment:


  • dshimer
    replied to RE:Pythonpath
    No, sorry, I use the .pth method on all my computers and paths so I'm not sure why your environment isn't working. How does it fail, I mean how does the problem show itself?

    Would it help to add paths from inside the script using sys.path.append ()?

    Forgive me for not answering your actual question but python normally offers many routes to the same destination I just haven't traveled the one you are currently using....
    See more | Go to post

    Leave a comment:


  • dshimer
    replied to newbie loop efficiency
    As far as cleaning up some of the other code. I would be interested in seeing where these values are coming from, how they are being stored, and what the goal is. It looks like you are reading through a sequence of coordinates and making decisions based on their relationship to other values. There may be code outside this loop which would influence the best way to accomplish the task.
    See more | Go to post

    Leave a comment:


  • dshimer
    replied to newbie loop efficiency
    You will find from some of the sharpest guys here that you could probably do that in 1 line and about 10% of the characters. Let me just start with a more efficient way of looping over a list. This code just deals with the actual for loop mechanism, but notice there is no counter or conditional test. In plain english, for every value in the list do something, you don't necessarily have to reference the value inside the loop.
    Code:
    >>>
    ...
    See more | Go to post

    Leave a comment:


  • dshimer
    replied to RE:Pythonpath
    On my system it is just a text file in the same directory as the python.exe file and it contains the names of paths to be searched. For example I have a file called dennis.pth in my c:\python25 directory that looks like

    c:\users\dennis \python
    C:\users\dennis \python\pyinsta ller_1.2
    c:\users\python \common
    c:\vr\python...
    See more | Go to post

    Leave a comment:


  • I found an extremely simple pure win32 file open dialog and have been looking for a long time for something similar for data input, but to no avail. I sure would love to see one though.
    Code:
    import win32ui,win32con,sys
    fd = win32ui.CreateFileDialog(1,None,None,win32con.OFN_ALLOWMULTISELECT,'All Files|*.*')
    fd.SetOFNInitialDir('c:\\tmp')
    fd.SetOFNTitle('Select multiple files')
    if fd.DoModal() == win32con.IDCANCEL:sys.exit(1)
    ...
    See more | Go to post

    Leave a comment:


  • dshimer
    replied to How to run a command prompt EXE?
    Let me answer at the introductory level since it will be here forever and you never know what level a reader may be at.
    Assuming python is installed in c:\python24

    1. Right click "my computer"
    2. Select "Properties "
    3. Select "Advanced"
    4. Select "Environmen t Variables"
    5. Under "System Variables" select "Path"
    6. Select "Edit"
    7. In the "Variable Value"
    ...
    See more | Go to post

    Leave a comment:


  • dshimer
    replied to RE:Pythonpath
    I don't know if it will accomplish the same thing, but I add personal or custom directories to my python path by placing .pth files in the python executable directory....
    See more | Go to post

    Leave a comment:


  • dshimer
    replied to How to run a command prompt EXE?
    I only have a second and may contact you off list as one geomatic professional to another because I use python for tons of stuff. But quickly , check this out.
    Code:
    import glob
    filelist=glob.glob('*.tif')
    print filelist
    for filename in filelist:
    	print filename
    which returns

    Z:\Laptop\PLSO_ Technical\Cherr yValley>python test.py
    ['CherryValley.t if', 'CherryValleyDl g.tif', 'CherryValleyDo qq.tif',...
    See more | Go to post

    Leave a comment:


  • dshimer
    replied to How to run a command prompt EXE?
    Let me back up for a second, the question about the print statement didn't have anything to do with the mrsidsdw. Since it is there the print statement should output something each time through the loop, I was just trying to find out if the problem was that the file names weren't being passed properly to the command prompt. For example if they were, the filenames should be printed out one at a time to show the status of the processing. However if...
    See more | Go to post

    Leave a comment:

No activity results to display
Show More
Working...