On 24/12/12 16:31, bob gailer wrote:
On 12/23/2012 9:02 PM, Alan Gauld wrote:
You do realize that self is only defined inside a method?
Perhaps.
self is just another name - it could be "just" a variable, outside any
method.
True enough, but given the usage "self.A" it looks pretty certain
On 12/23/2012 9:02 PM, Alan Gauld wrote:
You do realize that self is only defined inside a method?
Perhaps.
self is just another name - it could be "just" a variable, outside any
method.
--
Bob Gailer
919-636-4239
Chapel Hill NC
___
Tutor mailli
On 12/23/2012 09:02 PM, Alan Gauld wrote:
> On 24/12/12 01:16, Mitya Sirenef wrote:
>> On 12/23/2012 08:03 PM, Tom Tucker wrote:
>>>
>>>
>>> Python Gurus,
>>> I got a question for ya. Below I have three instance variables
>>> (self.A, self.B, etc). How can I use the below
>>> for loop for A, B, C
On 24/12/12 01:16, Mitya Sirenef wrote:
On 12/23/2012 08:03 PM, Tom Tucker wrote:
Python Gurus,
I got a question for ya. Below I have three instance variables
(self.A, self.B, etc). How can I use the below
for loop for A, B, C to also call those instance variables?
Your example is not ent
On 12/23/2012 08:03 PM, Tom Tucker wrote:
Python Gurus,
I got a question for ya. Below I have three instance variables
(self.A, self.B, etc). How can I use the below
for loop for A, B, C to also call those instance variables?
Example
###
.
.
self.A = 1
self.
Python Gurus,
I got a question for ya. Below I have three instance variables (self.A,
self.B, etc). How can I use the below
for loop for A, B, C to also call those instance variables?
Example
###
.
.
self.A = 1
self.B= 2
self.C= 3
myDict = {'A': 1, 'B':
On 7/1/2012 2:50 PM Jim said...
Hello Friends,
I apologize for being such a bother. This problem has been evading me
all day. Can you please give me a hint as to why I cannot put the
variable UpperCaseSentence outside of the for loop?
I can do it in other instances but not in this one.
Thank you
On Sun, Jul 1, 2012 at 11:50 PM, Jim wrote:
> Hello Friends,
> I apologize for being such a bother. This problem has been evading me all
> day. Can you please give me a hint as to why I cannot put the variable
> UpperCaseSentence outside of the for loop?
> I can do it in other instances but not i
Hello Friends,
I apologize for being such a bother. This problem has been evading me
all day. Can you please give me a hint as to why I cannot put the
variable UpperCaseSentence outside of the for loop?
I can do it in other instances but not in this one.
Thank you so much,
Jim
#Main function.
On Fri, Jun 27, 2008 at 2:45 AM, Mark Tolonen <[EMAIL PROTECTED]> wrote:
> The above solutions create new lists. If a functional requirement is to
> modify the list in place, then the original is fine (on Python 2.6 and
> later) or should use xrange instead of range (on Python 2.5 or earlier,
> e
"Lie Ryan" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
On Thu, Jun 26, 2008 at 3:18 AM, Dick Moores <[EMAIL PROTECTED]> wrote:
Hi I'm learning FOR loop now, very easy too learn. But I get confused
to understand this code :
myList = [1,2,3,4]
for index in range(len(myList)):
On Thu, Jun 26, 2008 at 3:18 AM, Dick Moores <[EMAIL PROTECTED]> wrote:
> Hi I'm learning FOR loop now, very easy too learn. But I get confused
> to understand this code :
>
> myList = [1,2,3,4]
> for index in range(len(myList)):
> myList[index] += 1
> print myList
>
> And the response is:
>
Le Thursday 26 June 2008 15:27:05 Danny Laya, vous avez écrit :
> Hi I'm learning FOR loop now, very easy too learn. But I get confused to
> understand this code : myList = [1,2,3,4]
> for index in range(len(myList)):
> myList[index] += 1
> print myList
>
> And the response is:
> [2, 3, 4, 5]
>
On Thu, Jun 26, 2008 at 9:27 AM, Danny Laya <[EMAIL PROTECTED]> wrote:
> Hi I'm learning FOR loop now, very easy too learn. But I get confused to
> understand this code :
>
> myList = [1,2,3,4]
> for index in range(len(myList)):
> myList[index] += 1
> print myList
>
> And the response is:
> [2,
Hi I'm learning FOR loop now, very easy too learn. But I get confused to
understand this code :
myList = [1,2,3,4]
for index in range(len(myList)):
myList[index] += 1
print myList
And the response is:
[2, 3, 4, 5]
Can you explain me as a newbie, how that code works ??
_
e typed something incorrectly previously :\
Thanks again
Gideon (aka Fatfingers)
-Original Message-
From: w chun [mailto:[EMAIL PROTECTED]
Sent: Thursday, 11 May 2006 1:11 PM
To: STREET Gideon (SPARQ)
Cc: tutor@python.org
Subject: Re: [Tutor] For loop question
> Thanks all, appears it is
> Thanks all, appears it is the newline character which was causing me
> grief. For some reason I still have to do a readlines on the open file
> at this stage, but I can muck about with that to figure it out.
that is surprising... i would be interested in hearing what problems
you are encounter
Behalf Of Kent Johnson
Sent: Thursday, 11 May 2006 1:03 AM
Cc: tutor@python.org
Subject: Re: [Tutor] For loop question
w chun wrote:
> Kent Johnson wrote:
>> For short Python scripts I usually allow the runtime to close the
file.
>> For longer programs and anything written in Jy
> >> For short Python scripts I usually allow the runtime to close the file.
> >> For longer programs and anything written in Jython (which has different
> >> garbage collection behaviour) I usually use an explicit close().
> >
> > i'm still not comfortable without doing my own explicit close(), es
w chun wrote:
> Kent Johnson wrote:
>> For short Python scripts I usually allow the runtime to close the file.
>> For longer programs and anything written in Jython (which has different
>> garbage collection behaviour) I usually use an explicit close().
>
> i'm still not comfortable without doing
>> HostFile = open("hosts.txt", 'r')
>> for item in [x.strip() for x in HostFile]:
>> :
>>
>>Why is this better when the file is large? It still creates a list with
all lines in it.
yup, that's why i mention this fact below while giving the genex solution.
> > Why not simply:
> >
> > for
CTED] [mailto:[EMAIL PROTECTED] On
Behalf Of Kent Johnson
Sent: Wednesday, May 10, 2006 5:52 AM
Cc: tutor@python.org
Subject: Re: [Tutor] For loop question
w chun wrote:
> another thing is that if the host file is large, you may wish to
> iterate through the file one line at a time with a l
Behalf Of Kent Johnson
> Sent: Wednesday, May 10, 2006 5:52 AM
> Cc: tutor@python.org
> Subject: Re: [Tutor] For loop question
>
>
> w chun wrote:
>> another thing is that if the host file is large, you may wish to
>> iterate through the file one line at a time with
> Been trying to understand why the following doesn't work:
>
> HostFile = open("hosts.txt", 'r')
> host = HostFile.readlines()
>
> for item in host:
> print "Connecting to device",item
> tn = telnetlib.Telnet(item)
>:
> File "c:\gideon\python24\lib\telnetlib.py", line 225, in ope
Hi all,
Been trying to understand why the following doesn't work:
HostFile = open("hosts.txt", 'r')
host = HostFile.readlines()
for item in host:
print "Connecting to device",item
tn = telnetlib.Telnet(item)
...
Do some other stuff here
...
I get the following error:
Traceback (most r
w chun wrote:
> another thing is that if the host file is large, you may wish to
> iterate through the file one line at a time with a list comprehension
> to do the stripping for you:
>
> HostFile = open("hosts.txt", 'r')
> for item in [x.strip() for x in HostFile]:
> :
Why is this better
26 matches
Mail list logo