Re: for -- else: what was the motivation?

2022-10-22 Thread Drew Pierson
the fuck? On Sat, Oct 22, 2022 at 9:06 AM Peter J. Holzer wrote: > On 2022-10-19 12:10:52 +1100, Chris Angelico wrote: > > On Wed, 19 Oct 2022 at 12:01, Peter J. Holzer wrote: > > > On 2022-10-17 09:25:00 +0200, Karsten Hilbert wrote: > > > > http://literateprogramming.com/ > > > > > > Right. T

Re: Installing ssdeep on Portable Python

2016-03-08 Thread morr . drew
Were you able to solve this problem? I am also seeing this On Thursday, March 20, 2014 at 2:22:19 PM UTC-4, lagu...@mail.com wrote: > Portable Python 2.7 for Windows, the Python application have dependency on > ssdeep-2.10, which is a binary exe. > > The ssdeep (libfuzzy) installation example wa

python-list history

2013-11-26 Thread Drew Crawford
Hello folks, I’m interested in digging up some Python mailing list archives from ages past. Google Groups’ archive goes sporadically back to ’94, but clearly the list is older. Does any one have a lead on where I could get an archive of the very oldest posts to this list? Drew -- https

Re: How to pass class instance to a method?

2012-11-26 Thread Drew
On Sunday, November 25, 2012 7:11:29 AM UTC-5, ALeX inSide wrote: > How to "statically type" an instance of class that I pass to a method of > other instance? > > > > I suppose there shall be some kind of method decorator to treat an argument > as an instance of class? > > > > Generally it

Re: python on iPad (PyPad)

2011-05-05 Thread Drew
uite excited about this. It will certainly be better > than my current workflow of connecting via ssh to a server just to run > python code. > > Matt. There's a Pypad on SourceForge, but it is flagged as no longer under active development. Dead or just sleeping? Is this Pypad distinct from that old one on SourceForge? Or a revival? OpenSource? Drew -- http://mail.python.org/mailman/listinfo/python-list

Re: Need help improving number guessing game

2008-12-16 Thread r . drew . davis
so you can track the evolution and refinement of your source code over time. The player-visible part of that is perhaps just to have something that announces which revision of the game they are running such that you can tell from that which revision of the source code to look at if you are tracking down a fix for a problem they have encountered and reported to you. Drew -- http://mail.python.org/mailman/listinfo/python-list

filter func chaining

2008-11-28 Thread Drew Schaeffer
collection) Traceback (most recent call last): File , line 0, in ##44 File c:\proj\ofts\com.oakwoodft.ofts.compliance\complianceframework\filters\assetfilters.py, line 5, in is not enumerable Am I going about this totally wrong? Is there a better solution? Thanks. Drew Schaeffer -- http

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

FastCGI on Windows: socket.fromfd() support?

2007-10-10 Thread Drew
Microsoft's IIS server recently added native support for FastCGI. The big roadblock to Python support seems to be that socket.fromfd() doesn't work on Windows. Are there any plans to add this or similar functionality to the Windows build? Thanks, Drew -- http://mail.python.org/mailma

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: Simple csv read/write

2007-04-26 Thread Drew
On Apr 24, 8:35 pm, John Machin <[EMAIL PROTECTED]> wrote: > On 25/04/2007 8:27 AM, Drew wrote: > > > Ok, I'm trying to do the simplest read/write from one csv file to > > another. For some reason, every other row on the output file is a > > blank row. What

Simple csv read/write

2007-04-24 Thread Drew
Ok, I'm trying to do the simplest read/write from one csv file to another. For some reason, every other row on the output file is a blank row. What am I doing wrong? import csv reader = csv.reader(open('current.csv')) writer = csv.writer(open('new.csv','w')) for line in reader: writer.writer

Blank rows resulting from simple csv script

2007-04-24 Thread Drew
v','w')) for row in reader: if row[3] == '0': writer.writerow(row) This is writing out the correct rows, however it is writing a blank row between each of the rows written out. Any ideas? Thanks, Drew -- http://mail.python.org/mailman/listinfo/python-list

Blank rows resulting from simple csv script

2007-04-24 Thread Drew
v','w')) for row in reader: if row[3] == '0': writer.writerow(row) This is writing out the correct rows, however it is writing a blank row between each of the rows written out. Any ideas? Thanks, Drew -- http://mail.python.org/mailman/listinfo/python-list

Re: Code Explaination: Spelling correction code

2007-04-12 Thread Drew
On Apr 12, 10:28 am, Steven Bethard <[EMAIL PROTECTED]> wrote: > Drew wrote: > > On Apr 11, 11:27 pm, Steven Bethard <[EMAIL PROTECTED]> wrote: > >> Drew wrote: > >>> def known_edits2(word): > >>> return set(e2 for e1 in edits1(word) for

Re: Code Explaination: Spelling correction code

2007-04-12 Thread Drew
On Apr 11, 11:27 pm, Steven Bethard <[EMAIL PROTECTED]> wrote: > Drew wrote: > > I recently saw this website:http://www.norvig.com/spell-correct.html > > > All the code makes sense to me save one line: > > > def known_edits2(word): > > return set(e2 for

Code Explaination: Spelling correction code

2007-04-11 Thread Drew
I recently saw this website: http://www.norvig.com/spell-correct.html All the code makes sense to me save one line: def known_edits2(word): return set(e2 for e1 in edits1(word) for e2 in edits1(e1) if e2 in NWORDS) I understand (from seeing a ruby version of the code) that the goal here is t

Re: Converting a list to a dictionary

2007-03-14 Thread Drew
On Mar 14, 4:52 pm, "Samuel" <[EMAIL PROTECTED]> wrote: > On Mar 14, 9:48 pm, "Drew" <[EMAIL PROTECTED]> wrote: > > > This is interesting behavior, but may not be what the original poster > > intended. > > I am the original poster :). >

Re: Converting a list to a dictionary

2007-03-14 Thread Drew
On Mar 14, 4:43 pm, "Samuel" <[EMAIL PROTECTED]> wrote: > What this does is it maps the id to the object. In your case, you only > have one id. > > -Samuel This is interesting behavior, but may not be what the original poster intended. If I understand correctly, this means that if more than one ob

Re: Converting a list to a dictionary

2007-03-14 Thread Drew
On Mar 14, 4:52 pm, Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: > res_dict = dict((r.get_id(), r) for r in res_list) I'm using Python2.5 and it seems that this only gives me a hash with the first id and first record. Am I doing something wrong? >>> class Person(): ... def __init__(self):

Re: dict.items() vs dict.iteritems and similar questions

2007-03-14 Thread Drew
On Mar 14, 2:53 pm, [EMAIL PROTECTED] wrote: > >> When is it appropriate to use dict.items() vs dict.iteritems. > > Laurent> Both work, you may prefer xrange/iteritems for iteration on > Laurent> large collections... > > I find "iter" to be extremely ugly and hope to avoid using them >

Re: dict.items() vs dict.iteritems and similar questions

2007-03-14 Thread Drew
are > going to manipulate the original container in the loop. > > A+ > > Laurent. Laurent - Extremely helpful, exactly what I was looking for. Thanks, Drew -- http://mail.python.org/mailman/listinfo/python-list

dict.items() vs dict.iteritems and similar questions

2007-03-14 Thread Drew
() essentially gives you an iterator across a range, so it should be used when iterating. Should you only use range() when want to physically store the range as a list? Thanks, Drew -- http://mail.python.org/mailman/listinfo/python-list

Re: Iterating across a filtered list

2007-03-13 Thread Drew
preferred rather than initially filtering and then iterating. However, you're examples make a lot of sense are are quite helpful. Thanks, Drew -- http://mail.python.org/mailman/listinfo/python-list

Iterating across a filtered list

2007-03-13 Thread Drew
All - I'm currently writing a toy program as I learn python that acts as a simple address book. I've run across a situation in my search function where I want to iterate across a filtered list. My code is working just fine, but I'm wondering if this is the most "elegant" way to do this. Essentiall

Re: List Behavior when inserting new items

2007-01-29 Thread Drew
> > Is there any way to produce this kind of behavior easily?Hints: > >>> [None] * 5 > [None, None, None, None, None] > >>> [1, 2, 3, None] + [10] > [1, 2, 3, None, 10] > > HTH That is exactly what I was looking for. I'm actually working on some problems at http://codgolf.com. I find it helps

Re: List Behavior when inserting new items

2007-01-29 Thread Drew
every time I add an element, I could find the difference between the size of the list and the desired index and fill in the range between with " " values, however I just wanted to see if there was a more natural way in the language. Thanks, Drew -- http://mail.python.org/mailman/listinfo/python-list

List Behavior when inserting new items

2007-01-29 Thread Drew
ind of behavior easily? Thanks, Drew -- http://mail.python.org/mailman/listinfo/python-list

Re: multiple file deletes using ftp.delete

2007-01-20 Thread Drew
On Jan 19, 11:16 pm, "Drew" <[EMAIL PROTECTED]> wrote: > Hi all > I'm fairly new to python so please forgive my lack of comprehension of > the obvious. > > I'm writing a script to ftp files to a server. This script will run > weekly. Part of the script

multiple file deletes using ftp.delete

2007-01-19 Thread Drew
ull name of the files that need to be deleted. All the files start with the same string but have different extensions (eg drew.1 drew.2 drew.tmp drew.hlp). So I was wondering if anybody knows how to use a wild card similar to * in UNIX to do the delete? Something like: ftp.delete("drew.*")

Zenoss Version 0.22.3 Available

2006-09-18 Thread Drew Bray
st of 2006. (http://www.zenoss.org/ about/news_items/articles/nw-10towatch) Zenoss is currently hiring talented Zope & Python developers. Join the team! http://www.zenoss.org/jobs. Enjoy, Drew Project Zenoss [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

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: Guido at Google

2005-12-22 Thread drew . smathers
And I have around one year to wait for Ruby to get rid of the nasty syntax copied from Perl and make it look as beautiful as Python Then I'll consider switching. ;) Ummm, I'm sorry, did you say clean reflective meta-model??? So this: caller[0] =~ /in `([^']+)'/ ? $1 : '(anonymous)' vs. th

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

MySQL newsgroup proposal.

2005-06-06 Thread William Drew
ANNOUNCEMENT: A RFD (REQUEST FOR DISCUSSION) has been posted for the creation of a new Usenet newsgroup: comp.databases.mysql The proposal and related discussion can be read in the Usenet group news.groups ... feel free to weigh in and make any suggestions you may have. Message-ID: <[EMAI

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:/