Re: [Tutor] Integer division Help requested

2006-10-03 Thread Luke Paireepinart
Joseph John wrote: > HI All >I am trying out python > I understoon when > 7/3 gives "2" > But I cannot understand , > when i give 7/-3 gives resuls "-3" > I feel > 7/3 should give -2 > > since integer divison returns floor >Advice re

[Tutor] Integer division Help requested

2006-10-03 Thread Joseph John
HI All    I am trying out python I  understoon when 7/3  gives "2"But I cannot understand ,   when i give 7/-3  gives resuls "-3"I feel 7/3  should give -2 since  integer  divison returns floor    Advice requested   

Re: [Tutor] save configuration of one application.

2006-10-03 Thread John Fouhy
On 04/10/06, Luke Paireepinart <[EMAIL PROTECTED]> wrote: > you can make a config.ini file and use that one module that parses ini > files. > I can't remember what it's called. > configparser I think, but I wouldn't bet my life on it :) Yes, ConfigParser. The docs for ConfigParser are a bit confu

Re: [Tutor] save configuration of one application.

2006-10-03 Thread Luke Paireepinart
hok kakada wrote: > Hi, > > Can anybody guide me how to write the code for configure one application? > For example, I want to set Font and Color for a textbox; later when the > application is opened again. the previous font is set. > > So, which related function are used to form this feature? >

[Tutor] save configuration of one application.

2006-10-03 Thread hok kakada
Hi, Can anybody guide me how to write the code for configure one application? For example, I want to set Font and Color for a textbox; later when the application is opened again. the previous font is set. So, which related function are used to form this feature? Thanks, da _

Re: [Tutor] What not to put in __init__()

2006-10-03 Thread Kent Johnson
Tony Cappellini wrote: > > I've just inherited a lot of python code to maintain. > > The __init__ functions in many of the classes are very long- some over > 100 lines. > > I like to keep functions/methods short & readable at a glance, if possible. > > 1. Is it good methodology to move some co

Re: [Tutor] byte[] array

2006-10-03 Thread Kent Johnson
gert wohlgemuth wrote: > Hi, > > I'm used to java byte arrays (byte[]) and need the same type in python, > cause we have a couple of established web services, which return a byte[] or > take a byte[] as parameter. > > As anybody an idea how I can do this in python? A string can be used as a byte

[Tutor] What not to put in __init__()

2006-10-03 Thread Tony Cappellini
I've just inherited a lot of python code to maintain.The __init__ functions in many of the classes are very long- some over 100 lines.I like to keep functions/methods short & readable at a glance, if possible. 1. Is it good methodology to move some code from _init__ to it's own method within the cl

[Tutor] Random Variable at root

2006-10-03 Thread Jonathon Sisson
Hugo, You need to create an instance of the Root class before you can call rootState in your final print statement. Your code doesn't do this. A class is merely a template, something like blueprints to a house. For you to be able to unlock the front door (for instance), you need to actually bui

Re: [Tutor] Random Variable at root

2006-10-03 Thread Eric Walstad
Hi Hugo, halamillo wrote: > I;m starting this > code so I can assign either a 0 or a 1 at a root node that I will later > evolve throughout a tree, but for some reason it is not printing the > rootState value. It's not clear to me which variable you are trying to assign a zero or one. Here's

[Tutor] number game

2006-10-03 Thread Jonathon Sisson
Mike, The algorithm you use is what causes the infinite loop (it cycles through the same numbers repeatedly). I've updated the code and I'll post it here: def num(number): r=input("range >") ran=range(r+1) guess=r/2 print guess guesses=1 min = 0 max = r while gues

[Tutor] Random Variable at root

2006-10-03 Thread halamillo
Hello,  I'm a really-green-to-python Biology Grad Student. I;m starting this code so I can assign either a 0 or a 1 at a root node that I will later evolve throughout a tree, but for some reason it is not printing the rootState value.  I know its probably a really stupid mistake, but I can't seem t

[Tutor] number game

2006-10-03 Thread mike viceano
i wrote a program that guesses number in the most effective way i could think of but i keep running into endless loops any help fixing it would be great :) here it is: def num(number): r=input("range >") ran=range(r+1) guess=r/2 print guess guesses=1 while guess!=number

[Tutor] byte[] array

2006-10-03 Thread gert wohlgemuth
Hi, I'm used to java byte arrays (byte[]) and need the same type in python, cause we have a couple of established web services, which return a byte[] or take a byte[] as parameter. As anybody an idea how I can do this in python? Thx, g. ___ Tutor mai

Re: [Tutor] What is a Python "project"?

2006-10-03 Thread Brian van den Broek
Dick Moores said unto the world upon 03/10/06 01:41 PM: > At 10:01 AM 10/3/2006, Mike Hansen wrote: >> I've been doing some web programming, so my "projects" consist of >> cheetah template files, CSS, config files, a handful of python >> modules... > > Why do you make python modules part of a p

Re: [Tutor] question about sys.path and importing

2006-10-03 Thread Dick Moores
At 12:30 PM 10/3/2006, you wrote: >Dick Moores wrote: >>At 11:38 AM 10/3/2006, Kent Johnson wrote: >>>Normally you will need to either >>>- make 'mine' be a package, by creating an empty file named >>>site-packages\mine\__init__.py, and changing your imports to include the >>>package name (from min

Re: [Tutor] CGKit

2006-10-03 Thread Carlos
Thanks Luke and Kent, To get CGKit running I need to do two different things: First the Python Computer Graphics Kit is composed by an "cgkit-2.0.0alpha6.win32-py2.4.exe" file and some dependencies that are PyProtocols, numarray, PyOpenGL, PIL, pygame, PyODE and pySerial, with the exception of

Re: [Tutor] Keycodes

2006-10-03 Thread Luke Paireepinart
Chris Hengge wrote: > Is it possible to capture keycodes for things like ctrl/alt/shift? > > I've made a script using msvcrt but it seems to skips most of the non > alphanumeric keys. > > Thanks. You can in Pygame. I don't know about msvcrt. > --

[Tutor] Keycodes

2006-10-03 Thread Chris Hengge
Is it possible to capture keycodes for things like ctrl/alt/shift?   I've made a script using msvcrt but it seems to skips most of the non alphanumeric keys.   Thanks. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] question about sys.path and importing

2006-10-03 Thread Kent Johnson
Dick Moores wrote: > At 11:38 AM 10/3/2006, Kent Johnson wrote: >> Normally you will need to either >> - make 'mine' be a package, by creating an empty file named >> site-packages\mine\__init__.py, and changing your imports to include the >> package name (from mine import mycalc), or >> - add site-

Re: [Tutor] What is a Python "project"?

2006-10-03 Thread Mike Hansen
> -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Dick Moores > Sent: Tuesday, October 03, 2006 12:41 PM > To: tutor@python.org > Subject: Re: [Tutor] What is a Python "project"? > > At 10:01 AM 10/3/2006, Mike Hansen wrote: > > > > > > > -Orig

Re: [Tutor] question about sys.path and importing

2006-10-03 Thread Dick Moores
At 11:38 AM 10/3/2006, Kent Johnson wrote: >Normally you will need to either >- make 'mine' be a package, by creating an empty file named >site-packages\mine\__init__.py, and changing your imports to include the >package name (from mine import mycalc), or >- add site-packages\mine to sys.path, mayb

Re: [Tutor] What is a Python "project"?

2006-10-03 Thread Dick Moores
At 10:01 AM 10/3/2006, Mike Hansen wrote: > > > > -Original Message- > > From: [EMAIL PROTECTED] > > [mailto:[EMAIL PROTECTED] On Behalf Of Dick Moores > > Sent: Tuesday, October 03, 2006 12:52 AM > > To: tutor@python.org > > Subject: [Tutor] What is a Python "project"? > > > > I tried out

Re: [Tutor] question about sys.path and importing

2006-10-03 Thread Kent Johnson
Dick Moores wrote: > This morning I was sternly warned by Wingware support not to leave my > module of useful functions in Python25\Lib. So I put it in a > subfolder in site-packages I named "mine". Importing of or from that > module, mycalc.py goes well, to my surprise, because of > > >>> imp

[Tutor] question about sys.path and importing

2006-10-03 Thread Dick Moores
This morning I was sternly warned by Wingware support not to leave my module of useful functions in Python25\Lib. So I put it in a subfolder in site-packages I named "mine". Importing of or from that module, mycalc.py goes well, to my surprise, because of >>> import sys >>> [x for x in sys.pa

Re: [Tutor] What is a Python "project"?

2006-10-03 Thread Kent Johnson
Dick Moores wrote: > I tried out Wing IDE Personal > () off and on for 30 days, and > then, finding it easy to use (probably because it's designed for > Python), decided to buy it. I'm happy with it, and very pleased with > the fast response from technical

Re: [Tutor] What is a Python "project"?

2006-10-03 Thread Mike Hansen
> -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Dick Moores > Sent: Tuesday, October 03, 2006 12:52 AM > To: tutor@python.org > Subject: [Tutor] What is a Python "project"? > > I tried out Wing IDE Personal > (

Re: [Tutor] [Fwd: Re: database web app, what tool?]

2006-10-03 Thread Mike Hansen
> To: Liam Clarke <[EMAIL PROTECTED]> > References: <[EMAIL PROTECTED]> > <[EMAIL PROTECTED]> <[EMAIL PROTECTED]> > > > > Thank you Liam, > > > Our web server is IIS, but it would be no problem to use > another one for this > particular purpose. > > I'v been looking for information on h

Re: [Tutor] CGKit

2006-10-03 Thread Kent Johnson
Carlos wrote: > Hi, > > I'm new to python and have been trying to install CGKit, it has a bunch > of dependencies that I have to install. /At this point /the problem that > I have is that I need to install Py++, I already installed pygccxml and > GCC-XML. To install Py++ I downloaded it, and ex

Re: [Tutor] what is "user time" in os.times()?

2006-10-03 Thread Michael P. Reilly
Dang; sorry, thought I hit "Reply to all".I ran your program on two separate systems, three versions of Python here at work:1. Pent M 2GHz/Windows XP Pro, running Cygwin Python 2.4.3:  flips   heads  tails diff   %100 499598 500402 804 99.9196 per centTime was 2.863 secondsos.times() is (2.5779

Re: [Tutor] CGKit

2006-10-03 Thread Luke Paireepinart
> To install Py++ I downloaded it, and extracted it, next I > opened a windows command prompt and went to the corresponding directory, > then I typed "python setup.py install" this is supposed to install the > package? Because I only get a message from windows that states that to > install any

Re: [Tutor] timeit at the command line

2006-10-03 Thread Dick Moores
At 07:08 AM 10/3/2006, Kent Johnson wrote: >Dick Moores wrote: > > At 05:54 AM 10/3/2006, Kent Johnson wrote: > >> Dick Moores wrote: > >>> Very interesting. I thought a line of that template looked > >>> familiar. I was seeing "_t0 = _timer()" regularly when I had the -s > >>> option set without a

Re: [Tutor] what is "user time" in os.times()?

2006-10-03 Thread Dick Moores
At 05:24 AM 10/3/2006, Michael P. Reilly wrote: >It is not really a "ghost". On most systems, there is a split >between what happens while you are a "user" and what happens deep >inside the operation "system". The function is showing you how much >time elapsed while in those two areas of the s

[Tutor] CGKit

2006-10-03 Thread Carlos
Hi, I'm new to python and have been trying to install CGKit, it has a bunch of dependencies that I have to install. /At this point /the problem that I have is that I need to install Py++, I already installed pygccxml and GCC-XML. To install Py++ I downloaded it, and extracted it, next I opened

Re: [Tutor] timeit at the command line

2006-10-03 Thread Kent Johnson
Dick Moores wrote: > At 05:54 AM 10/3/2006, Kent Johnson wrote: >> Dick Moores wrote: >>> Very interesting. I thought a line of that template looked >>> familiar. I was seeing "_t0 = _timer()" regularly when I had the -s >>> option set without any setup: >>> C:\>python -m timeit -r 3 -s"for x in

Re: [Tutor] timeit at the command line

2006-10-03 Thread Dick Moores
At 05:54 AM 10/3/2006, Kent Johnson wrote: >Dick Moores wrote: >>Very interesting. I thought a line of that template looked >>familiar. I was seeing "_t0 = _timer()" regularly when I had the -s >>option set without any setup: >>C:\>python -m timeit -r 3 -s"for x in range(1):" " x*x" >>Traceb

Re: [Tutor] timeit at the command line

2006-10-03 Thread Kent Johnson
Dick Moores wrote: > Very interesting. I thought a line of that template looked familiar. > I was seeing "_t0 = _timer()" regularly when I had the -s option set > without any setup: > > C:\>python -m timeit -r 3 -s"for x in range(1):" " x*x" > Traceback (most recent call last): >File "E

Re: [Tutor] timeit at the command line

2006-10-03 Thread Dick Moores
At 04:35 AM 10/3/2006, Kent Johnson wrote: >Dick Moores wrote: > > At 03:05 AM 10/3/2006, Kent Johnson wrote: > >> timeit runs the setup code once, then runs the timed code many times > >> with the timer running. If "x=0" is outside the loop, then the while > >> loop only runs once, because x == 10

Re: [Tutor] Is there Python code for accessing an object's reference count?

2006-10-03 Thread Dick Moores
At 04:44 AM 10/3/2006, Kent Johnson wrote: >Dick Moores wrote: > > At 03:25 AM 10/3/2006, Andre Roberge wrote: > >> On 10/3/06, Dick Moores <[EMAIL PROTECTED]> wrote: > >>> Is there Python code for accessing an object's reference count? > >> See sys.getrefcount. > > > > Fascinating. And surprising.

Re: [Tutor] Is there Python code for accessing an object's reference count?

2006-10-03 Thread Kent Johnson
Dick Moores wrote: > At 03:25 AM 10/3/2006, Andre Roberge wrote: >> On 10/3/06, Dick Moores <[EMAIL PROTECTED]> wrote: >>> Is there Python code for accessing an object's reference count? >> See sys.getrefcount. > > Fascinating. And surprising. > >>> from sys import getrefcount > >>> getrefcount(

Re: [Tutor] timeit at the command line

2006-10-03 Thread Kent Johnson
Dick Moores wrote: > At 03:05 AM 10/3/2006, Kent Johnson wrote: >> timeit runs the setup code once, then runs the timed code many times >> with the timer running. If "x=0" is outside the loop, then the while >> loop only runs once, because x == 100 after the first time through the >> loop. So your

Re: [Tutor] timeit at the command line

2006-10-03 Thread Dick Moores
At 03:05 AM 10/3/2006, Kent Johnson wrote: >Dick Moores wrote: > > I DID have setup code, the "x=0". I now notice that if the "x=0" is > > not stated as the setup code, the time difference is enormous, > > 132-to-1 in this case. > > > > python -m timeit -s"x=0" "while x<100:" " x+=1" > > 100

Re: [Tutor] Is there Python code for accessing an object's reference count?

2006-10-03 Thread Dick Moores
At 03:25 AM 10/3/2006, Andre Roberge wrote: >On 10/3/06, Dick Moores <[EMAIL PROTECTED]> wrote: > > Is there Python code for accessing an object's reference count? > >See sys.getrefcount. Fascinating. And surprising. >>> from sys import getrefcount >>> getrefcount(1) 493 >>> getrefcount(2) 157

Re: [Tutor] Is there Python code for accessing an object's reference count?

2006-10-03 Thread Andre Roberge
On 10/3/06, Dick Moores <[EMAIL PROTECTED]> wrote: > Is there Python code for accessing an object's reference count? See sys.getrefcount. André Roberge > > And does it matter to Python what this count is, other than whether > it is zero or greater than zero (for garbage collection)? > > Thanks, >

[Tutor] Is there Python code for accessing an object's reference count?

2006-10-03 Thread Dick Moores
Is there Python code for accessing an object's reference count? And does it matter to Python what this count is, other than whether it is zero or greater than zero (for garbage collection)? Thanks, Dick Moores ___ Tutor maillist - Tutor@python.org

Re: [Tutor] timeit at the command line

2006-10-03 Thread Kent Johnson
Dick Moores wrote: > I DID have setup code, the "x=0". I now notice that if the "x=0" is > not stated as the setup code, the time difference is enormous, > 132-to-1 in this case. > > python -m timeit -s"x=0" "while x<100:" " x+=1" > 1000 loops, best of 3: 0.116 usec per loop > > python -

[Tutor] what is "user time" in os.times()?

2006-10-03 Thread Dick Moores
In a recent(ongoing?) thread on python-list, "PATCH: Speed up direct string concatenation by 20+%!", Larry Hastings, the op, says he computed his benchmark times using "sum(os.times()[:2])". Curious, I looked up os.times and tried it out on a little script I wrote to demonstrate the Law of Larg