Re: [Tutor] Reading Files and Such
Title: Signature.html bob gailer wrote: Wayne Watson wrote: I have a Python application that requires the program be run in a specific folder, Win XP. It analyzes and modifies txt files there, and only txt files. The mods require creating a tmp file. The tmp files could just as well be an xyz suffix file. That is, it seems as though they could be almost any non-conflicting type with hundreds of file types in use. There may be other file types in the folder, possibly jpg. As such, why would I want to use the tmp files module? With a similar program, it requires reading through all txt files, among other files types, in the folder. It purely analyzes the data in the txt files. Is there some way of doing the reading without the use of os.listdir()? I'm finding it a little hard to grok your question / concern. One does not use os.listdir() to read files. One opens them then uses read or readline. There are many ways to get and filter directory contents. I guess you would benefit from the glob module. import glob fileList = glob.glob('*.txt') grok. An interesting word. I guess it means understand. Surprisingly the Mozilla spell checker OKed it. Anyway, I'm finally back. About one hour after posting this message, my c-drive. Amazingly I got it back up. Yes, listdir does not read files, it just prepares a list of all files in the folder. I work my way through them as needed. It looks like glob does something similar. The real question is about tmp files. I believe there's a tmpfiles module. Someone back a few weeks ago noted in a post I made that I was using a tmp suffix and suggested using tmpfiles. In my case, I don't see the need. What is the tmpfiles module going to do for me? What's so special about the tmp suffix? -- Wayne Watson (Watson Adventures, Prop., Nevada City, CA) (121.01 Deg. W, 39.26 Deg. N) GMT-8 hr std. time) "Truth is mighty and will prevail. There is nothing wrong with this, except that it ain't so." -- Mark Twain Web Page: www.speckledwithstars.net/ ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Python Working Environment, Checkout, Compare (diff), ...
Title: Signature.html Is there a Win Python environment that provides Linux like facilities like diff (compare) and checking in and out program files? For starters, I'm particularly interested in diff-ing two files. I'm modifying someone else's Python program and would like to see the line by line differences between what I now have and the original program. Is there some way I might be able to simply identity my code from the original? I suppose I could put a comment after every line, but that seems tedious. -- Wayne Watson (Watson Adventures, Prop., Nevada City, CA) (121.01 Deg. W, 39.26 Deg. N) GMT-8 hr std. time) "Truth is mighty and will prevail. There is nothing wrong with this, except that it ain't so." -- Mark Twain Web Page: www.speckledwithstars.net/ ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Pyserial and general python serial help
Hi! New to python but finding it fast and effective to use! But heres my problem, Im trying to read data from the serial port which is being sent from a device every 10ms, I seem to be able to read the data in a while loop but eventually the buffer seems to overflow and the data gets scrambled. Any help would be fantastic! Regards D ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Python Working Environment, Checkout, Compare (diff), ...
On Thu, Oct 9, 2008 at 12:03 PM, Wayne Watson [EMAIL PROTECTED] wrote: Is there a Win Python environment that provides Linux like facilities like diff (compare) and checking in and out program files? This is not really a Python question. There are many good diff programs for Windows, a couple of free ones are WinMerge and ExamDiff. http://www.winmerge.org/ http://www.prestosoft.com/ps.asp?page=edp_examdiff A big list here: http://en.wikipedia.org/wiki/Comparison_of_file_comparison_tools For checkin/checkout you need a version control system, many are listed here: http://en.wikipedia.org/wiki/List_of_revision_control_software If you are already using a VCS then you just need the Windows client. Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Pyserial and general python serial help
On Thu, Oct 9, 2008 at 1:28 PM, Damon McCartney [EMAIL PROTECTED] wrote: Im trying to read data from the serial port which is being sent from a device every 10ms, I seem to be able to read the data in a while loop but eventually the buffer seems to overflow and the data gets scrambled. It helps if you show us your code and evidence of the problem you are having. Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Pyserial and general python serial help
Are you reading everything in the buffer? How much data is sent every 10ms? At 9600/8/N/1, the throughput is 960 byes a second, so if there's more than 9 bytes, something will give. Similarly, at 115200 baud, the limit is 115 bytes. Some general advice: don't try to sync your program to the 10ms cycle, that will be very difficult to do under a modern operating system. Just grab all the data waiting in the buffer and find some way to divide it into the appropriate time slices. PySerial has a method that returns the number of bytes in the buffer, so use that to set how many bytes you read. Cheers ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] return a dictionary?
Can I ‘return’ a dictionary from an imported Python script? I have a utility module (NameAddress.py) done using Tkinter. (For example, Name/Address City,State,Zip,Email, Phone) that I want to use as imported module. I wanted to return the values as a dictionary to the module that imported but this does not seem to work. This is the dictionary as printed out from the NameAddress.py by print theDict shows what I want: {'City': 'San Francisco', 'Name': 'Sam Spade', 'Zip': '98765', 'Address1': 'Apt. #87', 'Address2': '2345 Union Street', 'Phone': '1-415-896-9876', 'State': 'Ca.', 'Email': '[EMAIL PROTECTED]'} However the code for return in NameAddress.py , I.E. return theDict gives this error when called from a testing module (Inter_module.py) whose code looks like this: import NameAddress y = NameAddress.getName() print y Traceback (most recent call last): File C:\Python24\Lib\SITE-P~1\PYTHON~1\pywin\framework\scriptutils.py, line 310, in RunScript exec codeObject in __main__.__dict__ File C:\Users\B\Desktop\Inter_module.py, line 6, in ? y = NameAddress.getName() File C:\Users\B\Desktop\NameAddress.py, line 22, in getName theDict={'Name': w2.get(), 'Address1': w4.get(), 'Address2': w6.get(),'City':w8.get()} File C:\Python24\Lib\lib-tk\Tkinter.py, line 2303, in get return self.tk.call(self._w, 'get') TclError: invalid command name .43065216 ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Output parameters from a stored procedure
Does anyone know how to get the output parameters from a stored procedure? I'm using pymssql on a linux box to call a stored procedure on a mssql database. I'm not sure of the correct syntax to get the output parameters. import pymssql con = pymssql.connect(host='x',user='',password='x',database='x') cur = con.cursor() query = EXECUTE blah blah blah cur.execute(query) con.commit() con.close() Mike ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] return a dictionary?
2008/10/9 Bill Gibson [EMAIL PROTECTED]: Traceback (most recent call last): File C:\Python24\Lib\SITE-P~1\PYTHON~1\pywin\framework\scriptutils.py, line 310, in RunScript exec codeObject in __main__.__dict__ File C:\Users\B\Desktop\Inter_module.py, line 6, in ? y = NameAddress.getName() File C:\Users\B\Desktop\NameAddress.py, line 22, in getName theDict={'Name': w2.get(), 'Address1': w4.get(), 'Address2': w6.get(),'City':w8.get()} File C:\Python24\Lib\lib-tk\Tkinter.py, line 2303, in get return self.tk.call(self._w, 'get') TclError: invalid command name .43065216 This looks like an error in NameAddress.py, perhaps something that is not being initialized correctly when you import it? Do you have a if __name__ == '__main__': section in NameAddress.py? Does it do some required initialization? It sounds like you are doing something similar to EasyGui's multienterbox: http://easygui.sourceforge.net/easygui.html#-multenterbox Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Installation Problems
Matthew Hill wrote: I am a newly beginning aspiring programmer. I have been learning Blender 3D and I want to use python with it. I downloaded the newest version of python and I tried running it with Blender 2.47. Python would work alone but would not with Blender. I read on a forum that I needed to get python 5.52 to match with what blender wants. Version 5.52 ??? The latest version of python is 2.6 (3.0 for beta). Only the new (5.52) version won't install. It says 'contact the vender to verify this is a windows program' when I try the install. What is going on? Is 5.52 compatible with windows vista? Am I just missing something? The prompt I got inside blender with 2.6 was: 'import site' failed; use -v for traceback checking for installed Python... no installed Python found. Sounds like a blender problem, blender can't find python.exe which usually is in C:\python26. Unfortunately I'm not familiar with blender. Only built-in modules are available. some scripts may not run. continuing happily. any insight to these problems would really help me out ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor No virus found in this incoming message. Checked by AVG - http://www.avg.com Version: 8.0.173 / Virus Database: 270.7.6/1715 - Release Date: 08/10/2008 7:19 PM ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Python Working Environment, Checkout, Compare (diff), ...
Vim also has a diff mode. -Wayne ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Python Working Environment, Checkout, Compare (diff), ...
Title: Signature.html I'm sure you're correct, but I posted a similar message about diff on the Newsgroup, and got nowhere. Anyway, it looks like there are some good choices. Thanks. Kent Johnson wrote: On Thu, Oct 9, 2008 at 12:03 PM, Wayne Watson [EMAIL PROTECTED] wrote: Is there a Win Python environment that provides Linux like facilities like diff (compare) and checking in and out program files? This is not really a Python question. There are many good diff programs for Windows, a couple of free ones are WinMerge and ExamDiff. http://www.winmerge.org/ http://www.prestosoft.com/ps.asp?page=edp_examdiff A big list here: http://en.wikipedia.org/wiki/Comparison_of_file_comparison_tools For checkin/checkout you need a version control system, many are listed here: http://en.wikipedia.org/wiki/List_of_revision_control_software If you are already using a VCS then you just need the Windows client. Kent -- Wayne Watson (Watson Adventures, Prop., Nevada City, CA) (121.01 Deg. W, 39.26 Deg. N) GMT-8 hr std. time) "Truth is mighty and will prevail. There is nothing wrong with this, except that it ain't so." -- Mark Twain Web Page: www.speckledwithstars.net/ ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Python Working Environment, Checkout, Compare (diff), ...
Title: Signature.html Well, maybe I'll give Cygwin a go again. I tried it 2-3 years ago and it was troublesome. I'd really like to have Unix/Linux available, so maybe. I really don't use Linux any longer, but it does have some very good features like diff than can be helpful even in a Win env. What's the trick win comp? The window disappears quickly. Alan Gauld wrote: "Wayne Watson" [EMAIL PROTECTED] wrote Is there a Win Python environment that provides Linux like facilities like diff (compare) and checking in and out program files? Cygwin provides a fill Unix like environment on Windows and if you know Unix at all is a must-have addon IMHO! :-) But iof you don;t you can use the standard XP comp commandline tool, Try HELP COMP at the OS prompt... For version control most toos have Windows versions: RCS, CVS, SVN etc Some are even file compatible with their *nix versions. Is there some way I might be able to simply identity my code from the original? That depends, but COMP may be sufficient. Othewise there are various GUI based diff tools that you can download, both freeware and shareware. Try a search on download.com or simtel or any other download site HTH, -- Wayne Watson (Watson Adventures, Prop., Nevada City, CA) (121.01 Deg. W, 39.26 Deg. N) GMT-8 hr std. time) "Truth is mighty and will prevail. There is nothing wrong with this, except that it ain't so." -- Mark Twain Web Page: www.speckledwithstars.net/ ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Python Working Environment, Checkout, Compare (diff), ...
Title: Signature.html Make that "with" and not "win" comp. Wayne Watson wrote: Well, maybe I'll give Cygwin a go again. I tried it 2-3 years ago and it was troublesome. I'd really like to have Unix/Linux available, so maybe. I really don't use Linux any longer, but it does have some very good features like diff than can be helpful even in a Win env. What's the trick win comp? The window disappears quickly. Alan Gauld wrote: "Wayne Watson" [EMAIL PROTECTED] wrote Is there a Win Python environment that provides Linux like facilities like diff (compare) and checking in and out program files? Cygwin provides a fill Unix like environment on Windows and if you know Unix at all is a must-have addon IMHO! :-) But iof you don;t you can use the standard XP comp commandline tool, Try HELP COMP at the OS prompt... For version control most toos have Windows versions: RCS, CVS, SVN etc Some are even file compatible with their *nix versions. Is there some way I might be able to simply identity my code from the original? That depends, but COMP may be sufficient. Othewise there are various GUI based diff tools that you can download, both freeware and shareware. Try a search on download.com or simtel or any other download site HTH, -- Wayne Watson (Watson Adventures, Prop., Nevada City, CA) (121.01 Deg. W, 39.26 Deg. N) GMT-8 hr std. time) "Truth is mighty and will prevail. There is nothing wrong with this, except that it ain't so." -- Mark Twain Web Page: www.speckledwithstars.net/ -- Signature.html Wayne Watson (Watson Adventures, Prop., Nevada City, CA) (121.01 Deg. W, 39.26 Deg. N) GMT-8 hr std. time) "Truth is mighty and will prevail. There is nothing wrong with this, except that it ain't so." -- Mark Twain Web Page: www.speckledwithstars.net/ ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Python Working Environment, Checkout, Compare (diff), ...
On Thu, Oct 9, 2008 at 7:48 PM, Wayne Watson [EMAIL PROTECTED] wrote: Well, maybe I'll give Cygwin a go again. I tried it 2-3 years ago and it was troublesome. I'd really like to have Unix/Linux available, so maybe. I really don't use Linux any longer, but it does have some very good features like diff than can be helpful even in a Win env. Many of the GNU tools - including diff - are available for native Windows (not Cygwin) from the GnuWin32 project: http://gnuwin32.sourceforge.net/packages.html I use TCC as a shell, it's not bash but it is a bit smarter than cmd.exe. Unfortunately it still runs in the brain-dead Windows console. http://jpsoft.com/ Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Python Working Environment, Checkout, Compare (diff), ...
Wayne Watson [EMAIL PROTECTED] wrote What's the trick win comp? The window disappears quickly. Its a command line tool, you need to run it from a CMD window. Like so: H:\PROJECTS\Pythoncomp foo.py foo.tst /L /A Comparing foo.py and foo.tst... Compare error at LINE 1 file1 = g file2 = h Compare more files (Y/N) ? Use HELP COMP for more options. HTH -- Alan Gauld Author of the Learn to Program web site http://www.freenetpages.co.uk/hp/alan.gauld ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor