maxskywalker wrote:
Vurb wrote:
maxskywalker wrote:
Yeah, I know. I just don't get what makes it better to say, for example, 'g.say()' instead of 'say()'. But yeah, I guess so.Who builds classes just for a say()? Your example of classes is like this example of functions - "who needs funcprint(this) instead of cout < this?
Yes, I know, I know. I was just using that as an example, from a classic Ruby Hello World program (
class Greeter
def initialize( name )
@name = name.capitalize
end
def say
puts "Hello #{@name}!"
end
end
g = Greeter.new( "world" )
g.say
in case you were wondering).
It's not a hello world for nothing isn't it. Simple examples are what make it.
Offline
Vurb wrote:
maxskywalker wrote:
Vurb wrote:
Who builds classes just for a say()? Your example of classes is like this example of functions - "who needs funcprint(this) instead of cout < this?
Yes, I know, I know. I was just using that as an example, from a classic Ruby Hello World program (
class Greeter
def initialize( name )
@name = name.capitalize
end
def say
puts "Hello #{@name}!"
end
end
g = Greeter.new( "world" )
g.say
in case you were wondering).It's not a hello world for nothing isn't it. Simple examples are what make it.
Um, not quite sure what that means, but yeah, sure, I think so. So… back on topic?
Last edited by maxskywalker (2011-10-03 12:45:53)
Offline
Back on topic... anyone?
Offline
Okay, I'm starting to think that someone closed the topic or something.
Offline
Well then, what's the difference between
class Class:
and
class Class(object):
? I can't figure out what functions are in the object class.
Offline
maxskywalker wrote:
Okay, I'm starting to think that someone closed the topic or something.
If someone closed it, you would not be able to post on it.
Offline
alldaykade28471 wrote:
maxskywalker wrote:
Okay, I'm starting to think that someone closed the topic or something.
If someone closed it, you would not be able to post on it.
I know. I was testing it.
Offline
nickbrickmaster wrote:
maxskywalker wrote:
7. Is Python capable of handling time (as in 'wait so-and-so seconds')?
You can use
Code:
sleep 5000That's for 5 secs.
I'm just learning python.
not quite
import time
sleep (5)this will sleep 5 seconds
Offline
maxskywalker wrote:
alldaykade28471 wrote:
maxskywalker wrote:
Okay, I'm starting to think that someone closed the topic or something.
If someone closed it, you would not be able to post on it.
I know. I was testing it.
It says "Topic closed" at the top... If it was...
Offline
maxskywalker wrote:
Well then, what's the difference between
Code:
class Class:and
Code:
class Class(object):? I can't figure out what functions are in the object class.
in 3, it's the same. Class inherits automatically from object if no superclass is present.
use dir(object) to get list of functions in it
Offline
roijac wrote:
maxskywalker wrote:
Well then, what's the difference between
Code:
class Class:and
Code:
class Class(object):? I can't figure out what functions are in the object class.
in 3, it's the same. Class inherits automatically from object if no superclass is present.
use dir(object) to get list of functions in it
but dir(object) doesn't tell me what they do.
Offline
Bump. Oh, and also, check my capitalization.
Offline
roijac wrote:
maxskywalker wrote:
...
but dir(object) doesn't tell me what they do.nothing, actually
![]()
h. L
L
Offline
Check my capitalization in the original post. Then tell me if you can figure out the riddle.
Offline