koka282

Members
  • Content count

    89
  • Joined

  • Last visited

Community Reputation

412 Neutral

About koka282

  • Rank
    Member

Personal Information

  • Interests
    Art
    Programming
  1. I need to one give me the string between ~ and ^. I have a string like this: ~~~~ ABC ^ DEF ^ HGK > LMN ^ I need to get the string between them with python. I've tried this: import re target = ' ~~~~ ABC ^ DEF ^ HGK > LMN ^ ' matchObj = re.findall(r'~(.*?)\^', target) print matchObj But the result is:['~~~ ABC '] What I expect is: [ABC , DEF , HGK , LMN ] or [^ABC , ^DEF , ^HGK , LMN ] I want to do all this because i am trying to extract text from an html page. like this example <td class="cell-1"> <div><span class="value-frame">&nbsp;~~~~ ABC ^ DEF ^ HGK > LMN ^ </span></div> </td>  
  2. hi,  i have a custom module, I want to put it in the directory to import it. What should I do?   i got this error : importError: No module named 'pyperclip'      ?i use Linux Debian   i downloaded the module from :   https://pypi.python.org/pypi/pyperclip/     what should i do to import it     i tried many commands in Konsole   like sudo apt-get install python3-setuptools etc....             Thanks
  3. error while importing module

    i searched before and i saw some typed this for 64 bit then i got this error !  :) Thanks :)
  4. error while importing module

    hi all i have little problem here import pyHook , pythoncom ,sys , logging Traceback (most recent call last): File "<pyshell#0>", line 1, in <module> import pyHook , pythoncom ,sys , logging File "C:\Python27\lib\site-packages\pythoncom.py", line 2, in <module> import pywintypes File "C:\Python27\lib\site-packages\win32\lib\pywintypes.py", line 124, in <module> __import_pywin32_system_module__("pywintypes", globals()) File "C:\Python27\lib\site-packages\win32\lib\pywintypes.py", line 64, in __import_pywin32_system_module__ import _win32sysloader ImportError: DLL load failed: %1 is not a valid Win32 application. Thanks :)
  5. Error while using sublime text 2 (only!)

    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
  6. Error while using sublime text 2 (only!)

    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 !???
  7. Error while using sublime text 2 (only!)

    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
  8. 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
  9. Hangman error

    hi all, i was reading someone's code i want to make like this project but when i run it i get error !! can you tell me what should i do ?! class Hangman(): def __init__(self): print "Welcome to 'Hangman', are you ready to die?" print "(1)Yes, for I am already dead.\n(2)No, get me outta here!" user_choice_1 = raw_input("->") if user_choice_1 == '1': print "Loading nooses, murderers, rapists, thiefs, lunatics..." self.start_game() elif user_choice_1 == '2': print "Bye bye now..." exit() else: print "I'm sorry, I'm hard of hearing, could you repeat that?" self.__init__() def start_game(self): print "A crowd begins to gather, they can't wait to see some real" print "justice. There's just one thing, you aren't a real criminal." print "No, no. You're the wrong time, wrong place type. You may think" print "you're dead, but it's not like that at all. Yes, yes. You've" print "got a chance to live. All you've gotta do is guess the right" print "words and you can live to see another day. But don't get so" print "happy yet. If you make 6 wrong guess, YOU'RE TOAST! VAMANOS!" self.core_game() def core_game(self): guesses = 0 letters_used = "" the_word = "pizza" progress = ["?", "?", "?", "?", "?"] while guesses < 6: guess = raw_input("Guess a letter ->") if guess in the_word and not in letters_used: print "As it turns out, your guess was RIGHT!" letters_used += "," + guess self.hangman_graphic(guesses) print "Progress: " + self.progress_updater(guess, the_word, progress) print "Letter used: " + letters_used elif guess not in the_word and not in letters_used: guesses += 1 print "Things aren't looking so good, that guess was WRONG!" print "Oh man, that crowd is getting happy, I thought you" print "wanted to make them mad?" letters_used += "," + guess self.hangman_graphic(guesses) print "Progress: " + "".join(progress) print "Letter used: " + letters_used else: print "That's the wrong letter, you wanna be out here all day?" print "Try 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__() def progress_updater(self, guess, the_word, progress): i = 0 while i < len(the_word): if guess == the_word[i]: progress[i] = guess i += 1 else: i += 1 return "".join(progress) game = Hangman()   Thanks all
  10.   Yes         i must focus more i often type them by mistake          it should be  elif (comp == "rock" and you == "scissor") or (comp == "scissor" and you == "paper") or (comp == "paper" and you == "rock")             i want to make the comp be variable in whowin function  & comp will be the hand value like : paper or rock ,,  i should type pc=comp() & whowin(you,pc)     you mean like that ?       Thanks     Smile
  11. Hi, i have little problem here    i was trying to make rock,paper,scissor project  while running it    i got this error UnboundLocalError: local variable 'comp' referenced before assignment   what should i do to fix it ?   code: from random import randint #Computer draws hand. def comp(): r=randint(1,3) if r == 1: hand = "rock" if r == 2 : hand = "paper" if r == 3 : hand = "scissor" return hand # who is the winner. def whowin(you,comp): if you == comp: winner = "tie" elif comp == ("rock" and you == "scissor") or comp == ("scissor" and you == "paper") or comp == ("paper" and you == "rock"): winner = "comp" else: winner = "you" return winner # start def play(): print "------welcome to my game------" comp_wins = 0 you_wins = 0 tie_wins = 0 while True: you = raw_input("Please choose rock or scissor or paper ") you=you.lower() comp = comp() winner = whowin(you,comp) if not you == "rock" or you == "paper" or you =="scissor": print" invalid" continue play() Thanks
  12. sorry for hard understanding  i shouldn't ask sorry
  13.  must be defined in a scope containing the derived class definition       but see : class product(object): why we type object !!  where i type object !   Sorry for hard understanding     .................   but i think  in class Teacher(Human) def __init__(self,name) self.name=name it was inheritance   but in .. class product(object): i here type the object Because (it is not an inheritance from another class)   Thanks
  14. Ty but please answer this question class Teacher(Human) def __init__(self,name) self.name=name now we are talking about the object that object have name etc so you are talking about the human not the teacher ,, between the bracket i type the object right ?? so now saying human has-a name not teacher right ?