Re: Mouse LED Control in Python

2012-05-29 Thread reledtubes
We are a LED factory in China, our products are LED tube light, LED bulb
light, LED screen, LED strips and so on, our website:, could you please
advise how to exploit market on abroad?


---
http://www.ledlightonsale.com/ LED Tubes   
http://www.ledlightonsale.com/catalog/led-bulbs led bulbs lights   
http://www.ledlightonsale.com/catalog/dimmable-led-lights Dimmable LED
Lights 


--
View this message in context: 
http://python.6.n6.nabble.com/Mouse-LED-Control-in-Python-tp1035960p4976047.html
Sent from the Python - python-list mailing list archive at Nabble.com.
-- 
http://mail.python.org/mailman/listinfo/python-list


Python 2.7.3, C++ embed memory leak?

2012-05-29 Thread Qi

Hi guys,

Is there any known memory leak problems, when embed Python 2.7.3
in C++?
I Googled but only found some old posts.

I tried to only call Py_Initialize() and Py_Finalize(), nothing else
between those functions, Valgrind still reports memory leaks
on Ubuntu?

Is that a know problem? Did Python 3.x solve it?

I want some confirmation.


Thanks


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


Re: Wish: Allow all log Handlers to accept the level argument

2012-05-29 Thread Vinay Sajip
Fayaz Yusuf Khan  gmail.com> writes:

> 
> ***TRIVIAL ISSUE***, but this has been irking me for a while now.
> The main logging.Handler class' __init__ accepts a level argument while none 
> of its children do. The poor minions seem to be stuck with the setLevel 
> method which considerably lengthens the code.
> 
> In short:
> Let's do this:
> root.addHandler(FileHandler('debug.log', level=DEBUG)
> Instead of this:
> debug_file_handler = FileHandler('debug.log')
> debug_file_handler.setLevel(DEBUG)
> root.addHandler(debug_file_handler)

Levels on handlers are generally not needed (though of course they are sometimes
needed) - level filtering should be applied at the logger first, and at the
handler only when necessary. I don't especially want to encourage the pattern
you suggest, because it isn't needed much of the time.

The code above won't do any more or less than if you hadn't bothered to set the
level on the handler.

Don't forget, more complex configurations are effected even more simply using
dictConfig().

Regards,

Vinay Sajip

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


Re: parallel programming in Python

2012-05-29 Thread Jabba Laci
Hehe, I just asked this question a few days ago but I didn't become
much cleverer:

http://www.gossamer-threads.com/lists/python/python/985701

Best,

Laszlo

On Thu, May 10, 2012 at 2:14 PM, Jabba Laci  wrote:
> Hi,
>
> I would like to do some parallel programming with Python but I don't
> know how to start. There are several ways to go but I don't know what
> the differences are between them: threads, multiprocessing, gevent,
> etc.
>
> I want to use a single machine with several cores. I want to solve
> problems like this: iterate over a loop (with millions of steps) and
> do some work at each step. The steps are independent, so here I would
> like to process several steps in parallel. I want to store the results
> in a global list (which should be "synchronised"). Typical use case:
> crawl webpages, extract images and collect the images in a list.
>
> What's the best way?
>
> Thanks,
>
> Laszlo
-- 
http://mail.python.org/mailman/listinfo/python-list


pygame: transparency question

2012-05-29 Thread Scott Siegler
Hello,

I have a surface that I load an image onto.  During a collision I would like to 
clear out the images of both surfaces that collided and show the score.  Is 
there a function call to clear a surface with an image?

One way I was thinking was to fill the surface with a color and then set that 
color as the colorkey.  Is this the only way or does pygame have a function to 
make the whole surface transparent?

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


Re: parallel programming in Python

2012-05-29 Thread Werner Thie

For such tasks my choice would be twisted combined with ampoule.
Let's you spread out work to whatever amount of processes you desire, 
maxing out whatever iron you're sitting on..


HTH, Werner

http://twistedmatrix.com/trac/
https://launchpad.net/ampoule

On 29.05.2012 16:43, Jabba Laci wrote:

Hehe, I just asked this question a few days ago but I didn't become
much cleverer:

http://www.gossamer-threads.com/lists/python/python/985701

Best,

Laszlo

On Thu, May 10, 2012 at 2:14 PM, Jabba Laci  wrote:

Hi,

I would like to do some parallel programming with Python but I don't
know how to start. There are several ways to go but I don't know what
the differences are between them: threads, multiprocessing, gevent,
etc.

I want to use a single machine with several cores. I want to solve
problems like this: iterate over a loop (with millions of steps) and
do some work at each step. The steps are independent, so here I would
like to process several steps in parallel. I want to store the results
in a global list (which should be "synchronised"). Typical use case:
crawl webpages, extract images and collect the images in a list.

What's the best way?

Thanks,

Laszlo
<>-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python 2.7.3, C++ embed memory leak?

2012-05-29 Thread Ulrich Eckhardt
Am 29.05.2012 16:37, schrieb Qi:
> I tried to only call Py_Initialize() and Py_Finalize(), nothing else
> between those functions, Valgrind still reports memory leaks
> on Ubuntu?

Call the pair of functions twice, if the reported memory leak doesn't
increase, there is no problem. I personally wouldn't even call this a
leak then, but that depends a bit on the precise definition.

Uli

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


Re: Help doing it the "python way"

2012-05-29 Thread Jan Kuiken

On 5/24/12 22:22 , Scott Siegler wrote:


I am an experienced programmer but a beginner to python.  As such, I can figure out a way 
to code most algorithms using more "C" style syntax.

I am doing something now that I am sure is a more python way but i can't quite 
get it right.  I was hoping someone might help.

So I have a list of grid coordinates (x, y).  From that list, I want to create 
a new list that for each coordinate, I add the coordinate just above and just 
below (x,y+1) and (x,y-1)

right now I am using a for loop to go through all the coordinates and then 
separate append statements to add the top and bottom.

is there a way to do something like: [(x,y-1), (x,y+1) for zzz in coord_list] 
or something along those lines?


If you have lot's of numerical data you can use the NumPy module 
(http://numpy.scipy.org/), your problem would reduce to something like 
this (copied from an IPython shell, could be shorter)


Regards,
Jan Kuiken


In [1]: first_list = np.arange(0, 10).reshape((5,2))

In [2]: above = np.array([0,-1])

In [3]: below = np.array([0,+1])

In [4]: N,d = first_list.shape

In [5]: second_list = np.empty((N*2,d))

In [6]: second_list[0::2] = first_list + above

In [7]: second_list[1::2] = first_list + below

In [8]: second_list
Out[8]:
array([[  0.,   0.],
   [  0.,   2.],
   [  2.,   2.],
   [  2.,   4.],
   [  4.,   4.],
   [  4.,   6.],
   [  6.,   6.],
   [  6.,   8.],
   [  8.,   8.],
   [  8.,  10.]])

In [9]: first_list
Out[9]:
array([[0, 1],
   [2, 3],
   [4, 5],
   [6, 7],
   [8, 9]])
--
http://mail.python.org/mailman/listinfo/python-list


Re: pygame: transparency question

2012-05-29 Thread Terry Reedy

On 5/29/2012 11:33 AM, Scott Siegler wrote:

Hello,

I have a surface that I load an image onto.  During a collision I
would like to clear out the images of both surfaces that collided and
show the score.  Is there a function call to clear a surface with an
image?

One way I was thinking was to fill the surface with a color and then
set that color as the colorkey.  Is this the only way or does pygame
have a function to make the whole surface transparent?


I recommend that you ask this on the pygame list, also accessible via 
news.gmane.org.


--
Terry Jan Reedy

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


Re: Help doing it the "python way"

2012-05-29 Thread Arnaud Delobelle
On 24 May 2012 21:22, Scott Siegler  wrote:
> Hello,
>
> I am an experienced programmer but a beginner to python.  As such, I can 
> figure out a way to code most algorithms using more "C" style syntax.
>
> I am doing something now that I am sure is a more python way but i can't 
> quite get it right.  I was hoping someone might help.
>
> So I have a list of grid coordinates (x, y).  From that list, I want to 
> create a new list that for each coordinate, I add the coordinate just above 
> and just below (x,y+1) and (x,y-1)
>
> right now I am using a for loop to go through all the coordinates and then 
> separate append statements to add the top and bottom.
>
> is there a way to do something like: [(x,y-1), (x,y+1) for zzz in coord_list] 
> or something along those lines?

AFAICS nobody's suggested yet the simple yet effective:

new_list = [(x, y + i) for x, y in coord_list for i in (-1, 1)]

IMHO these list comprehensions are often overlooked too quickly in
favour of itertools (in this case chain.from_iterable).

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


Install lxml package on Windows 7

2012-05-29 Thread David Fanning
Folks,

I need some help. I need the lxml package to run a particular
Python program. 

   http://lxml.de/

I downloaded the appropriate binary egg package for lxml, and
I found easy_install.exe in my Python 2.7 distribution. I ran
that.

Then, at the command prompt I typed this:

   easy_install --allow-hosts=lxml.de,*.python.org lxml==2.3.4

The usual installation pop-ups appear. "Do I want to allow
such and so to install, etc.". Yes, yes. Finally, I get
a message, "Installation may not have been done correctly."
I have several choices, including "Install with recommended
parameters", which I choose. The installation proceeds without
any other indication of failure.

I presume I have the package installed now. So, I enter
Python and type this:

   >>>import lxml

I get an error. No module with that name found, etc.

Sure enough, I look in C:\Python27\site_packages and there
is no lxml-2.3.4 folder.

Any idea what I might be doing wrong?

Thanks,

David


-- 
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Install lxml package on Windows 7

2012-05-29 Thread David Fanning
David Fanning writes: 

> 
> Folks,
> 
> I need some help. I need the lxml package to run a particular
> Python program. 
> 
>http://lxml.de/
> 
> I downloaded the appropriate binary egg package for lxml, and
> I found easy_install.exe in my Python 2.7 distribution. I ran
> that.
> 
> Then, at the command prompt I typed this:
> 
>easy_install --allow-hosts=lxml.de,*.python.org lxml==2.3.4
> 
> The usual installation pop-ups appear. "Do I want to allow
> such and so to install, etc.". Yes, yes. Finally, I get
> a message, "Installation may not have been done correctly."
> I have several choices, including "Install with recommended
> parameters", which I choose. The installation proceeds without
> any other indication of failure.
> 
> I presume I have the package installed now. So, I enter
> Python and type this:
> 
>>>>import lxml
> 
> I get an error. No module with that name found, etc.
> 
> Sure enough, I look in C:\Python27\site_packages and there
> is no lxml-2.3.4 folder.
> 
> Any idea what I might be doing wrong?

If I try to install from the lxml binary package I downloaded 
and upzipped I get this:

c:\Python27>python lxml-2.3.4/setup.py install
Building lxml version 2.3.4.
WARNING: Trying to build without Cython, but pre-generated 
'src/lxml/lxml.etree.
c' does not seem to be available.
ERROR: 'xslt-config' is not recognized as an internal or external 
command,
operable program or batch file.

** make sure the development packages of libxml2 and libxslt are 
installed **

Using build configuration of libxslt
running install
running bdist_egg
error: error in 'egg_base' option: 'src' does not exist or is not a 
directory


Confused. :-)

Cheers,

David
-- 
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Install lxml package on Windows 7

2012-05-29 Thread David Fanning
David Fanning writes: 

> I need some help. I need the lxml package to run a particular
> Python program. 
> 
>http://lxml.de/

OK, maybe I am getting somewhere now. I am now running my
command window as an Administrator. So, the command window
stays open so I can see what is happening.

So, from the command window I run this command (on one line):

   easy_install -allow-hosts=lxml.de,
*.python.org,codespeak.net,gethub.com lxml==2.3.4

I added codespeak.net and gethub.com to the command myself, as I was
getting BLOCKED messages from the script for those URLs.

Now, I am *still* getting BLOCKED messages for the github sites.
These, I notice, are https, rather than http addresses. Is this
the source of my problem?

I get 8 "file not found" warnings during the build (e.g. missing
file lxml.etree.c, lxml.objectify.c, etc.), then a fatal error:
'IDB' is illegal extension for PDB file. It is trying to run
cl.exe in a Visual Studio 9 bin directory.

Running this on an completely up-to-date version of Windows 7.

Any ideas? Thanks!

David
-- 
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Install lxml package on Windows 7

2012-05-29 Thread David Fanning
David Fanning writes: 

> > I need some help. I need the lxml package to run a particular
> > Python program. 
> > 
> >http://lxml.de/

OK, to answer my own question and help someone else out, I
eventually found an lxml-2.3.4.exe file on this page:
   
http://code.google.com/p/pythonxy/wiki/AdditionalPlugins#Installation_no
tes

The *.exe file downloaded and installed the lxml-2.3.4 directory
into the proper location in my PythonXY distribution. Actually
in the C:\Python27\Lib\site-packages directory.

Still not sure what all those other directions were all
about. :-(

Cheers,

David
-- 
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Install lxml package on Windows 7

2012-05-29 Thread Irmen de Jong
On 29-5-2012 22:41, David Fanning wrote:
> Folks,
> 
> I need some help. I need the lxml package to run a particular
> Python program. 
> 
>http://lxml.de/
> 
> I downloaded the appropriate binary egg package for lxml, and
> I found easy_install.exe in my Python 2.7 distribution. I ran
> that.
> 
> Then, at the command prompt I typed this:
> 
>easy_install --allow-hosts=lxml.de,*.python.org lxml==2.3.4


[..snip..]

Save yourself the pain trying to get it to build from source. Instead, just 
install a
precompiled binary, for instance the one available from:
http://www.lfd.uci.edu/~gohlke/pythonlibs/#lxml

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


Finding all regex matches by index?

2012-05-29 Thread Roy Smith
I have a long string (possibly 100s of Mbytes) that I want to search for 
regex matches.  re.finditer() is *almost* what I want, but the problem 
is that it returns matching strings.  What I need is a list of offsets 
in the string where the regex matched.  Thus:

s = "this is a string"
find("is", s) => [2, 5]

Is there anything that does this?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Finding all regex matches by index?

2012-05-29 Thread MRAB

On 30/05/2012 02:33, Roy Smith wrote:

I have a long string (possibly 100s of Mbytes) that I want to search for
regex matches.  re.finditer() is *almost* what I want, but the problem
is that it returns matching strings.  What I need is a list of offsets
in the string where the regex matched.  Thus:

s = "this is a string"
find("is", s) =>  [2, 5]

Is there anything that does this?


re.finditer() doesn't return matching strings, it returns match
objects. What you want are the start positions of each match which the
match object can provide:

>>> s = "this is a string"
>>> [m.start() for m in re.finditer("is", s)]
[2, 5]
--
http://mail.python.org/mailman/listinfo/python-list


Re: Finding all regex matches by index?

2012-05-29 Thread Roy Smith
In article ,
 Roy Smith  wrote:

> I have a long string (possibly 100s of Mbytes) that I want to search for 
> regex matches.  re.finditer() is *almost* what I want, but the problem 
> is that it returns matching strings.  What I need is a list of offsets 
> in the string where the regex matched.  Thus:
> 
> s = "this is a string"
> find("is", s) => [2, 5]
> 
> Is there anything that does this?

Ugh, looks like I simply mis-read the docs.  findall() returns strings, 
finditer() returns match objets (which is what I need).  Duh.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Finding all regex matches by index?

2012-05-29 Thread Ian Kelly
On Tue, May 29, 2012 at 7:33 PM, Roy Smith  wrote:
> I have a long string (possibly 100s of Mbytes) that I want to search for
> regex matches.  re.finditer() is *almost* what I want, but the problem
> is that it returns matching strings.  What I need is a list of offsets
> in the string where the regex matched.  Thus:
>
> s = "this is a string"
> find("is", s) => [2, 5]
>
> Is there anything that does this?

s = "this is a string"
pattern = re.compile("is")
pos = 0
while True:
match = pattern.search(s, pos)
if match:
print(match.start())
pos = match.start() + 1
else:
break

Cheers,
Ian
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Finding all regex matches by index?

2012-05-29 Thread Ian Kelly
On Tue, May 29, 2012 at 7:45 PM, MRAB  wrote:
> On 30/05/2012 02:33, Roy Smith wrote:
>>
>> I have a long string (possibly 100s of Mbytes) that I want to search for
>> regex matches.  re.finditer() is *almost* what I want, but the problem
>> is that it returns matching strings.  What I need is a list of offsets
>> in the string where the regex matched.  Thus:
>>
>> s = "this is a string"
>> find("is", s) =>  [2, 5]
>>
>> Is there anything that does this?
>
>
> re.finditer() doesn't return matching strings, it returns match
> objects. What you want are the start positions of each match which the
> match object can provide:
>
>
 s = "this is a string"
 [m.start() for m in re.finditer("is", s)]
> [2, 5]

Or that.  I simply assumed without checking from the OP's post that
finditer yielded strings, not matches.
-- 
http://mail.python.org/mailman/listinfo/python-list


WatPy: A new Python User Group in Kitchener-Waterloo, Ontario

2012-05-29 Thread Albert O'Connor
We are having our first night of talks on Thursday June 7th, 6:30 at the
Communitech Hub in downtown Kitchener.

More information: http://watpy.ca/blog/post/peer-2-peer-talks/

Albert O'Connor
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python 2.7.3, C++ embed memory leak?

2012-05-29 Thread Qi

On 2012-5-29 23:29, Ulrich Eckhardt wrote:


Call the pair of functions twice, if the reported memory leak doesn't
increase, there is no problem. I personally wouldn't even call this a
leak then, but that depends a bit on the precise definition.


I should still call it a memory leak though it seems less harmful.
And it causes trouble that I have difficulty to distinguish if
the leaks are from Python or from my binding code, if I add binding
between that pair of functions.


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


PIL threading problems

2012-05-29 Thread Paul Rubin
Kind of a long shot, but are there known problems in calling PIL from
multiple threads?  I'm getting weird intermittent core dumps from my
app, no idea what's causing them, but PIL is the only C module I'm
using, and I do see some mention on the interwebs that there might
be an issue:

  http://lists.tiker.net/pipermail/pycuda/2009-March/001393.html

Any suggestions?  Would it be enough to put a lock around the PIL
calls that I use?

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