Re: dividing tuple elements with an int or float

2008-03-24 Thread castironpi
On Mar 23, 12:22 pm, Lie <[EMAIL PROTECTED]> wrote: > On Mar 22, 2:23 pm, [EMAIL PROTECTED] wrote: > > > > Sane programmers don't write such semi-functional things (unless it > > > helps expressing the problem in certain domains). > > > I now think that deprecating map, lambda & Co. was a good thin

Re: dividing tuple elements with an int or float

2008-03-23 Thread Lie
On Mar 22, 2:23 pm, [EMAIL PROTECTED] wrote: > > Sane programmers don't write such semi-functional things (unless it > > helps expressing the problem in certain domains). > > I now think that deprecating map, lambda & Co. was a good thing after > > all. > > If you write it that way the first time,

Re: dividing tuple elements with an int or float

2008-03-23 Thread Lie
On Mar 20, 1:06 pm, royG <[EMAIL PROTECTED]> wrote: > hi > i am trying to resize some images.First i'd read the size as a 2 > tuple  and then i want to divide it by 2 or 4 or 2.5 etc.. > > suppose > origsz=(400,300) > i want to divide the origsize by 2.5 so i can resize to (160,120) There are seve

Re: dividing tuple elements with an int or float

2008-03-22 Thread castironpi
On Mar 21, 1:08 pm, Gabriel Genellina <[EMAIL PROTECTED]> wrote: > Sane programmers replace that crazyness with this code: > > tuple(x+1 for x in y) > > Sane programmers -like D'Aprano, Jerry Hill and me- replace that > crazyness with this code: > > tuple(x/2.5 for x in y) > > Sane programmers don'

Re: dividing tuple elements with an int or float

2008-03-21 Thread Gabriel Genellina
On 21 mar, 10:14, [EMAIL PROTECTED] wrote: > On Mar 20, 9:28 am, "Jerry Hill" <[EMAIL PROTECTED]> wrote: > > A more general > > solution might use a generator expression, like this: > > newsz = tuple(x/scale for x in origsz) > > You want to perform a uniform call on the elements of a collection. >

Re: dividing tuple elements with an int or float

2008-03-21 Thread castironpi
On Mar 21, 8:14 am, [EMAIL PROTECTED] wrote: > On Mar 20, 9:28 am, "Jerry Hill" <[EMAIL PROTECTED]> wrote: > > On Thu, Mar 20, 2008 at 3:42 AM, Steven D'Aprano > > <[EMAIL PROTECTED]> wrote: > > > On Wed, 19 Mar 2008 23:06:44 -0700, royG wrote: > > > >  > suppose > > >  > origsz=(400,300) > > >  >

Re: dividing tuple elements with an int or float

2008-03-21 Thread castironpi
On Mar 20, 9:28 am, "Jerry Hill" <[EMAIL PROTECTED]> wrote: > On Thu, Mar 20, 2008 at 3:42 AM, Steven D'Aprano > > <[EMAIL PROTECTED]> wrote: > > On Wed, 19 Mar 2008 23:06:44 -0700, royG wrote: > > >  > suppose > >  > origsz=(400,300) > >  > i want to divide the origsize by 2.5 so i can resize to (

Re: dividing tuple elements with an int or float

2008-03-20 Thread Jerry Hill
On Thu, Mar 20, 2008 at 3:42 AM, Steven D'Aprano <[EMAIL PROTECTED]> wrote: > On Wed, 19 Mar 2008 23:06:44 -0700, royG wrote: > > > > suppose > > origsz=(400,300) > > i want to divide the origsize by 2.5 so i can resize to (160,120) > > > > scale=2.5 > > how can i get the newsz? > > obviousl

Re: dividing tuple elements with an int or float

2008-03-20 Thread Steven D'Aprano
On Wed, 19 Mar 2008 23:06:44 -0700, royG wrote: > suppose > origsz=(400,300) > i want to divide the origsize by 2.5 so i can resize to (160,120) > > scale=2.5 > how can i get the newsz? > obviously origsz/2.5 won't work .. newsz = (origsz[0]/scale, origsz[1]/scale) -- Steven -- http://ma