761 Posted Topics
Re: Does the *thing* have to be the source of the emitted vibration? I mean... any object could emit vibration if you consider reflected light as being [I]emitted[/I] vibration. And a Dr. Pepper can will emit vibration if you squeeze it. The crinkling aluminum produces the vibration of sound waves. | |
Re: Some of your comments may be overkill. Here's how I'd revise your function: * Added Billy's suggestion from above * I like comments on separate lines unless they're extremely short * Tabs are an absolute no-no in my book * No need to say [ICODE]if something: continue[/ICODE] ... when there's … | |
Re: [QUOTE=Vexten;876052]I'm trying to make this game (pseudo code below) [/QUOTE] You never posted your psuedo code. I suggest starting with a 'Hello World' program that maybe prints a menu and asks the user for their input. Next, I would work on a question/answer function that is ambiguous and can pick … | |
Re: I suggest downloading the 'Docs and Demos' along with your wxPython install, as it gives you a great launch pad to start writing your own GUIs by giving you sample code of almost every single type of wx object. It's ridiculously helpful when starting wxPython. | |
Re: It would help the forum members here to answer your question if you provided information regarding what toolkit you're using. | |
Re: [QUOTE=hunterm;876942]What did I screw up?[/QUOTE] You used [ICODE]input [/ICODE]and you're not using Python30. For anything prior to Python30 you should be using [ICODE]raw_input[/ICODE] like you did for the earlier user input. Try entering the following into [ICODE]input[/ICODE] and see what happens: [ICODE]4 * 10 + 2 / 5[/ICODE]. | |
Re: [QUOTE=ithelp;870585]What are old C/C++ programmers supposed to do then ? :([/QUOTE] Learn Python ;) | |
Re: Yeah, the process to import is: [code=python] import modulename [/code] Where [icode]modulename[/icode] is the name of the module (I'm assuming login for your case) | |
Re: Well it's hard to say without defined rules of what needs to be excluded. Is it every "|XXX ##" that follows an instance of 'Spec ##' ? If so I would suggest using the re module to come up with a regex. It'll make it super easy to do this … | |
Re: Here's some clues to help you! [code=python] >>> ord('A') 65 >>> ord('a') 97 >>> ord('Z') 90 >>> ord('z') 122 >>> from string import letters >>> letters 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' >>> uppers = letters[26:] >>> lowers = letters[:26] >>> uppers 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' >>> lowers 'abcdefghijklmnopqrstuvwxyz' >>> [/code] you cna iterate over those strings easily … | |
Re: here's some sample loops: [code=python] # For loop temp = range(6) for item in temp: print item # While loop i = 0 while i < 6: i += 1 [/code] Note the indentation. I'm using 4 spaces instead of a 'tab', as that's the preferred method of indentation (4 … | |
Re: [QUOTE=shoemoodoshaloo;873211]Thanks for the help woooee[/QUOTE] Hey, it helps to read the code posted in this forum if it's in code tags. And also, if you wanted to do a single write that included your newline you can do something like this: [code=python] temp = ["4", "5", "6", "7", "8"] for … | |
Re: hi, use parameters into drop down box in python... configure how you need.... | |
Re: [QUOTE=kenny1989;872034]I am pretty sure that you can see your files in xp as long as you are on a admin account.[/QUOTE] Yeah, without the operating system actually running to protect the files there's nothing that can stop you from viewing them. To enable hidden/system files/folders go to an explorer window … | |
Re: [QUOTE=scru;872502]The best way I think is to get a solid foundation in Python 2. That and read up a bit on unicode. Once done, you can just read the "What's new in python 3" page (Google it) and learn everything there is to know about using python 3.[/QUOTE] I second … | |
Re: [QUOTE=kiddo39;872184]I guess I would need to add an 'if pixel[2] >0:' statement in and I've tried that in several locations but keep getting error messages. any help?[/QUOTE] That's right... so what are the error messages? By showing us your mistakes we can help you resolve them. That way, you learn … | |
Re: [QUOTE=David.lewing;864228]cPickle.dump(pickleFile, lst)[/QUOTE] [code=python]help(cPickle.dump) Help on built-in function dump in module cPickle: dump(...) dump(obj, file, protocol=0) -- Write an object in pickle format to the given file. See the Pickler docstring for the meaning of optional argument proto. [/code] Looks like the order's backwards... try instead: [icode]cPickle.dump(lst, pickleFile)[/icode] | |
Re: I concur with Jice. In case you're simply asking us for suggestions of how to perform the same action with two different targets I would propose a for loop: [code=python] >>> for octet in [ '8', '9' ]: ... ip_add = '10.0.2.' + octet ... print 'IP Address:', ip_add ... … | |
Re: [QUOTE=punjabi;872522]need help please have been trying and have gotten no where[/QUOTE] What have you been trying? Let us help. Show us your code and your errors/mistakes and we'll teach you how to fix them. | |
Re: I thought python was baked into RHEL 4 ? Are the dependencies you're looking for tcl/tk for Tkinter support? | |
Re: Usually complaints of a syntax error on a particular line actually mean that the error is contained on the line before that. | |
Re: [QUOTE=gotm;871125][code=python] [Snipped for brevity][/code][/QUOTE] Your problems all stem from the fact that you aren't recognizing the 'scope' of your variables. You shouldn't be using global variables at all in fact, and your code could use a more coherent structure (for your own sake). Here's a quick example of a better … | |
![]() | Re: [code=python] #each line in passwords.txt will have another passwords password_list = password.readlines() password_list = [ i.strip() for i in password_list ] username_list = username.readlines() username_list = [ i.strip() for i in username_list ] [/code] ![]() |
Re: A quicker way would be to check if a [icode]split()[/icode] results in a list with length greater than 1: [code=python] >>> s1 = 'Test string' >>> s2 = 'Test' >>> s1.split() ['Test', 'string'] >>> s2.split() ['Test'] >>> len(s1.split()) 2 >>> len(s2.split()) 1 >>> [/code] On second thought, it'd be easier … | |
Re: Write an empty string to them, a.k.a. [icode]''[/icode] That's the best answer you could hope for with as little info as you provided. | |
Re: Please use code tags when posting code in this forum. If you don't, your code is excruciatingly hard to read and makes it less likely that forum members will answer your question. To use code tags: [noparse][code=python] # Put your code inside here [/code][/noparse] Now regarding the 'main' module: there … | |
Re: How about you use __init__.py in each of your subdirectories? Here's an illustration of the __init__.py idea from an old mailing list: [QUOTE=John Roth] __init__.py is used for two things. One is as a flag to indicate that the python programs in the directory are part of a module. The … | |
Re: Holy crap no. Jython is the scourge of humanity, and in my opinion utter and complete garbage. I don't even know why it exists except to astound and bewilder. I used it once to make an application that could interface with Lotus Notes. Every time I look back at that … | |
Re: I think the most straight forward resource is [URL="http://www.py2exe.org/"]py2exe[/URL]. [URL="http://www.py2exe.org/index.cgi/Tutorial"]Here's a tutorial[/URL]. Also, if you search this forum, you'll find numerous examples. | |
Re: What, you mean like this? [code=python] >>> def funA(): ... print 'A' ... >>> def funB(): ... print 'B' ... >>> def funC(): ... print 'C' ... >>> my_tup = ( funA, funB, funC ) >>> for each_function in my_tup: ... each_function() ... A B C >>> [/code] | |
Re: Here's a way to only check against the last character (as a function): [code=python] >>> def remove_dups( word ): ... """ Remove all adjacent duplicate letters """ ... new_word = word[0] ... for c in word: ... if c != new_word[-1]: ... new_word += c ... return new_word ... >>> … | |
Re: That's an interesting challenge... If it were me I would use a two-tiered scoring system, whereby you could assign a value to the hand itself, ie: [QUOTE]high card = 1 pair = 2 two pair = 3 three of kind = 4 etc...[/QUOTE] Then, in the event of a tie, … | |
Re: In Python 3.0 the built-in method zip() contains an iterable instead of a list (much like the new range() function)... meaning that after the first sorted() call, the internal pointer of the zip object is pointed at the END position of the object. I don't think it's possible to "reset" … | |
Re: How about you use a dictionary for usrlst. here's an example of a dictionary: [code=python] >>> usr_dict = { 'bob': 'foobar', 'joe': 'barfood', 'sally':'choco' } >>> usr_inp = 'Bob' >>> if usr_inp.lower() in usr_dict: ... print usr_dict[usr_inp.lower()] ... foobar >>> [/code] Also, you should not be using [icode]input[/icode], you should … | |
Re: Alright, here's some psuedo code for how I did it. I had two functions. First I made one to handle each row: [code] def handle_row(row_a, row_b): new_row = [] Get the length of each row compute the difference in length if diff > 0: extend row_b by diff else: extend … | |
Re: Didn't notice the double post. Shame on you, shame on me... | |
Re: This is pretty straight forward: [code=python] >>> my_dict = {} >>> for item in str1.split(','): ... key,value = item.split(':') ... if my_dict.get( key ): ... my_dict[ key ] += int( value ) ... else: ... my_dict[ key ] = int( value ) ... >>> my_dict {'a': 3, 'c': 4, 'b': … | |
Re: Search this forum or google for subprocess. It's the new de facto method of spawning processes. There's plenty of examples if you look. | |
Re: Use .py instead of .pyw, as .pyw hides the console. .pyw are ran with pythonw.exe, whereas .py are ran with python.exe | |
Re: You need to use code tags when posting code in this forum, like so: [noparse][code=python] # Your code in here [/code][/noparse] That will preserve your indents so that your code is readable, and will entice other forum members to actually read your post. Here's a way to split up a … | |
Re: I don't know how you could possibly be getting a tuple object... I used your code exactly and it worked just fine. A tuple is this: [code=python] a = (1, 2, 3, 4) # tuple with 4 elements b = ('a', 'b') # tuple with 2 elements # tuples can … | |
Re: No, you should never be declaring classes inside a function... Your class definitions should go out on the main level and then call them from within the functions... Also, get rid of your calls to [icode]input[/icode] as it's not safe. You should always use [icode]raw_input[/icode] and then convert to a … | |
Re: So what are the chances of starting a pyQT or pyGTK thread like the wxPython thread we have... sticky and all! I'd love to see some examples of either pyQT or pyGTK as I've no experience with either... Thoughts? | |
Re: I don't know about a "go interactive" command, but if you use pdb (python debugger) and set the pdb mark somewhere, it dumps you out into the interpreter with all your current workspace that the program has worked on so far. It's pretty simple to do, simply [icode]import pdb[/icode] at … | |
Re: This is the first result from googling [URL="http://tinyurl.com/op4ep4"]'delete registry key python'[/URL] | |
Re: According to [URL="http://docs.python.org/library/xml.etree.elementtree.html#xml.etree.ElementTree.Element.remove"]documentation[/URL]: [QUOTE]Unlike the findXYZ methods this method compares elements based on the instance identity, not on tag value or contents.[/QUOTE] Which means that likely your iterator is returning the contents and not the instance itself. | |
Re: What do you mean by "obtained nothing yet"? I would suggest using a regular expression to group out the SEC= portion and the beginning of the line, but I don't know how consistent that data will appear in said form. Refer [URL="http://docs.python.org/library/re.html"]here[/URL] for the re module information To write a … | |
![]() | Re: You might want to rethink what the line [icode]c = factors [0:] * factors [:40][/icode] is doing... Look at this example for what happens using * on lists: [code=python] >>> [ 1, 2, 3 ] * 3 [1, 2, 3, 1, 2, 3, 1, 2, 3] >>> [ 1, 2, … |
Re: Okay, so post your code and tell us what the errors that you're getting are. What are you stuck on? |
The End.