[Tutor] Dictionary to variable copy

2011-12-08 Thread sunil tech
*Can i copy the content if a dictionary in to another variable, with out any link between the dictionary the variable? if so, please teach. * ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options:

Re: [Tutor] Dictionary to variable copy

2011-12-08 Thread Timo
Op 08-12-11 10:03, sunil tech schreef: /Can i copy the content if a dictionary in to another variable, with out any link between the dictionary the variable? / Have a look at the copy module [1], or use the builtin dict.copy() method. Cheers, Timo [1]

[Tutor] how to calculate program compile time?

2011-12-08 Thread surya k
I'm doing puzzles where we need to write code that works as fast a possible So, how can I check the compile time of my program ?... ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription

[Tutor] unable to use find(), index()

2011-12-08 Thread surya k
I am using the following code  astr = foobarstr1 =fooastr.find(str1, beg=0, end=3) This is showing the following error Traceback (most recent call last):  File interactive input, line 1, in moduleTypeError: find() takes no keyword arguments I even tried by importing string module, but it isn't

Re: [Tutor] unable to use find(), index()

2011-12-08 Thread Walter Prins
Hi Surya, On 8 December 2011 11:19, surya k sur...@live.com wrote: astr.find(str1, beg=0, end=3) This is showing the following error Traceback (most recent call last): File interactive input, line 1, in moduleTypeError: find() takes no keyword arguments See the documentation for the

Re: [Tutor] how to calculate program compile time?

2011-12-08 Thread Christian Witts
On 2011/12/08 12:59 PM, surya k wrote: I'm doing puzzles where we need to write code that works as fast a possible So, how can I check the compile time of my program ?... ___ Tutor maillist - Tutor@python.org To unsubscribe or change

Re: [Tutor] unable to use find(), index()

2011-12-08 Thread Christian Witts
On 2011/12/08 01:19 PM, surya k wrote: I am using the following code astr = foobarstr1 =fooastr.find(str1, beg=0, end=3) This is showing the following error Traceback (most recent call last): File interactive input, line 1, inmoduleTypeError: find() takes no keyword arguments I even tried by

Re: [Tutor] unable to use find(), index()

2011-12-08 Thread Steven D'Aprano
surya k wrote: I am using the following code astr = foobarstr1 =fooastr.find(str1, beg=0, end=3) You have mangled the code in your email and lost line breaks. Fortunately this is simple enough to fix: astr = foobar str1 =foo astr.find(str1, beg=0, end=3) Please take more care to post code

[Tutor] how to use int and split() simultaneously

2011-12-08 Thread surya k
This is something I am trying to do.. Say, we are entering a string 1 2 3 4 5.so, I want to assign the numbers directly as numbers. how can I do it? I could put that numbers as string but not as number.. strNum = raw_input('enter:').split() I can convert the list into numbers by doing this...

Re: [Tutor] how to use int and split() simultaneously

2011-12-08 Thread Dario Lopez-Kästen
oh, yes, no top posting. See below. On Thu, Dec 8, 2011 at 1:33 PM, surya k sur...@live.com wrote: This is something I am trying to do.. Say, we are entering a string 1 2 3 4 5.so, I want to assign the numbers directly as numbers. how can I do it? I could put that numbers as string but not

[Tutor] print method name

2011-12-08 Thread rail shafigulin
i created a class and in some instances when i use it call some of its methods i need to print a method name. the online search did produce some results but none of them seem to work for me. for example one of them said just to use __name__ or func_name but it didn't work for me. i'm using python

Re: [Tutor] print method name

2011-12-08 Thread James Reynolds
On Thu, Dec 8, 2011 at 9:49 AM, rail shafigulin rail.shafigu...@gmail.comwrote: i created a class and in some instances when i use it call some of its methods i need to print a method name. the online search did produce some results but none of them seem to work for me. for example one of them

Re: [Tutor] print method name

2011-12-08 Thread Joel Goldstick
On Thu, Dec 8, 2011 at 9:49 AM, rail shafigulin rail.shafigu...@gmail.comwrote: i created a class and in some instances when i use it call some of its methods i need to print a method name. the online search did produce some results but none of them seem to work for me. for example one of them

[Tutor] how to find index of list with its value

2011-12-08 Thread surya k
Well, we all know to know the value when we have the index of a list. But how can we find it in the reverse way... say a listl=[1,2,3,4] l[0]=1.but how can I find its address with its value 1 ?? ___ Tutor

Re: [Tutor] how to find index of list with its value

2011-12-08 Thread Joel Goldstick
On Thu, Dec 8, 2011 at 10:28 AM, surya k sur...@live.com wrote: Well, we all know to know the value when we have the index of a list. But how can we find it in the reverse way... say a listl=[1,2,3,4] l[0]=1.but how can I find its address with its value 1 ??

Re: [Tutor] how to find index of list with its value

2011-12-08 Thread Tim Golden
On 08/12/2011 15:28, surya k wrote: Well, we all know to know the value when we have the index of a list. But how can we find it in the reverse way... say a listl=[1,2,3,4] l[0]=1.but how can I find its address with its value 1 ?? help ([]) ... index(...) L.index(value, [start,

Re: [Tutor] how to find index of list with its value

2011-12-08 Thread bodsda
mylist = [1,2,3,4,1] mylist.index(1) 0 But note that this only shows the index for the first occurrence of the item. Bodsda Sent from my BlackBerry® wireless device -Original Message- From: surya k sur...@live.com Sender: tutor-bounces+bodsda=googlemail@python.org Date: Thu, 8 Dec

Re: [Tutor] print method name

2011-12-08 Thread Lie Ryan
On 12/09/2011 01:49 AM, rail shafigulin wrote: i created a class and in some instances when i use it call some of its methods i need to print a method name. the online search did produce some results but none of them seem to work for me. for example one of them said just to use __name__ or

Re: [Tutor] print method name

2011-12-08 Thread rail shafigulin
On Thu, Dec 8, 2011 at 10:17 AM, Joel Goldstick joel.goldst...@gmail.comwrote: On Thu, Dec 8, 2011 at 9:49 AM, rail shafigulin rail.shafigu...@gmail.com wrote: i created a class and in some instances when i use it call some of its methods i need to print a method name. the online search

Re: [Tutor] print method name

2011-12-08 Thread rail shafigulin
On Thu, Dec 8, 2011 at 10:40 AM, Lie Ryan lie.1...@gmail.com wrote: On 12/09/2011 01:49 AM, rail shafigulin wrote: i created a class and in some instances when i use it call some of its methods i need to print a method name. the online search did produce some results but none of them seem to

Re: [Tutor] how to calculate program compile time?

2011-12-08 Thread Alan Gauld
On 08/12/11 10:59, surya k wrote: I'm doing puzzles where we need to write code that works as fast a possible So, how can I check the compile time of my program ?... Why would that be helpful? The code is only compiled the first time you use it so any second run will use the compiled code

Re: [Tutor] how to use int and split() simultaneously

2011-12-08 Thread Wayne Werner
On Thu, Dec 8, 2011 at 7:43 AM, Dario Lopez-Kästen cl2dl...@gmail.comwrote: snip In that case a for loop with a try-except would better: strNum = raw_input(enter numbers, separated by space: ).split() num_list = [] for token in strNum: try: num_list.append(int(token))

Re: [Tutor] print method name

2011-12-08 Thread Alan Gauld
On 08/12/11 14:49, rail shafigulin wrote: i created a class and in some instances when i use it call some of its methods i need to print a method name. I'm curious why you need this? In most cases if you call a method you know its name... myObj = MyClass() myObj.spam() print Just called

Re: [Tutor] Dictionary to variable copy

2011-12-08 Thread Alan Gauld
On 08/12/11 09:03, sunil tech wrote: /Can i copy the content if a dictionary in to another variable, with out any link between the dictionary the variable? if so, please teach. Yes, but they will both refer to the same object. But the two references will be entirely independant: D =

Re: [Tutor] how to link GUI app to the code

2011-12-08 Thread Prasad, Ramit
self.Bind(wx.EVT_BUTTON, self.OnSubmit, self.button_submit) How do you decide when it is appropriate to bind to a panel/frame and when to bind to the widget itself? I understand that certain events do not propagate up the widget stack, but what about for events that do? Is there a guideline of

Re: [Tutor] how to link GUI app to the code

2011-12-08 Thread ALAN GAULD
The general rule with GUIs is to bind at the lowest practical level, usually the widget itself. The exception is usually for things like global accelerators. For example launching a  help browser might be at window level.   Alan Gauld Author of the Learn To Program website

Re: [Tutor] how to use int and split() simultaneously

2011-12-08 Thread शंतनू
On 08-Dec-2011, at 7:13 PM, Dario Lopez-Kästen wrote: oh, yes, no top posting. See below. On Thu, Dec 8, 2011 at 1:33 PM, surya k sur...@live.com wrote: This is something I am trying to do.. Say, we are entering a string 1 2 3 4 5.so, I want to assign the numbers directly as numbers.

[Tutor] list.index() question

2011-12-08 Thread Robert Berman
Hi, Assuming a list similar to this: l1=[['a',1],['b',2],['c',3]] and I want to get the index of 'c'. A one dimensional list is extremely easy; val = list.index(value). But how do I get it for a list similar to l1. I have tried ind = l1[0].index('c') and that tells me 'c' is not in list.

Re: [Tutor] list.index() question

2011-12-08 Thread Alex Hall
On 12/8/11, Robert Berman berma...@cfl.rr.com wrote: Hi, Assuming a list similar to this: l1=[['a',1],['b',2],['c',3]] and I want to get the index of 'c'. A one dimensional list is extremely easy; val = list.index(value). But how do I get it for a list similar to l1. I have tried ind =

Re: [Tutor] list.index() question

2011-12-08 Thread bodsda
That won't work because l1[0] is ['a', 1] What happens if you don't change the code? l1.index('c') Bodsda Sent from my BlackBerry® wireless device -Original Message- From: Robert Berman berma...@cfl.rr.com Sender: tutor-bounces+bodsda=googlemail@python.org Date: Thu, 08 Dec 2011

Re: [Tutor] list.index() question

2011-12-08 Thread Robert Berman
On 12/08/2011 04:27 PM, bod...@googlemail.com wrote: That won't work because l1[0] is ['a', 1] What happens if you don't change the code? l1.index('c') Bodsda Sent from my BlackBerry® wireless device -Original Message- From: Robert Bermanberma...@cfl.rr.com Sender:

Re: [Tutor] list.index() question

2011-12-08 Thread Steven D'Aprano
Robert Berman wrote: Hi, Assuming a list similar to this: l1=[['a',1],['b',2],['c',3]] and I want to get the index of 'c'. You will need to explain what you mean by the index of 'c'. Do you mean 0, because 'c' is in position 0 of the sub-list ['c', 3]? Or do you mean 2, because 'c' is in

Re: [Tutor] how to use int and split() simultaneously

2011-12-08 Thread Steven D'Aprano
शंतनू wrote: Using re module: === import re strNum = raw_input(enter numbers, separated by space: ) if re.search('[^\d ]', strNum): print('Invalid input') else: data = [int(x) for x in strNum.split()] print(data) This is not Perl, where everything is a nail that needs to be

Re: [Tutor] list.index() question

2011-12-08 Thread Joel Goldstick
On Thu, Dec 8, 2011 at 5:03 PM, Steven D'Aprano st...@pearwood.info wrote: Robert Berman wrote: Hi, Assuming a list similar to this: l1=[['a',1],['b',2],['c',3]] and I want to get the index of 'c'. You will need to explain what you mean by the index of 'c'. Do you mean 0, because 'c'

Re: [Tutor] list.index() question

2011-12-08 Thread Robert Berman
On 12/08/2011 05:03 PM, Steven D'Aprano wrote: Robert Berman wrote: Hi, Assuming a list similar to this: l1=[['a',1],['b',2],['c',3]] and I want to get the index of 'c'. You will need to explain what you mean by the index of 'c'. Do you mean 0, because 'c' is in position 0 of the sub-list

Re: [Tutor] Super In tkinter class inheritance

2011-12-08 Thread Prasad, Ramit
class ChooseDestinationWindow(Frame): def __init__(self,master): super(ChooseDestinationWindow,self).__init_ _(master) What exactly does this super method since I have seen it numerous times before and as far as I can see it is not anything the user created himself in the class? This has to do