Alan Gauld via Tutor wrote:
> On 15/10/18 08:57, Peter Otten wrote:
>
>> By the way, you do not need a map (dict) at all to implement a game like
>> this, you may return the next scene directly. A sketch:
>>
>> class Bridge:
>> def enter(self):
>> ...
>> action = ...
>>
On 15/10/18 08:57, Peter Otten wrote:
> By the way, you do not need a map (dict) at all to implement a game like
> this, you may return the next scene directly. A sketch:
>
> class Bridge:
> def enter(self):
> ...
> action = ...
> if action == "jump off the bridge":
bob gailer wrote:
> Python coding "trick"1
> when I build a map I omit the () after the class e.g. 'death' = Death,
> ... and apply them to the item retrieved from the map.
>
> use a decorator to build the map dictionary:
>
> # the decorator function:
> def
More comments on code:
guess = raw_input("[pod #]> ")
if int(guess) != good_pod:
If user enters something that will not convert to integer an exception
will be raised. For example
>>> int('a')
Traceback (most recent call last):
File "", line 1, in
ValueError: invalid literal
On 10/14/2018 1:42 PM, Mats Wichmann wrote:
Hint here: don't use 'map' as your own variable name, since it's a
built-in function.
Absolutely, I am always warning others about this gotcha. In this case
map is local to add_to_map so it does not affect then global namespace.
The reason I used it
On 10/14/2018 10:08 AM, bob gailer wrote:
> Python coding "trick"1
> when I build a map I omit the () after the class e.g. 'death' = Death,
> ... and apply them to the item retrieved from the map.
>
> use a decorator to build the map dictionary:
>
> # the decorator
More comments:
User Friendly?
I hope this game is not intended for actual use. No one will be able to
guess the correct actions in a reasonable time. or 3 digit random code
given 10 tries for any one code. I for one would give up pretty quickly.
The original
On 10/13/2018 4:25 AM, Mariam Haji wrote:
...
Your problem intrigued me enough to spend some time "fixing" your
program so it will compile with no errors and run at least the initial
case where I entered "shoot!"
Here are the problems I found: (line numbers refer to your original code)
-
suggestions:
1-Use triple-quoted strings:
print """take the
short-cut!""'
2 - make the program much simpler to start with. The usual approach to
developing programs like this is to start simple get the simple things
working right then add more complicated scene descriptions.
Even better:
Mariam Haji wrote:
> Hi guys,
>
> I am still on the learn python the hard way.
> I built the below on python 2.7 and my OS is windows 7.
>
> I am getting this error:
> Traceback (most recent call last):
> File "ex43.py", line 205, in
> a_game.play()
> File "ex43.py", line 21, in play
>
On Sat, Oct 13, 2018 at 11:25:20AM +0300, Mariam Haji wrote:
> Hi guys,
>
> I am still on the learn python the hard way.
> I built the below on python 2.7 and my OS is windows 7.
>
> I am getting this error:
> Traceback (most recent call last):
> File "ex43.py", line 205, in
>
Hi guys,
I am still on the learn python the hard way.
I built the below on python 2.7 and my OS is windows 7.
I am getting this error:
Traceback (most recent call last):
File "ex43.py", line 205, in
a_game.play()
File "ex43.py", line 21, in play
next_scene_name =
12 matches
Mail list logo