Re: Rounding a number to nearest even

2008-04-11 Thread colas . francis
On 11 avr, 12:14, bdsatish <[EMAIL PROTECTED]> wrote: > The built-in function round( ) will always "round up", that is 1.5 is > rounded to 2.0 and 2.5 is rounded to 3.0. > > If I want to round to the nearest even, that is > > my_round(1.5) = 2# As expected > my_round(2.5) = 2# Not 3

Re: Rounding a number to nearest even

2008-04-11 Thread colas . francis
On 11 avr, 14:14, Gerard Flanagan <[EMAIL PROTECTED]> wrote: > On Apr 11, 2:05 pm, Gerard Flanagan <[EMAIL PROTECTED]> wrote: > > > On Apr 11, 12:14 pm, bdsatish <[EMAIL PROTECTED]> wrote: > > > > The built-in function round( ) will always "round up", that is 1.5 is > > > rounded to 2.0 and 2.5 is

Re: eval modifies passed dict

2008-04-14 Thread colas . francis
On 14 avr, 17:23, Janto Dreijer <[EMAIL PROTECTED]> wrote: > It seems eval is modifying the passed in locals/globals. This is > behaviour I did not expect and is really messing up my web.py app. > > Python 2.5.1 (r251:54863, Mar 7 2008, 04:10:12) > [GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16

Re: eval modifies passed dict

2008-04-14 Thread colas . francis
On 14 avr, 18:05, Duncan Booth <[EMAIL PROTECTED]> wrote: > Janto Dreijer <[EMAIL PROTECTED]> wrote: > > It seems eval is modifying the passed in locals/globals. This is > > behaviour I did not expect and is really messing up my web.py app. > > > Python 2.5.1 (r251:54863, Mar 7 2008, 04:10:12) > >

Re: Rounding a number to nearest even

2008-04-15 Thread colas . francis
On 14 avr, 20:02, Thomas Dybdahl Ahle <[EMAIL PROTECTED]> wrote: > On Fri, 2008-04-11 at 03:14 -0700, bdsatish wrote: > > The built-in function round( ) will always "round up", that is 1.5 is > > rounded to 2.0 and 2.5 is rounded to 3.0. > > > If I want to round to the nearest even, that is > > > m

Re: use object method without initializing object

2008-04-15 Thread colas . francis
On 15 avr, 17:27, Reckoner <[EMAIL PROTECTED]> wrote: > would it be possible to use one of an object's methods without > initializing the object? > > In other words, if I have: > > class Test: > def __init__(self): > print 'init' > def foo(self): > print 'foo' > > and I want to use

Re: use object method without initializing object

2008-04-15 Thread colas . francis
On 15 avr, 17:43, Robert Bossy <[EMAIL PROTECTED]> wrote: > Reckoner wrote: > > would it be possible to use one of an object's methods without > > initializing the object? > > > In other words, if I have: > > > class Test: > > def __init__(self): > > print 'init' > > def foo(self): > >

Re: insert python script in current script

2008-04-16 Thread colas . francis
On 16 avr, 09:42, "Prashant" <[EMAIL PROTECTED]> wrote: > I was wondering is there any way to do this: > > I have written a class in python and __init__ goes like this: > > def __init__(self): > > self.name = 'jack' > self.age = 50 > > import data > > now here there is data.py in the same directory

Re: vary number of loops

2008-04-16 Thread colas . francis
On 16 avr, 15:31, [EMAIL PROTECTED] wrote: > Hi everyone, > > I'm new to Python and the notion of lambda, and I'm trying to write a > function that would have a varying number of nested for loops > depending on parameter n. This just smells like a job for lambda for > me, but I can't figure out how

Re: def power, problem when raising power to decimals

2008-04-17 Thread colas . francis
On 17 avr, 00:49, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: > En Wed, 16 Apr 2008 19:21:18 -0300, John Machin <[EMAIL PROTECTED]> > escribió: > > > [EMAIL PROTECTED] wrote: > >> also i found a link which states 0^0 isnt 1 even though every > >> calculator ive tried says it is. > >> it doesnt s

Re: Python and stale file handles

2008-04-17 Thread colas . francis
On 17 avr, 14:43, [EMAIL PROTECTED] wrote: > On 17 Apr, 04:22, tgiles <[EMAIL PROTECTED]> wrote: > > > > > Hi, All! > > > I started back programming Python again after a hiatus of several > > years and run into a sticky problem that I can't seem to fix, > > regardless of how hard I try- it it start

Re: Can't do a multiline assignment!

2008-04-17 Thread colas . francis
On 17 avr, 17:40, [EMAIL PROTECTED] wrote: > > Yuck! No way!! If you *want* to make your code that hard to read, I'm > > sure you can find lots of ways to do so, even in Python, but don't > > expect Python to change to help you toward such a dubious goal. > > Well, my actual code doesn't look lik

Re: Can't do a multiline assignment!

2008-04-17 Thread colas . francis
On 17 avr, 18:19, [EMAIL PROTECTED] wrote: > On Apr 17, 10:54 am, [EMAIL PROTECTED] wrote: > > > On 17 avr, 17:40, [EMAIL PROTECTED] wrote: > > > Out of sheer curiosity, why do you need thirty (hand-specified and > > dutifully commented) names to the same constant object if you know > > there will