Heterogeneous lists

2007-08-07 Thread Gordon Airporte
This is one of those nice, permissive Python features but I was wondering how often people actually use lists holding several different types of objects. It looks like whenever I need to group different objects I create a class, if only so I can use more meaningful names than '[2]' for the items

Re: Any way to monitor windows network connection?

2007-07-31 Thread Gordon Airporte
momobear wrote: > hi, Is there any way to show me detailed listings of all TCP and UDP > endpoints in my microsoft windows XP in python way? > thanks. Unless you're looking for a programming exercise: http://www.microsoft.com/technet/sysinternals/Utilities/TcpView.mspx -- http://mail.python.org/

Re: idiom for RE matching

2007-07-25 Thread Gordon Airporte
Ben Finney wrote: > > Not that I want to pick on you; I just don't want something wrong > labelled as "proper" to go unchallenged in the archives :-) Oh gawd :-P I swear I have it right in the actual file! heh. Copy and paste something that's compiled kids, copy and paste. -- http://mail.pytho

Re: idiom for RE matching

2007-07-25 Thread Gordon Airporte
Miles wrote: > On 7/24/07, Gordon Airporte <[EMAIL PROTECTED]> wrote: >> I did already find that it speeds things up to pre-test a line like >> >> if 'bets' or 'calls' or 'raises' in line: >> run the appropriate re's >

Re: idiom for RE matching

2007-07-24 Thread Gordon Airporte
Gabriel Genellina wrote: > As is often the case, a regular expression is NOT the right tool to use > in this case. > > --Gabriel Genellina Very interesting, thank you. I think 'pattern matching' and I automatically think 'regular expressions'. I did already find that it speeds things up to pre

Re: idiom for RE matching

2007-07-23 Thread Gordon Airporte
[EMAIL PROTECTED] wrote: > if your search is not overly complicated, i think regexp is not > needed. if you want, you can post a sample what you want to search, > and some sample input. I'm afraid it's pretty complicated :-). I'm doing analysis of hand histories that online poker sites leave for

Re: Where is the collections module?

2007-07-22 Thread Gordon Airporte
Gordon Airporte wrote: > I was going to try tweaking defaultdict, but I can't for the life of me > find where the collections module or its structures are defined. Python > 2.5. Thanks all. I was expecting it in Python. Time to dust off my C :-P -- http://mail.python.org/ma

Re: idiom for RE matching

2007-07-22 Thread Gordon Airporte
[EMAIL PROTECTED] wrote: > Have you read and understood what MULTILINE means in the manual > section on re syntax? > > Essentially, you can make a single pattern which tests a match against > each line. > > -- Michael Dillon No, I have not looked into this - thank you. RE's are hard enough to g

Where is the collections module?

2007-07-22 Thread Gordon Airporte
I was going to try tweaking defaultdict, but I can't for the life of me find where the collections module or its structures are defined. Python 2.5. -- http://mail.python.org/mailman/listinfo/python-list

Re: A way to re-organize a list

2007-07-19 Thread Gordon Airporte
beginner wrote: > > What I want to do is to reorganize it in groups, first by the middle > element of the tuple, and then by the first element. I'd like the > output look like this: itertools.groupby has already been mentioned, but it has a very specific and complex behavior which may not be exa

idiom for RE matching

2007-07-18 Thread Gordon Airporte
I have some code which relies on running each line of a file through a large number of regexes which may or may not apply. For each pattern I want to match I've been writing gotit = mypattern.findall(line) if gotit: gotit = gotit[0] ...do whatever else... This seems kind of clun

Re: itertools.groupby

2007-05-28 Thread Gordon Airporte
Paul Rubin wrote: > It chops up the iterable into a bunch of smaller ones, but the total > size ends up the same. "Telescope", "compact", "collapse" etc. make > it sound like the output is going to end up smaller than the input. Good point... I guess I was thinking in terms of the number of iter

Re: itertools.groupby

2007-05-28 Thread Gordon Airporte
7stud wrote: > Bejeezus. The description of groupby in the docs is a poster child > for why the docs need user comments. Can someone explain to me in > what sense the name 'uniquekeys' is used this example: > This is my first exposure to this function, and I see that it does have some uses in

ClientForm .click() oddity

2007-05-14 Thread Gordon Airporte
I've written a script using ClientForm to automate opening and closing ports on my Linksys router. It works, but I wonder if there isn't a better way to do it. The problem is that the list of arguments in the request generated by .click()ing the form is incomplete and I have to edit it manually.

Re: searching algorithm

2007-05-10 Thread Gordon Airporte
> For the above (abrideged) dictionary, you would generate (use a > fixed-width "programmers" font so the tree looks good): > > a > | > b > | > s > / \ >i o > / /

Re: Watching a file another app is writing

2007-03-12 Thread Gordon Airporte
Vishal Bhargava wrote: > What kind of file is it? CSV? It's a hand history file generated by an online poker client, thus it probably keeps it's data pretty much to itself otherwise, and in any case I'm not a Windows programmer so I probably don't have the stomach to get very deep into its proc

Re: Watching a file another app is writing

2007-03-12 Thread Gordon Airporte
Gabriel Genellina wrote: > This article explains it in detail: > http://tgolden.sc.sabren.com/python/win32_how_do_i/watch_directory_for_changes.html > > > BTW, it's the top result on Google for "python notify file change windows" > > --Gabriel Genellina Ah, excelent. Thank you. I'd started w

Re: Watching a file another app is writing

2007-03-11 Thread Gordon Airporte
Nick Vatamaniuc wrote: > You might need to look at pywin32 for Windows specific ways to listen > to "file changed" event. > > On Unix a quick shortcut would be to simply read the output of 'tail - > f ' command... Ah, I forgot I have Cygwin installed, so I do have tail. Unfortunately Windows w

Watching a file another app is writing

2007-03-11 Thread Gordon Airporte
I'm trying to find a way to take a file that another program has opened and writes to periodically, open it simultaneously in Python, and automatically update some of my objects in Python when the file is written to. I can open the file and manually readlines() from it to keep up to date, it's

Re: Type-checking unpickled objects

2005-11-20 Thread Gordon Airporte
> I guess I'll > need a throwaway instance of the class to run type() on to get a usable > type object for comparison, but I'll work something out. Never mind - I can just pass the name of the class, as it should be. -- http://mail.python.org/mailman/listinfo/python-list

Re: Type-checking unpickled objects

2005-11-20 Thread Gordon Airporte
isinstance! Now why didn't I know about that? Thanks you. I guess I'll need a throwaway instance of the class to run type() on to get a usable type object for comparison, but I'll work something out. As to the security considerations...this is a small enough program with a limited enough release

Type-checking unpickled objects

2005-11-18 Thread Gordon Airporte
I have this class, and I've been pickling it's objects as a file format for my program, which works great. The problems are a.) how to handle things when the user tries to load a non-pickled file, and b.) when they load a pickled file of the wrong class. a. I can handle with a general exception

Returning a value from a Tk dialog

2005-11-07 Thread Gordon Airporte
The dialogs in tkColorChooser, tkFileDialog, etc. return useful values from their creation somehow, so I can do stuff like this: filename = tkFileDialog.askopenfilename( master=self ) I would like to make a Yes/No/Cancel dialog that can be used the same way (returning 1/0/-1), but I just cannot

Generic utility class for passing data

2005-10-28 Thread Gordon Airporte
I'm wondering if this is might be bad practice. Sometimes when I need to pass around several pieces of datum I will put them in a tuple, then when I need to use them in a receiving function I get them out with subscripts. The problem is that the subscript number is completely meaningless and I

Re: Tkinter - Resizing a canvas with a window

2005-07-27 Thread Gordon Airporte
Thanks you very much. I found something interesting though, the canvas's width and height properties are not updated when it is resized by its packing. Looks like an oversight to me, but I've just demonstrated that I don't have a complete grasp of Tk, so... I can use a Configure callback to kee

Tkinter - Resizing a canvas with a window

2005-07-26 Thread Gordon Airporte
I'm trying to get my canvas to resize to fill its frame within a window, but I can't figure out how to handle the callback data from the window's properly. It has very strange behavior - resizing randomly or growing by itself, shrinking to 0. The following works passably but jumps around at ra