Re: PEP 350: Codetags

2005-09-27 Thread Alexandre Fayolle
Le 27-09-2005, Paul  nous disait:

> Maybe the checking functions don't really belong in the
> compiler/interpreter.  PyChecker might be a good home for them, if
> it's made part of the distro.  There could be an interpreter flag to
> invoke PyChecker automatically.

Just to make a quick note that pylint [1] already has some limited
support for this, though it was developed independently from this PEP.
We will most probably add more complete support for codetags based on this
PEP in a future release of pylint.

[1] http://www.logilab.org/projects/pylint/

-- 
Alexandre Fayolle  LOGILAB, Paris (France).
http://www.logilab.com   http://www.logilab.fr  http://www.logilab.org
-- 
http://mail.python.org/mailman/listinfo/python-list


morphological image processing in Python

2005-10-03 Thread Alexandre Fayolle
Hello,

I'm about to start a project which will involve some greyscale image
processing using morphological operators (erosion, dilation, distance
transforms...), and I was wondering if these operators were available in
Python through some open source libraries. 

A quick google search returned pymorphpro[1], which is unfortunately not
free software, and there also seem to be something available in ITK [2].
Unless I'm mistaken, the PIL does not provide these operations, nore do
Numeric/numarray/scipy. 

Have I missed the one true Python mathematical morphology toolbox?

Thanks in advance for any advice.

[1] http://www.mmorph.com/pymorphpro/index.html
[2] http://www.itk.org/

-- 
Alexandre Fayolle  LOGILAB, Paris (France).
http://www.logilab.com   http://www.logilab.fr  http://www.logilab.org
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ANN: python-constraint 1.0

2005-07-07 Thread Alexandre Fayolle
On Thu, Jul 07, 2005 at 03:40:10AM -0300, Gustavo Niemeyer wrote:
> 
> Overview
> 
> 
> **python-constraint** [1]_ is a Python module offering solvers for
> Constraint Solving Problems (CSPs) over finite domains in simple
> and pure Python. CSP is class of problems which may be represented
> in terms of variables (`a`, `b`, ...), domains (`a in [1, 2, 3]`, ...),
> and constraints (`a < b`, ...).
> 
> .. [1] http://codespeak.net/~niemeyer/constraint/

People interested in CSP and python may also want to check Logilab's
constraint module which has been available from some time at:

http://www.logilab.org/projects/constraint/

Gustavo, maybe we should coordinate and merge our efforts?

-- 
Alexandre Fayolle  LOGILAB, Paris (France).
http://www.logilab.com   http://www.logilab.fr  http://www.logilab.org


signature.asc
Description: Digital signature
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Are there any AOP project in python community?

2006-08-04 Thread Alexandre Fayolle
Le 02-08-2006, steve <[EMAIL PROTECTED]> nous disait:
> I mean Aspect-Oriented Programming.
> If any please give me some of links.
> Thanks a lot.

You may want to look at http://www.logilab.org/projects/aspects

-- 
Alexandre Fayolle  LOGILAB, Paris (France)
Formations Python, Zope, Plone, Debian:  http://www.logilab.fr/formations
Développement logiciel sur mesure:   http://www.logilab.fr/services
Python et calcul scientifique:   http://www.logilab.fr/science
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: using import * with GUIs?

2006-05-31 Thread Alexandre Fayolle
Le 31-05-2006, John <[EMAIL PROTECTED]> nous disait:
> Hi all. Quick question (but aren't they all?) :)
>
> Do you think it's a good idea to use the 'from  import *' 
> statement when using a GUI module? It seems on wxPython's site, they 
> recommend using import wx nowadays, but I wonder if that advice is 
> followed. Also, I'm still reading some Tkinter docs that seem to use 
> 'from Tkinter import *' a lot.
>
> I understand the danger of doing this, but is it safer in these cases, 
> given the more specific names that GUI frameworks tend to use 
> (sometimes!)? Or should you still qualify all your calls with the module?


Don't overlook the "import module as shortname" construct, which is a
real lifesaver for large modules when you'd rather avoid importing * 

Common idiom when using Numeric/numarray/numpy is 

import Numeric as N

Importing Tkinter as tk is imo worth it. 

-- 
Alexandre Fayolle  LOGILAB, Paris (France)
Formations Python, Zope, Plone, Debian:  http://www.logilab.fr/formations
Développement logiciel sur mesure:   http://www.logilab.fr/services
Python et calcul scientifique:   http://www.logilab.fr/science
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: default argument values qns

2006-06-01 Thread Alexandre Fayolle
Le 01-06-2006, [EMAIL PROTECTED] <[EMAIL PROTECTED]> nous disait:
> hi
> i have declared a function like this:
>
> def aFunction ( arg1 , arg2 = 0):
>  
>  print type(arg2)
>
> when i try to print the type of arg2, it gives me 'str' type..why is it
> not integer type, since i have
> declared it as 0 ??

You probably either called the function with a string as the second
argument, or assigned a string to arg2 in the ... part of the function. 

On my box, I get what you would expect:

>>> def aFunction ( arg1 , arg2 = 0):
...  print type(arg2)
... 
>>> aFunction(2)



Now, remember that there are no variables in Python, only identifiers,
which are refering to values. When you print type(arg2), you are not
printing the "type of variable arg2", but the "type of the value
referenced by arg2", which is quite different, especially because it can
change during the execution of the program. 

-- 
Alexandre Fayolle  LOGILAB, Paris (France)
Formations Python, Zope, Plone, Debian:  http://www.logilab.fr/formations
Développement logiciel sur mesure:   http://www.logilab.fr/services
Python et calcul scientifique:   http://www.logilab.fr/science
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: argmax

2006-06-01 Thread Alexandre Fayolle
Le 01-06-2006, David <[EMAIL PROTECTED]> nous disait:
> 1. Why is there no argmax built-in?
> (This would return the index of the largest element in a sequence.)

You'll get argmin and argmax in Numeric and its descendants (numarray
and numpy). 


-- 
Alexandre Fayolle  LOGILAB, Paris (France)
Formations Python, Zope, Plone, Debian:  http://www.logilab.fr/formations
Développement logiciel sur mesure:   http://www.logilab.fr/services
Python et calcul scientifique:   http://www.logilab.fr/science
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: pylab doesn't find numpy on Windows

2006-06-13 Thread Alexandre Fayolle
Le 13-06-2006, timw.google <[EMAIL PROTECTED]> nous disait:
> Hi all.
>
> I installed matplotlib 0.87.3 under Python 2.4 on both Linux (FC3) and
> Windows XP Pro. On the linux install, I can import pylab, but when I
> try to do the same thing on the Windows installation, I get
>
>>>> from pylab import *
>

> ImportError: No module named Numeric
>
> I have numpy 0.9.8 installed in both places too.

it is trying to load Numeric python. You need to configure matplotlib to
use numpy by saying

numerix  : numpy 

in the matplotlibrc file.


-- 
Alexandre Fayolle  LOGILAB, Paris (France)
Formations Python, Zope, Plone, Debian:  http://www.logilab.fr/formations
Développement logiciel sur mesure:   http://www.logilab.fr/services
Python et calcul scientifique:   http://www.logilab.fr/science
-- 
http://mail.python.org/mailman/listinfo/python-list


[ANN] pyqonsole-0.2.0

2006-02-15 Thread Alexandre Fayolle
Logilab has released pyqonsole-0.2.0

Pyqonsole is a X Window terminal written in Python. The code is based
on konsole, and it uses the Qt toolkit. It is mainly meant for use by
Python application developpers who would like to embed a terminal in
their application, but it can be used as a not blazingly fast XTerm
replacement.

Download: http://www.logilab.org/projects/pyqonsole
Mailing List: http://www.logilab.org/mailinglists/python_projects

-- 
Alexandre Fayolle  LOGILAB, Paris (France).
http://www.logilab.com   http://www.logilab.fr  http://www.logilab.org
Retrait du projet de loi DADVSI: http://eucd.info/petitions/index.php?petition=2


signature.asc
Description: Digital signature
-- 
http://mail.python.org/mailman/listinfo/python-list

[ANN] pyqonsole-0.2.0

2006-02-16 Thread Alexandre Fayolle
Logilab has released pyqonsole-0.2.0

Pyqonsole is a X Window terminal written in Python. The code is based
on konsole, and it uses the Qt toolkit. It is mainly meant for use by
Python application developpers who would like to embed a terminal in
their application, but it can be used as a not blazingly fast XTerm
replacement.

Download: http://www.logilab.org/projects/pyqonsole
Mailing List: http://www.logilab.org/mailinglists/python_projects

-- 
Alexandre Fayolle  LOGILAB, Paris (France).
http://www.logilab.com   http://www.logilab.fr  http://www.logilab.org
Retrait du projet de loi DADVSI: http://eucd.info/petitions/index.php?petition=2


signature.asc
Description: Digital signature
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: PyLint results?

2006-04-24 Thread Alexandre Fayolle

Others have answered most of your questions, I won't repeat the answers
here, but only join the choir to stress that pylint needs tuning to
your coding style. An obvious case is camelCaseMethodNames versus
underscored_method_names, but there are also a lot of issues. The
default pylint settings match Logilab's coding standards. The coding
metrics were heavily inspired by Steve McConnell's Code Complete book,
but the figures provided therein have been heavily downscaled to match
for Python's expressivity (Code Complete deals mostly with C/C++/Java
code). 

Le 21-04-2006, Michael <[EMAIL PROTECTED]> nous disait:

> 2) C:  0: Missing required attribute "__revision__"
>What is this? Is that for CVS? I don't use CVS (we use SVN). I have not
>seen any sample code which includes this tag yet. But if I include
>__revision 1.0  somewhere in the code it will remove that warning?


We generally have a 
__revision__ = '$Id$' 

statement at module top level, which gets replaced a check in time by
CVS, which makes it easy to know who checked in the HEAD revision of the
module. This behaviour can be emulated with subversion properties. 



> 5) R:547:readDiscreteData: Too many branches (28/12)
>Python doesn't have the switch/case statements that C/C++ have. So I
>could have a large block if/elif/else statements.
>Is there any way to avoid that?
>
> 6) R:722:waitDiscretes: Too many local variables (38/15)
>That's new to me. What is wrong with too many local variables?
>Can anything be done to improve that besides having too many globals?

For these two, I strongly recommend giving a look at Martin Fowler's
Refactoring book (published by Addison Wesley). These are typical so
called "code smells" which can be solved using for instance the "Extract
Method" refactoring.

Of course, it all depends on the kind of program you are working, and
sometimes using intermediate variables helps understanding the code (by
providing useful names, for instance). What pylint tells you is "there
could be an issue here, you should check."


-- 
Alexandre Fayolle  LOGILAB, Paris (France).
http://www.logilab.com   http://www.logilab.fr  http://www.logilab.org
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Unicode code has no method float() ?

2006-05-04 Thread Alexandre Fayolle
Le 04-05-2006, Rony <[EMAIL PROTECTED]> nous disait:
> How can I get the value of a Unicode object ?
>
> When I do myobject.float() I get the error message that it doesn't have 
> a float() attribute

Try to use the float builtin function, as in: float(myobject) instead of
a method. 


-- 
Alexandre Fayolle  LOGILAB, Paris (France)
Formations Python, Zope, Plone, Debian:  http://www.logilab.fr/formations
Développement logiciel sur mesure:   http://www.logilab.fr/services
Python et calcul scientifique:   http://www.logilab.fr/science
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Job opportunity in France

2006-05-05 Thread Alexandre Fayolle
Le 05-05-2006, Rony <[EMAIL PROTECTED]> nous disait:
> We have a vacancy for a python programmer for a 6 months assignement.

Hi Rony,

You may find interested people on fr.comp.lang.python and on the
python-fr mailing list (python at aful dot org), if you post your
announce (in French) on these forums. 


-- 
Alexandre Fayolle  LOGILAB, Paris (France)
Formations Python, Zope, Plone, Debian:  http://www.logilab.fr/formations
Développement logiciel sur mesure:   http://www.logilab.fr/services
Python et calcul scientifique:   http://www.logilab.fr/science
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Tuple assignment and generators?

2006-05-05 Thread Alexandre Fayolle
Le 05-05-2006, Diez <[EMAIL PROTECTED]> nous disait:

> The thing you observe as accident is that sometimes "0 is 0" is true just
> because of an optimization of number objects allocation. Such things happen
> in the "real" world - other examples are string-interning in e.g. the JVM
> (and I bet they have a similar scheme to boxed number object allocation as
> python has).

String interning is available in Python too, by using the intern()
builtin function. 

-- 
Alexandre Fayolle  LOGILAB, Paris (France)
Formations Python, Zope, Plone, Debian:  http://www.logilab.fr/formations
Développement logiciel sur mesure:   http://www.logilab.fr/services
Python et calcul scientifique:   http://www.logilab.fr/science
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Unicode digit to unicode string

2006-05-16 Thread Alexandre Fayolle
Le 16-05-2006, Gabriele <[EMAIL PROTECTED]> nous disait:
> Hi, I have a unicode digit stored into a variable ('0020' for example)
> and I'd like to retrieve the corrisponding unicode character based on
> the current encoding. How can i do that ?

use the unichr builtin function


-- 
Alexandre Fayolle  LOGILAB, Paris (France)
Formations Python, Zope, Plone, Debian:  http://www.logilab.fr/formations
Développement logiciel sur mesure:   http://www.logilab.fr/services
Python et calcul scientifique:   http://www.logilab.fr/science
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: string.count issue (i'm stupid?)

2006-05-22 Thread Alexandre Fayolle
Le 22-05-2006, Matteo <[EMAIL PROTECTED]> nous disait:
> Hi all,
>
> i've noticed a strange beaviour of string.count:
>
> in my mind this code must work in this way:
>
> str = "a_a_a_a_"
> howmuch = str.count("_a_")
> print howmuch -> 3
>
> but the count return only 2
>
> Ok this can be fine, but why? The doc string tell that count will
> return the number of substring in the master string, if we spoke about
> substring i count 3 substring...
>
> Can someone explain me this? And in which way i can count all the
> occurrence of a substring in a master string? (yes all occurrence
> reusing already counter character if needed)

Use the optional start argument of find or index in a loop, such as: 

>>> def count_all(string, substring):
... index = 0
... count = 0
... while True:
... index = string.find(substring, index)  
... if index < 0:
... return count
... else:
...         count += 1
... index += 1
... 
>>> count_all("a_a_a_a_", '_a_')
3


-- 
Alexandre Fayolle  LOGILAB, Paris (France)
Formations Python, Zope, Plone, Debian:  http://www.logilab.fr/formations
Développement logiciel sur mesure:   http://www.logilab.fr/services
Python et calcul scientifique:   http://www.logilab.fr/science
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ANN: Pylint bug day, 2nd edition

2010-03-23 Thread Alexandre Fayolle
On Monday 22 March 2010 18:38:07 Alexandre Fayolle wrote:
> .. _pylint bugs day: https://www.logilab.net/elo/blogentry/18781

Correct link is : http://www.logilab.org/blogentry/18781

Sorry for the inconvenience. 

-- 
Alexandre Fayolle  LOGILAB, Paris (France)
Formations Python, CubicWeb, Debian :  http://www.logilab.fr/formations
Développement logiciel sur mesure :  http://www.logilab.fr/services
Informatique scientifique:   http://www.logilab.fr/science
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [pylint] why pylint wants only capitals identifiers?

2010-04-19 Thread Alexandre Fayolle
top level "variables" in real code are often constants and pylint tries to help 
you get rid of global variables. 

---
frmsrcurl: 
http://compgroups.net/comp.lang.python/-pylint-why-pylint-wants-only-capitals-identifiers
-- 
http://mail.python.org/mailman/listinfo/python-list


Windows debugging symbols for python 2.5.4 and pywin32 214

2010-04-21 Thread Alexandre Fayolle
Hi everyone,

I have a production server running a Windows Service written in Python, which 
uses python 2.5.4 (yes I know it is old, but I am somewhat stuck with this for 
now) and pywin32 214. 

Given a set of manipulations, I get a stack overflow in the service, and a bad  
crash. The same operation when running without 
win32serviceutil.ServiceFramework does not trigger the bug. I'm looking for 
some debugging tools (debug build of the interpreter and the pywin32 
libraries) that some good soul could have kept from a previous debugging 
session to try to get a C stack trace and understand what causes this. 

Any hint towards what could cause that stack overflow would be welcome too. 
The application is multithreaded (and uses pyro and twisted). I can provide 
more information for the curious. 

Many thanks. 

-- 
Alexandre Fayolle
Logilab, Paris, France. 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Windows debugging symbols for python 2.5.4 and pywin32 214

2010-04-23 Thread Alexandre Fayolle
On Friday 23 April 2010 08:36:01 Mark Hammond wrote:
> On 22/04/2010 7:23 AM, Alexandre Fayolle wrote:
> > Hi everyone,
> >
> > I have a production server running a Windows Service written in Python,
> > which uses python 2.5.4 (yes I know it is old, but I am somewhat stuck
> > with this for now) and pywin32 214.
> >
> > Given a set of manipulations, I get a stack overflow in the service, and
> > a bad crash. The same operation when running without
> > win32serviceutil.ServiceFramework does not trigger the bug. I'm looking
> > for some debugging tools (debug build of the interpreter and the pywin32
> > libraries) that some good soul could have kept from a previous debugging
> > session to try to get a C stack trace and understand what causes this.
> 
> I expect the problem might be that pythonservice.exe isn't linked with a
> large enough stack - python itself builds with a larger than default
> stack.  That difference could cause a recursive function to hard-crash
> before Python itself detected the recursion as being too deep.
> 
> You could test this by playing with the sys.setrecursionlimit function -
> at some limit I expect you would find the hard-crash would be replaced
> with a max recursion exception.  Let me know if that is the case and
> I'll be sure to adjust the stack size for the next pywin32 build.
> 
> > Any hint towards what could cause that stack overflow would be welcome
> > too. The application is multithreaded (and uses pyro and twisted). I can
> > provide more information for the curious.
> 
> Some parts of twisted are written such that server responses are
> processed recursively, and very large input can cause the recursion
> limit to be hit.  I'm still occasionally bitten by this in the IMAP
> client code...

Thank you for this very helpful information. I've found on my side that 
upgrading to python2.6 will prevent the crash from happening in the reported 
conditions, and used this as a fix (currently running extensive tests to be on 
the safe side). 

Runnning 2.6 will among other things enable me to use a recent VS compiler to 
rebuild stuff if required. 

I'm very interested in a pywin32 build with a larger stack for 
pythonservice.exe, as this would seriously increase my confidence level and 
improve my sleep quality :-) 

-- 
Alexandre Fayolle  LOGILAB, Paris (France)
Formations Python, CubicWeb, Debian :  http://www.logilab.fr/formations
Développement logiciel sur mesure :  http://www.logilab.fr/services
Informatique scientifique:   http://www.logilab.fr/science
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Please help: pylint does not work with Emacs23 on Windows

2010-10-04 Thread Alexandre Fayolle
Alexandre Fayolle wrote:

> Dsrt Egle wrote:
> 
>> Hi,
>> 
>> I am trying to use Pylint with Emacs on Windows XP. My Emacs version
>> is EmacsW32 23.1, pylint is 0.21.3 with Python 2.5. After easy_install
>> pylint, I added the code block below to Emacs init file, copied form
>> Emacs Wiki.
> 
> there are some files provided by pylint for emacs integration. And a patch
> was sent a few weeks ago on the pylint mailing list which improves emacs
> support on Windows : http://lists.logilab.org/pipermail/python-
> projects/2009-September/002039.html

Sorry for the noise : if you're using a recent version of pylint, this has 
been integrated in there for a while now... 

-- 
Alexandre Fayolle
Logilab
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Please help: pylint does not work with Emacs23 on Windows

2010-10-04 Thread Alexandre Fayolle
Dsrt Egle wrote:

> Hi,
> 
> I am trying to use Pylint with Emacs on Windows XP. My Emacs version
> is EmacsW32 23.1, pylint is 0.21.3 with Python 2.5. After easy_install
> pylint, I added the code block below to Emacs init file, copied form
> Emacs Wiki.

there are some files provided by pylint for emacs integration. And a patch 
was sent a few weeks ago on the pylint mailing list which improves emacs 
support on Windows : http://lists.logilab.org/pipermail/python-
projects/2009-September/002039.html 

Could you give it a try? And maybe report back on the python-projects 
mailing list (info at http://lists.logilab.org/mailman/listinfo/python-
projects). 

Regards,

-- 
Alexandre Fayolle
Logilab
-- 
http://mail.python.org/mailman/listinfo/python-list