Re: Evil, evil wxPython (and a glimmer of hope)

2006-02-17 Thread snoe
[EMAIL PROTECTED] wrote: I rarely do GUIs, and reminded myself today why that is the case (simply, it's not fun). I implemented a simple TreeCtrl, and had to implement my own 'children' method, of all things! Here it is: def children(self,node): c = [] nc,cookie =

Re: is there a better way?

2006-02-10 Thread snoe
[EMAIL PROTECTED] wrote: Problem: You have a list of unknown length, such as this: list = [X,X,X,O,O,O,O]. You want to extract all and only the X's. You know the X's are all up front and you know that the item after the last X is an O, or that the list ends with an X. There are never O's

Re: Too Many if Statements?

2006-02-07 Thread snoe
slogging_away wrote: Hi - I'm running Python 2.4.2 (#67, Sep 28 2005, 12:41:11) [MSC v.1310 32 bit (Intel)] on win32, and have a script that makes numerous checks on text files, (configuration files), so discrepancies can be reported. The script works fine but it appears that I may have hit a

Re: Code Feedback

2006-02-06 Thread snoe
I believe the while 1: pass is there to keep the main thread alive until all the readers are done. If you want the program to end after the readers are done you can append them all to a list then iterate through and wait for the threads to join() if __name__==__main__: library = Library()

Re: Changing numbers into characters using dictionaries

2006-01-26 Thread snoe
Ok there's a couple things going on here. t = text.split('@') // splits the digits/blocks apart from each other this will give you a list: ['', '7706', '7002', '7075', '7704'] You may want to change the line to skip the first empty value: t = text.split('@')[1:] Next your loop. something = 1

Re: forced spaces when inserting a variable between strings

2006-01-17 Thread snoe
You can use: print img src=%s.jpg % (number) or print img src=+str(number)+.jpg or a number of others, but for short strings one of these two generally work fine. -- http://mail.python.org/mailman/listinfo/python-list

Re: MVC in wxPython HELP!

2006-01-11 Thread snoe
See this recent explanation by has: http://groups.google.ca/group/comp.lang.python/msg/f8990a2c666a793c?hl=en; (The rest of the thread may lead you to more concrete examples as well.) -- http://mail.python.org/mailman/listinfo/python-list

Re: strange behaviour when writing a large amount of data on stdout

2005-11-23 Thread snoe
Python 2.4 (#60, Nov 30 2004, 11:49:19) [MSC v.1310 32 bit (Intel)] on win32 No problems on Windows 2000 Pro with 512MB of RAM -- http://mail.python.org/mailman/listinfo/python-list

Re: asyncore question

2005-11-23 Thread snoe
Not 100% sure why print d gives None but if you need to print something that represents the instance, use repr d.__str__ method-wrapper object at 0x0098C450 str(d) 'None' repr(d) 'asyncore.dispatcher at 0x8d5be8' print repr(d) asyncore.dispatcher at 0x8d5be8 Why isn't __str__ in dir?

Re: Cursor Position.

2005-11-16 Thread snoe
This script should be a good start: from ctypes import * import time PUL = POINTER(c_ulong) class KeyBdInput(Structure): _fields_ = [(wVk, c_ushort), (wScan, c_ushort), (dwFlags, c_ulong), (time, c_ulong), (dwExtraInfo, PUL)] class

Re: Hash map with multiple keys per value ?

2005-11-11 Thread snoe
Are you looking for this type of thing? class Test: value = 900 t = Test() d['1'] = t d['2'] = t d['3'] = t d['3'].value = 800 d['1'].value -- http://mail.python.org/mailman/listinfo/python-list

Re: Function to execute only once

2005-10-14 Thread snoe
I've been seeing alot about decorators and closures lately and my initial thought was that this would be a good place to use them instead of wrapping it around a class. That was my initial thought :) What I came up with was this: def execute_once(fn): result = None def executor(*args,

Re: Function to execute only once

2005-10-14 Thread snoe
The problem seemed to be because I was rebinding result inside executor. Can someone explain why it works below but not in the first one? Also why is it if I set tmp as a global and don't pass it as a paremeter to the various functions as per the OP that I get an UnboundLocalError: local variable

Wrapping a class set method

2005-07-27 Thread snoe
Hi there, I have the following simplified classes: class Project: def __init__(self,pname): self.devices = {} # Dictionary of Device objects self.pname = pname def setpname(self,pname): self.pname = pname def adddevice(self,dname):

Re: Mouseclick

2005-05-02 Thread snoe
I did this a little while ago, there's some setup stuff in here for sending keyboard commands as well. Coercing the structs into python was the hardest part. Basically Click(x,y) moves the mouse to the specified spot on the screen (not window) sends a mouse down followed by mouse up event then

Re: Help Optimizing Word Search

2005-01-12 Thread snoe
With a list of letters: 'ABAE?S?' your implementation ran 3.5 times faster than the one from http://blog.vrplumber.com/427 (in 0.437 seconds vs 1.515) Without wildcards yours runs slightly quicker as well. I guess with the wildcards, using an re as a quick filter against each word, versus the

Re: Help Optimizing Word Search

2005-01-11 Thread snoe
First of all thank you very much for the reply. I hope I'm not too verbose here, just hope that if someone else runs into a similar problem they can find an answer here. This appears to be a Computer Science 101 Data Structures and Algorithms question, not a Python question, but here's an

Re: Help Optimizing Word Search

2005-01-11 Thread snoe
Mike, Thanks, this worked great, and was 4x faster than my method! Thanks everyone for replying! The changes I made were: !rest = ''.join([chr(i) for i in range(256) if chr(i).upper() not in WORD]) !# a wildcard in the word means that we check all letters !if '?' in WORD: !rest = ''