Negativ nearest interger?

2011-09-22 Thread joni
Have a simple question in the Integer calculator in Python 2.65 and
also 2.7..

The consol showing:

Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56)
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.

>>> 7.0/3  #fist to show floiting-point calculation
2.3335
>>> -7.0/3
-2.3335
>>> -7/-3 #Rounding to nearest interger.
2
>>> 7/3
2
>>> 7/-3  #Now to the problem with interger rounding with negative anwser.
-3
>>> -7/3
-3
>>>

-3 are more wrong than -2. Negativ number seems not to round to
nearest interger, but the integer UNDER the anwser!! Or?

Why?

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


Re: Negativ nearest interger?

2011-09-22 Thread joni
On Sep 22, 1:44 pm, Jussi Piitulainen 
wrote:
> joni writes:
> > Have a simple question in the Integer calculator in Python 2.65 and
> > also 2.7..
>
> > The consol showing:
>
> > Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56)
> ...
> > >>> -7/3
> > -3
>
> > -3 are more wrong than -2. Negativ number seems not to round to
> > nearest interger, but the integer UNDER the anwser!! Or?
>
> > Why?
>
> It simply does not round to the nearest integer. It floors. This has
> nicer mathematical properties. In particular, it allows the remainder
> (notated as "per cent") operation (n % m) to return a number that
> differs from n by a multiple of m ("is congruent to n modulo m").
> These two operations go together.

Thanx. See if I can understand it /Cheers
-- 
http://mail.python.org/mailman/listinfo/python-list


Python 3.11 with Pygame

2022-10-25 Thread Joni Ekholm
Hi,

Does Pygame work with 3.11? with 3.10 no problems.

Br Joni
-- 
https://mail.python.org/mailman/listinfo/python-list


Help newbie with how to call a source command

2009-08-13 Thread Joni Lee
Hi all,
 
I'm landing here because I need some help that I couldn't get through it.
Question 1. 
I want to call a source command from python script. It will source 
some variables enviroment for further commands. I tried the following which did 
not work
os.sys('source '+source_text)
call(['source',source_text], shell=True)
commands.getoutput('source '+source_text)
 
Anyone have experiences with this? Because I'm very new to this world so a 
details reply is really appreciated!!! thank you very much
 
Question 2.
I call a shell command from python, this time it runs a script which runs some 
ruby scripts. And the error returns: "ruby: command not found"
 
Thank you again


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


a popen question. Please help

2009-08-30 Thread Joni Lee
Hi all,

I write a small script

texts = os.popen('top').readlines()
print texts

It calls the command line "top" and will print out some texts.
But first I have to press the keyboard "q" to quit the subprocess "top", then 
the texts will be printed, otherwise it just stands by with blank.

Question
is. Do you know how to give "q" into my python script so that "top" is
automatically quit immediately or maybe after 1s and print out the texts.

Thank you



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


a popen command line question

2009-08-30 Thread Joni Lee
Hi all,

I write a small script

status = os.popen('top').readlines()
print status

It calls the command line "top" and will print out the status.
But I have to press the keyboard "q" to quit "top", then the status will be 
printed, otherwise it just stands by with blank.

Question is. Do you know how to give "q" into my python script so that "top" is 
automatically quit immediately or maybe after 1s (for gathering information)

Sorry the question is weird.



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


The story of Christmas.

2008-12-07 Thread David and Joni
Receive the TRUE story of Christmas via e mail, just click on the
link.  Thank you !!

http://app.formassembly.com/forms/view/56128
--
http://mail.python.org/mailman/listinfo/python-list