Re: max(), sum(), next()

2008-09-06 Thread Manu Hack
On Sat, Sep 6, 2008 at 12:57 AM, castironpi <[EMAIL PROTECTED]> wrote:
> On Sep 5, 9:20 pm, "Manu Hack" <[EMAIL PROTECTED]> wrote:
>> On Fri, Sep 5, 2008 at 1:04 PM, castironpi <[EMAIL PROTECTED]> wrote:
>> > On Sep 5, 3:28 am, "Manu Hack" <[EMAIL PROTECTED]> wrote:
>> >> On Thu, Sep 4, 2008 at 4:25 PM, castironpi <[EMAIL PROTECTED]> wrote:
>> >> > On Sep 4, 2:42 pm, [EMAIL PROTECTED] wrote:
>> >> >> David C. Ullrich:
>>
>> >> >> > At least in mathematics, the sum of the elements of
>> >> >> > the empty set _is_ 0, while the maximum element of the
>> >> >> > empty set is undefined.
>>
>> >> >> What do you think about my idea of adding that 'default' argument to
>> >> >> the max()/min() functions?
>>
>> >> >> Bye,
>> >> >> bearophile
>>
>> >> > For max and min, why can't you just add your argument to the set
>> >> > itself?
>>
>> >> > The reason max([]) is undefined is that max( S ) is in S.
>>
>> >> It makes sense.
>>
>> >> >The reason sum([]) is 0 is that sum( [ x ] ) - x = 0.
>>
>> >> It doesn't make sense to me.  What do you set x to?
>>
>> > For all x.
>>
>> But then how can you conclude sum([]) = 0 from there?  It's way far
>> from obvious.
>
> You can define sum([a1,a2,...,aN]) recursively as
> sum([a1,a2,...a(N-1)])+aN.  Call the sum sum([a1,a2,...,aN]) "X", then
> subtract aN.
>
> sum([a1,a2,...a(N-1)])+aN=X
> sum([a1,a2,...a(N-1)])+aN-aN=X-aN
>
> For N=2, we have:
>
> sum([a1,a2])=X
> sum([a1,a2])-a2=X-a2
> sum([a1,a2])-a2-a1=X-a2-a1
>
> Since X= a1+ a2, replace X.
>
> sum([a1,a2])-a2-a1=(a1+a2)-a2-a1
>
> Or,
>
> sum([a1,a2])-a2-a1=0
>
> Apply the recursive definition:
>
> sum([a1])+a2-a2-a1=0
>
> And again:
>
> sum([])+a1+a2-a2-a1=0
>
> And we have:
>
> sum([])=0.

It makes more sense now, I just wanted to point out that only with
sum([x]) = x, you can't get sum([]) = 0.
--
http://mail.python.org/mailman/listinfo/python-list


Re: max(), sum(), next()

2008-09-05 Thread Manu Hack
On Fri, Sep 5, 2008 at 11:45 PM, Steven D'Aprano
<[EMAIL PROTECTED]> wrote:
> On Fri, 05 Sep 2008 22:20:06 -0400, Manu Hack wrote:
>
>> On Fri, Sep 5, 2008 at 1:04 PM, castironpi <[EMAIL PROTECTED]> wrote:
> ...
>>>> >The reason sum([]) is 0 is that sum( [ x ] ) - x = 0.
>>>>
>>>> It doesn't make sense to me.  What do you set x to?
>>>
>>> For all x.
>>
>> But then how can you conclude sum([]) = 0 from there?  It's way far from
>> obvious.
>
> I think Castironpi's reasoning is to imagine taking sum([x])-x for *any*
> possible x (where subtraction and addition is defined). Naturally you
> always get 0.
>
> Now replace x by *nothing at all* and you get:
>
> sum([]) "subtract nothing at all" = 0
>
> I think that this is a reasonable way to *informally* think about the
> question, but it's not mathematically sound, because if you replace x
> with "nothing at all" you either get:
>
> sum([]) - = 0
>
> which is invalid (only one operand to the subtraction operator), or you
> get:
>
> sum([0]) - 0 = 0
>
> which doesn't involve an empty list. What castironpi seems to be doing is
> replacing "nothing at all" with, er, nothing at all in one place, and
> zero in the other. And that's what makes it unsound and only suitable as
> an informal argument.

Actually it's even more natural to state sum([x]) = x, and this way
you can never conclude that sum([]) = 0 from there.
--
http://mail.python.org/mailman/listinfo/python-list


Re: max(), sum(), next()

2008-09-05 Thread Manu Hack
On Fri, Sep 5, 2008 at 1:04 PM, castironpi <[EMAIL PROTECTED]> wrote:
> On Sep 5, 3:28 am, "Manu Hack" <[EMAIL PROTECTED]> wrote:
>> On Thu, Sep 4, 2008 at 4:25 PM, castironpi <[EMAIL PROTECTED]> wrote:
>> > On Sep 4, 2:42 pm, [EMAIL PROTECTED] wrote:
>> >> David C. Ullrich:
>>
>> >> > At least in mathematics, the sum of the elements of
>> >> > the empty set _is_ 0, while the maximum element of the
>> >> > empty set is undefined.
>>
>> >> What do you think about my idea of adding that 'default' argument to
>> >> the max()/min() functions?
>>
>> >> Bye,
>> >> bearophile
>>
>> > For max and min, why can't you just add your argument to the set
>> > itself?
>>
>> > The reason max([]) is undefined is that max( S ) is in S.
>>
>> It makes sense.
>>
>> >The reason sum([]) is 0 is that sum( [ x ] ) - x = 0.
>>
>> It doesn't make sense to me.  What do you set x to?
>
> For all x.

But then how can you conclude sum([]) = 0 from there?  It's way far
from obvious.
--
http://mail.python.org/mailman/listinfo/python-list


Re: max(), sum(), next()

2008-09-05 Thread Manu Hack
On Thu, Sep 4, 2008 at 4:25 PM, castironpi <[EMAIL PROTECTED]> wrote:
> On Sep 4, 2:42 pm, [EMAIL PROTECTED] wrote:
>> David C. Ullrich:
>>
>> > At least in mathematics, the sum of the elements of
>> > the empty set _is_ 0, while the maximum element of the
>> > empty set is undefined.
>>
>> What do you think about my idea of adding that 'default' argument to
>> the max()/min() functions?
>>
>> Bye,
>> bearophile
>
> For max and min, why can't you just add your argument to the set
> itself?
>
> The reason max([]) is undefined is that max( S ) is in S.

It makes sense.

>The reason sum([]) is 0 is that sum( [ x ] ) - x = 0.

It doesn't make sense to me.  What do you set x to?
--
http://mail.python.org/mailman/listinfo/python-list


Re: fromfile error on windows, not mac

2008-07-23 Thread Manu Hack
On Wed, Jul 23, 2008 at 3:37 PM, jadamwil <[EMAIL PROTECTED]> wrote:

> I found the problem: I thought it was opening in binary mode on BOTH
> windows and the mac, but on windows I passed "rb" with double quotes,
> not 'rb' with single quotes to the open file function. Changing it to
> 'rb' fixed it.
>
>

by the way, anyone could explain why changing to single quote makes a
difference?

>>> "rb" == 'rb'
True
--
http://mail.python.org/mailman/listinfo/python-list

Re: Rpy Module

2008-05-16 Thread Manu Hack
On Fri, May 16, 2008 at 6:14 PM, Mike P <[EMAIL PROTECTED]>
wrote:

> Hi experts,
>
> I've just seen there is an R module, what i can't see easily is if you
> can / how to import other modules for R into the Rpy module
>
> Can anyone advise on this?


Say if you want to use Hmisc within rpy,

import rpy
rpy.r.library('Hmisc')

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

Re: Official IRC channel for Python?

2008-02-23 Thread Manu Hack
On 23 Feb 2008 22:21:59 -0800, Paul Rubin
<"http://phr.cx"@nospam.invalid> wrote:
> "Manu Hack" <[EMAIL PROTECTED]> writes:
>  > > Really? maybe I'm been blocked from it...
>  > >  thanks.
>  >
>
> > Maybe you need your nick name to be recognized.  You need to register
>  > your nickname somewhere.
>
>  On freenode, you need to register your nick in order to send private
>  messages, but you can join a channel with an unregistered nick.  If
>  the nick is registered to someone else, you get a message saying to
>  identify (which in this situation actually means change nicks, since
>  you presumably don't have the password to identify as the other
>  person).
>
>  Manu, what happens when you try to join?  What happens if you change
>  nicks?  Can you connect to freenode at all?  Can you join other
>  channels?
>  --

For most of the channels there is not problem joining.  Only the
python channel I need to use message nickserv to identify in order to
join.  I'm not very into the irc thing so after the first time I
register the nickname and then I don't seem to remember  where I
registered.

LIke if I run /join python in irssi it gives  #python You need to be
identified to join that channel

so I need to run /msg nickserv identify my_password

and then I can join #python by running /join python.

Manu

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


Re: Official IRC channel for Python?

2008-02-23 Thread Manu Hack
On Sun, Feb 24, 2008 at 12:16 AM, js <[EMAIL PROTECTED]> wrote:
> Really? maybe I'm been blocked from it...
>  thanks.

Maybe you need your nick name to be recognized.  You need to register
your nickname somewhere.

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


property question

2007-10-08 Thread Manu Hack
hi all,

If I have a class A with A.x, A.y, A.z.  A.y and A.z are property and
in order to compute the value of them, A.y depends on A.x while A.z
depends on A.y and A.x.  If I call A.y, and A.z, the value A.y would
be computed twice.  Is there a smart way to avoid that as to A.y will
be recomputed only if A.x has been changed?  Now I can define more
variables to keep track of what is changed but when there are more
variables and the dependency becomes more involved it could be very
complicated.  Thanks a lot.

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


Re: RegEx question

2007-10-04 Thread Manu Hack
On 10/4/07, Robert Dailey <[EMAIL PROTECTED]> wrote:
> On 10/4/07, Adam Lanier <[EMAIL PROTECTED]> wrote:
> >
> > try @param\[(in|out)\] \w+
> >
>
> This didn't work either :(
>
> The tool using this regular expression (Comment Reflower for VS2005) May be
> broken...
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>

How about @param\[[i|o][n|u]t*\]\w+ ?
-- 
http://mail.python.org/mailman/listinfo/python-list