Re: greatest and least of these...

2007-10-23 Thread Jason Drew
What do you mean when you say the menu doesn't kick in? Do you get an exception, or does simply nothing happen? Before the if statements, you should put "print choice" so you can see what value is being returned by the input function. Also maybe "print type(choice)" for a bit more inspection. Spe

Re: simple regular expression problem

2007-09-17 Thread Jason Drew
31 am, duikboot <[EMAIL PROTECTED]> wrote: > Thank you very much, it works. I guess I didn't read it right. > > Arjen > > On Sep 17, 3:22 pm, Jason Drew <[EMAIL PROTECTED]> wrote: > > > You just need a one-character addition to your regex: > > > regex = re

Re: simple regular expression problem

2007-09-17 Thread Jason Drew
You just need a one-character addition to your regex: regex = re.compile(r'', re.S) Note, there is now a question mark (?) after the .* By default, regular expressions are "greedy" and will grab as much text as possible when making a match. So your original expression was grabbing everything bet

Re: Lists in classes

2007-07-12 Thread Jason Drew
Thanks for clearing up the other incorrect answers! In true Python fashion, I would also remind everyone of the *documentation* - in particular the Python tutorial. These are very elementary mistakes to be making - even worse as part of attempted answers. The Python tutorial is at http://docs.pyth

Re: How to move optparse from main to function?

2006-02-24 Thread Jason Drew
You're welcome! As usual, each of us is free to write the code whichever way works best for the particular problem at hand. That's why the module documentation often avoids advocating here-is-the-one-best-way-to-do-it. I just like sticking all the option setup stuff in a single function because i

Re: How to move optparse from main to function?

2006-02-23 Thread Jason Drew
As pointed out, the module documentation is helpful. For your 'test' option, I don't think 'action="count"' is the best action. 'Test' is basically an on/off option, so why count it? I would use: parser.add_option("-t", "--test", action="store_true", dest="optparse_test", default=False, help="tes

Re: converting sqlite return values

2006-02-20 Thread Jason Drew
Hi, You can use the built-in function "eval" to return how Python evaluates your string. For example: >>> eval( '(1,2,3,4)' ) (1, 2, 3, 4) In other words, eval will take your string that looks like a tuple, and return an actual tuple object. Note that the 'u' prefix in your string will cause an

Re: Sorta noob question - file vs. open?

2005-08-23 Thread Jason Drew
Both your code snippets above work should work OK. If it seems like a file isn't being written, maybe you should specify its full path so you are sure about where to check for it. On the file-or-open question, the Python docs state, "The intent is for open() to continue to be preferred for use as

Re: What is Python?!

2005-08-10 Thread Jason Drew
Roy Smith wrote: "there's a system called Jython, which lets you compile Java source to Python byte code." Don't you have that the wrong way 'round? From the Jython website: "Jython is an implementation of the high-level, dynamic, object-oriented language Python written in 100% Pure Java, and seam

Re: Documentation

2005-08-10 Thread Jason Drew
The standard pydoc module is very useful. A simple example of how you could use it: >>> import pydoc >>> mymodule = pydoc.importfile(r"C:\My Py\my_foo.py") >>> html = pydoc.html.page(pydoc.describe(mymodule), >>> pydoc.html.document(mymodule)) >>> open("foo.html", "w").write(html) Then you have

Re: Hiding

2005-08-01 Thread Jason Drew
Ah, good point, thanks. Must stop forgetting that "C:\file.txt" is bad. The whole open()/file() clairification is useful too. The Python docs for the file() constructor simply state that, "File objects ... can be created with the built-in constructor file() described in section 2.1, 'Built-in Func

Re: Hiding

2005-07-29 Thread Jason Drew
Well, using the open function in Python doesn't launch any application associated with the file (such as Media Player). It just makes the contents of the file accessible to your Python code. Also, I think using file("C:\file.txt") is now preferred to open("C:\file.txt"). To answer the specific que

Re: retrieve data from 2 database

2005-07-28 Thread Jason Drew
For a start, asking a better question will get better answers: http://www.catb.org/~esr/faqs/smart-questions.html Googling for python odbc gives this as the first result: http://www.python.org/windows/win32/odbc.html In general, how you compare database tables will depend a lot on the nature of t

Re: tuple to string?

2005-07-22 Thread Jason Drew
''.join((chr(e) for e in (0x73, 0x70, 0x61, 0x6D))) -- http://mail.python.org/mailman/listinfo/python-list

Re: Changing size of Win2k/XP console?

2005-07-14 Thread Jason Drew
SetConsoleWindowInfo looks like a better candidate. See http://tinyurl.com/budzk (I.e. http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/setconsolewindowinfo.asp) Haven't tried it though. Good luck! -- http://mail.python.org/mailman/listinfo/python-list

Re: Convert from numbers to letters

2005-05-20 Thread Jason Drew
Hey, that's good. Thanks Steve. Hadn't seen it before. One to use. Funny that Pythonwin's argument-prompter (or whatever that feature is called) doesn't seem to like it. E.g. if I have def f(tupl): print tupl Then at the Pythonwin prompt when I type f( I correctly get "(tupl)" in the argumen

Re: Convert from numbers to letters

2005-05-20 Thread Jason Drew
Sorry, scratch that "P.S."! The act of hitting Send seems to be a great way of realising one's mistakes. Of course you need colnr - m for those times when m is set to 26. Remembered that when I wrote it, forgot it 2 paragraphs later! -- http://mail.python.org/mailman/listinfo/python-list

Re: Convert from numbers to letters

2005-05-20 Thread Jason Drew
Er, yes! It's REALLY ugly! I was joking (though it works)! I retract it from the code universe. (But patent pending nr. 4040404.) Here's how I really would convert your (row_from_zero, col_from_zero) tuple to spreadsheet "A1" coords, in very simple and easy to read code. ##def tuple2coord(tupl):

Re: Convert from numbers to letters

2005-05-19 Thread Jason Drew
Oh yeah, oops, thanks. (I mean the line continuations, not the alleged sin against man and nature, an accusation which I can only assume is motivated by jealousy :-) Or fear? They threw sticks at Frankenstein's monster too. And he turned out alright. My elegant "line" of code started out without t

Re: Convert from numbers to letters

2005-05-19 Thread Jason Drew
We weren't really backwards; just gave a full solution to a half-stated problem. Bill, you've forgotten the least-lines-of-code requirement :-) Mine's still a one-liner (chopped up so line breaks don't break it): z = lambda cp: (int(cp[min([i for \ i in xrange(0, len(cp)) if \ cp[i].isdi

Re: Convert from numbers to letters

2005-05-19 Thread Jason Drew
It seems strange to want to set the values in actual variables: a, b, c, ..., aa, ab, ..., aaa, ..., ... Where do you draw the line? A function seems more reasonable. "In terms of lines of code" here is my terse way of doing it: nrFromDg = lambda dg: sum(((ord(dg[x])-ord('a')+1) * (26 ** (len(dg

Re: CGI on Windows

2005-05-16 Thread Jason Drew
Rainer Mansfeld wrote: > Jason Drew wrote: > > I believe you're experiencing a bug that I also encountered, and for > > which there is a patch. See: > > http://sourceforge.net/tracker/?group_id=5470&atid=105470&func=detail&aid=1110478 > > > > F

Re: CGI on Windows

2005-05-16 Thread Jason Drew
I believe you're experiencing a bug that I also encountered, and for which there is a patch. See: http://sourceforge.net/tracker/?group_id=5470&atid=105470&func=detail&aid=1110478 Fixing os.py as described in the patch fixed all my CGI-related problems. Hope it does for you too! Jason -- http:/