On 08Mar2018 20:25, C W wrote:
Thank you guys, lots of great answers, very helpful. I got it!
A follow-up question:
How did the value of "object" get passed to "time"? Obviously, they have
different names. How did Python make that connection?
Code is below for convenience.
class Clock(object
On Thu, 08 Mar 2018 20:25:42 -0500, C W wrote:
> Thank you guys, lots of great answers, very helpful. I got it!
>
> A follow-up question:
>
> How did the value of "object" get passed to "time"? Obviously, they have
> different names. How did Python make that connection?
It didn't. You have misu
Thank you guys, lots of great answers, very helpful. I got it!
A follow-up question:
How did the value of "object" get passed to "time"? Obviously, they have
different names. How did Python make that connection?
Code is below for convenience.
class Clock(object):
def __init__(self, time):
On Wed, 07 Mar 2018 16:57:51 -0500, C W wrote:
> Hello,
>
> I am new to OOP. I'm a bit confused about the following code.
>
> class Clock(object):
> def __init__(self, time):
> self.time = time
Here you set the instance attribute "self.time".
> def print_time(self):
> t
C W writes:
> I am new to OOP. I'm a bit confused about the following code.
>
> class Clock(object):
> def __init__(self, time):
> self.time = time
> def print_time(self):
> time = '6:30'
> print(self.time)
>
> clock = Clock('5:30')
> clock.print_time()
> 5:30
>
> I
"C W" wrote in message
news:cae2fw2nudjcmvukavzh01trkqeentkdxdpbawcphhsgx8jv...@mail.gmail.com...
Hello,
I am new to OOP. I'm a bit confused about the following code.
class Clock(object):
def __init__(self, time):
self.time = time
def print_time(self):
time = '6:30'
On Wed, 07 Mar 2018 16:57:51 -0500, C W wrote:
> class Clock(object):
> def __init__(self, time):
> self.time = time
> def print_time(self):
> time = '6:30'
> print(self.time)
>
> clock = Clock('5:30')
> clock.print_time()
> 5:30
>
> I set time to 6:30, but it's c
On Wed, 07 Mar 2018 16:57:51 -0500, C W wrote:
> Hello,
>
> I am new to OOP. I'm a bit confused about the following code.
>
> class Clock(object):
> def __init__(self, time):
> self.time = time
> def print_time(self):
> time = '6:30'
> print(self.time)
>
> clock
On Wed, Mar 7, 2018 at 1:57 PM, C W wrote:
> I set time to 6:30, but it's coming out to 5:30. I guess it's because I
> passed in 5:30, so, it's replaced?
time and self.time are 2 different things.
> How does line-by-line execution run inside a frame
To quickly come to grips with execution order
On 07Mar2018 16:57, C W wrote:
I am new to OOP. I'm a bit confused about the following code.
class Clock(object):
def __init__(self, time):
self.time = time
def print_time(self):
time = '6:30'
print(self.time)
clock = Clock('5:30')
clock.print_time()
5:30
I set time
On 3/7/2018 4:57 PM, C W wrote:
Hello,
I am new to OOP. I'm a bit confused about the following code.
class Clock(object):
def __init__(self, time):
self.time = time
def print_time(self):
time = '6:30'
print(self.time)
Local name 'time' is bound to '6:30'.
C W writes:
> I am new to OOP.
Welcome, and congratulations on learning Python.
> I'm a bit confused about the following code.
>
> def print_time(self):
Begins a function definition. The function will receive one argument
(the class instance), and bind the name ‘self’ to that.
>
On Wednesday, March 7, 2018 at 1:58:33 PM UTC-8, C W wrote:
> Hello,
>
> I am new to OOP.
There are (at least) two purposes for classes:
1) To group together data and functions in a meaningful way. Functions which
are defined inside a class are called methods.
2) To allow the preservation of
13 matches
Mail list logo