Re: [Tutor] LCM revisited + OOP

2012-11-27 Thread wrw
On Nov 27, 2012, at 8:13 PM, Ray Jones wrote: > > Part I > I am a good way through MIT's Introduction to Computer Science and > Programming as offered through edX. I'm not certain I'm going to pass > the course this first time through, the major hangup being the > understanding of OOP. > > Part

Re: [Tutor] LCM revisited + OOP

2012-11-27 Thread Ray Jones
On 11/27/2012 07:27 PM, Steven D'Aprano wrote: > For something as simple as Least Common Multiple? Using a function is > much more sensible than writing a class. > > OOP is for when you have a single data type that needs *state* and > *behaviour*. A LCM function only has behaviour, and so a func

Re: [Tutor] LCM revisited + OOP

2012-11-27 Thread Steven D'Aprano
On Tue, Nov 27, 2012 at 06:13:52PM -0700, Ray Jones wrote: > Part I > I am a good way through MIT's Introduction to Computer Science and > Programming as offered through edX. I'm not certain I'm going to pass > the course this first time through, the major hangup being the > understanding of OOP.

Re: [Tutor] Question about the raw string

2012-11-27 Thread Steven D'Aprano
On Wed, Nov 28, 2012 at 01:01:12AM +, JiangShan wrote: > Hi everyone, > >I am studying the python 3 and I am confused about the raw >string. Why does the python interpreter do not escape the >single backslash before the quotes even I add a "r" before the >st

[Tutor] LCM revisited + OOP

2012-11-27 Thread Ray Jones
Part I I am a good way through MIT's Introduction to Computer Science and Programming as offered through edX. I'm not certain I'm going to pass the course this first time through, the major hangup being the understanding of OOP. Part II When the LCM thread came through, I wrote some quick code do

[Tutor] Question about the raw string

2012-11-27 Thread JiangShan
Hi everyone, I am studying the python 3 and I am confused about the raw string. Why does the python interpreter do not escape the single backslash before the quotes even I add a "r" before the string. The following is an example: >>> print(r"\") SyntaxError: EOL

Re: [Tutor] manipulating a string in python

2012-11-27 Thread Albert-Jan Roskam
' > >import re >media_re = re.compile(r'(auto|10+T-[HF]D)') > >instr = """tmsh list net interface 1.1 media-capa \rbilities\nnet >interface 1.1 >{\n    media-capabilities {\n        none\n        auto\n        10T-FD\n >10T-HD\n        100TX-FD\n        100TX-HD\n        1000T-FD\n >1000T-HD\n 

Re: [Tutor] manipulating a string in python

2012-11-27 Thread Dave Angel
On 11/27/2012 11:49 AM, Dave Wilder wrote: Could you please use text mode in your messages? Your email editor produces double-spacing when it converts the html stuff you wrote into the text this forum supports. > > > I believe there is a simple answer to this, but I am confused on what > direct

Re: [Tutor] manipulating a string in python

2012-11-27 Thread Stuart Sears
On 27/11/12 16:49, Dave Wilder wrote: Hello, I believe there is a simple answer to this, but I am confused on what direction I should go that would perform what I wish to do most efficiently. ** My Environment *** [root@f5ite ~/tests]$ python Python 2.7 (r27:82500, Jul 6 2010, 02:54:50) [G

[Tutor] manipulating a string in python

2012-11-27 Thread Dave Wilder
Hello, I believe there is a simple answer to this, but I am confused on what direction I should go that would perform what I wish to do most efficiently. ** My Environment *** [root@f5ite ~/tests]$ python Python 2.7 (r27:82500, Jul 6 2010, 02:54:50) [GCC 4.1.2 20080704 (Red Hat 4.1.2-48

Re: [Tutor] doctest question

2012-11-27 Thread Steven D'Aprano
On 27/11/12 20:50, Albert-Jan Roskam wrote: Function name "_setMultRespDefsEx" is not self-explanatory, or even *hint* at what the function is supposed to do. It appears to take a dictionary of stuff, and formats it as a string. It would be nice[1] if your docstring explained what sort of stuff.

Re: [Tutor] doctest question

2012-11-27 Thread Dave Angel
On 11/27/2012 04:50 AM, Albert-Jan Roskam wrote: > >> On 27/11/12 08:06, Albert-Jan Roskam wrote: >>> (Steven D'Aprano wrote, even though the indentation is wrong) >>> >>> >>> >>> Doctesting anything to do with dictionaries is tricky, because you >>> cannot rely on the order of a dict. There are

Re: [Tutor] doctest question

2012-11-27 Thread Albert-Jan Roskam
  > On 27/11/12 08:06, Albert-Jan Roskam wrote: >> Hi, >> >> I am using doctest and I am struggling with newlines characters >> (see below). One is the newline escape (backslash) for a long >> dictionary definition. The other is an embedded \n in the output. >> I used the +NORMALIZE_WHITESPACE dir