Alan thanks for the response;
> Message: 8
> Date: Sun, 1 Apr 2007 08:54:02 +0100
> From: "Alan Gauld" <[EMAIL PROTECTED]>
> Subject: Re: [Tutor] Another parsing question
> To: tutor@python.org
> Message-ID: <[EMAIL PROTECTED]>
> Content-Type: text/plain; format=flowed; charset="iso-8859-1";
>
On 4/1/07, Jay Mutter III <[EMAIL PROTECTED]> wrote:
> For some reason this never works for me;
That's because you are ignoring the linefeed character:
[...]
> if line.endswith('No.'):
>>> s1 = "some line\n"
>>> s2 = "some line"
>>> s1.endswith("line"), s2.endswith("line")
(False, True)
J
"Rikard Bosnjakovic" <[EMAIL PROTECTED]> wrote
s1 = "some line\n"
s2 = "some line"
s1.endswith("line"), s2.endswith("line")
> (False, True)
>
> Just skip the if and simply rstrip the string.
Or add \n to the endswith() test string if you really only
want to strip the newline in
"Jay Mutter III" <[EMAIL PROTECTED]> wrote
> inp = open('test.txt','r')
> s = inp.readlines()
> for line in s:
> if line.endswith('No.'):
> line = line.rstrip()
> print line
BTW,
You do know that you can shorten that considerably?
With:
for line in open('test.txt'):
if line.
Hi again,
I am still in the process of learning OOP concepts and reasons why classes
should be used instead of functions etc.
One thing that is not apparent to me is the best way for classes to communicate
with each other. For example, I have created an Args class that sets a variety
of inter
Hi Greg,
Greg Perry wrote:
> I am still in the process of learning OOP concepts and
> reasons why classes should be used instead of functions etc.
>
> One thing that is not apparent to me is the best way for
> classes to communicate with each other. For example,
Good question. Unfortunately
Hello
I am trying to convert from MATLAB to Python.
I am using Python 2.4.3 for Windows (Enthought Edition)
In one of the first programs, I tried to use the special functions from the
SciPy "special" module.
However, when I tryed:
>> from scipy import *
>> special.jv(0,1+1j)
I got an error me
That makes sense, thank you for the detailed explanation Andrei. For this
simple project I am working on, it looks like the most direct route would be to
use functions and only develop classes for the portions of the program that can
be reused.
Is it safe to say that classes are only useful fo
Is there a way to have the output of "print tis" in the same format as
"print now" and "print tafmsd" in the code below?
Thanks,
Will
savage:~ wallison$ python
Python 2.5 (r25:51918, Sep 19 2006, 08:49:13)
[GCC 4.0.1 (Apple Computer, Inc. build 5341)] on darwin
Type "help", "copyright", "credits
"Greg Perry" <[EMAIL PROTECTED]> wrote
> I am still in the process of learning OOP concepts and
> reasons why classes should be used instead of
> functions etc.
That's OK, many folks find the transition hard at first.
It is a new way of looking at problems.
> One thing that is not apparent to
"Greg Perry" <[EMAIL PROTECTED]> wrote
> That makes sense, thank you for the detailed explanation
> Andrei. For this simple project I am working on, it looks
> like the most direct route would be to use functions
Thats often the case. Often when people start with OOP
they try to do everythi
"Eli Brosh" <[EMAIL PROTECTED]> wrote
>> from scipy import *
>> special.jv(0,1+1j)
>
> I got an error message and python restarted.
It would be good if you could include the error text.
However, did you try putting the complex number in parens?
or assigning to a variable and then pass the var
> Is there a way to have the output of "print tis" in the same format as
> "print now" and "print tafmsd" in the code below?
> Thanks,
> Will
> savage:~ wallison$ python
> Python 2.5 (r25:51918, Sep 19 2006, 08:49:13)
> [GCC 4.0.1 (Apple Computer, Inc. build 5341)] on darwin
> Type "help", "copy
13 matches
Mail list logo