anyedie Posted August 17, 2006 Share Posted August 17, 2006 calling all coders! Help a poor python noob. ive spent 2 days (not stright, thad be crazy!) searing and for the life of me cannot find how to modify user input. its driving me crazy. i think ive worked with nearly everything in the string library and cannot get it right. can someone help with this? ahhh! string.replace.... why cant i harness your power!!!! *gulp..* did i say something wrong? 18 views 0 responses :( Quote Link to comment Share on other sites More sharing options...
blizz Posted August 17, 2006 Share Posted August 17, 2006 i'm not a python coder but may i ask how you want to modify the user input? Quote Link to comment Share on other sites More sharing options...
sharpnyourteeth Posted August 17, 2006 Share Posted August 17, 2006 *gulp..* did i say something wrong? 18 views 0 responses :( i think a better description of what you're trying to do is needed. the source code would also help quite a bit. Quote Link to comment Share on other sites More sharing options...
anyedie Posted August 17, 2006 Author Share Posted August 17, 2006 yes bliz you can... ( what im working on is top secret, but will be posted here later) for example, lets say i want to make a L337 h4x0r sp3ak translator. user enters hi im jenny, how are you today? i would want to replace certain characters in there input. i would want to modify there input and print )-( i 1// j3//nY, )-(0// ar3 Y0u t0daY? Quote Link to comment Share on other sites More sharing options...
jollyrancher82 Posted August 18, 2006 Share Posted August 18, 2006 <insert random Snakes on a Plane joke /> Quote Link to comment Share on other sites More sharing options...
anyedie Posted August 18, 2006 Author Share Posted August 18, 2006 does anyone know any snakes on a plane jokes? Quote Link to comment Share on other sites More sharing options...
blizz Posted August 18, 2006 Share Posted August 18, 2006 No, but there are millions to come. Just wait a few more days. I wish Indiana Jones was on that movie. </totally pointless unfunny joke> Quote Link to comment Share on other sites More sharing options...
blizz Posted August 18, 2006 Share Posted August 18, 2006 btw, to answer your python question, I googled and basically found that: import re p = re.compile('Hello') p.sub('Good Bye', 'Hello, World!') // produces: Good Bye, World! I hope I could help you. Quote Link to comment Share on other sites More sharing options...
anyedie Posted August 18, 2006 Author Share Posted August 18, 2006 btw, to answer your python question, I googled and basically found that: import re p = re.compile('Hello') p.sub('Good Bye', 'Hello, World!') // produces: Good Bye, World! I hope I could help you. thankx blizz, yea, i found that, but i cannot get it to work correctly. + after playing with that i have no idea what its doing. plus with the user input all my planning just goes down the shute. Quote Link to comment Share on other sites More sharing options...
blizz Posted August 18, 2006 Share Posted August 18, 2006 huh? show me your code please Quote Link to comment Share on other sites More sharing options...
anyedie Posted August 18, 2006 Author Share Posted August 18, 2006 my code thus far. from Tkinter import * # from re import *        ? # from string import *    ? def insert():     name = ent.get()                  #i know that somewhere you can     print name                        # replace the entered text 'ent'     listbox.insert(END,name)          # but am having an impossible time     ent.delete(0,END)                  # trying to get this done!     root = Tk() root.geometry('200x210+350+70') ent = Entry(root) button = Button(root, text = 'Leet Me Up!', command = insert) listbox = Listbox(root) ent.pack() button.pack() listbox.pack() root.mainloop() Quote Link to comment Share on other sites More sharing options...
sharpnyourteeth Posted August 18, 2006 Share Posted August 18, 2006 http://docs.python.org/lib/string-methods.html take a look at the documentation for replace. it takes two parameters anda third optional parameter. The first parameter is the string you want replaced. the second is the string to replace it with, and the optional is the number of times to do it so say you want to replace e with 3. you would do name = ent.get() name = name.replace("e", "3") that will replace all occurences of "e" in name with "3" Quote Link to comment Share on other sites More sharing options...
anyedie Posted August 18, 2006 Author Share Posted August 18, 2006 http://docs.python.org/lib/string-methods.htmltake a look at the documentation for replace. it takes two parameters anda third optional parameter. The first parameter is the string you want replaced. the second is the string to replace it with, and the optional is the number of times to do it so say you want to replace e with 3. you would do name = ent.get() name = name.replace("e", "3") that will replace all occurences of "e" in name with "3" THANKX!!! Arrrrrg! coding sux for me because i do dumb things like this and never see it! i had it correct probably 5 times EXCEPT i was putting ent.replace insted of name.replace. Thankx sharpen! Quote Link to comment Share on other sites More sharing options...
anyedie Posted August 18, 2006 Author Share Posted August 18, 2006 ok last thing... mml, im likeing l33t sp34ker. i was thinking... and it would be kinda lame if everything was the same replacement... like above when i wrote sp34er.. that is much better than sp34k3r, i think. Or what if i wanted to replace some of the E's with 3 and some with < or something else. the question is, does anyone know how i could get the program to replace some instances of 'o' with 0 and some with '()'. I think that the best way would be to use the random module, and make variables for each letter that could have more than one output in leet. then have it replace like sharpen pointed out. the problem with that is it returns the same random out put for every instance. the o's are always (n)0000000000000000000(b) insted of 0()()00()0() im stumped. Quote Link to comment Share on other sites More sharing options...
Erroneous Posted August 18, 2006 Share Posted August 18, 2006 Be sure when you are randomly replacing things that you set the number of occurences to replace as 1 or whatever. You may want to iterate through the string (I don't program in python so I don't know how easy it is) and copy each character into a temp string. Randomly l33t it, then append it to an output string. Also be sure to set the random number generator's seed to the clock (if that is necessary in python). Quote Link to comment Share on other sites More sharing options...
Bigbro69 Posted August 18, 2006 Share Posted August 18, 2006 If you make a leet speak maker, I'll personally fly over to America and kick your ass. Quote Link to comment Share on other sites More sharing options...
anyedie Posted August 18, 2006 Author Share Posted August 18, 2006 If you make a leet speak maker, I'll personally fly over to America and kick your ass. mml! (makes me laugh) first of all, Leet Speaker is an example as to not give away something. BUT: seeing as how you are so intrested in it, i will be releasing it in the coding section very soon, per your request. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.