ANN: xlrd 0.6.1 final is now available

2007-06-11 Thread John Machin
The final release of version 0.6.1 of xlrd is now available from http://www.lexicon.net/sjmachin/xlrd.htm and from the Cheeseshop (http://cheeseshop.python.org/pypi/xlrd). What is xlrd? It's a small (download approx 0.1 Mb) pure-Python library for extracting information from Microsoft Excel (tm)

Re: unicode mystery

2005-01-11 Thread John Machin
Sean McIlroy wrote: I recently found out that unicode(\347, iso-8859-1) is the lowercase c-with-cedilla, so I set out to round up the unicode numbers of the extra characters you need for French, and I found them all just fine EXCEPT for the o-e ligature (oeuvre, etc). I examined the unicode

Octal notation: severe deprecation

2005-01-11 Thread John Machin
Some poster wrote (in connexion with another topic): ... unicode(\347, iso-8859-1) ... Well, I haven't had a good rant for quite a while, so here goes: I'm a bit of a retro specimen, being able (inter alia) to recall octal opcodes from the ICT 1900 series (070=call, 072=exit, 074=branch, ...)

Re: Importing Problem on Windows

2005-01-11 Thread John Machin
brolewis wrote: I have a directory that has two files in it: parse.py parser.py parse.py imports a function from parser.py and uses it to parse out the needed information. On Linux, the following code works without a problem: parse.py, line 1: from parser import regexsearch However,

Re: Importing Problem on Windows

2005-01-11 Thread John Machin
brolewis wrote: I have a directory that has two files in it: parse.py parser.py parse.py imports a function from parser.py and uses it to parse out the needed information. On Linux, the following code works without a problem: parse.py, line 1: from parser import regexsearch However,

Re: Help Optimizing Word Search

2005-01-11 Thread John Machin
Case Nelson wrote: Hi there I've just been playing around with some python code and I've got a fun little optimization problem I could use some help with. Basically, the program needs to take in a random list of no more than 10 letters, and find all possible mutations that match a word in

Re: SciTe

2005-01-11 Thread John Machin
Lucas Raab wrote: I didn't want to go through the rigamole of adding myself to the SciTe mailing list, so I'm asking my question here. How do I choose a different C/C++ compiler to compile in?? I don't use the g++ compiler; I use the VC 7 compiler. TIA, Lucas How the @#$% should we know?

Re: Help Optimizing Word Search

2005-01-11 Thread John Machin
Paul Rubin wrote: Case Nelson [EMAIL PROTECTED] writes: Basically, the program needs to take in a random list of no more than 10 letters, and find all possible mutations that match a word in my dictionary (80k words). However a wildcard letter '?' is also an acceptable character which

Re: What strategy for random accession of records in massive FASTA file?

2005-01-12 Thread John Machin
Chris Lasher wrote: Hello, I have a rather large (100+ MB) FASTA file from which I need to access records in a random order. The FASTA format is a standard format for storing molecular biological sequences. Each record contains a header line for describing the sequence that begins with a ''

Re: Pickled text file causing ValueError (dos/unix issue)

2005-01-14 Thread John Machin
On Fri, 14 Jan 2005 09:12:49 -0500, Tim Peters [EMAIL PROTECTED] wrote: [Aki Niimura] I started to use pickle to store the latest user settings for the tool I wrote. It writes out a pickled text file when it terminates and it restores the settings when it starts. ... I guess DOS text format

Re: How to del item of a list in loop?

2005-01-15 Thread John Machin
Fredrik Lundh wrote: lst = [i for i in lst if i != 2] (if you have 2.4, try replacing [] with () and see what happens) The result is a generator with a name (lst) that's rather misleading in the context. Achieving the same result as the list comprehension, by doing lst = list(i for ...

Re: How to del item of a list in loop?

2005-01-15 Thread John Machin
Nick Coghlan wrote: I think this is about the best you can do for an in-place version: for i, x in enumerate(reversed(lst)): if x == 2: del lst[-i] I think del lst[-i-1] might be functionally better. -- http://mail.python.org/mailman/listinfo/python-list

Re: How to del item of a list in loop?

2005-01-15 Thread John Machin
Michael Hoffman wrote: John Machin wrote: Three significant figures is plenty. Showing just the minimum of the results might be better. It might be, but how much time do you want to spend on getting your results for a benchmark that will be run once in the better format? About the same

generator expressions: performance anomaly?

2005-01-16 Thread John Machin
Please consider the timings below, where a generator expression starts out slower than the equivalent list comprehension, and gets worse: python -m timeit -s orig=range(10) lst=orig[:];lst[:]=(x for x in orig) 10 loops, best of 3: 6.84e+004 usec per loop python -m timeit -s

Re: Fuzzy matching of postal addresses

2005-01-17 Thread John Machin
Ermmm ... only remove the when you are sure it is a whole word. Even then it's a dodgy idea. In the first 1000 lines of the nearest address file I had to hand, I found these: Catherine, Matthew, Rotherwood, Weatherall, and The Avenue. Ermmm... don't rip out commas (or other punctuation); replace

Re: Fuzzy matching of postal addresses

2005-01-17 Thread John Machin
You can't even get anywhere near 100% accuracy when comparing authoritative sources e.g. postal authority and the body charged with maintaining a database of which streets are in which electoral district -- no, not AUS, but close :-) -- http://mail.python.org/mailman/listinfo/python-list

Re: Fuzzy matching of postal addresses

2005-01-18 Thread John Machin
John Machin wrote: Ermmm ... only remove the when you are sure it is a whole word. Even then it's a dodgy idea. In the first 1000 lines of the nearest address file I had to hand, I found these: Catherine, Matthew, Rotherwood, Weatherall, and The Avenue. Partial apologies: I wasn't reading

Re: file copy portability

2005-01-18 Thread John Machin
Bob Smith wrote: Is shutil.copyfile(src,dst) the *most* portable way to copy files with Python? I'm dealing with plain text files on Windows, Linux and Mac OSX. Thanks! Portable what? Way of copying?? Do you want your files transferred (a) so that they look like native text files on the

Re: list item's position

2005-01-19 Thread John Machin
On Wed, 19 Jan 2005 22:02:51 -0700, Steven Bethard [EMAIL PROTECTED] wrote: See Mark's post, if you need to know the index of something this is the perfect case for enumerate (assuming you have at least Python 2.3): But the OP (despite what he says) _doesn't_ need to know the index of the

Re: why no time() + timedelta() ?

2005-01-20 Thread John Machin
Tim Peters wrote: [josh] Why can't timedelta arithmetic be done on time objects? Obviously, because it's not implemented wink. (e.g. datetime.time(5)-datetime.timedelta(microseconds=3) Nonzero days of the timedelta could either be ignored, or trigger an exception. And if the result

Re: Unbinding multiple variables

2005-01-20 Thread John Machin
Johnny Lin wrote: Hi! Is there a way to automate the unbinding of multiple variables? Say I have a list of the names of all variables in the current scope via dir(). Is there a command using del or something like that that will iterate the list and unbind each of the variables? Yes. It's

Re: Simple (newbie) regular expression question

2005-01-21 Thread John Machin
André Roberge wrote: Sorry for the simple question, but I find regular expressions rather intimidating. And I've never needed them before ... How would I go about to 'define' a regular expression that would identify strings like __alphanumerical__ as in __init__ (Just to spell things

Re: why am I getting a segmentation fault?

2005-01-21 Thread John Machin
Jay donnell wrote: I have a short multi-threaded script that checks web images to make sure they are still there. I get a segmentation fault everytime I run it and I can't figure out why. Writing threaded scripts is new to me so I may be doing something wrong that should be obvious :( def

Re: why am I getting a segmentation fault?

2005-01-21 Thread John Machin
Jay donnell wrote: ### Have you looked in your database to see if the script has actually updated item.goodImage? Do you have a test plan? Thank you for the help. Sorry for the messy code. I was under time constraints. I had class, and I was rushing to get this working before class. I

Re: getting file size

2005-01-21 Thread John Machin
Bob Smith wrote: Are these the same: 1. f_size = os.path.getsize(file_name) 2. fp1 = file(file_name, 'r') data = fp1.readlines() last_byte = fp1.tell() I always get the same value when doing 1. or 2. Is there a reason I should do both? When reading to the end of a file, won't

Re: getting file size

2005-01-23 Thread John Machin
Tim Roberts wrote: Bob Smith [EMAIL PROTECTED] wrote: Are these the same: 1. f_size = os.path.getsize(file_name) 2. fp1 = file(file_name, 'r') data = fp1.readlines() last_byte = fp1.tell() I always get the same value when doing 1. or 2. Is there a reason I should do both?

Re: getting file size

2005-01-23 Thread John Machin
Tim Roberts wrote: Bob Smith [EMAIL PROTECTED] wrote: Are these the same: 1. f_size = os.path.getsize(file_name) 2. fp1 = file(file_name, 'r') data = fp1.readlines() last_byte = fp1.tell() I always get the same value when doing 1. or 2. Is there a reason I should do both?

Re: Fuzzy matching of postal addresses [1/1]

2005-01-23 Thread John Machin
Andrew McLean wrote: In case anyone is interested, here is the latest. def insCost(tokenList, indx, pos): The cost of inserting a specific token at a specific normalised position along the sequence. if containsNumber(tokenList[indx]): return INSERT_TOKEN_WITH_NUMBER +

Re: bad argument type for built-in operation

2005-01-24 Thread John Machin
Gilles Arnaud wrote: Hello, I've got a nasty bug and no idea to deal with : here is the method : Big snip. The Python code is unlikely to be your problem. and the trace trace in None [(-2.0, 2.0), (-2.0, 2.0)] [0.1385039192456847, 0.87787941093093491] 2 2 function undo at 0x81ff94c

Re: Looking for Form Feeds

2005-01-24 Thread John Machin
Greg Lindstrom wrote: Hello- I have a file generated by an HP-9000 running Unix containing form feeds signified by ^M^L. I am trying to scan for the linefeed to signal certain processing to be performed but can not get the regex to see it. Suppose I read my input line into a variable named

Re: Browsing text ; Python the right tool?

2005-01-25 Thread John Machin
Paul Kooistra wrote: I need a tool to browse text files with a size of 10-20 Mb. These files have a fixed record length of 800 bytes (CR/LF), and containt records used to create printed pages by an external company. Each line (record) contains an 2-character identifier, like 'A0' or 'C1'.

Re: Browsing text ; Python the right tool?

2005-01-25 Thread John Machin
Paul Kooistra wrote: I need a tool to browse text files with a size of 10-20 Mb. These files have a fixed record length of 800 bytes (CR/LF), and containt records used to create printed pages by an external company. Each line (record) contains an 2-character identifier, like 'A0' or 'C1'.

Re: How to input one char at a time from stdin?

2005-01-25 Thread John Machin
On Wed, 26 Jan 2005 01:15:10 +0530, Swaroop C H [EMAIL PROTECTED] wrote: On Tue, 25 Jan 2005 12:38:13 -0700, Brent W. Hughes [EMAIL PROTECTED] wrote: I'd like to get a character from stdin, perform some action, get another character, etc. If I just use stdin.read(1), it waits until I finish

Re: Browsing text ; Python the right tool?

2005-01-25 Thread John Machin
Jeff Shannon wrote: Paul Kooistra wrote: 1. Does anybody now of a generic tool (not necessarily Python based) that does the job I've outlined? 2. If not, is there some framework or widget in Python I can adapt to do what I want? Not that I know of, but... 3. If not, should I

Re: Browsing text ; Python the right tool?

2005-01-26 Thread John Machin
Jeff Shannon wrote: John Machin wrote: Jeff Shannon wrote: [...] If each record is CRLF terminated, then you can get one record at a time simply by iterating over the file (for line in open('myfile.dat'): ...). You can have a dictionary classes or factory functions, one for each

Re: Responding to trollish postings.

2005-01-26 Thread John Machin
Terry Reedy wrote: No offense taken. My personal strategy is to read only as much of trollish threads as I find interesting or somehow instructive, almost never respond, and then ignore the rest. I also mostly ignore discussions about such threads. Indeed. Let's just nominate XL to the

Re: Why do look-ahead and look-behind have to be fixed-width patterns?

2005-01-27 Thread John Machin
inhahe wrote: Hi i'm a newbie at this and probably always will be, so don't be surprised if I don't know what i'm talking about. but I don't understand why regex look-behinds (and look-aheads) have to be fixed-width patterns. i'm getting the impression that it's supposed to make searching

Re: py.dll for version 2.2.1 (Windows)

2005-01-28 Thread John Machin
mike wrote: Just recently, my virus checker detected what it called a Trojan Horse in the py.dll file in the python22 folder. Sorry to come on like the Inquisition, but this _might_ be something of significance to the whole Windows Python community: When was just recently? Which virus checker

Re: Awkwardness of C API for making tuples

2005-02-01 Thread John Machin
Dave Opstad wrote: One of the functions in a C extension I'm writing needs to return a tuple of integers, where the length of the tuple is only known at runtime. I'm currently doing a loop calling PyInt_FromLong to make the integers, What is the purpose of this first loop? In what

Re: Awkwardness of C API for making tuples

2005-02-01 Thread John Machin
Dave Opstad wrote: In article [EMAIL PROTECTED], John Machin [EMAIL PROTECTED] wrote: What is the purpose of this first loop? Error handling. If I can't successfully create all the PyInts then I can dispose the ones I've made and not bother making the tuple at all. In what variable

Re: Reference count question

2005-02-02 Thread John Machin
Fredrik Lundh wrote: PyList_SetItem(List,i,Str); you should check the return value, though. PyList_SetItem may (in theory) fail. :-) Only a bot could say that. We mere mortals have been known to do things like (a) pass a non-list as the first argument (b) pass an out-of-range value

Re: Crashing Python interpreter! (windows XP, python2.3.4, 2.3.5rc1, 2.4.0)

2005-02-03 Thread John Machin
Leeuw van der, Tim wrote: Do you have a file called drwtsn32.log anywhere on your computer? No, unfortunately I cannot find such file anywhere on my computer What do I do to get such file? Or anything equally useful? On my Windows 2000 box, just crash something :-) Perhaps this may

Re: Crashing Python interpreter! (windows XP, python2.3.4, 2.3.5rc1, 2.4.0)

2005-02-03 Thread John Machin
Leeuw van der, Tim wrote: -Original Message- From: [EMAIL PROTECTED] on behalf of John Machin Sent: Thu 2/3/2005 12:00 PM To: python-list@python.org Subject: Re: Crashing Python interpreter! (windows XP, python2.3.4, 2.3.5rc1,2.4.0) Leeuw van der, Tim wrote: Do

Re: Crashing Python interpreter! (windows XP, python2.3.4, 2.3.5rc1, 2.4.0)

2005-02-03 Thread John Machin
Leeuw van der, Tim wrote: -Original Message- From: [EMAIL PROTECTED] on behalf of John Machin Sent: Thu 2/3/2005 12:00 PM To: python-list@python.org Subject: Re: Crashing Python interpreter! (windows XP, python2.3.4, 2.3.5rc1,2.4.0) Leeuw van der, Tim wrote: Do

Re: Converting a string to a function pointer

2005-02-04 Thread John Machin
On Fri, 04 Feb 2005 12:01:35 +0100, Håkan Persson [EMAIL PROTECTED] wrote: Hi. I am trying to convert a string into a function pointer. Suppose I have the following: from a import a from b import b from c import c funcString = GetFunctionAsString() and funcString is a string that contains

Re: newbie: Syntax error

2005-02-04 Thread John Machin
Chad Everett wrote: Hi Everyone, I am new to Python and programming in general. I bought the book Python Programming for the Absolute Beginner by michael Dawson. I have been working through it but am having trouble. I am trying to make a coin flip program and keep geting a Synax Error

Re: Error!

2005-02-04 Thread John Machin
administrata wrote: I'm programming Car Salesman Program. It's been 3 days learning python... From whom or what book or what tutorial? But, i got problem You got problemS. What Jeff Brian wrote, plus: You have change instead of charge. You forgot to add in the base price -- actual price

Re: remove duplicates from list *preserving order*

2005-02-06 Thread John Machin
Francis Girard wrote: Hi, I think your last solution is not good unless your list is sorted (in which case the solution is trivial) since you certainly do have to see all the elements in the list before deciding that a given element is not a duplicate. You have to exhaust the iteratable

Re: Choosing the right parser for parsing C headers

2005-02-08 Thread John Machin
Jean de Largentaye wrote: Hi, I need to parse a subset of C (a header file), and generate some unit tests for the functions listed in it. I thus need to parse the code, then rewrite function calls with wrong parameters. What I call shaking the broken tree :) I was thinking cdecl, and

Re: Java Integer.ParseInt translation to python

2005-02-09 Thread John Machin
jose isaias cabrera wrote: the question is, how can I make this java (byte) call in python? so that the result would be the right one, [EMAIL PROTECTED] Let's get this straight: you have 40 hex digits; both your Java code and your Python code each do 20 iterations, printing the 20 bytes that

Re: negative integer division

2005-02-09 Thread John Machin
[EMAIL PROTECTED] (Mark Jackson) wrote in message news:[EMAIL PROTECTED]... A: 42 Q: What multiple of 7 did I add to the critical expression in the Zeller algorithm so it would remain nonnegative for the next few centuries? What are you calling the Zeller algorithm, and what is the

Re: newbie question

2005-02-12 Thread John Machin
Dan Perl wrote: [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Hello All, What is the python equivalent of the following statement? while (n--) Like other posters said, you should give more details with your question. What do you mean by equivalent? The following is

Re: a Variable in multiple quotes...

2005-02-13 Thread John Machin
administrata wrote: Is it possible? I tried... I = John print \ I used to love pizza Error occurs!!! But, I don't know how to fix... HELP thx 4 reading. Point 0: It helps if you post a copy of what the actual screen display looked like, instead of just saying Error occurs!!!. It

Re: builtin functions for and and or?

2005-02-13 Thread John Machin
Michael Hartl wrote: I warmly recommend downloading Peter Norvig's Python utilities file (http://aima.cs.berkeley.edu/python/utils.py) and putting it on your Python path. (E.g., in bash, put a line like export PYTHONPATH=/path/to/utilities_directory in your .bashrc file.) The utils.py

Re: win32 extension install hiccup

2005-02-13 Thread John Machin
MM wrote: Hi, I downloaded the latest win32all build 202 and tried to install under win2000 with Py2.4. Install complains about 'couldn't open py2.4 to run script pywin32-preinstall.py'. I checked the directories and there was no sign of this file (preinstall.py) so I presume this is why

Re: custom classes in sets

2005-02-14 Thread John Machin
vegetax wrote: How can i make my custom class an element of a set? the idea is that it accepts file paths and construct a set of unique files (the command cmp compares files byte by byte.),the files can have different paths but the same content Q: How do I transport ten sumo wrestlers on a

Re: Why doesn't join() call str() on its arguments?

2005-02-16 Thread John Machin
On 16 Feb 2005 18:47:21 GMT, Leo Breebaart [EMAIL PROTECTED] wrote: What I can't find an explanation for is why str.join() doesn't automatically call str() on its arguments, so that e.g. str.join([1,2,4,5]) would yield 1245, and ditto for e.g. user-defined classes that have a __str__() defined.

Re: Why doesn't join() call str() on its arguments?

2005-02-16 Thread John Machin
On Wed, 16 Feb 2005 14:24:02 -0600, Skip Montanaro [EMAIL PROTECTED] wrote: John 4. For consistency, would you like 1 + 2 to produce 12? No, the correct answer is obviously 3. ;-) Obviously, in awk. Bletch! I once had to help out some users of a system where software development had been

Re: Help with C extensions under VC6 / WinXP and Python 2.4

2005-02-16 Thread John Machin
On Wed, 16 Feb 2005 20:57:18 -0500, Scott [EMAIL PROTECTED] wrote: I've installed Python 2.4 under WinXP and am attempting to create an extension module using the steps outlined here: http://python.org/doc/2.4/ext/win-cookbook.html I'm specifically trying to perform step 6. Creating a brand new

Re: How did you learn Python?

2004-12-03 Thread John Machin
Jeffrey Maitland [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED]... Well I would suggest the Python in a Nutshell and the Python Cookbook both by O'Reilly as references. They are great for a desktop reference and I check them first before I google/search else where for answers.

Re: New versions breaking extensions, etc.

2004-12-11 Thread John Machin
Jive wrote: Martin v. Löwis [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] OTOH, people who only have VC6 just need to buy VS.NET 2003, which is still available. I don't even know how to do that! :-) What's the difference between VC++ .net Standard and Visual Studio .net Pro?

Re: Upgrade woes: Numeric, gnuplot, and Python 2.4

2004-12-11 Thread John Machin
Jive wrote: Here's my sitch: I use gnuplot.py at work, platform Win32. I want to upgrade to Python 2.4. Gnuplot.py uses extension module Numeric. Numeric is now unsupported. The documentation says If you are new to Numerical Python, please use Numarray.. It's not that easy, dangit. The

Re: newbie questions

2004-12-12 Thread John Machin
Fredrik Lundh wrote: John Machin wrote: Of course, in this simple case, I wouldn't be likely to write the clear function since the inline code is simpler and has less overhead: def main() var1 = [] var1.append('a') var1[:] = [] Even less overhead: del var1

Re: extending python with a C-written dll

2004-12-20 Thread John Machin
Jean-Baptiste PERIN wrote: Hi, I'm trying to make a windows dll reachable from a python script .. and I'm encountering troubles during link step .. I use lcc to compile and link I use python 2.3 under win XP [snip] Here are the errors : - Error c:\...\plugins\hello.c

Re: Best GUI for small-scale accounting app?

2004-12-20 Thread John Machin
Thomas Heller wrote: Bulba! [EMAIL PROTECTED] writes: I'll soon start development of a specialized small app and need to choose GUI for it. Quoting a somewhat popular german blogger, on the state of cross platform Python GUI toolkits (http://blog.schockwellenreiter.de/7282): [snip]

Re: input record sepArator (equivalent of $| of perl)

2004-12-21 Thread John Machin
Nick Coghlan wrote: [snip] delimeter. Hey, Terry, another varmint over here! -- http://mail.python.org/mailman/listinfo/python-list

Re: input record sepArator (equivalent of $| of perl)

2004-12-21 Thread John Machin
Steven Bethard wrote: John Machin wrote: Nick Coghlan wrote: [snip] delimeter. Hey, Terry, another varmint over here! No, no. He's talking about a deli-meter. It's the metric standard for measuring subs and sandwiches. ;) Nobody mention the wurst! I did once, but I think I got

Re: word to digit module

2004-12-22 Thread John Machin
Stephen Thorne wrote: On Wed, 22 Dec 2004 10:27:16 +0530, Gurpreet Sachdeva [EMAIL PROTECTED] wrote: Is there any module available that converts word like 'one', 'two', 'three' to corresponding digits 1, 2, 3?? This seemed like an interesting problem! So I decided to solve it. I started

Re: regular expression: perl == python

2004-12-22 Thread John Machin
Fredrik Lundh wrote: JZ wrote: import re line = The food is under the bar in the barn. if re.search(r'foo(.*)bar',line): print 'got %s\n' % _.group(1) Traceback (most recent call last): File jz.py, line 4, in ? print 'got %s\n' % _.group(1) NameError: name '_'

Re: mathmatical expressions evaluation

2004-12-22 Thread John Machin
Paul McGuire wrote: Here's a simple loan amortization schedule generator: def amortizationSchedule( principal, term, rate ): pmt = ( principal * rate * ( 1 + rate)**term ) / (( 1 + rate)**term - 1) Simpliciter: pmt = principal * rate / (1 - (1 + rate)**(-term)) pmt = round(pmt,2)

Re: regular expression: perl == python

2004-12-22 Thread John Machin
Fredrik Lundh wrote: John Machin wrote: I forgot to add: I am using Python 2.3.4/Win32 (from ActiveState.com). The code works in my interpreter. only if you type it into the interactive prompt. see: No, it doesn't work at all, anywhere. Did you actually try this? the OP

Re: word to digit module

2004-12-22 Thread John Machin
Stephen Thorne wrote: Thankyou for you feedback, both of you. No wuckas. http://thorne.id.au/users/stephen/scripts/eng2num.py contains your suggestions. This points to some javascript which prints No. -- http://mail.python.org/mailman/listinfo/python-list

Re: Tinkering with py2exe

2004-12-25 Thread John Machin
Ishwor wrote: Having coded 1.72kb python test file, i decided to convert it to .exe file using py2exe. Having succeded doing it, i found the need to distribute the whole directory including these files ?!!!??? 26/12/2004 09:16 AM 203,096 library.zip 26/11/2004 09:16 AM

Re: Clearing the screen

2004-12-25 Thread John Machin
Ishwor wrote: i was just tinkering with it actually. ;-) In your command prompt just do Pythonwin.exe /run C:\Python24\file\PyFiles\clear.py It's not a very good idea to store your own scripts in the PythonXY directory -- other than tested working modules which you install in

Re: program in interactive mode

2004-12-26 Thread John Machin
Mike Meyer wrote: I've discovered a truly elegant trick with python programs that interpret other data. Q0. Other than what? You make them ignore lines that start with # at the beginning of the line, Q1. After the first user accidentally gets a # at the start of a real data line, a few

Re: Problems installing MySQLdb on Windows [newbie]

2004-12-28 Thread John Machin
Alex Meier wrote: hi, all! this is my first contact with python, I installed python 2.4 (on Win2k) and unzipped the MySQLdb package MySQL-Python 1.0.0 for win32 into Lib/site-packages. However, when I try to import the MySQLdb package, I am faced with the error message DLL load failed, in

Re: Parsing a search string

2004-12-31 Thread John Machin
Andrew Dalke wrote: It's me wrote: Here's a NDFA for your text: b 0 1-9 a-Z , . + - '\n S0: S0 E E S1 E E E S3 E S2 E S1: T1 E E S1 E E E E E E T1 S2: S2 E E S2 E E E E E T2 E S3: T3 E E S3 E E E E E E T3 Now if I only had an NDFA for

Re: Calling Function Without Parentheses!

2005-01-02 Thread John Machin
Kamilche wrote: What a debug nightmare! I just spent HOURS running my script through the debugger, sprinkling in log statements, and the like, tracking down my problem. I called a function without the ending parentheses. I sure do WISH Python would trap it when I try to do the following:

Re: Calling Function Without Parentheses!

2005-01-02 Thread John Machin
Dan Bishop wrote: Kamilche wrote: What a debug nightmare! I just spent HOURS running my script through the debugger, sprinkling in log statements, and the like, tracking down my problem. I called a function without the ending parentheses. I sure do WISH Python would trap it when I

Re: Py2exe and extension issues

2005-01-03 Thread John Machin
[EMAIL PROTECTED] wrote: Is anyone aware of issues with Py2exe and extensions compiled with cygwin/mingw for Python 2.3? I have an extension that wraps access to some C DLLs. The generated executable always segfaults at startup, although things work fine when running through the normal

Re: Speed ain't bad

2005-01-03 Thread John Machin
Anders J. Munch wrote: Another way is the strategy of it's easier to ask forgiveness than to ask permission. If you replace: if(not os.path.isdir(zfdir)): os.makedirs(zfdir) with: try: os.makedirs(zfdir) except EnvironmentError: pass then not only

Re: emulating an and operator in regular expressions

2005-01-03 Thread John Machin
Terry Reedy wrote: Craig Ringer [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] On Mon, 2005-01-03 at 08:52, Ross La Haye wrote: How can an and operator be emulated in regular expressions in Python? Regular expressions are designed to define and detect repetition and

Re: why does UserDict.DictMixin use keys instead of __iter__?

2005-01-04 Thread John Machin
Steven Bethard wrote: Sorry if this is a repost -- it didn't appear for me the first time. So I was looking at the Language Reference's discussion about emulating container types[1], and nowhere in it does it mention that .keys() is part of the container protocol. I don't see any reference

Re: Reaching the real world

2005-01-04 Thread John Machin
Fuzzyman wrote: I have a friend who would like to move and program lights and other electric/electro-mechanical devices by computer. I would like to help - and needless to say Python would be an ideal language for the 'programmers interface'. Try Googling for Python X10 --

Re: why does UserDict.DictMixin use keys instead of __iter__?

2005-01-04 Thread John Machin
Steven Bethard wrote: John Machin wrote: Steven Bethard wrote: So I was looking at the Language Reference's discussion about emulating container types[1], and nowhere in it does it mention that .keys() is part of the container protocol. I don't see any reference to a container

Re: Pythonic search of list of dictionaries

2005-01-04 Thread John Machin
Bulba! wrote: [big snip] Forget the csv-induced dicts for the moment, they're just an artifact of your first solution attempt. Whether english = csv_row[1], or english = csv_row_dict[english], doesn't matter yet. Let's take a few steps back, and look at what you are trying to do through a

Re: Speed revisited

2005-01-08 Thread John Machin
Bulba! wrote: On 4 Jan 2005 14:33:34 -0800, John Machin [EMAIL PROTECTED] wrote: (b) Fast forwarding 30+ years, let's look at the dictionary method, assuming you have enough memory to hold all your data at once: Step 1: read the left table; for each row, if english not in mydict, then do

Re: Speed revisited

2005-01-09 Thread John Machin
Bulba! wrote: On 8 Jan 2005 18:25:56 -0800, John Machin [EMAIL PROTECTED] wrote: Secondly, you are calling cmp() up to THREE times when once is enough. Didn't it occur to you that your last elif needed an else to finish it off, and the only possible action for the else suite was assert

Re: Python3: on removing map, reduce, filter

2005-01-09 Thread John Machin
Steven Bethard wrote: Note that list comprehensions are also C-implemented, AFAIK. Rather strange meaning attached to C-implemented. The implementation generates the code that would have been generated had you written out the loop yourself, with a speed boost (compared with the fastest DIY

Re: Speed revisited

2005-01-09 Thread John Machin
Andrea Griffini wrote: On 9 Jan 2005 12:39:32 -0800, John Machin [EMAIL PROTECTED] wrote: Tip 1: Once you have data in memory, don't move it, move a pointer or index over the parts you are inspecting. Tip 2: Develop an abhorrence of deleting data. I've to admit that I also found strange

Re: How To Read Excel Files In Python?

2005-12-15 Thread John Machin
An alternative: the xlrd module. Don't need Excel on your machine, don't even need Windows. Pure Python. Happily handles large files (e.g. 120 Mb). Good date support. See http://www.lexicon.net/sjmachin/xlrd.htm or look for xlrd in the Cheese Shop. --

Re: Find day of week from month and year

2005-09-14 Thread John Machin
Terry Reedy wrote: Laguna wrote: I want to find the expiration date of stock options (3rd Friday of the month) for an any give month and year. From year and month (and day=1) get the day of the week (n in [0,6]) of the first of the month using some version of the the standard formula (see

Re: evaluated function defaults: stored where?

2005-05-26 Thread John Machin
David Isaac wrote: Default parameter values are evaluated once when the function definition is executed. Where are they stored? A good bet for where to start looking for the storage would be as an attribute of the function object. From this point, there are two paths: (a) Make a function and

Re: Strange Execution Times

2005-05-26 Thread John Machin
[EMAIL PROTECTED] wrote: I am running two functions in a row that do the same thing. 1. I see no functions here. You should set out a script like this: def main(): your_code_goes_here() if __name__ == '__main__': main() for two reasons (a) your code will be referring to locals

Re: Strange Execution Times

2005-05-26 Thread John Machin
Elliot Temple wrote: [copying Elliot's e-mail reply back to the list because it's educational and scarcely private] On 5/26/05, John Machin [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] wrote: I am running two functions in a row that do the same thing. 1. I see no functions

Re: Case Sensitive, Multiline Comments

2005-05-26 Thread John Machin
Mike Meyer wrote: Personally, I think anyone who has two variables whose names differ only in case should be shot. No, let me extend that - anyone who has two variables whose names would be pronounced the same should be shot. I've had to debug such code, and it ain't fun. Here's a pair of

Re: overflowerror!!

2005-05-26 Thread John Machin
Will McGugan wrote: [EMAIL PROTECTED] wrote: I tried that. Still get an Overflowerror: unsigned long is less than minimum. You'll also need to reserve enough space for the 256 ints. Try this.. data = array('L', '\0' * 256*4) I don't understand. Why not just do the whole thing

Re: Strange Execution Times

2005-05-27 Thread John Machin
Elliot Temple wrote: On May 26, 2005, at 3:22 PM, John Machin wrote: Then post your summarised results back to the newsgroup for the benefit of all -- there's this vague hope that folk actually read other peoples' posts before firing off questions :-) Here is my new version

Re: Strings for a newbie

2005-05-27 Thread John Machin
Malcolm Wooden wrote: I'm trying to get my head around Python but seem to be failing miserably. I use RealBasic on a Mac and find it an absolute dream! But PythonUGH! I want to put a sentence of words into an array, eg This is a sentence of words In RB it would be simple: Dim s

Re: Strings for a newbie

2005-05-27 Thread John Machin
Malcolm Wooden wrote: Sorry John but that don't do it for me. Just get errors comming back John Machin [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] s = This is a sentence of words a = s.split() a ['This', 'is', 'a', 'sentence', 'of', 'words'] Malcolm, What errors did

  1   2   3   4   5   6   7   8   9   10   >