How to create a PUG mailing list?

2007-10-25 Thread Kevin D. Smith
I'm trying to get a Python User Group started in Norman, OK and I want 
to get one of those fancy mailing lists on mail.python.org.  There is a 
link there to create a new list if you have the proper authority.  How 
does someone get the proper authority?

-- 
Kevin D. Smith

-- 
http://mail.python.org/mailman/listinfo/python-list


Debugging a Python Program that Hangs

2008-12-02 Thread Kevin D . Smith
I have a fairly large python program that, when a certain combination 
of options is used, hangs.  I have no idea where it is hanging, so 
simply putting in print statements to locate the spot would be quite 
difficult.  Unfortunately, ctrl-C'ing the program doesn't print a 
traceback either.  Looking through the python debugger documentation, I 
don't see how to run a python program and interactively stopping it 
while it is running.  Is there a way to stop within a running python 
program to see where it is getting hung up?


--
Kevin D. Smith

--
http://mail.python.org/mailman/listinfo/python-list


PIL: Getting a two color difference between images

2008-10-24 Thread Kevin D . Smith
I'm trying to get the difference of two images using PIL.  The 
ImageChops.difference function does almost what I want, but it takes 
the absolute value of the pixel difference.  What I want is a two color 
output image: black where the image wasn't different, and white where 
it was different.  Right now I get black where it wasn't different, and 
abs(image1-image2) where it was different.


It would be nice if I could specify the colors for difference and no 
difference.  This sounds like it should be easy, but I just don't see 
how to do it.


--
Kevin D. Smith

--
http://mail.python.org/mailman/listinfo/python-list


Re: PIL: Getting a two color difference between images

2008-10-27 Thread Kevin D . Smith

On 2008-10-25 12:41:51 -0500, [EMAIL PROTECTED] said:

Kevin D. Smith:
What I want is a two color output image: black where the image wasn't 
different, and white where it was different.<


There are several ways to do that. If speed isn't essential, then you
can create a third blank image of the right size, and then use the
method that iterates on the pixels of an image, and assign p1 != p2 at
every pixel of the third image.

If speed is important you can copy the images into numpy arrays and
then your operation becomes easy.

Maybe there are built-in ways in PIL too, I don't know. You can also
find an intermediate solution, like computing the difference image
with PIL and then binarize it manually.


This last method is what I ended up doing for now.  I use the PIL 
differencing function, then walk through the result of getdata() to 
binarize it.  I was hoping there might be a way to run a filter or 
something that might be faster, but I haven't figured it out.


--
Kevin D. Smith

--
http://mail.python.org/mailman/listinfo/python-list


Doc strings in descriptors

2009-05-02 Thread Kevin D . Smith

I have a simple descriptor to create a cached property as shown below.

class cproperty(object):
   """ Property whose value is only calculated once and cached """
   def __init__(self, func):
   self._func = func
   self.__doc__ = func.__doc__
   def __get__(self, obj, type=None):
   if obj is None:
   return self
   try:
   return getattr(obj, '@%s' % self._func.func_name)
   except AttributeError:
   result = self._func(obj)
   setattr(obj, '@%s' % self._func.func_name, result)
   return result

The problem is that when I use the help() function on them, I don't get 
the doc string from the function that is being wrapped.  Instead, I get 
the following:


   hasEmployees = 

What do I need to do to get the doc string of the wrapped function to 
apper when using help()?


--
Kevin D. Smith

--
http://mail.python.org/mailman/listinfo/python-list


heapq.merge with key=

2009-05-07 Thread Kevin D . Smith
I need the behavior of heapq.merge to merge a bunch of results from a 
database.  I was doing this with sorted(itertools.chain(...), key=...), 
but I would prefer to do this with generators.  My issue is that I need 
the key= argument to sort on the correct field in the database.  
heapq.merge doesn't have this argument and I don't understand the code 
enough to know if it's possible to add it.  Is this enhancement 
possible without drastically changing the current code?


--
Kevin D. Smith

--
http://mail.python.org/mailman/listinfo/python-list


Re: heapq.merge with key=

2009-05-08 Thread Kevin D . Smith

On 2009-05-07 23:48:43 -0500, Chris Rebert  said:


On Thu, May 7, 2009 at 2:23 PM, Kevin D. Smith  wrote:

I need the behavior of heapq.merge to merge a bunch of results from a
database.  I was doing this with sorted(itertools.chain(...), key=

...), but

I would prefer to do this with generators.  My issue is that I need

the key

argument to sort on the correct field in the database.  heapq.merge

doesn't

have this argument and I don't understand the code enough to know if it's
possible to add it.  Is this enhancement possible without drasticall

y

changing the current code?


I think so. Completely untested code:

def key(ob):
#code here

class Keyed(object):
def __init__(self, obj):
self.obj = obj
def __cmp__(self, other):
return cmp(key(self.obj), key(other.obj))

def keyify(gen):
for item in gen:
yield Keyed(item)

def stripify(gen):
for keyed in gen:
yield keyed.obj

merged = stripify(merge(keyify(A), keyify(B), keyify(C))) #A,B,C being
the iterables


Ah, that's not a bad idea.  I think it could be simplified by letting 
Python do the comparison work as follows (also untested).


def keyify(gen, key=lamda x:x):
   for item in gen:
   yield (key(item), item)

def stripify(gen):
   for item in gen:
   yield item[1]

After looking at the heapq.merge code, it seems like something like 
this could easily be added to that code.  If the next() calls were 
wrapped with the tuple creating code above and the yield simply 
returned the item.  It would, of course, have to assume that the 
iterables were sorted using the same key, but that's better than not 
having the key option at all.


--
Kevin D. Smith

--
http://mail.python.org/mailman/listinfo/python-list


Re: 2.6 windows install

2009-08-21 Thread Kevin D . Smith

On 2009-08-21 10:39:09 -0500, "Martin v. Löwis"  said:


Did you install Python to the network device from your XP box? That
would explain why you can run it: the required registry settings &
environment variables are added by the installer, none of which is
occurring on any computer other than the one from which you installed.


In principle, Python doesn't need any registry settings or environment
variables in order to run.


That may be true, but it doesn't explain why python won't run.  I'm 
guessing that it has something to do with the msvc*90.dll files not 
getting installed.  If those dlls haven't been previously installed, 
they won't be on the client machine in order for python to use them.  
However, I haven't had any luck installing these files manually and 
getting python to work that way.


--
Kevin D. Smith

--
http://mail.python.org/mailman/listinfo/python-list


Re: 2.6 windows install

2009-08-21 Thread Kevin D . Smith
On 2009-08-21 11:43:31 -0500, Kevin D. Smith 
 said:



On 2009-08-21 10:39:09 -0500, "Martin v. Löwis"  said:


Did you install Python to the network device from your XP box? That
would explain why you can run it: the required registry settings &
environment variables are added by the installer, none of which is
occurring on any computer other than the one from which you installed.


In principle, Python doesn't need any registry settings or environment
variables in order to run.


That may be true, but it doesn't explain why python won't run.  I'm 
guessing that it has something to do with the msvc*90.dll files not 
getting installed.  If those dlls haven't been previously installed, 
they won't be on the client machine in order for python to use them.  
However, I haven't had any luck installing these files manually and 
getting python to work that way.


Installing those files from 
<http://www.microsoft.com/downloads/details.aspx?FamilyID=9b2da534-3e03-4391-8a4d-074b9f2bc1bf&displaylang=en> 
does seem to help, but python still gives an error of "The application 
failed to initialize properly (0xc00000022)."  I'm not really sure 
where to go from here.


--
Kevin D. Smith

--
http://mail.python.org/mailman/listinfo/python-list