Re: [Tutor] Pyhton editor

2012-02-17 Thread Laszlo Antal
Hi, On Feb 17, 2012, at 20:23, Robert Berman wrote: > > > On Fri, Feb 17, 2012 at 10:48 PM, Kapil Shukla wrote: > All > > Couple of weeks ago I was looking for a nice free IDE for python and got many > wonderful suggestion form very helpful people. However I stumbled upon > PyScripter and

Re: [Tutor] Pyhton editor

2012-02-17 Thread Robert Berman
On Fri, Feb 17, 2012 at 10:48 PM, Kapil Shukla wrote: > All > > Couple of weeks ago I was looking for a nice free IDE for python and got > many wonderful suggestion form very helpful people. However I stumbled upon > PyScripter and I find it really amazing. > > I feel once u try it you will hook o

Re: [Tutor] dict vs several variables?

2012-02-17 Thread Steven D'Aprano
Leam Hall wrote: I'm building a program that uses one of my own modules for a bunch of formula defs and another module for the tkinter GUI stuff. There are half a dozen input variables and about the same in calculated variables. Is it better/cleaner to just build a global dict and have everythi

[Tutor] Pyhton editor

2012-02-17 Thread Kapil Shukla
All Couple of weeks ago I was looking for a nice free IDE for python and got many wonderful suggestion form very helpful people. However I stumbled upon PyScripter and I find it really amazing. I feel once u try it you will hook on to it for ever Thanks Best Regards Kapil __

Re: [Tutor] dict vs several variables?

2012-02-17 Thread Leam Hall
On 02/17/2012 09:26 AM, Dave Angel wrote: There are two ways to think of a class. One is to hold various related data, and the other is to do operations on that data. If you just consider the first, then you could use a class like a dictionary whose keys are fixed (known at "compile time"). I t

Re: [Tutor] How to hide cursor in Terminal?

2012-02-17 Thread brandon w
This is what I ended up using: import time import sys import os def countd(): seconds = 59 minutes = 4 five_minutes = 0 os.system('clear') os.system('setterm -cursor off') while five_minutes != 300: sys.stdout.write("\r%d:%02.f\t" % (minutes, seconds)) s

Re: [Tutor] How to hide cursor in Terminal?

2012-02-17 Thread Alan Gauld
On 17/02/12 11:38, brandon w wrote: I made a timer that counts down from five minutes. This code runs fine but I a seeing a cursor blinking on the first number as the code is running. How do I avoid this? Try putting the carriage return at the start of the line. You print the line then reset

Re: [Tutor] dict vs several variables?

2012-02-17 Thread Alan Gauld
On 17/02/12 14:10, leam hall wrote: The variables input seem to be assumed to be strings They are not assumed to be strings, they *are* strings. Users can only type characters at the keyboard (the usual source of input). Your program has to interpret those characters and convert to the right

Re: [Tutor] Debugging While Loops for Control

2012-02-17 Thread Peter Otten
Alan Gauld wrote: >>The "x for x in y:" syntax makes it harder to follow for learners, > > Read about list comprehensions first. > It helps if you studied sets in math at school. The format is > somewhat like the math notation for defining a set. But FWIW it took me > a long time to get used to t

Re: [Tutor] Debugging While Loops for Control

2012-02-17 Thread Robert Sjoblom
>> class Card(object): >>        def __init__(self): >>                self.score = self.deal() >> >>        def deal(self): >>                """deal a card from 1 to 52 and return it's points""" >>                return self.getValue(int(math.floor(random.uniform(1, >> 52 > > I think you only

Re: [Tutor] finding a maximum between the absolute difference of several columns

2012-02-17 Thread Andre' Walker-Loud
> import numpy as np >> Vhel_fdiff3 = np.array([abs(Vmatch3_1 - Vmatch3_2), abs(Vmatch3_1 - >> Vmatch3_3), abs(Vmatch3_3 - Vmatch3_2)]) >> your_answer = Vhel_fdiff3.max(axis=0) > > or > > import numpy as np > a = np.array([Vmatch3_1-Vmatch3_2, Vmatch3_1-Vmatch3_3, Vmatch3_3- > Vmatch3_2]) > print

Re: [Tutor] dict vs several variables?

2012-02-17 Thread Peter Otten
leam hall wrote: > On 2/17/12, Peter Otten <__pete...@web.de> wrote: >> leam hall wrote: >>> and they may have to have their type set >> >> I have no idea what you mean by "have their type set". Can you give an >> example? > > Peter, > > The variables input seem to be assumed to be strings and I

Re: [Tutor] dict vs several variables?

2012-02-17 Thread Dave Angel
On 02/17/2012 09:06 AM, leam hall wrote: On 2/17/12, Dave Angel wrote: Real question is whether some (seldom all) of those variables are in fact part of a larger concept. If so, it makes sense to define a class for them, and pass around objects of that class. Notice it's not global, it's sti

Re: [Tutor] dict vs several variables?

2012-02-17 Thread leam hall
On 2/17/12, Peter Otten <__pete...@web.de> wrote: > leam hall wrote: >> and they may have to have their type set > > I have no idea what you mean by "have their type set". Can you give an > example? Peter, The variables input seem to be assumed to be strings and I need them to be an integer or a

Re: [Tutor] dict vs several variables?

2012-02-17 Thread leam hall
On 2/17/12, Dave Angel wrote: > Real question is whether some (seldom all) of those variables are in > fact part of a larger concept. If so, it makes sense to define a class > for them, and pass around objects of that class. Notice it's not > global, it's still passed as an argument. This can

Re: [Tutor] dict vs several variables?

2012-02-17 Thread Peter Otten
leam hall wrote: > My concern with variables is that they have to be passed in specific > order to the function, Yes, unless you use keywords. You can invoke def div(x, y): return x // y a = div(3, 2) b = div(y=3, x=2) assert a == b > and they may have to have their type set I have no ide

Re: [Tutor] dict vs several variables?

2012-02-17 Thread Dave Angel
On 2/17/12, Peter Otten<__pete...@web.de> wrote: Leam Hall wrote: I'm building a program that uses one of my own modules for a bunch of formula defs and another module for the tkinter GUI stuff. There are half a dozen input variables and about the same in calculated variables. Is it better/c

Re: [Tutor] dict vs several variables?

2012-02-17 Thread Sander Sweers
On 17 February 2012 14:04, leam hall wrote: > My concern with variables is that they have to be passed in specific > order to the function, and they may have to have their type set > multiple times so that you can perform the right functions on them. In > a dict you could set it on insert and not

Re: [Tutor] dict vs several variables?

2012-02-17 Thread leam hall
Thanks Peter! My concern with variables is that they have to be passed in specific order to the function, and they may have to have their type set multiple times so that you can perform the right functions on them. In a dict you could set it on insert and not have to worry about it. Thanks! Leam

Re: [Tutor] How to hide cursor in Terminal?

2012-02-17 Thread Hugo Arts
On Fri, Feb 17, 2012 at 12:38 PM, brandon w wrote: > I made a timer that counts down from five minutes. This code runs fine but I > a seeing a cursor blinking on the first number as the code is running. How > do I avoid this? > > I am using gnome-terminal and Python 2.6.6. > > > #!/usr/bin/python

Re: [Tutor] dict vs several variables?

2012-02-17 Thread Peter Otten
Leam Hall wrote: > I'm building a program that uses one of my own modules for a bunch of > formula defs and another module for the tkinter GUI stuff. There are > half a dozen input variables and about the same in calculated variables. > Is it better/cleaner to just build a global dict and have eve

Re: [Tutor] finding a maximum between the absolute difference of several columns

2012-02-17 Thread Peter Otten
Andre' Walker-Loud wrote: > import numpy as np > Vhel_fdiff3 = np.array([abs(Vmatch3_1 - Vmatch3_2), abs(Vmatch3_1 - > Vmatch3_3), abs(Vmatch3_3 - Vmatch3_2)]) > your_answer = Vhel_fdiff3.max(axis=0) or import numpy as np a = np.array([Vmatch3_1-Vmatch3_2, Vmatch3_1-Vmatch3_3, Vmatch3_3- Vmatch3

[Tutor] How to hide cursor in Terminal?

2012-02-17 Thread brandon w
I made a timer that counts down from five minutes. This code runs fine but I a seeing a cursor blinking on the first number as the code is running. How do I avoid this? I am using gnome-terminal and Python 2.6.6. #!/usr/bin/python import time import sys import os def countd(): seconds = 5

[Tutor] dict vs several variables?

2012-02-17 Thread Leam Hall
I'm building a program that uses one of my own modules for a bunch of formula defs and another module for the tkinter GUI stuff. There are half a dozen input variables and about the same in calculated variables. Is it better/cleaner to just build a global dict and have everything go into it or

Re: [Tutor] Debugging While Loops for Control

2012-02-17 Thread Alan Gauld
On 17/02/12 03:27, Luke Thomas Mergner wrote: In the meantime, and continuing my problem of over-cleverness, At least you know what your problem is :-) Bonus question: when I create a the "def score(self)" in class Hand, > should that be an generator? No. And if so where do I go as a n

Re: [Tutor] How to convert seconds to hh:mm:ss format

2012-02-17 Thread Asokan Pichai
On Fri, Feb 17, 2012 at 3:16 AM, alain Delon wrote: > userName = raw_input("Enter your name ") >      print "hi " + userName + ". \n " >      seconds = input("Enter the number of seconds since midnight:") >      hours = seconds/3600 >      hoursRemain = hours%60 **