Re: #!/usr/bin/python or #!/usr/bin/env python?

2006-08-08 Thread Stephan Kuhagen
> Always prefer to use env over a hardcoded path, because that hardcoded > path will invariably be wrong. (Yes, for those about to nitpick, it's > conceivable that env might be somewhere other than /usr/bin. However, > that is very rare and results in a no-win situations regardless of the > issue

Re: Need a compelling argument to use Django instead of Rails

2006-08-08 Thread Damjan
>> Yes, but your mod_python programs still run with the privileges of the >> Apache process, as are all the other mod_python programs. This means that >> my mod_python program can (at least) read files belonging to you - >> including your config file holding your database password > > I think

ANN: xtopdf: PDF creation / conversion toolkit: alpha release of v1.3

2006-08-08 Thread vasudevram
Hi group, xtopdf: PDF creation / conversion toolkit: alpha release of v1.3 This is actually a somewhat preliminary announcement, but may be of interest to developers / users who know Python and/or have earlier checked out my xtopdf PDF creation / conversion toolkit: I've released (via my web si

Re: Polyform Puzzler

2006-08-08 Thread david_wahler
I'll be out of the office until approximately August 20th. If you have any questions, please email [EMAIL PROTECTED] -- David Wahler -- http://mail.python.org/mailman/listinfo/python-list

Re: No August Fredericksburg ZPUG

2006-08-08 Thread david_wahler
I'll be out of the office until approximately August 20th. If you have any questions, please email [EMAIL PROTECTED] -- David Wahler -- http://mail.python.org/mailman/listinfo/python-list

Re: ANN: xtopdf: PDF creation / conversion toolkit: alpha release of v1.3

2006-08-08 Thread david_wahler
I'll be out of the office until approximately August 20th. If you have any questions, please email [EMAIL PROTECTED] -- David Wahler -- http://mail.python.org/mailman/listinfo/python-list

Weekly Python Patch/Bug Summary

2006-08-08 Thread Kurt B. Kaiser
Patch / Bug Summary ___ Patches : 402 open ( +6) / 3360 closed ( +6) / 3762 total (+12) Bugs: 861 open ( -3) / 6114 closed (+27) / 6975 total (+24) RFE : 228 open ( +2) / 234 closed ( +0) / 462 total ( +2) New / Reopened Patches __ Replace t

Re: singleton decorator

2006-08-08 Thread Paddy
Andre Meyer wrote: > Am I missing something here? What is the preferred pythonic way of > implementing singleton elegantly? > > Thanks for your help > André Hi Andre, You might also google for python borg pattern As a discussion on the 'borg' design pattern might be informative. - Pad. -- ht

Re: Class data being zapped by method

2006-08-08 Thread John Machin
Kevin M wrote: > Inline > > > 1.) Why are you removing the .pyc file? > > After I had run the script once and subsequently changed the class > file, I would run the script again, and it would use the pyc file from > the older revision of the script. I got frustrated with having to > manually delet

Re: Regd:Video Converter Programming

2006-08-08 Thread placid
Ch3ru5 wrote: > Hi, > I want to write an avi to flv converter in php but i am a complete > newbie to it. > > I would like to know the basic flow of entire process of how a > converter code is written > (ie. the basic algorithm ) . > > Example: "You first create an flv stream , then compress the av

import logging fails on MacPython 2.4.3

2006-08-08 Thread Tod Olson
Anyone have advice for importing the logging module using MacPython 2.4.3? MacPython installs the logging module in: /Library/Frameworks/Python.framework/Versions/2.4/lib/logging/ There's an __init__.py there and everything, but this directory is not in sys.path. I add it to sys.path as follows:

PIL Image transform

2006-08-08 Thread Dean Card
Okay, so here is the situation. I have need to do some on-the-fly image creation. I have everything working great except for the last part of it, applying a perspective type transform to the image. The transform will take a rectangular 2D image and transform it to a 3D representation in 2D.

Re: technique to enter text using a mobile phone keypad (T9 dictionary-based disambiguation)

2006-08-08 Thread Justin Azoff
Petr Jakeš wrote: > I have a standard 12-key mobile phone keypad connected to my Linux > machine as a I2C peripheral. I would like to write a code which allows > the text entry to the computer using this keypad (something like T9 on > the mobile phones) > > According to the http://www.yorku.ca/mack

Re: technique to enter text using a mobile phone keypad (T9 dictionary-based disambiguation)

2006-08-08 Thread gene tani
Petr Jakeš wrote: > I have a standard 12-key mobile phone keypad connected to my Linux > machine as a I2C peripheral. I would like to write a code which allows > the text entry to the computer using this keypad (something like T9 on > the mobile phones) > > According to the http://www.yorku.ca/mac

Re: Class data being zapped by method

2006-08-08 Thread Kevin M
Inline > 1.) Why are you removing the .pyc file? After I had run the script once and subsequently changed the class file, I would run the script again, and it would use the pyc file from the older revision of the script. I got frustrated with having to manually delete the pyc file before rerunnin

Regd:Video Converter Programming

2006-08-08 Thread Ch3ru5
Hi, I want to write an avi to flv converter in php but i am a complete newbie to it. I would like to know the basic flow of entire process of how a converter code is written (ie. the basic algorithm ) . Example: "You first create an flv stream , then compress the avi code , then copy that code in

Re: SocketServer and timers

2006-08-08 Thread alf
[EMAIL PROTECTED] wrote: > alf wrote: > >>I have one thread app using SocketServer and use server_forever() as a >>main loop. All works fine, but now I need certain timer checking let's >>say every 1 second something and stopping the main loop. So questions are: >> -how to stop serve_forever

Re: How to reverse tuples in a list?

2006-08-08 Thread Paul Rubin
"Noah" <[EMAIL PROTECTED]> writes: > I know I could do this long-form: > q = [] > y = [('a', 1.0), ('b', 2.0), ('c', 3.0)] > ... y = [tuple(reversed(t)) for t in y] -- http://mail.python.org/mailman/listinfo/python-list

Re: Tkinter module not found

2006-08-08 Thread Dan
Shuaib wrote: > Hey again, > > I am using the latest python available on my system (2.4). So I don't > think that's the problem. > > Any more ideas? Do I need to install Tkinter as a seperate > module/package? As I said, I've already installed Tcl/Tk, though. This is a wild guess, but I just ins

Re: newb question: file searching

2006-08-08 Thread [EMAIL PROTECTED]
I'm sorry. I didn't mean to offend you. I never thought your way was inferior. Justin Azoff wrote: > [EMAIL PROTECTED] wrote: > > I do appreciate the advice, but I've got a 12 line function that does > > all of that. And it works! I just wish I understood a particular line > > of it. > > You

Re: newb question: file searching

2006-08-08 Thread John Machin
[EMAIL PROTECTED] wrote: > I do appreciate the advice, but I've got a 12 line function that does > all of that. And it works! I just wish I understood a particular line > of it. > > def getFileList(*extensions): > import os > imageList = [] > for dirpath, dirnames, files in os.walk('.

Re: newb question: file searching

2006-08-08 Thread Justin Azoff
[EMAIL PROTECTED] wrote: > I do appreciate the advice, but I've got a 12 line function that does > all of that. And it works! I just wish I understood a particular line > of it. You miss the point. The functions I posted, up until get_files_by_ext which is the equivalent of your getFileList, to

Re: How to reverse tuples in a list?

2006-08-08 Thread jon cashman
sorry ... i replied to sender instead of all ... so here we go again ... >>>t = [('a', 1.0), ('b',2.0),('c',3.0)] >>>t = [s[::-1] for s in t] >>>print t [(1.0, 'a'), (2.0, 'b'), (3.0, 'c')] >>> >From: "Paul McGuire" <[EMAIL PROTECTED]> >To: python-list@python.org >Subject: Re: How to reverse t

Re: newb question: file searching

2006-08-08 Thread [EMAIL PROTECTED]
I do appreciate the advice, but I've got a 12 line function that does all of that. And it works! I just wish I understood a particular line of it. def getFileList(*extensions): import os imageList = [] for dirpath, dirnames, files in os.walk('.'): for filename in files:

Re: newb question: file searching

2006-08-08 Thread Justin Azoff
[EMAIL PROTECTED] wrote: > I've narrowed down the problem. All the problems start when I try to > eliminate the hidden files and directories. Is there a better way to > do this? > Well you almost have it, but your problem is that you are trying to do too many things in one function. (I bet I am

Re: How to reverse tuples in a list?

2006-08-08 Thread Paul McGuire
"Noah" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I have a list of tuples > [('a', 1.0), ('b', 2.0), ('c', 3.0)] > I want to reverse the order of the elements inside the tuples. > [(1.0,'a'), (2.0, 'b'), (3.0, 'c')] > >>> tups = [('a', 1.0), ('b', 2.0), ('c', 3.0)] >>>

Re: newb question: file searching

2006-08-08 Thread [EMAIL PROTECTED]
That worked perfectly. Thank you. That was exactly what I was looking for. However, can you explain to me what the following code actually does? reversed(range(len(dirnames))) Gabriel Genellina wrote: > At Tuesday 8/8/2006 21:11, [EMAIL PROTECTED] wrote: > > > >Here's my code: > > > >def getF

Re: newb question: file searching

2006-08-08 Thread [EMAIL PROTECTED]
I've narrowed down the problem. All the problems start when I try to eliminate the hidden files and directories. Is there a better way to do this? [EMAIL PROTECTED] wrote: > I'm new at Python and I need a little advice. Part of the script I'm > trying to write needs to be aware of all the file

Re: newb question: file searching

2006-08-08 Thread Gabriel Genellina
At Tuesday 8/8/2006 21:11, [EMAIL PROTECTED] wrote: Here's my code: def getFileList(): import os imageList = [] for dirpath, dirnames, filenames in os.walk(os.getcwd()): for filename in filenames: for dirname in dirnames:

Re: Class data being zapped by method

2006-08-08 Thread John Machin
John Machin wrote: > print [i, len(x.data), id(x) for i, x in enumerate(arrTests)] but should have written: print [(i, len(x.data), id(x)) for i, x in enumerate(arrTests)] -- http://mail.python.org/mailman/listinfo/python-list

Re: Unicode/utf-8 data in SQL Server

2006-08-08 Thread John Machin
thebjorn wrote: > I'm working with a MS SQL Server database created by a program from a > fine US company who seems to have gotten run over by the Unicode truck. > In their infinite wisdom they've decided to store Unicode data directly > in regular varchar fields, utf-8 encoded! (on the bright sid

Re: beginner questions on embedding/extending python with C++

2006-08-08 Thread Qun Cao
Thanks for all the good pointers! I am still reading throught them, but Boost seems to be the way to go! Roman Yakovenko wrote: > On 8 Aug 2006 02:28:31 -0700, Qun Cao <[EMAIL PROTECTED]> wrote: > > Hi Everyone, > > > > I am a beginner on cross language development. My problem at hand is to > > bu

Re: newb question: file searching

2006-08-08 Thread [EMAIL PROTECTED]
Something's really not reliable in my logic. I say this because if I change the extension to .png then a file in a hidden directory (one the starts with '.') shows up! The most frustrating part is that there are .jpg files in the very same directory that don't show up when it searches for jpegs.

Re: beginner questions on embedding/extending python with C++

2006-08-08 Thread Qun Cao
Thanks Diez, It is a good relief that I only need to wrap the classes I need. I decide to try Boost first because it seems to have a wider audience than SIP, but I would definately look into SIP if I want to do Qt development in the future. Diez B. Roggisch wrote: > > Since the main program is s

Re: How to reverse tuples in a list?

2006-08-08 Thread Robert Kern
Erik Max Francis wrote: > Noah wrote: > >> But it seems like there should be a clever way to do this with >> a list comprehensions. Problem is I can't see how to apply >> reverse() to each tuple in the list because reverse() a >> list method (not a tuple method) and because it operates >> in-pla

Re: How to reverse tuples in a list?

2006-08-08 Thread Simon Forman
Noah wrote: > I have a list of tuples > [('a', 1.0), ('b', 2.0), ('c', 3.0)] > I want to reverse the order of the elements inside the tuples. > [(1.0,'a'), (2.0, 'b'), (3.0, 'c')] > > I know I could do this long-form: > q = [] > y = [('a', 1.0), ('b', 2.0), ('c', 3.0)] > for i i

Re: How to reverse tuples in a list?

2006-08-08 Thread Adonis
Noah wrote: > I have a list of tuples > [('a', 1.0), ('b', 2.0), ('c', 3.0)] > I want to reverse the order of the elements inside the tuples. > [(1.0,'a'), (2.0, 'b'), (3.0, 'c')] > > I know I could do this long-form: > q = [] > y = [('a', 1.0), ('b', 2.0), ('c', 3.0)] > for i

Re: newb question: file searching

2006-08-08 Thread [EMAIL PROTECTED]
Here's my code: def getFileList(): import os imageList = [] for dirpath, dirnames, filenames in os.walk(os.getcwd()): for filename in filenames: for dirname in dirnames: if not dirname.startswith('.'):

Re: Class data being zapped by method

2006-08-08 Thread Simon Forman
Kevin M wrote: > Figures. I'll try to complicate it sufficiently ;) > > > [edit] I was going to try to sum up what goes on, but I realized that I > was retyping what I already programmed in an effort to better > illustrate exactly what I'm doing. Pastebin it is. Don't fear, it's > only around 200 l

Re: How to reverse tuples in a list?

2006-08-08 Thread Robert Kern
Noah wrote: > I have a list of tuples > [('a', 1.0), ('b', 2.0), ('c', 3.0)] > I want to reverse the order of the elements inside the tuples. > [(1.0,'a'), (2.0, 'b'), (3.0, 'c')] Python 2.4+: y = [tuple(reversed(t)) for t in y] -- Robert Kern "I have come to believe that the whole

Re: How to reverse tuples in a list?

2006-08-08 Thread Erik Max Francis
Noah wrote: > But it seems like there should be a clever way to do this with > a list comprehensions. Problem is I can't see how to apply > reverse() to each tuple in the list because reverse() a > list method (not a tuple method) and because it operates > in-place (does not return a value). Thi

Re: Unicode/utf-8 data in SQL Server

2006-08-08 Thread Neil Hodgson
bjorn: > I also > tried creating an Excel VB macro using the StrConv function, but (a) it > isn't entirely clear to me that this function can do this, and (b) the > third argument to the function is an LCID, a Locale ID, which is > numeric and not defined anywhere I can find it... http://www.micr

How to reverse tuples in a list?

2006-08-08 Thread Noah
I have a list of tuples [('a', 1.0), ('b', 2.0), ('c', 3.0)] I want to reverse the order of the elements inside the tuples. [(1.0,'a'), (2.0, 'b'), (3.0, 'c')] I know I could do this long-form: q = [] y = [('a', 1.0), ('b', 2.0), ('c', 3.0)] for i in y: t=list(t)

Re: threading.Event usage causing intermitent exception

2006-08-08 Thread Tim Peters
[EMAIL PROTECTED] > Admittedly this problem causes no actual functional issues aside from > an occasional error message when the program exits. The error is: > > Unhandled exception in thread started by > Error in sys.excepthook: > Original exception was: > > Yes all that info is blank. That's ty

Re: do people really complain about significant whitespace?

2006-08-08 Thread Gerhard Fiedler
On 2006-08-08 19:02:27, Stephen Kellett wrote: > In message <[EMAIL PROTECTED]>, > Gerhard Fiedler <[EMAIL PROTECTED]> writes >>conclusion for me: they must not like self-documenting code... :) > > Oh dear. So if the code is wrong it is self documenting? ?? I'm not sure you are actually respond

Re: (Boost.Python) How to load header files?

2006-08-08 Thread Neil Hodgson
Qun Cao wrote: > I have a C++ class foo.cpp, defined in foo.h, I wrote a wrapper class > for it to generate a python module. > > #include "Foo.h" If you are on Windows it shouldn't matter but try to keep capitalisation consistent: #include "foo.h". > The problem is that when I bjam it, the

Re: Class data being zapped by method

2006-08-08 Thread John Machin
Kevin M wrote: > Figures. I'll try to complicate it sufficiently ;) > > > [edit] I was going to try to sum up what goes on, but I realized that I > was retyping what I already programmed in an effort to better > illustrate exactly what I'm doing. Pastebin it is. Don't fear, it's > only around 200 l

Re: ImportError: libclntsh.so.10.1: cannot open shared object file: Permission denied

2006-08-08 Thread Damjan
> I have a similar question (importing cx_Oracle, but not related to > cron). I would like to use solution #2 below and it does not work. If > I set LD_LIBRARY_PATH before running python, it works. If I try to set > it via os.environ, it does not work. > > I have tried this in an interactive Py

(Boost.Python) How to load header files?

2006-08-08 Thread Qun Cao
Hi Everyone, I just started to use boost.python and having problem trying to get my first program working. I have a C++ class foo.cpp, defined in foo.h, I wrote a wrapper class for it to generate a python module. #include "Foo.h" #include #include #include using namespace boost::python; BOO

Re: newb question: file searching

2006-08-08 Thread thebjorn
[EMAIL PROTECTED] wrote: [...] > that? And also, I'm still not sure I know exactly how os.walk() works. > And, finally, the python docs all note that symbols like . and .. > don't work with these commands. How can I grab the directory that my > script is residing in? os.getcwd() will get you th

Re: Proposal: [... for ... while cond(x)]

2006-08-08 Thread Neil Hodgson
Eighty: > So does no one have a comment on this? Similar proposals have appeared before (such as on python-dev about a year ago) and haven't attracted much positive comment. The benefits appear to be small compared to the cost of making the language larger. You could try the formal route

Re: do people really complain about significant whitespace?

2006-08-08 Thread Carl Banks
Michiel Sikma wrote: > Op 8-aug-2006, om 1:49 heeft Ben Finney het volgende geschreven: > > > As others have pointed out, these people really do exist, and they > > each believe their preconception -- that significant whitespace is > > intrinsically wrong -- is valid, and automatically makes Python

Re: newb question: file searching

2006-08-08 Thread infidel
> Also, I've noticed that files are being found within hidden > directories. I'd like to exclude hidden directories from the walk, or > at least not add anything within them. Any advice? The second item in the tuple yielded by os.walk() is a list of subdirectories inside the directory indicated

technique to enter text using a mobile phone keypad (T9 dictionary-based disambiguation)

2006-08-08 Thread Petr Jakeš
I have a standard 12-key mobile phone keypad connected to my Linux machine as a I2C peripheral. I would like to write a code which allows the text entry to the computer using this keypad (something like T9 on the mobile phones) According to the http://www.yorku.ca/mack/uist01.html dictionary-based

Re: Class data being zapped by method

2006-08-08 Thread Kevin M
Figures. I'll try to complicate it sufficiently ;) [edit] I was going to try to sum up what goes on, but I realized that I was retyping what I already programmed in an effort to better illustrate exactly what I'm doing. Pastebin it is. Don't fear, it's only around 200 lines total. Class file --

Re: newb question: file searching

2006-08-08 Thread Steve M
[EMAIL PROTECTED] wrote: > Okay. This is almost solved. I just need to know how to have each > entry in my final list have the full path, not just the file name. from http://docs.python.org/lib/os-file-dir.html: walk() generates the file names in a directory tree, by walking the tree either top

Re: String.digits help!!!

2006-08-08 Thread bearophileHUGS
Simon Forman: > accessing it from a > module (perhaps math.. math.infinity, math.epsilon, etc., just like > math.pi and math.e.) It too looks acceptable. > I look forward to hearing your thoughts an the subject. Thank you, but I am not expert enough on such topics to give you good comments, s

Re: how to save a screenshot in pygame?

2006-08-08 Thread [EMAIL PROTECTED]
liuliuliu wrote: > hi -- sorry if this is trivial -- but how do you make a screenshot of a > pygame display? i have a surface which is basically the entire visible > screen -- how do you write this surface as an image file during > specific events in the script execution? image format doesnt matte

Re: newb question: file searching

2006-08-08 Thread John Machin
[EMAIL PROTECTED] wrote: > And, finally, the python docs all note that symbols like . and .. > don't work with these commands. Where did you read that? The docs for os.listdir do say that '.' and '..' are (sensibly) not returned as *results*. AFAIK there is nothing to stop you using '.' or '..'

Re: newb question: file searching

2006-08-08 Thread Gabriel Genellina
At Tuesday 8/8/2006 17:55, [EMAIL PROTECTED] wrote: I must ask, in the interest of learning, what is [file for file in files if file.endswith(extension)] actually doing? I know that 'file' is a type, but what's with the set up and the brackets and all? Can someone run down the syntax for me

Re: do people really complain about significant whitespace?

2006-08-08 Thread Stephen Kellett
In message <[EMAIL PROTECTED]>, Gerhard Fiedler <[EMAIL PROTECTED]> writes >conclusion for me: they must not like self-documenting code... :) Oh dear. So if the code is wrong it is self documenting? Comments document what the code should do. The code shows what the code actually does. Also from

Re: newb question: file searching

2006-08-08 Thread [EMAIL PROTECTED]
Okay. This is almost solved. I just need to know how to have each entry in my final list have the full path, not just the file name. Also, I've noticed that files are being found within hidden directories. I'd like to exclude hidden directories from the walk, or at least not add anything within

Re: Open file handles?

2006-08-08 Thread Jon
Perhaps using os you could work with lsof [http://www.linuxcommand.org/man_pages/lsof8.html] Jon Thomas Bartkus wrote: > This may be more of a Linux question, but I'm doing this from Python. . > > How can I know if anything (I don't care who or what!) is in the middle of > using a particular

Re: Getting previous file name

2006-08-08 Thread John Machin
Miki wrote: > Hello hj, > > > I have a small script here that goes to inside dir and sorts the file > > by create date. I can return the create date but I don't know how to > > find the name of that file... > > I need file that is not latest but was created before the last file. > > Any hints... I

Re: New to Python-- Help

2006-08-08 Thread Ravi Teja
Philippe Martin wrote: > John & Mary Cook wrote: > > > I just installed Python on Windows XP Pro. When I enter 'python' at the > > >>> prompt in Pythonwin IDE I get the following: > > > > Traceback (most recent call last): > >File "", line 1, in ? > > Name Error: name 'python' is not defined

how to save a screenshot in pygame?

2006-08-08 Thread liuliuliu
hi -- sorry if this is trivial -- but how do you make a screenshot of a pygame display? i have a surface which is basically the entire visible screen -- how do you write this surface as an image file during specific events in the script execution? image format doesnt matter. thanks! christine --

Re: #!/usr/bin/python or #!/usr/bin/env python?

2006-08-08 Thread Martin v. Löwis
Erik Max Francis schrieb: >> I use /usr/bin/env if I don't know what the operating system is; >> some systems don't have Python in /usr/bin. I use /usr/bin/pythonX.Y >> if I want a specific version on a specific operating system (typically >> Linux). > > Even there, /usr/bin/env pythonX.Y would be

Re: newb question: file searching

2006-08-08 Thread Steve M
[EMAIL PROTECTED] wrote: > I must ask, in the interest of learning, what is > > [file for file in files if file.endswith(extension)] > > actually doing? I know that 'file' is a type, but what's with the set > up and the brackets and all? Other people explained the list comprehension, but you m

Open file handles?

2006-08-08 Thread Thomas Bartkus
This may be more of a Linux question, but I'm doing this from Python. . How can I know if anything (I don't care who or what!) is in the middle of using a particular file? This comes in context of needing to copy a file BUT only if I can verify that something else doesn't have an open write h

Re: New to Python-- Help

2006-08-08 Thread [EMAIL PROTECTED]
Are you refering to IDLE? or simply running python at the command line? In either case - python is just the language's name. It is not a defined name within the language. If you describe what you are trying to do, perhaps some more specific help could be had. What is happening: There currently

Re: New to Python-- Help

2006-08-08 Thread Jason
John & Mary Cook wrote: > I just installed Python on Windows XP Pro. When I enter 'python' at the >>> > prompt in Pythonwin IDE I get the following: > > Traceback (most recent call last): >File "", line 1, in ? > Name Error: name 'python' is not defined > > Can anyone help? > > Thank you, > >

Re: python - HTML processing - need tips

2006-08-08 Thread wipit
I figured it out... Just turned the POST request into a GET to see what was getting appended to the URL - thanks Gabe! Gabriel Genellina wrote: > At Monday 7/8/2006 20:58, wipit wrote: > > >I need to process a HTML form in python. I'm using urllib2 and > >HTMLParser to handle the html. There are s

Re: New to Python-- Help

2006-08-08 Thread Philippe Martin
John & Mary Cook wrote: > I just installed Python on Windows XP Pro. When I enter 'python' at the > >>> prompt in Pythonwin IDE I get the following: > > Traceback (most recent call last): >File "", line 1, in ? > Name Error: name 'python' is not defined > > Can anyone help? > > Thank you,

Re: newb question: file searching

2006-08-08 Thread Simon Forman
[EMAIL PROTECTED] wrote: > hiaips wrote: > > > [EMAIL PROTECTED] wrote: > > > > I'm new at Python and I need a little advice. Part of the script I'm > > > > trying to write needs to be aware of all the files of a certain > > > > extension in the script's path and all sub-directories. Can someone

Re: newb question: file searching

2006-08-08 Thread [EMAIL PROTECTED]
So far, so good. I just have a few more questions. Here's my code so far: import os top = '/home/USERNAME/' images = [] for files in os.walk(top, topdown=True): images += [file for file in files[2] if file.endswith('jpg')] print images I still need to know how I can dynamically get the

threading.Event usage causing intermitent exception

2006-08-08 Thread [EMAIL PROTECTED]
Admittedly this problem causes no actual functional issues aside from an occasional error message when the program exits. The error is: Unhandled exception in thread started by Error in sys.excepthook: Original exception was: Yes all that info is blank. The application is a console application

Re: newb question: file searching

2006-08-08 Thread hiaips
Oops, what I wrote above isn't quite correct. As another poster pointed out, you'd want to do for file in x[2]: ... --dave -- http://mail.python.org/mailman/listinfo/python-list

Re: newb question: file searching

2006-08-08 Thread hiaips
[EMAIL PROTECTED] wrote: > Thanks, Dave. That's exactly what I was looking for, well, except for > a few small alterations I'll make to achieve the desired effect. I > must ask, in the interest of learning, what is > > [file for file in files if file.endswith(extension)] > > actually doing? I k

New to Python-- Help

2006-08-08 Thread John & Mary Cook
I just installed Python on Windows XP Pro. When I enter 'python' at the >>> prompt in Pythonwin IDE I get the following: Traceback (most recent call last): File "", line 1, in ? Name Error: name 'python' is not defined Can anyone help? Thank you, J. T. Cook -- http://mail.python.org/ma

Re: (easy question) Find and replace multiple items

2006-08-08 Thread Simon Forman
ds4ff1z wrote: > Hello, i'm looking to find and replace multiple characters in a text > file (test1). I have a bunch of random numbers and i want to replace > each number with a letter (such as replace a 7 with an f and 6 with a > d). I would like a suggestion on an a way to do this. Thanks http

Re: (easy question) Find and replace multiple items

2006-08-08 Thread Mark Peters
ds4ff1z wrote: > Hello, i'm looking to find and replace multiple characters in a text > file (test1). I have a bunch of random numbers and i want to replace > each number with a letter (such as replace a 7 with an f and 6 with a > d). I would like a suggestion on an a way to do this. Thanks how

Re: (easy question) Find and replace multiple items

2006-08-08 Thread Tim Chase
> Hello, i'm looking to find and replace multiple characters in a text > file (test1). I have a bunch of random numbers and i want to replace > each number with a letter (such as replace a 7 with an f and 6 with a > d). I would like a suggestion on an a way to do this. Thanks Well, the canonical

Re: newb question: file searching

2006-08-08 Thread Jason
[EMAIL PROTECTED] wrote: > Mike Kent wrote: > > What you want is os.walk(). > > > > http://www.python.org/doc/current/lib/os-file-dir.html > > I'm thinking os.walk() could definitely be a big part of my solution, > but I need a little for info. If I'm reading this correctly, os.walk() > just goes

Re: String.digits help!!!

2006-08-08 Thread Simon Forman
[EMAIL PROTECTED] wrote: > Simon Forman: > > It's unlikely to > > be deprecated since it doesn't make much sense to make it an attribute > > of the str type. > > Why? > > Thank you, > bearophile Let me toss the question back at you: Does it make sense to you that str should have this attribute?

Re: Proposal: [... for ... while cond(x)]

2006-08-08 Thread Eighty
Terry Reedy wrote: > whereas the analogous expansion of your proposal > > for x in xs: > while cond(x): > yield e(x) > > is an infinite loop and not at all what you mean. You're right. The syntax is ambiguous. I agree it's not a good idea, now. :) > x for x in xs while cond(x) if blah(x)

Re: newb question: file searching

2006-08-08 Thread [EMAIL PROTECTED]
Thanks, Dave. That's exactly what I was looking for, well, except for a few small alterations I'll make to achieve the desired effect. I must ask, in the interest of learning, what is [file for file in files if file.endswith(extension)] actually doing? I know that 'file' is a type, but what's

Re: newb question: file searching

2006-08-08 Thread hiaips
> I'm thinking os.walk() could definitely be a big part of my solution, > but I need a little for info. If I'm reading this correctly, os.walk() > just goes file by file and serves it up for your script to decide what > to do with each one. Is that right? So, for each file it found, I'd > have

Re: is it possible to dividing up a class in multiple files?

2006-08-08 Thread roelmathys
Martin Höfling wrote: > Hi there, > > is it possible to put the methods of a class in different files? I just > want to order them and try to keep the files small. > > Regards > Martin you could do this: file_1.py: class A: def __init__(self): self.a = 1 file_2.py: from file_

(easy question) Find and replace multiple items

2006-08-08 Thread ds4ff1z
Hello, i'm looking to find and replace multiple characters in a text file (test1). I have a bunch of random numbers and i want to replace each number with a letter (such as replace a 7 with an f and 6 with a d). I would like a suggestion on an a way to do this. Thanks -- http://mail.python.org/

Re: newb question: file searching

2006-08-08 Thread [EMAIL PROTECTED]
Mike Kent wrote: > What you want is os.walk(). > > http://www.python.org/doc/current/lib/os-file-dir.html I'm thinking os.walk() could definitely be a big part of my solution, but I need a little for info. If I'm reading this correctly, os.walk() just goes file by file and serves it up for your s

Re: Proposal: [... for ... while cond(x)]

2006-08-08 Thread Terry Reedy
"Eighty" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > > Eighty wrote: >> I suggest a new extension of the list comprehension syntax: >> >> [x for x in xs while cond(x)] This does not work. e(x) for x in xs if cond(x) is an abbreviation of for x in xs: if cond(x) yield e

Re: #!/usr/bin/python or #!/usr/bin/env python?

2006-08-08 Thread Erik Max Francis
Martin v. Löwis wrote: > I use /usr/bin/env if I don't know what the operating system is; > some systems don't have Python in /usr/bin. I use /usr/bin/pythonX.Y > if I want a specific version on a specific operating system (typically > Linux). Even there, /usr/bin/env pythonX.Y would be a better

Re: newb question: file searching

2006-08-08 Thread hiaips
> [EMAIL PROTECTED] wrote: > > I'm new at Python and I need a little advice. Part of the script I'm > > trying to write needs to be aware of all the files of a certain > > extension in the script's path and all sub-directories. Can someone > > set me on the right path to what modules and calls t

Re: #!/usr/bin/python or #!/usr/bin/env python?

2006-08-08 Thread Erik Max Francis
John Salerno wrote: > I understand the difference, but I'm just curious if anyone has any > strong feelings toward using one over the other? I was reading that a > disadvantage to the more general usage (i.e. env) is that it finds the > first python on the path, and that might not be the proper

Re: newb question: file searching

2006-08-08 Thread Mike Kent
[EMAIL PROTECTED] wrote: > I'm new at Python and I need a little advice. Part of the script I'm > trying to write needs to be aware of all the files of a certain > extension in the script's path and all sub-directories. What you want is os.walk(). http://www.python.org/doc/current/lib/os-file-d

Re: binary conversion issues

2006-08-08 Thread Grant Edwards
On 2006-08-08, godavemon <[EMAIL PROTECTED]> wrote: > You guys are awesome! I had to set the 'b' flag when writing the > binaries. > > file_obj = open('filename.bin', 'wb') > > instead of just using 'w' > > It worked fine for all of the other 10 binary files I made, > but had a small error with on

Native Win32 text entry dialog?

2006-08-08 Thread utabintarbo
Is there a native Win32 text entry dialog available through the Win32 extensions. I am looking for something similar to easygui's (http://www.ferg.org/easygui/) enterbox. Any ideas? TIA -- http://mail.python.org/mailman/listinfo/python-list

Re: newb question: file searching

2006-08-08 Thread godavemon
Hey, I've done similar things. You can use system comands with the following import os os.system('command here') You'd maybe want to do something like dir_name = 'mydirectory' import os os.system('ls ' +dir_name + ' > lsoutput.tmp') fin = open('lsoutput.tmp', 'r') file_list = fin.readlines() fi

Re: newb question: file searching

2006-08-08 Thread godavemon
Hey, I've done similar things. You can use system comands with the following import os os.system('command here') You'd maybe want to do something like dir_name = 'mydirectory' import os os.system('ls ' +dir_name + ' > lsoutput.tmp') fin = open('lsoutput.tmp', 'r') file_list = fin.readlines() fi

matplotlib not plotting dates

2006-08-08 Thread OKB (not okblacke)
I just downloaded matplotlib and I was trying to do some simple date plots, but I'm running up against a puzzling error. Whenever I attempt to plot dates, I get an exception on line 157 of matplotlib/dates.py that says 'ValueError: need more than 0 values to unpack'. That line is:

  1   2   3   >