Re: [Tutor] function error

2010-09-28 Thread Nitin Das
It seems that ur turtle.position doesn't return a list because of this when indexing is done on that u get this kind of error. --nitin On Tue, Sep 28, 2010 at 3:39 PM, Alan Gauld wrote: > > "roberto" wrote > > > i have the following error when i call this function: >> 20 def outOfBounds(): >>

Re: [Tutor] import problem

2010-08-28 Thread Nitin Das
it is >>> import calendar not calender --nitin On Sat, Aug 28, 2010 at 10:51 PM, wrote: > > > tutor-bounces+christopher.henk=allisontransmission@python.org wrote on > 08/28/2010 12:54:28 PM: > > > Hello, > > > > Im trying to do a import on a linux machine. > > But now Im gettting this messag

Re: [Tutor] question about lists and doctest

2010-08-26 Thread Nitin Das
The doctest module searches for pieces of text that look like interactive Python sessions, and then executes those sessions to verify that they work exactly as shown. Here ur a_list[3] in docstring is 42 then doctest expects it to be 42 for success. Since u changed 42 to 16 then it is not = 42 as p

Re: [Tutor] Trouble with exercise regarding classes

2010-08-25 Thread Nitin Das
There are 2 ways to get the ypos value one is cball.ypos and another is call.getY() both will give u the current ypos. --nitin On Thu, Aug 26, 2010 at 7:26 AM, Andrew Martin wrote: > All I want to do is add a line that displays that maximum height the > cannonball reaches. I created a variable z

Re: [Tutor] continuous running of a method

2010-08-24 Thread Nitin Das
The problem with this while loop is if your random value doesn't lie between the mentioned range then ur 100% cpu would be utilized. The one thing u can do is to sleep for some time lets say 0.5 sec after every while loop iteration , in this case ur cpu utilization will go down. --nitin On Mon, A

Re: [Tutor] Adding all numbers in a file or list

2010-08-24 Thread Nitin Das
alternatively you can use the lambda , reduce function for summing up all the numbers in a list for e.g:- lis = [1,2,3,4,5] p = reduce(lambda x,y : x+y, lis) p will have the value = 15. --nitin On Mon, Aug 23, 2010 at 9:05 PM, aug dawg wrote: > Oh okay, sorry about that. > > Thanks for the

Re: [Tutor] check the terminal keyword

2010-08-21 Thread Nitin Das
You can use raw_input like for e.g. u_input = raw_input("user_command") n then u can check u_input against anything. if doesn't matches then u can throw an error. I hope it shall help you. --nitin On Sat, Aug 21, 2010 at 6:37 PM, ANKUR AGGARWAL wrote: > i m making a app in which i launch applic

Re: [Tutor] prime test problem

2010-08-21 Thread Nitin Das
For this problem u will get lots of solutions on the net. e.g wilson's theorem , sieve of eranthoses etc. --nitin On Sat, Aug 21, 2010 at 7:05 PM, Roelof Wobben wrote: > Hello, > > I have to make a programm which can test if a number is a prime. > I know a prime is a number which can only be d

Re: [Tutor] List comprehension for dicts?

2010-08-20 Thread Nitin Das
result = [i%2 for i in itertools.takewhile(lamda x:i< 10, seq)] is a good approach but it is taking little more time than the for loop over iterator. def takewhile(predicate, iterable): # takewhile(lambda x: x<5, [1,4,6,4,1]) --> 1 4 for x in iterable: if predicate(x):

Re: [Tutor] Immutable objects

2010-08-19 Thread Nitin Das
Thanks guys, NamedTuple implementation is preety nice solution. --nitin On Thu, Aug 19, 2010 at 6:28 PM, Peter Otten <__pete...@web.de> wrote: > Peter Otten wrote: > > > Nitin Das wrote: > > > >> class mymut(object): > >> > >> def

Re: [Tutor] Immutable objects

2010-08-18 Thread Nitin Das
bject") class mm(mymut): x = '' y = '' def __init__(self,x,y): self.x = x self.y = y p = mm(10,11) print p.x print p.y I have created this immutable object.Is there any other better implementation? thanks -- nitin On Thu, Aug 19, 201

[Tutor] Immutable objects

2010-08-18 Thread Nitin Das
Hello, Can somebody help me how to make immutable objects in python. I have seen overriding the __new__, __setattr__ methods.. but not comfortable with how to use them to make the object immutable. thanks in advance --nitin ___ Tutor maillist - T

Re: [Tutor] Getting confusing NameError

2010-08-18 Thread Nitin Das
use raw_input instead of input . as using input is unsafe as it evaluates your input as python command. for e,g. x = input("enter command") and u entered "1 + 2" as input., then it will evaluate 1+2 = 3 = x. -nitin On Wed, Aug 18, 2010 at 12:45 PM, shane brennan wrote: > Hi Tutors > > This is m

Re: [Tutor] reading from 2 file output to 1

2010-08-17 Thread Nitin Das
I think in both the while loops , for loops are iterating over the new lines, as a result col1,col2,col3,col4,col5,col6,col7 as a result after both the while loop finishes these colums would only be having the values of the last lines from both the files. as a result the new file3 would only be hav

Re: [Tutor] Parsing RSS Feeds

2010-08-15 Thread Nitin Das
http://www.feedparser.org/ --nitin On Mon, Aug 16, 2010 at 3:50 AM, aug dawg wrote: > Hey all, > > Does anyone know of any modules to help my program parse RSS feeds? > > Thanks! > > ___ > Tutor maillist - Tutor@python.or