[Tutor] functions and default argument

2011-10-21 Thread Praveen Singh
In function- Default value is *evaluated only once*.This makes different when the default is a mutable object such as a list, dictionary or instance of most classes. I am not getting it properly-evaluated once?? different behaviour???-- please explain this.

Re: [Tutor] functions and default argument

2011-10-21 Thread Christian Witts
On 2011/10/21 03:00 PM, Praveen Singh wrote: In function- Default value is *evaluated only once*.This makes different when the default is a mutable object such as a list, dictionary or instance of most classes. I am not getting it properly-evaluated once?? different behaviour???-- please

[Tutor] Web Praser

2011-10-21 Thread Crusier
Hi, I am new to programming. I want to know what I should look at if I want to learn more about Web Praser. I know there is something called Beautiful Soup but I think it is kind of difficult for me at this stage. Thank you Regards, Crusier ___ Tutor

Re: [Tutor] functions and default argument

2011-10-21 Thread Steven D'Aprano
Praveen Singh wrote: In function- Default value is *evaluated only once*.This makes different when the default is a mutable object such as a list, dictionary or instance of most classes. I am not getting it properly-evaluated once?? different behaviour???-- please explain this. Look at an

Re: [Tutor] Web Praser

2011-10-21 Thread Steven D'Aprano
Crusier wrote: Hi, I am new to programming. I want to know what I should look at if I want to learn more about Web Praser. I know there is something called Beautiful Soup but I think it is kind of difficult for me at this stage. What do you mean by web parser? The web (world wide web) is a

Re: [Tutor] functions and default argument

2011-10-21 Thread Prasad, Ramit
The same thing occurs when you use a mutable object like a list or a dict. The default value is assigned once, and once only. But notice that you can modify the default value, say by appending to it: Not sure this will work exactly the same way in other IDEs, but in mine: a = [] def

Re: [Tutor] functions and default argument

2011-10-21 Thread Albert-Jan Roskam
Interesting thread and webpages. Insightful, but is this really used as a technique in daily practice? It feels a bit like a hack to me. Like the author of one of the websites said: rule #1 don't mess with this.   Cheers!! Albert-Jan

Re: [Tutor] functions and default argument

2011-10-21 Thread Prasad, Ramit
Interesting thread and webpages. Insightful, but is this really used as a technique in daily practice? It feels a bit like a hack to me. Like the author of one of the websites said: rule #1 don't mess with this. I think the problem with rule #1 is that this can occur when you do *not*

[Tutor] difference between super() and parent.__init__()?

2011-10-21 Thread Alex Hall
Hi all, I am just curious: I have seen classes that are subclasses initialize their parents through both super and parentClass.__init__. What is the difference, if any, and is one better or more pythonic than the other? -- Have a great day, Alex (msg sent from GMail website) mehg...@gmail.com;

Re: [Tutor] functions and default argument

2011-10-21 Thread Alan Gauld
On 21/10/11 21:40, Albert-Jan Roskam wrote: Interesting thread and webpages. Insightful, but is this really used as a technique in daily practice? Yes, one example is where you use it for a counter to determine how often a function gets called: def reserveScarceResource(p1,p2,count = [0]):

Re: [Tutor] difference between super() and parent.__init__()?

2011-10-21 Thread Steven D'Aprano
Alex Hall wrote: Hi all, I am just curious: I have seen classes that are subclasses initialize their parents through both super and parentClass.__init__. What is the difference, if any, and is one better or more pythonic than the other? A simple question with a complicated answer... First

Re: [Tutor] Web Praser

2011-10-21 Thread Alan Gauld
On 21/10/11 17:37, Crusier wrote: want to learn more about Web Praser. I know there is something called Beautiful Soup but I think it is kind of difficult for me at this stage. One of the objectives of Beautiful Soup is to make parsing fairly easy. Its certainly easier than most of the other

Re: [Tutor] functions and default argument

2011-10-21 Thread Steven D'Aprano
Prasad, Ramit wrote: Interesting thread and webpages. Insightful, but is this really used as a technique in daily practice? It feels a bit like a hack to me. Like the author of one of the websites said: rule #1 don't mess with this. I think the problem with rule #1 is that this can occur when

Re: [Tutor] difference between super() and parent.__init__()?

2011-10-21 Thread Alex Hall
On 10/21/11, Steven D'Aprano st...@pearwood.info wrote: Alex Hall wrote: Hi all, I am just curious: I have seen classes that are subclasses initialize their parents through both super and parentClass.__init__. What is the difference, if any, and is one better or more pythonic than the other?