[Tutor] Second follow up

2013-02-26 Thread Jack Little
How would I go from one def statement to another? I am developing a text based 
rpg.

Sent from my iPod
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Second follow up

2013-02-26 Thread Dave Angel

On 02/26/2013 09:23 AM, Jack Little wrote:

How would I go from one def statement to another? I am developing a text based 
rpg.

Sent from my iPod
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor




For your next thread, please try to pick a subject line that has 
something to do with what you're asking, or what you're trying to learn 
about.


A def statement defines a function (or method).  Once it's defined, the 
compiler goes on to the next line, and if that's a def statement, it 
defines that function.


So all you need is a text editor.  Just understand that code that will 
call those functions from the top-level needs to be *after* the 
definition is complete.  Code that calls functions from inside a 
function does not need to be in any particular order.


If this isn't what you want, then try composing a ten-line sample, tell 
us what environment you're running it in, and what you hoped for, and 
what it did instead.



On the other hand, perhaps you're asking how to make indirect calls to 
functions.  A function object can be stored in a 'variable', simply by 
assigning it without using parentheses.  You can then later call that 
function by naming the object, and following the object with the 
parentheses.  Simple example follows;


def func1(name):
print function1, running with, name

def func2(name):
print function2, running with, name

funclist = []
funclist.append(func1)
funclist.append(func2)
funclist.append(func1)

funclist[1](Sam)
will call func2, and pass it Sam as an argument.

Normally, if you're doing this type of thing, you'd be using methods, 
not functions, but I'm not going to introduce classes unless you're 
already familiar with them.


--
DaveA
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Second follow up

2013-02-26 Thread Alan Gauld

On 26/02/13 14:23, Jack Little wrote:

How would I go from one def statement to another?


Type it in.

Based on your message that's all I can suggest.
Can you explain what you mean?

What do you have in mind by a def statement?

def foo():
   print 'foo'

def bar():
   print 'bar'

Those are two def statements. You can add as many
more as you like? But I suspect that's not really
what you mean?


I am developing a text based rpg.


I don't see whether/how that makes any difference to anything.

Telling us which OS and Python version you are using and what 
programming tools might help though.


--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Second follow up

2013-02-26 Thread Mark Lawrence

On 26/02/2013 14:23, Jack Little wrote:

How would I go from one def statement to another? I am developing a text based 
rpg.

Sent from my iPod
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor



I'd like to see your project when it's finished as a text based rocket 
propelled grenade seems very interesting, or are we talking cross 
purposes owing to a major lack of data?


--
Cheers.

Mark Lawrence

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Second follow up

2013-02-26 Thread Steven D'Aprano

On 27/02/13 01:23, Jack Little wrote:

How would I go from one def statement to another? I am developing a text based 
rpg.



def first_function():
# write your code here, indented by FOUR spaces or ONE tab


def second_function():  # NO INDENT
# write your code here, indented by FOUR spaces or ONE tab


Does that help?


--
Steven
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Second follow up

2013-02-26 Thread Steven D'Aprano

On 27/02/13 02:12, Mark Lawrence wrote:

On 26/02/2013 14:23, Jack Little wrote:

How would I go from one def statement to another? I am developing a text based 
rpg.


I'd like to see your project when it's finished as a text based rocket 
propelled grenade seems very interesting, or are we talking cross purposes 
owing to a major lack of data?



RPG: Role Playing Game.



--
Steven



___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Second follow up

2013-02-26 Thread Mark Lawrence

On 26/02/2013 16:01, Steven D'Aprano wrote:

On 27/02/13 01:23, Jack Little wrote:

How would I go from one def statement to another? I am developing a
text based rpg.



def first_function():
 # write your code here, indented by FOUR spaces or ONE tab


def second_function():  # NO INDENT
 # write your code here, indented by FOUR spaces or ONE tab


Does that help?




Get thee behind me Satan/Steven, tabs indeed :)

--
Cheers.

Mark Lawrence

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor