Re: [Tutor] Subclassing vs. stand alone functions

2007-06-15 Thread Jorgen Bodde
Hi, Basically you write a (sub)class when you want to preserve state information of your instance. If the functionality in question lives longer then the scope of the function, and will be called from different methods to obtain the same information and state of the functionality at that time, it

[Tutor] Subclassing vs. stand alone functions

2007-06-15 Thread chrispython
Hi there, I am new to Python and trying to get my head around the OO stuff. I guess my question is - when do you go with subclassing vs. making a standalone function? Let's say you want to load a dictionary. Do I create a function that accepts some argument (say a file name) and returns a dict

Re: [Tutor] Subclassing vs. stand alone functions

2007-06-15 Thread Senthil_OR
[EMAIL PROTECTED] wrote: > > Let's say you want to load a dictionary. Do I create a function that > accepts some argument (say a file name) and returns a dictionary, or > do I subclass dict and override the __init__ and __setitem__ > functions to make 'self-loading' dictionary? It seems the end r

Re: [Tutor] Subclassing vs. stand alone functions

2007-06-15 Thread Alan Gauld
<[EMAIL PROTECTED]> wrote > I am new to Python and trying to get my head around > the OO stuff. I guess my question is - when do you go > with subclassing vs. making a standalone function? OK, I'll take a slightly different approach than the other answers so far. First: procedural and OO st

Re: [Tutor] Automatic generation of an "all possible combinations" array

2007-06-15 Thread Andy Cheesman
The code works great, Thanks for the speedy response. The only problem which I can see is that the code scales very bad with the size of n. So, as I want a small subsection of the data (i.e lines where there are only 4 1s, number in the code below) for a system where n is large(>20). The idea is

Re: [Tutor] Automatic generation of an "all possible combinations" array

2007-06-15 Thread Luke Paireepinart
Andy Cheesman wrote: > The code works great, Thanks for the speedy response. The only problem > which I can see is that the code scales very bad with the size of n. > You could also do this by iterating in base-16 instead of base-10... given a string of hex, like "59FDE", there is a direct corre

Re: [Tutor] Automatic generation of an "all possible combinations" array

2007-06-15 Thread Alan Gauld
"Luke Paireepinart" <[EMAIL PROTECTED]> wrote > You could also do this by iterating in base-16 instead of base-10... I was going to suggest the same but using octal which has the same property but fewer values to map. :-) > hexmap = > {"0":"","1":"0001","2":"0010","3":"0011","4":"0100","5"

Re: [Tutor] Subclassing vs. stand alone functions

2007-06-15 Thread chrispython
I am new to Python and trying to get my head around the OO stuff. I guess my question is - when do you go with subclassing vs. making a standalone function? OK, I'll take a slightly different approach than the other answers so far. First: procedural and OO styles of programming are diffrent

Re: [Tutor] Automatic generation of an "all possible combinations" array

2007-06-15 Thread Hugh M
Ah, in the case of looking for all n-digit bit-strings that contain exactly m-1's, the recursive solution is even nicer. Here's how I think of it: Base Case(s): - if you want 0 1's (m==0) then return all 0's. - if you want all 1's (n==m) then return all 1's. Otherwise Recursive Case: - return th

[Tutor] How to localize PyKaraoke ?

2007-06-15 Thread Eiwot
Hi all, Can I use PyKaraoke in another language such as German ? How to make a song lyrics that match with the song , any word break or phrase break algorithm required ? Thanks Eiwot http://pyarticles.blogspot.com/ http://pythonforge.blogspot.com

Re: [Tutor] Tutor Digest, Vol 40, Issue 38

2007-06-15 Thread János Juhász
Hi Andy, > The code works great, Thanks for the speedy response. The only problem > which I can see is that the code scales very bad with the size of n. > So, as I want a small subsection of the data (i.e lines where there are > only 4 1s, number in the code below) for a system where n is large(