Larry Bates wrote:
I also have a personal dislike for early returns because I've found it
makes it harder insert execution trace logging into the code.
in a language that makes it trivial to wrap arbitrary callables in
tracing wrappers?
--
http://mail.python.org/mailman/listinfo/python-li
Bruno Desthuilliers a écrit :
Larry Bates a écrit :
(snip)
Sorry but I respectfully disagree that this is "abuse" of the __call__
method.
As long as we respectfully agree to disagree...
!-)
Anyway, I don't think we have enough background to seriously agree or
disagree on what would make
Larry Bates a écrit :
Bruno Desthuilliers wrote:
Bruno Desthuilliers a écrit :
Larry Bates a écrit :
(snip)
IMHO it reads better if you use the __call__ method of the class to
return the value
IMHO, it makes no sense at all to abuse the __call__ magic method here.
Sorry - after a more car
Bruno Desthuilliers wrote:
Bruno Desthuilliers a écrit :
Larry Bates a écrit :
(snip)
IMHO it reads better if you use the __call__ method of the class to
return the value
IMHO, it makes no sense at all to abuse the __call__ magic method here.
Sorry - after a more careful re-read of other p
Marco Bizzarri wrote:
On Fri, Sep 12, 2008 at 4:09 PM, Diez B. Roggisch <[EMAIL PROTECTED]> wrote:
You should also consider using PEP8 style naming.
Diez
class FolderInUse:
def __init__(self, core):
self.core = core
def true_for(self, archivefolder):
return any(
Bruno Desthuilliers a écrit :
Larry Bates a écrit :
(snip)
IMHO it reads better if you use the __call__ method of the class to
return the value
IMHO, it makes no sense at all to abuse the __call__ magic method here.
Sorry - after a more careful re-read of other posts in the thread, it
migh
Marco Bizzarri a écrit :
On Sat, Sep 13, 2008 at 4:11 PM, Fredrik Lundh <[EMAIL PROTECTED]> wrote:
Marco Bizzarri wrote:
class FolderInUse:
def true_for(self, archivefolder):
return any([instance.forbid_to_close(archivefolder) for instance in
self.core.active_outgoing_reg
Larry Bates a écrit :
(snip)
IMHO it reads better if you use the __call__ method of the class to
return the value
IMHO, it makes no sense at all to abuse the __call__ magic method here.
and rewrite it as a regular loop for clarity.
Sometimes the simplest way is the easiest to read.
class
Marco Bizzarri wrote:
On Sat, Sep 13, 2008 at 4:11 PM, Fredrik Lundh <[EMAIL PROTECTED]> wrote:
Marco Bizzarri wrote:
class FolderInUse:
def true_for(self, archivefolder):
return any([instance.forbid_to_close(archivefolder) for instance in
self.core.active_outgoing_regist
On Sat, Sep 13, 2008 at 4:11 PM, Fredrik Lundh <[EMAIL PROTECTED]> wrote:
> Marco Bizzarri wrote:
>
>> class FolderInUse:
>
>>
>>
>>def true_for(self, archivefolder):
>>return any([instance.forbid_to_close(archivefolder) for instance in
>>self.core.active_outgoing_registrati
Marco Bizzarri wrote:
class FolderInUse:
>
def true_for(self, archivefolder):
return any([instance.forbid_to_close(archivefolder) for instance in
self.core.active_outgoing_registration_instances()])
Is this any better? The true_for name does not satisfy me a lot...
w
On Fri, Sep 12, 2008 at 4:09 PM, Diez B. Roggisch <[EMAIL PROTECTED]> wrote:
>
> You should also consider using PEP8 style naming.
>
>
> Diez
class FolderInUse:
def __init__(self, core):
self.core = core
def true_for(self, archivefolder):
return any([instance.forbid_to_
On Fri, Sep 12, 2008 at 6:07 PM, Bruno Desthuilliers
<[EMAIL PROTECTED]> wrote:
> Marco Bizzarri a écrit :
> (snip)
>>
>> I'm afraid this have another problem for me...
>>
>>
>> [EMAIL PROTECTED]:/var/local/zope28/porting/Products/PAFlow$ python2.3
>> Python 2.3.5 (#2, Oct 18 2006, 23:04:45)
>> [GC
Marco Bizzarri:
> >>> any([x for x in [1, 2, 3]])
>
> I mean, I'm afraid I can't use an expression like that without
> building a list... not at least in python2.3
Note that you don't need a list comp there:
>>> any([x for x in [1, 2, 3]])
True
>>> any([1, 2, 3])
True
so this may suffice:
any(s
Marco Bizzarri a écrit :
(snip)
I'm afraid this have another problem for me...
[EMAIL PROTECTED]:/var/local/zope28/porting/Products/PAFlow$ python2.3
Python 2.3.5 (#2, Oct 18 2006, 23:04:45)
[GCC 4.1.2 20061015 (prerelease) (Debian 4.1.1-16.1)] on linux2
Type "help", "copyright", "credits" or "
D'Arcy J.M. Cain wrote:
Is there ever any advantage to having something as a builtin rather
than as a regular user method? What difference does it make to the
running script? I can see that adding "bar" from module "foo" to
"__builtins__" means that you can use "bar()" instead of "foo.bar()".
On Fri, 12 Sep 2008 17:11:47 +0200
Fredrik Lundh <[EMAIL PROTECTED]> wrote:
> The "__builtins__" object is an implementation detail, and shouldn't be
> accessed directly. And I hope I don't need to point out that adding
> custom builtins nillywilly is a bad idea...
Is there ever any advantage t
Marco Bizzarri wrote:
I would like to make this available to the whole project. I suspect I
could put it in the package __init__.py... in that way, the
__builtins__ namespace should have it... am I right?
the __init__ module for package "foo" defines the contents of the "foo"
module; it does
On Fri, Sep 12, 2008 at 4:44 PM, Diez B. Roggisch <[EMAIL PROTECTED]> wrote:
>>> if any(instance.forbitToClose(archivefolder) for instance in
>>> self.findActiveOutgoingRegistrationInstances())
>>
>> Can you clarify where I can find "any"? It seems to me I'm unable to find
>> it...
>
> It's part of
On Fri, Sep 12, 2008 at 4:44 PM, Diez B. Roggisch <[EMAIL PROTECTED]> wrote:
>>> if any(instance.forbitToClose(archivefolder) for instance in
>>> self.findActiveOutgoingRegistrationInstances())
>>
>> Can you clarify where I can find "any"? It seems to me I'm unable to find
>> it...
>
> It's part of
Marco Bizzarri wrote:
Can you clarify where I can find "any"? It seems to me I'm
> unable to find it...
it's a 2.5 addition. to use this in a "future-compatible" way in 2.3,
you can add
try:
any
except NameError:
def any(iterable):
for element in it
if any(instance.forbitToClose(archivefolder) for instance in
self.findActiveOutgoingRegistrationInstances())
Can you clarify where I can find "any"? It seems to me I'm unable to find it...
It's part of python2.5.
If you don't have that, you can write it your own and stuff it into
__builtins_
On Fri, Sep 12, 2008 at 4:09 PM, Diez B. Roggisch <[EMAIL PROTECTED]> wrote:
> Marco Bizzarri schrieb:
>>
>> Hi all.
>>
>> In many parts of my code I've the following schema of code:
>>
>>def isInUseByOutgoingRegistrations(self, archivefolder):
>>for instance in self.findActiveOutgoingR
Marco Bizzarri schrieb:
Hi all.
In many parts of my code I've the following schema of code:
def isInUseByOutgoingRegistrations(self, archivefolder):
for instance in self.findActiveOutgoingRegistrationInstances():
if instance.forbidToClose(archivefolder):
Hi all.
In many parts of my code I've the following schema of code:
def isInUseByOutgoingRegistrations(self, archivefolder):
for instance in self.findActiveOutgoingRegistrationInstances():
if instance.forbidToClose(archivefolder):
return True
return
25 matches
Mail list logo