Error while using sublime text 2 (only!)

Started by
5 comments, last by koka282 9 years, 5 months ago

hi all,

i'm using sublime text 2

and when i run my code on it


class hangman():
	def __init__(self):
		print "Welcome to Hangman game "
		print "if you want to play type 1 if you don't want type 2"
		user_choice = raw_input("> ")
		if user_choice == "1":
			print "Nice"
			self.startgame()
		elif user_choice == "2":
			print "Bye"
			exit()
		else:
			print "i can't understand please choose again"
	def hangman_graphic(self, guesses):
		if guesses == 0:
			print "________      "
			print "|      |      "
			print "|             "
			print "|             "
			print "|             "
			print "|             "
		elif guesses == 1:
			print "________      "
			print "|      |      "
			print "|      0      "
			print "|             "
			print "|             "
			print "|             "
		elif guesses == 2:
			print "________      "
			print "|      |      "
			print "|      0      "
			print "|     /       "
			print "|             "
			print "|             "
		elif guesses == 3:
			print "________      "
			print "|      |      "
			print "|      0      "
			print "|     /|      "
			print "|             "
			print "|             "
		elif guesses == 4:
			print "________      "
			print "|      |      "
			print "|      0      "
			print "|     /|\     "
			print "|             "
			print "|             "
		elif guesses == 5:
			print "________      "
			print "|      |      "
			print "|      0      "
			print "|     /|\     "
			print "|     /       "
			print "|             "
		else:
			print "________      "
			print "|      |      "
			print "|      0      "
			print "|     /|\     "
			print "|     / \     "
			print "|             "
			print "The noose tightens around your neck, and you feel the"
			print "sudden urge to urinate."
			print "GAME OVER!"
			self.__init__()			

game = hangman()			
			
	

I get error :

Welcome to Hangman game Traceback (most recent call last):
File "C:\Python27\hangg.py", line 69, in <module>
if you want to play type 1 if u don't want type 2
> [Finished in 0.1s with exit code 1]game = hangman()
File "C:\Python27\hangg.py", line 5, in __init__
user_choice = raw_input("> ")
EOFError: EOF when reading a line
But when i use python IDLE i don't get error !?
Thanks
Advertisement

It seems like Sublime's console does not allow input for scripts. You can install SublimeREPL and run your script from Tools -> SublimeREPL -> Python -> Python - RUN current file.

Then it will crash at line 8 because it can't find startgame(). smile.png

i know it will crash i just was trying it on IDLE and Sumblim i get error on sublime only

i download it then i put it in Pristine Packages and doesn't work sad.png

I don't know how Package Control works with Sublime 2 as I'm only using Sublime 3, but I guess they behave quite similar. In ST3 you open the Command Palette (Ctrl+Shift+P), select Package Control: Install Package and then type the name (or a part of the name) of the package you want to install. You don't need to download or unzip anything by yourself.
Looking at your screenshot it looks like you messed up the installation of Package Control itself. You can either install it using a script that you run from the Sublime Command Line or by downloading (but not unzipping!) the .sublime-package file. You might want to check out the installation instructions to set it up correctly.

it works when i use sublimerepl but it didn't print line 3 and 4

and i should everytime to run my script Tools>sublimerepl>python !???

it works when i use sublimerepl but it didn't print line 3 and 4


Now that you mention it, I think I didn't see the "Welcome to Hangman" text. But as far as I remember line 4 was visible. Can't check it right now though as I don't have Python on this computer.

and i should everytime to run my script [background=#eeeeee]Tools>sublimerepl>python !???[/background]


You can also start it from the Command Palette. SublimeREPL also seems to have some shortcuts, perhaps some of them can be useful for your, even though I can't see a Run shortcut in the documentation.

Line 3 & 4 were visible for 1 sec then it invisible ! :D

But No problem ! :)

i think Sublime not bad i will use it

Thanks smile.png

This topic is closed to new replies.

Advertisement