Dave Angel wrote:
> On 06/23/2013 02:18 AM, Jack Little wrote:
>> I am trying to use random.choice for a text based game. I am using
>> windows 7, 64-bit python. Here is my code:
>>
>> def lvl2():
>> print "COMMANDER: Who should you train with?"
>> trn=random.choice(1,2)
>> if trn==
On 06/23/2013 02:18 AM, Jack Little wrote:
I am trying to use random.choice for a text based game. I am using windows 7,
64-bit python. Here is my code:
def lvl2():
print "COMMANDER: Who should you train with?"
trn=random.choice(1,2)
if trn==1:
lvl2_1()
print "S
On 23/06/13 16:18, Jack Little wrote:
I am trying to use random.choice for a text based game. I am using windows 7,
64-bit python. Here is my code:
def lvl2():
print "COMMANDER: Who should you train with?"
trn=random.choice(1,2)
[...]
Here is my error:
File "C:\Users\Jack\Deskto
I am trying to use random.choice for a text based game. I am using windows 7,
64-bit python. Here is my code:
def lvl2():
print "COMMANDER: Who should you train with?"
trn=random.choice(1,2)
if trn==1:
lvl2_1()
print "Squad One!"
elif trn==2:
lvl2_2()
On 03/07/2008, Alan Gauld <[EMAIL PROTECTED]> wrote:
> "John Fouhy" <[EMAIL PROTECTED]> wrote
> > you can instead say:
> >
> > try:
> > foo()
> > except TypeError:
> > # do something else
> This makes slightly more sense, although a TypeError seems a bit
> too vague, if it had bveen a Callab
"John Fouhy" <[EMAIL PROTECTED]> wrote
otherwise. this will be removed for Python 3.x because you can
just
use hasattr(obj, '__call__').
I was about to go BOO HISS because callable() is much more
readable than hasattr() but...
you can instead say:
try:
foo()
except TypeError:
# do
On 03/07/2008, wesley chun <[EMAIL PROTECTED]> wrote:
> on a related note, currently in Python, there is a callable() Boolean
> function that returns True if the object's callable and False
> otherwise. this will be removed for Python 3.x because you can just
> use hasattr(obj, '__call__').
I
> > It seems to me that Wes is saying only that all function objects are
> > callable, not that all callable objects are functions.
>
> Wesley said that function objects have a "heaping distinction" of
> being callable. Only he can say for sure what that means; I took it to
> mean that being ca
On Wed, Jul 2, 2008 at 11:50 AM, Dick Moores <[EMAIL PROTECTED]> wrote:
> It seems to me that Wes is saying only that all function objects are
> callable, not that all callable objects are functions.
Wesley said that function objects have a "heaping distinction" of
being callable. Only he can say
At 03:46 AM 7/2/2008, Kent Johnson wrote:
On Wed, Jul 2, 2008 at 3:54 AM, wesley chun <[EMAIL PROTECTED]> wrote:
> in the former, you have a function object. it's just like any other
> Python object, but with one heaping distinction: it's callable --
> this means that u can slap on a pair of p
On Wed, Jul 2, 2008 at 3:54 AM, wesley chun <[EMAIL PROTECTED]> wrote:
> in the former, you have a function object. it's just like any other
> Python object, but with one heaping distinction: it's callable --
> this means that u can slap on a pair of parentheses after the object
> and execute it
At 12:54 AM 7/2/2008, wesley chun wrote:
ok, someone has to be the bad guy and show an example of equivalent
code that's more difficult to read:
choice([use_for_float_demo, use_for_integer_demo])()
seriously tho, the bottom line of what people have been telling you is
that for the function (or
ok, someone has to be the bad guy and show an example of equivalent
code that's more difficult to read:
choice([use_for_float_demo, use_for_integer_demo])()
seriously tho, the bottom line of what people have been telling you is
that for the function (or method) foo():
def foo():
:
there is
At 06:23 AM 7/1/2008, Cédric Lucantis wrote:
Le Tuesday 01 July 2008 15:04:11 Dick Moores, vous avez écrit :
> At 05:43 AM 7/1/2008, Tim Golden wrote:
> >Dick Moores wrote:
> >>So I want to randomly choose between them. I thought that I might
> >>be able to use choice() to do that. So,
> >>
Le Tuesday 01 July 2008 15:04:11 Dick Moores, vous avez écrit :
> At 05:43 AM 7/1/2008, Tim Golden wrote:
> >Dick Moores wrote:
> >>So I want to randomly choose between them. I thought that I might
> >>be able to use choice() to do that. So,
> >> (bunch of functions here)
> >>if __name__ == '_
Dick Moores wrote:
At 05:43 AM 7/1/2008, Tim Golden wrote:
Dick Moores wrote:
So I want to randomly choose between them. I thought that I might be
able to use choice() to do that. So,
(bunch of functions here)
if __name__ == '__main__':
choice([use_for_float_demo(), use_for_integer_de
At 05:52 AM 7/1/2008, Cédric Lucantis wrote:
Le Tuesday 01 July 2008 14:38:36 Dick Moores, vous avez écrit :
> I'm writing a demonstration version of a program which does things
> with integers, and with floats, which are randomly generated. I want
> to also randomly pick whether the integer side
At 05:43 AM 7/1/2008, Tim Golden wrote:
Dick Moores wrote:
So I want to randomly choose between them. I thought that I might
be able to use choice() to do that. So,
(bunch of functions here)
if __name__ == '__main__':
choice([use_for_float_demo(), use_for_integer_demo()])
I find that w
Le Tuesday 01 July 2008 14:38:36 Dick Moores, vous avez écrit :
> I'm writing a demonstration version of a program which does things
> with integers, and with floats, which are randomly generated. I want
> to also randomly pick whether the integer side, or the float side is
> demonstrated next. I h
Dick Moores wrote:
So I want to randomly choose between them. I thought that I might be
able to use choice() to do that. So,
(bunch of functions here)
if __name__ == '__main__':
choice([use_for_float_demo(), use_for_integer_demo()])
I find that what's gets run each time is BOTH of
I'm writing a demonstration version of a program which does things
with integers, and with floats, which are randomly generated. I want
to also randomly pick whether the integer side, or the float side is
demonstrated next. I have 2 functions, use_for_integer_demo()
and use_for_float_demo(), a
Hi,
This line:
ch = "So good to see you!","How are you?","Everything good
today?","Glad you're here!".split(" ")
Creates a tuple with 4 elements:
1. "So good to see you!"
2. "How are you?"
3. "Everything good today?"
and
4. "Glad you're here!".split(" "), which is equal to ["Glad","you're",
"he
"Cecilia Grahn" <[EMAIL PROTECTED]> wrote
> I am trying to make a script which returns a random string:
>
> ch = "So good to see you!","How are you?","Everything good
> today?","Glad you're here!".split(" ")
To python this line has 4 expressions which Pyhon will
assign as a tuple to ch. The firs
Hi,
this is my first mail and I apologize if I got something wrong =)
I am trying to make a script which returns a random string:
#hello.py
# Get the user's name and print a friendly hello
import random, string
name = raw_input("Your name please:")
ch = "So good to see you!","How are you?","Everyt
24 matches
Mail list logo