2

when loading the following (or any python script for xchat version 2.8.9 on 64 bit windows 7):

__module_name__ = "test.py"
__module_version__ = "0.666"
__module_description__ = "I AM AN EXPERT PROGRAMMER"

import xchat, random, string, re

def test(word, word_eol, userdata):
    cmd = word[1]
    text = open("E:\\xpy\\nickslol.txt","r")
    for line in text:
        line = line.rstrip("\r\n")
        xchat.command("%s %s" % (cmd, line))
xchat.hook_command("test", test)
[02:31:14]  ValueError: invalid \x escape
[02:31:14]  Module has no __module_name__ defined
agf
  • 171,228
  • 44
  • 289
  • 238
bob
  • 21
  • 2
  • clearly the answer is that your `module_description` should read `"Someone on SO is an expert programmer"` :P just kidding, welcome to SO – Eonasdan Sep 23 '11 at 19:24

3 Answers3

0

It appears to be an error within xchat. The script works in the C drive, but not in subfolders.

IOError: [Errno 2] No such file or directory: 'C:\test\\startup.py'

Either the single or double backslash should not be there, depending on interpretation. They should definitely be consistent!

Jacob Phillips
  • 8,841
  • 3
  • 51
  • 66
0

I recently came across this error. I'm far from an expert programmer, but I realized the problem is the \x in the string.

in python 2.7 (only version I tested)

x = 'C:\Users\xfolder\Desktop' # will give an "invalid \x escape"

x = 'C:\Users\\xfolder\Desktop' # will work properly (notice the stored value after)

I wish I could expand, but hopefully this is somewhat helpful.

0

Use raw strings for windows pathnames: r"E:\xpy\nickslol.txt"

Dan D.
  • 73,243
  • 15
  • 104
  • 123
  • Nope, that doesn't work, however i've discovered that if I move the python script to different folder, it will work. Maybe it's the folder name? I don't understand why tho. – bob Sep 24 '11 at 01:31