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

From NetHackWiki
Jump to navigation Jump to search
(the answer to the question :))
Line 11: Line 11:
 
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()
 
         ^
 
         ^
Line 18: Line 18:
  
 
: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:
 
: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):
+
def usage(self, exit=1):
 
         ak = alignmentSelection.keys()
 
         ak = alignmentSelection.keys()
 
         ak.sort()
 
         ak.sort()
Line 24: Line 24:
 
         rs.sort()
 
         rs.sort()
 
         print 'Usage: %s [-a%s] [-p%s] [-D]' % (sys.argv[0],
 
         print 'Usage: %s [-a%s] [-p%s] [-D]' % (sys.argv[0],
                                                 string.join(ak, ''),
+
                                                 string.join(ak, ''),''
                                                 string.join(rs, ''))
+
                                                 string.join(rs, ''))''
 
         sys.exit(exit)
 
         sys.exit(exit)
 
:—[[User:Shijun|Shijun]] 21:39, January 22, 2010 (UTC)
 
:—[[User:Shijun|Shijun]] 21:39, January 22, 2010 (UTC)
 +
thanks. [[Special:Contributions/60.242.66.41|60.242.66.41]] 23:07, January 22, 2010 (UTC)

Revision as of 23:07, 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)

thanks. 60.242.66.41 23:07, January 22, 2010 (UTC)