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...
User Profile
Collapse
-
What is the interface between the reader and the computer? Serial, USB?Leave a comment:
-
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
Leave a comment:
-
-
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...Leave a comment:
-
Also check out all the posts in this thread.
http://www.thescripts.com/forum/thread581370.html...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'):
Leave a comment:
-
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...Leave a comment:
-
Nothing original here, and you may have found it, but a search revealed the followingat the followingCode:>>> s='\\x02\\x06\\x0b\\x01$\\x00' >>> eval("'%s'" % s) '\x02\x06\x0b\x01$\x00' >>> new=eval("'%s'" % s) >>> new '\x02\x06\x0b\x01$\x00'
http://mail.python.org/pipermail/pyt...ly/268855.html...Leave a comment:
-
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)Leave a comment:
-
And don't forget Code tags.
My favorite way (because there are several) is using string formatting.
You could also move the int() call to tighten the code a little.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....Code:>>> num = int(raw_input("Pick a number: "))Leave a comment:
-
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....Leave a comment:
-
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.Leave a comment:
-
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:>>>
Leave a comment:
-
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...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)Leave a comment:
-
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
- Right click "my computer"
- Select "Properties "
- Select "Advanced"
- Select "Environmen t Variables"
- Under "System Variables" select "Path"
- Select "Edit"
- In the "Variable Value"
Leave a comment:
-
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....Leave a comment:
-
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.which returnsCode:import glob filelist=glob.glob('*.tif') print filelist for filename in filelist: print filename
Z:\Laptop\PLSO_ Technical\Cherr yValley>python test.py
['CherryValley.t if', 'CherryValleyDl g.tif', 'CherryValleyDo qq.tif',...Leave a comment:
-
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...Leave a comment:
No activity results to display
Show More
Leave a comment: