Difference between revisions of "Talk:What Fools These Mortals"

From NetHackWiki
Jump to navigation Jump to search
(question that need awnsering)
(the answer to the question :))
Line 6: Line 6:
  
 
[[User:69.228.170.186|69.228.170.186]] 02:13, 1 March 2008 (UTC)
 
[[User:69.228.170.186|69.228.170.186]] 02:13, 1 March 2008 (UTC)
 +
 +
== Running WFTM in recent versions of Python ==
  
 
I am having problems, when I run this, I get an error:
 
I am having problems, when I run this, I get an error:
  
File "./WhatFools.py", line 209
+
    File "./WhatFools.py", line 209
    as = alignmentSelection.keys()
+
        as = alignmentSelection.keys()
    ^
+
        ^
SyntaxError: invalid syntax
+
    SyntaxError: invalid syntax
 +
{{unsigned|60.242.66.41|2010-01-21, 23:00}}
 +
 
 +
:Are you running Python 2.6 (or higher)? "as" became a keyword in 2.6, so it can't be used as a name for a variable (giving you that syntax error). One solution is to use an older version of Python. The other is to rename that variable to "ak". You'll have to do this in three different places in that method. It should look something like this:
 +
    def usage(self, exit=1):
 +
        ak = alignmentSelection.keys()
 +
        ak.sort()
 +
        rs = roleMap.keys()
 +
        rs.sort()
 +
        print 'Usage: %s [-a%s] [-p%s] [-D]' % (sys.argv[0],
 +
                                                string.join(ak, ''),
 +
                                                string.join(rs, ''))
 +
        sys.exit(exit)
 +
:—[[User:Shijun|Shijun]] 21:39, January 22, 2010 (UTC)

Revision as of 21:39, 22 January 2010

whrandom

If you don't have whrandom, you can edit the file by:

  1. Delete import whrandom
  2. Change rand = whrandomm.whrandom to rand = random

69.228.170.186 02:13, 1 March 2008 (UTC)

Running WFTM in recent versions of Python

I am having problems, when I run this, I get an error:

   File "./WhatFools.py", line 209
       as = alignmentSelection.keys()
        ^
   SyntaxError: invalid syntax

— Preceding unsigned comment added by 60.242.66.41 (talkcontribs) 2010-01-21, 23:00

Are you running Python 2.6 (or higher)? "as" became a keyword in 2.6, so it can't be used as a name for a variable (giving you that syntax error). One solution is to use an older version of Python. The other is to rename that variable to "ak". You'll have to do this in three different places in that method. It should look something like this:
   def usage(self, exit=1):
       ak = alignmentSelection.keys()
       ak.sort()
       rs = roleMap.keys()
       rs.sort()
       print 'Usage: %s [-a%s] [-p%s] [-D]' % (sys.argv[0],
                                               string.join(ak, ),
                                               string.join(rs, ))
       sys.exit(exit)
Shijun 21:39, January 22, 2010 (UTC)