Wednesday, March 24, 2010

comp.lang.python - 25 new messages in 11 topics - digest

comp.lang.python
http://groups.google.com/group/comp.lang.python?hl=en

comp.lang.python@googlegroups.com

Today's topics:

* the Python Foundation - 4 messages, 4 authors
http://groups.google.com/group/comp.lang.python/t/dffd2f2d435be839?hl=en
* sum for sequences? - 2 messages, 2 authors
http://groups.google.com/group/comp.lang.python/t/139c0887a359405b?hl=en
* timers not canceling! - 6 messages, 3 authors
http://groups.google.com/group/comp.lang.python/t/c2867fa35f6e6266?hl=en
* RELEASED Python 2.6.5 - 1 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/61fd70791865e19b?hl=en
* Programmatically discovering encoding types supported by codecs module - 1
messages, 1 author
http://groups.google.com/group/comp.lang.python/t/38f757c3f72901a1?hl=en
* cxfreeze on ubuntu 9.10 - 1 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/3d4dd3e0a362fa90?hl=en
* threads (specifically timers) and releasing resources - 1 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/abed2aca6bc06ada?hl=en
* MySQLdb compiled -- Import issue - 4 messages, 2 authors
http://groups.google.com/group/comp.lang.python/t/ef04f908bf359804?hl=en
* Super() function - 3 messages, 3 authors
http://groups.google.com/group/comp.lang.python/t/544f50a791a9c400?hl=en
* Is there any library for indexing binary data? - 1 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/73b172b8c5c572ff?hl=en
* device identification - 1 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/22bc2b1c9d46f1c7?hl=en

==============================================================================
TOPIC: the Python Foundation
http://groups.google.com/group/comp.lang.python/t/dffd2f2d435be839?hl=en
==============================================================================

== 1 of 4 ==
Date: Wed, Mar 24 2010 1:50 pm
From: Mark Tarver


From the website

The Python Software Foundation (PSF) is a 501(c)(3) non-profit
corporation that
holds the intellectual property rights behind the Python programming
language. We manage the open source licensing for Python version 2.1
and later and own and protect the trademarks associated with Python.

Could somebody explain 'what holding the intellectual property rights'
means in this context and in what sense PSF manages the licensing and
protects the trademarks associated with Python? This is for my
education.

thanks

Mark


== 2 of 4 ==
Date: Wed, Mar 24 2010 2:09 pm
From: Robert Kern


On 2010-03-24 15:50 PM, Mark Tarver wrote:
>> From the website
>
> The Python Software Foundation (PSF) is a 501(c)(3) non-profit
> corporation that
> holds the intellectual property rights behind the Python programming
> language. We manage the open source licensing for Python version 2.1
> and later and own and protect the trademarks associated with Python.
>
> Could somebody explain 'what holding the intellectual property rights'
> means in this context and in what sense PSF manages the licensing and
> protects the trademarks associated with Python? This is for my
> education.

The PSF owns the Python language trademark:

http://tess2.uspto.gov/bin/showfield?f=doc&state=4007:oc64of.5.1

Its trademark policy is given in detail here:

http://www.python.org/psf/trademarks/

It also controls the license of the Python interpreter and its surrounding code.
Contributors license their code to the PSF. Contributors keep the copyright to
their code, but they agree to give the PSF the right to distribute it under a
different license if the PSF decides to change licenses. See the Contributor
Agreement:

http://www.python.org/psf/contrib/contrib-form/

I believe they also outright own the copyright to most of the code that was in
the Python 2.1 release and up until this Contributor Agreement was set up. I
could be wrong about that, though.

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco

== 3 of 4 ==
Date: Wed, Mar 24 2010 2:18 pm
From: "Steve Holden, Chairman, PSF"


Mark Tarver wrote:
>>From the website
>
> The Python Software Foundation (PSF) is a 501(c)(3) non-profit
> corporation that
> holds the intellectual property rights behind the Python programming
> language. We manage the open source licensing for Python version 2.1
> and later and own and protect the trademarks associated with Python.
>
> Could somebody explain 'what holding the intellectual property rights'
> means in this context and in what sense PSF manages the licensing and
> protects the trademarks associated with Python? This is for my
> education.
>
The PSF requires that contributors sign an agreement licensing their
code to us, and allowing us to distribute it under the license of our
choosing (this does not in any way preclude the contributor licensing
the same code to any other party under different terms).

In this way people who use Python can be relatively sure that the code
is untrammeled by claims of copyright or patent by anyone other than the
PSF, and can therefore use it without fear of losing their rights to do
so because of legal action by third parties.

We have also registered the trademark "Python" for use in reference to
computer programming languages, thereby ensuring that we can take action
should some ill-advised individual or organization decide to produce
another language with "Python" in its name which we did not feel
conformed sufficiently strictly to the language definition, for instance.

The PSF has an established policy with regard to the use of its
trademarks, which you can read at

http://www.python.org/psf/trademarks/

regards
Steve
--
Steve Holden Chairman, Python Software Foundation
See PyCon Talks from Atlanta 2010 http://pycon.blip.tv/
Holden Web LLC http://www.holdenweb.com/
UPCOMING EVENTS: http://holdenweb.eventbrite.com/


== 4 of 4 ==
Date: Wed, Mar 24 2010 4:22 pm
From: Paul Rubin


"Steve Holden, Chairman, PSF" <chairman@python.org> writes:
> We have also registered the trademark "Python" for use in reference to
> computer programming languages, thereby ensuring that we can take action
> should some ill-advised individual or organization decide to produce
> another language with "Python" in its name

There has been a Lisp compiler called "Python" for many years:

http://portal.acm.org/citation.cfm?id=141471.141558

==============================================================================
TOPIC: sum for sequences?
http://groups.google.com/group/comp.lang.python/t/139c0887a359405b?hl=en
==============================================================================

== 1 of 2 ==
Date: Wed, Mar 24 2010 2:07 pm
From: Steven D'Aprano


On Wed, 24 Mar 2010 15:29:07 +0000, kj wrote:

> Is there a sequence-oriented equivalent to the sum built-in? E.g.:
>
> seq_sum(((1, 2), (5, 6))) --> (1, 2) + (5, 6) --> (1, 2, 5, 6)
>
> ?

Yes, sum.

help(sum) is your friend.

>>> a = range(2)
>>> b = range(3)
>>> c = range(4)
>>> sum((a, b, c), [])
[0, 1, 0, 1, 2, 0, 1, 2, 3]


Beware though that sum on lists and tuples will be fairly inefficient if
you have lots of them. You may find that this will be much more efficient:

result = []
for seq in sequences:
result.extend(seq)

--
Steven


== 2 of 2 ==
Date: Wed, Mar 24 2010 4:19 pm
From: Paul Rubin


kj <no.email@please.post> writes:
> Is there a sequence-oriented equivalent to the sum built-in? E.g.:
> seq_sum(((1, 2), (5, 6))) --> (1, 2) + (5, 6) --> (1, 2, 5, 6)

use itertools.chain for this. A few people have mentioned that sum will
also work, but I think for that purpose it could have O(n**2)
complexity.

==============================================================================
TOPIC: timers not canceling!
http://groups.google.com/group/comp.lang.python/t/c2867fa35f6e6266?hl=en
==============================================================================

== 1 of 6 ==
Date: Wed, Mar 24 2010 2:12 pm
From: Alex Hall


Hi all,
I am having trouble with a timer I am trying to use. It is the same
timer, but I need to cancel it when a certain event happens, then
start it again when a second event happens. The below is from a shell
session, not a file, but it shows my problem: I call cancel on a
timer, then call start on it, and it thinks it is already running?
What am I missing?

>>> from threading import Timer
>>> def func():
... print("Time up!")
...
>>> t=Timer(10.0, func)
>>> t.start()
>>> t.cancel()
>>> t.start()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\python26\lib\threading.py", line 465, in start
raise RuntimeError("thread already started")
RuntimeError: thread already started
>>>

I typed start, then typed cancel within ten seconds (probably four or
five), then called start again a couple seconds later. I figured
canceling the timer would kill the thread so I could start it again. I
am not looking for a reset, since I do not want it counting always.
Thanks.
--
Have a great day,
Alex (msg sent from GMail website)
mehgcap@gmail.com; http://www.facebook.com/mehgcap


== 2 of 6 ==
Date: Wed, Mar 24 2010 2:36 pm
From: Steve Holden


Alex Hall wrote:
> Hi all,
> I am having trouble with a timer I am trying to use. It is the same
> timer, but I need to cancel it when a certain event happens, then
> start it again when a second event happens. The below is from a shell
> session, not a file, but it shows my problem: I call cancel on a
> timer, then call start on it, and it thinks it is already running?
> What am I missing?
>
>>>> from threading import Timer
>>>> def func():
> ... print("Time up!")
> ...
>>>> t=Timer(10.0, func)
>>>> t.start()
>>>> t.cancel()
>>>> t.start()
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> File "C:\python26\lib\threading.py", line 465, in start
> raise RuntimeError("thread already started")
> RuntimeError: thread already started
>
> I typed start, then typed cancel within ten seconds (probably four or
> five), then called start again a couple seconds later. I figured
> canceling the timer would kill the thread so I could start it again. I
> am not looking for a reset, since I do not want it counting always.
> Thanks.

I believe you'll need to create a new Timer each time you need one - a
Timer is a threading.thread, and these can only be started once.

"thread already started" implies that the thread is running, but you
actually get the same message if you try to start any terminated thread
(including a canceled one), so "threads cannot be restarted" might be a
better message.

regards
Steve
--
Steve Holden +1 571 484 6266 +1 800 494 3119
See PyCon Talks from Atlanta 2010 http://pycon.blip.tv/
Holden Web LLC http://www.holdenweb.com/
UPCOMING EVENTS: http://holdenweb.eventbrite.com/


== 3 of 6 ==
Date: Wed, Mar 24 2010 2:36 pm
From: Steve Holden


Alex Hall wrote:
> Hi all,
> I am having trouble with a timer I am trying to use. It is the same
> timer, but I need to cancel it when a certain event happens, then
> start it again when a second event happens. The below is from a shell
> session, not a file, but it shows my problem: I call cancel on a
> timer, then call start on it, and it thinks it is already running?
> What am I missing?
>
>>>> from threading import Timer
>>>> def func():
> ... print("Time up!")
> ...
>>>> t=Timer(10.0, func)
>>>> t.start()
>>>> t.cancel()
>>>> t.start()
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> File "C:\python26\lib\threading.py", line 465, in start
> raise RuntimeError("thread already started")
> RuntimeError: thread already started
>
> I typed start, then typed cancel within ten seconds (probably four or
> five), then called start again a couple seconds later. I figured
> canceling the timer would kill the thread so I could start it again. I
> am not looking for a reset, since I do not want it counting always.
> Thanks.

I believe you'll need to create a new Timer each time you need one - a
Timer is a threading.thread, and these can only be started once.

"thread already started" implies that the thread is running, but you
actually get the same message if you try to start any terminated thread
(including a canceled one), so "threads cannot be restarted" might be a
better message.

regards
Steve
--
Steve Holden +1 571 484 6266 +1 800 494 3119
See PyCon Talks from Atlanta 2010 http://pycon.blip.tv/
Holden Web LLC http://www.holdenweb.com/
UPCOMING EVENTS: http://holdenweb.eventbrite.com/

== 4 of 6 ==
Date: Wed, Mar 24 2010 2:38 pm
From: Steven D'Aprano


On Wed, 24 Mar 2010 17:12:45 -0400, Alex Hall wrote:

> Hi all,
> I am having trouble with a timer I am trying to use. It is the same
> timer, but I need to cancel it when a certain event happens, then start
> it again when a second event happens. The below is from a shell session,
> not a file, but it shows my problem: I call cancel on a timer, then call
> start on it, and it thinks it is already running? What am I missing?
>
>>>> from threading import Timer
>>>> def func():
> ... print("Time up!")
> ...
>>>> t=Timer(10.0, func)
>>>> t.start()
>>>> t.cancel()
>>>> t.start()
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> File "C:\python26\lib\threading.py", line 465, in start
> raise RuntimeError("thread already started")
> RuntimeError: thread already started


The start method is to start generic threads, not just timers, and
threads don't support being restarted.

Timers are fairly simple objects: after you start the thread, they just
wait until the time expires, then run a function. You can cancel them,
but not pause and restart them.

To do what you are trying to do, you will need to subclass either Timer
or thread and implement your own logic for pausing or restarting the
count down.


> I typed start, then typed cancel within ten seconds (probably four or
> five), then called start again a couple seconds later. I figured
> canceling the timer would kill the thread so I could start it again.


That's not how they work. "start" means "start the thread", not "start
the timer", and threads cannot be restarted.

The documentation is very clear:

"start()
Start the thread's activity.

It must be called at most once per thread object. It arranges for the
object's run() method to be invoked in a separate thread of control."

http://docs.python.org/library/threading.html#thread-objects


--
Steven


== 5 of 6 ==
Date: Wed, Mar 24 2010 5:26 pm
From: Steve Holden


Steve Holden wrote:
> Alex Hall wrote:
[...]
> "thread already started" implies that the thread is running, but you
> actually get the same message if you try to start any terminated thread
> (including a canceled one), so "threads cannot be restarted" might be a
> better message.
>
Or, better still, "Threads can only be started once".

regards
Steve
--
Steve Holden +1 571 484 6266 +1 800 494 3119
See PyCon Talks from Atlanta 2010 http://pycon.blip.tv/
Holden Web LLC http://www.holdenweb.com/
UPCOMING EVENTS: http://holdenweb.eventbrite.com/


== 6 of 6 ==
Date: Wed, Mar 24 2010 5:26 pm
From: Steve Holden


Steve Holden wrote:
> Alex Hall wrote:
[...]
> "thread already started" implies that the thread is running, but you
> actually get the same message if you try to start any terminated thread
> (including a canceled one), so "threads cannot be restarted" might be a
> better message.
>
Or, better still, "Threads can only be started once".

regards
Steve
--
Steve Holden +1 571 484 6266 +1 800 494 3119
See PyCon Talks from Atlanta 2010 http://pycon.blip.tv/
Holden Web LLC http://www.holdenweb.com/
UPCOMING EVENTS: http://holdenweb.eventbrite.com/


==============================================================================
TOPIC: RELEASED Python 2.6.5
http://groups.google.com/group/comp.lang.python/t/61fd70791865e19b?hl=en
==============================================================================

== 1 of 1 ==
Date: Wed, Mar 24 2010 3:22 pm
From: "Martin v. Loewis"


> Is anyone else having trouble with the 2.6.5 Windows x86 installer?

Not me. Run

msiexec /i py...msi /l*v py.log

and inspect py.log for errors (post it to bugs.python.org if you can't
determine the cause of the problems).

Are you using SUBST by any chance?

Regards,
Martin

==============================================================================
TOPIC: Programmatically discovering encoding types supported by codecs module
http://groups.google.com/group/comp.lang.python/t/38f757c3f72901a1?hl=en
==============================================================================

== 1 of 1 ==
Date: Wed, Mar 24 2010 3:50 pm
From: "Gabriel Genellina"


En Wed, 24 Mar 2010 14:58:47 -0300, <python@bdurham.com> escribi�:

>> After looking at how things are done in codecs.c and
>> encodings/__init__.py I think you should enumerate all modules in the
>> encodings package that define a getregentry function. Aliases come from
>> encodings.aliases.aliases.
>
> Thanks for looking into this for me. Benjamin Kaplan made a similar
> observation. My reply to him included the snippet of code we're using to
> generate the actual list of encodings that our software will support
> (thanks to Python's codecs and encodings modules).

I was curious as whether both methods would give the same results:

py> modules=set()
py> for name in glob.glob(os.path.join(encodings.__path__[0], "*.py")):
... name = os.path.basename(name)[:-3]
... try: mod = __import__("encodings."+name,
fromlist=['ilovepythonbutsometimesihateit'])
... except ImportError: continue
... if hasattr(mod, 'getregentry'):
... modules.add(name)
...
py> fromalias = set(encodings.aliases.aliases.values())
py> fromalias - modules
set(['tactis'])
py> modules - fromalias
set(['charmap',
'cp1006',
'cp737',
'cp856',
'cp874',
'cp875',
'idna',
'iso8859_1',
'koi8_u',
'mac_arabic',
'mac_centeuro',
'mac_croatian',
'mac_farsi',
'mac_romanian',
'palmos',
'punycode',
'raw_unicode_escape',
'string_escape',
'undefined',
'unicode_escape',
'unicode_internal',
'utf_8_sig'])

There is a missing 'tactis' encoding (?) and about twenty without alias.

--
Gabriel Genellina


==============================================================================
TOPIC: cxfreeze on ubuntu 9.10
http://groups.google.com/group/comp.lang.python/t/3d4dd3e0a362fa90?hl=en
==============================================================================

== 1 of 1 ==
Date: Wed, Mar 24 2010 5:33 pm
From: Waspinator


Hi,

I'm trying to compile a python script on Ubuntu 9.10. It uses the gtk
toolkit. I tried to run GUI2EXE for a cxfreeze gui, but even after
installing wxPython in synaptic it still complains about not having
it.

I also tried to use cxfreeze by itself but the file it produces does
not run.

I tried to follow the information at http://cx-freeze.sourceforge.net/cx_Freeze.html

I created a setup.py file that looks like this (from the page)

from cx_Freeze import setup, Executable

setup(
name = "gtk_test",
version = "0.1",
description = "gtk_test",
executables = [Executable("gtk_test.py")])

and ran:

python setup.py build


When I try to run the executable I get the following error:

../build/exe.linux-i686-2.6/library.zip/gtk/_gtk.py:12:
RuntimeWarning: tp_compare didn't return -1 or -2 for exception
ImportError: could not import gio
ImportError: could not import gio
Traceback (most recent call last):
File "/usr/lib/pymodules/python2.6/cx_Freeze/initscripts/
Console.py", line 29, in <module>
exec code in m.__dict__
File "gtk_test.py", line 274, in <module>
File "gtk_test.py", line 228, in main
AttributeError: 'module' object has no attribute 'Window'

I was thinking of using the 'copy-dependent-files' option but I'm not
sure how.

Any ideas?

Thanks

==============================================================================
TOPIC: threads (specifically timers) and releasing resources
http://groups.google.com/group/comp.lang.python/t/abed2aca6bc06ada?hl=en
==============================================================================

== 1 of 1 ==
Date: Wed, Mar 24 2010 7:31 pm
From: Alex Hall


Okay, I have my program and it has three different modes (there will
be more than that). Each mode will have a timer attached to it. If the
mode remains active and the timer runs out, a function specific to
that mode is called. If that mode is switched away from, however, the
timer is canceled and a new timer is created for the mode to which the
user just switched. My question is: what happens with resources taken
up by previous timers, whether they cancel or execute? I would hate
for my program to run for a long time and slowly build up a massive
list of old threads (timers), taking up resources which should have
been released. Will Python perform GC and completely erase a thread
once it is done, or will it keep hanging around? If the latter, is
there a way to completely destroy a thread? Thanks; Google was not too
helpful on this one!

--
Have a great day,
Alex (msg sent from GMail website)
mehgcap@gmail.com; http://www.facebook.com/mehgcap

==============================================================================
TOPIC: MySQLdb compiled -- Import issue
http://groups.google.com/group/comp.lang.python/t/ef04f908bf359804?hl=en
==============================================================================

== 1 of 4 ==
Date: Wed, Mar 24 2010 7:59 pm
From: Kurian Thayil


Hi All,

I am just a month old with Python and trying to learn CGI with Python. I
was trying to install MySQLdb module in my new CentOS 5.3 box with
Python 2.4.3 default install. I downloaded the tar-ball of MySQLdb
module (MySQL-python-1.2.3c1). Did build as normal user and install as
root. MySQL server version that I'm using is 5.1.41, if that has
anything to do with the error. I then copied, libmysqlclient_r.so.16
library to /usr/lib/ folder and then I am able to import the module as
root user. But cannot do this as normal user.

Now, while doing import MySQLdb as normal user, I get the following
error message. The scripts will be run as apache and hence cannot have
this error. Please check the following output. Also I have attached the
output while doing build and install process.

[kurianmt@server MySQL-python-1.2.3c1]$ python
Python 2.4.3 (#1, Jan 21 2009, 01:10:13)
[GCC 4.1.2 20071124 (Red Hat 4.1.2-42)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import MySQLdb
/usr/lib/python2.4/site-packages/MySQL_python-1.2.3c1-py2.4-linux-i686.egg/_mysql.py:3: UserWarning: Module _mysql was already imported from /usr/lib/python2.4/site-packages/MySQL_python-1.2.3c1-py2.4-linux-i686.egg/_mysql.pyc, but /opt/downloads/py-modules/MySQL-python-1.2.3c1 is being added to sys.path

It would be a great help if I understand what's going on!!! Thanks in
advance.

Regards,

Kurian Mathew Thayil.


== 2 of 4 ==
Date: Wed, Mar 24 2010 8:15 pm
From: Sean DiZazzo


On Mar 24, 7:59 pm, Kurian Thayil <kurianmtha...@gmail.com> wrote:
> Hi All,
>
> I am just a month old with Python and trying to learn CGI with Python. I
> was trying to install MySQLdb module in my new CentOS 5.3 box with
> Python 2.4.3 default install. I downloaded the tar-ball of MySQLdb
> module (MySQL-python-1.2.3c1). Did build as normal user and install as
> root. MySQL server version that I'm using is 5.1.41, if that has
> anything to do with the error. I then copied, libmysqlclient_r.so.16
> library to /usr/lib/ folder and then I am able to import the module as
> root user. But cannot do this as normal user.
>
> Now, while doing import MySQLdb as normal user, I get the following
> error message. The scripts will be run as apache and hence cannot have
> this error. Please check the following output. Also I have attached the
> output while doing build and install process.
>
> [kurianmt@server MySQL-python-1.2.3c1]$ python
> Python 2.4.3 (#1, Jan 21 2009, 01:10:13)
> [GCC 4.1.2 20071124 (Red Hat 4.1.2-42)] on linux2
> Type "help", "copyright", "credits" or "license" for more information.>>> import MySQLdb
>
> /usr/lib/python2.4/site-packages/MySQL_python-1.2.3c1-py2.4-linux-i686.egg/_mysql.py:3: UserWarning: Module _mysql was already imported from /usr/lib/python2.4/site-packages/MySQL_python-1.2.3c1-py2.4-linux-i686.egg/_mysql.pyc, but /opt/downloads/py-modules/MySQL-python-1.2.3c1 is being added to sys.path
>
> It would be a great help if I understand what's going on!!! Thanks in
> advance.
>
> Regards,
>
> Kurian Mathew Thayil.
>
>  MySQLdb-build.txt
> 3KViewDownload
>
>  MySQLdb-Install.txt
> 6KViewDownload
>
>  signature.asc
> < 1KViewDownload

The warning looks familiar. Are you running python from the MySQLdb
source directory? ie. /opt/downloads/py-modules/MySQL-python-1.2.3c1

I think you just need to change directories and the warning will go
away. Check what's happening on line 3 of _mysql.py I don't have the
source in front of me.

~Sean


== 3 of 4 ==
Date: Wed, Mar 24 2010 8:41 pm
From: Kurian Thayil


On Wed, 2010-03-24 at 20:15 -0700, Sean DiZazzo wrote:

> On Mar 24, 7:59 pm, Kurian Thayil <kurianmtha...@gmail.com> wrote:
> > Hi All,
> >
> > I am just a month old with Python and trying to learn CGI with Python. I
> > was trying to install MySQLdb module in my new CentOS 5.3 box with
> > Python 2.4.3 default install. I downloaded the tar-ball of MySQLdb
> > module (MySQL-python-1.2.3c1). Did build as normal user and install as
> > root. MySQL server version that I'm using is 5.1.41, if that has
> > anything to do with the error. I then copied, libmysqlclient_r.so.16
> > library to /usr/lib/ folder and then I am able to import the module as
> > root user. But cannot do this as normal user.
> >
> > Now, while doing import MySQLdb as normal user, I get the following
> > error message. The scripts will be run as apache and hence cannot have
> > this error. Please check the following output. Also I have attached the
> > output while doing build and install process.
> >
> > [kurianmt@server MySQL-python-1.2.3c1]$ python
> > Python 2.4.3 (#1, Jan 21 2009, 01:10:13)
> > [GCC 4.1.2 20071124 (Red Hat 4.1.2-42)] on linux2
> > Type "help", "copyright", "credits" or "license" for more information.>>> import MySQLdb
> >
> > /usr/lib/python2.4/site-packages/MySQL_python-1.2.3c1-py2.4-linux-i686.egg/_mysql.py:3: UserWarning: Module _mysql was already imported from /usr/lib/python2.4/site-packages/MySQL_python-1.2.3c1-py2.4-linux-i686.egg/_mysql.pyc, but /opt/downloads/py-modules/MySQL-python-1.2.3c1 is being added to sys.path
> >
> > It would be a great help if I understand what's going on!!! Thanks in
> > advance.
> >
> > Regards,
> >
> > Kurian Mathew Thayil.
> >
> > MySQLdb-build.txt
> > 3KViewDownload
> >
> > MySQLdb-Install.txt
> > 6KViewDownload
> >
> > signature.asc
> > < 1KViewDownload
>
> The warning looks familiar. Are you running python from the MySQLdb
> source directory? ie. /opt/downloads/py-modules/MySQL-python-1.2.3c1
>
> I think you just need to change directories and the warning will go
> away. Check what's happening on line 3 of _mysql.py I don't have the
> source in front of me.
>
> ~Sean


Hi Sean,

You are right. I was trying to import the module sitting on the source
folder :"-). Thanks for your quick response and let me try further.

Regards,

Kurian Mathew Thayil.


== 4 of 4 ==
Date: Wed, Mar 24 2010 8:54 pm
From: Sean DiZazzo

> You are right. I was trying to import the module sitting on the source
> folder :"-). Thanks for your quick response and let me try further.


Sweet! I remember it because it confused the hell out of me on at
least one past occasion. :)

==============================================================================
TOPIC: Super() function
http://groups.google.com/group/comp.lang.python/t/544f50a791a9c400?hl=en
==============================================================================

== 1 of 3 ==
Date: Wed, Mar 24 2010 8:17 pm
From: Alan Harris-Reid


Hi,

Using Python 3.1, I sometimes use the super() function to call the
equivalent method from a parent class, for example

def mymethod(self):
super().mymethod()
some more code...

Is there any way of writing the code so that the super() call is generic
and automatically recognises the name of the current method (ie.
something like super().thismethod()) or do I always have to repeat the
method name after super()?

TIA,
Alan


== 2 of 3 ==
Date: Wed, Mar 24 2010 8:47 pm
From: alex23


Alan Harris-Reid <aharrisr...@googlemail.com> wrote:
> Is there any way of writing the code so that the super() call is generic
> and automatically recognises the name of the current method (ie.
> something like super().thismethod()) or do I always have to repeat the
> method name after super()?

To the best of my knowledge, you always need to repeat the method
name. super() returns a proxy object that has no awareness of its
context, so it's unaware of the method it's being called within (in
fact, there's nothing that restricts super() to only being used in
methods...).

You could probably write a wrapper function that uses inspect to
determine in which context super() is being called, but unless you're
regularly finding this to be a problem with refactoring I wouldn't
worry about it.


== 3 of 3 ==
Date: Wed, Mar 24 2010 9:00 pm
From: "Gabriel Genellina"


En Thu, 25 Mar 2010 00:17:52 -0300, Alan Harris-Reid
<aharrisreid@googlemail.com> escribió:

> Using Python 3.1, I sometimes use the super() function to call the
> equivalent method from a parent class, for example
>
> def mymethod(self):
> super().mymethod()
> some more code...
>
> Is there any way of writing the code so that the super() call is generic
> and automatically recognises the name of the current method (ie.
> something like super().thismethod()) or do I always have to repeat the
> method name after super()?

This recipe does what you want:
http://code.activestate.com/recipes/286195-selfsuper/
(but requires a bit of black magic...)

--
Gabriel Genellina


==============================================================================
TOPIC: Is there any library for indexing binary data?
http://groups.google.com/group/comp.lang.python/t/73b172b8c5c572ff?hl=en
==============================================================================

== 1 of 1 ==
Date: Wed, Mar 24 2010 8:28 pm
From: 甜瓜


Howdy,

Recently, I am finding a good library for build index on binary data.
Xapian & Lucene for python binding focus on text digestion rather than
binary data. Could anyone give me some recommendation? Is there any
library for indexing binary data no matter whether it is written in
python?

In my case, there is a very big datatable which stores structured
binary data, eg:
struct Item
{
long id; // used as key
double value;
};

I want to build the index on "id" field to speed on searching. Since
this datatable is not constant, the library should support incremental
indexing. If there is no suitable library, I have to do the index by
myself...

Thank you in advance.

--
ShenLei

==============================================================================
TOPIC: device identification
http://groups.google.com/group/comp.lang.python/t/22bc2b1c9d46f1c7?hl=en
==============================================================================

== 1 of 1 ==
Date: Wed, Mar 24 2010 8:41 pm
From: Tim Roberts


Omer Ihsan <omrihsan@gmail.com> wrote:
>
>VID and PID is fair enough. now what i want is that i have a threaded
>code that threads two functions to run at the same time. i want each
>function to run seperate devices. the problem is if it doesnt identify
>the attached devices it might run the code on a single device which
>isnt what is required.

Some of the libraries that pyusb uses are not thread-safe, like libusb 0.1.

>how will i be able to run a code on a device of my choice???....you
>can leave away the threading part for now.

You can return all of the devices with a particular VID and PID:

collection = usb.core.find( find_all=True, idVendor=0x1234,
idProduct=0x5678 )

Then you can dish those out to threads using something like the queue
module.

Or, usb.core.find accepts a predicate function that allows you to use any
criteria you wish.

What kind of device are you trying to manipulate? I have a lot of USB
experience -- perhaps I can offer advice.
--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.


==============================================================================

You received this message because you are subscribed to the Google Groups "comp.lang.python"
group.

To post to this group, visit http://groups.google.com/group/comp.lang.python?hl=en

To unsubscribe from this group, send email to comp.lang.python+unsubscribe@googlegroups.com

To change the way you get mail from this group, visit:
http://groups.google.com/group/comp.lang.python/subscribe?hl=en

To report abuse, send email explaining the problem to abuse@googlegroups.com

==============================================================================
Google Groups: http://groups.google.com/?hl=en

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate