761 Posted Topics

Member Avatar for ithelp

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.

Member Avatar for GrimJack
0
310
Member Avatar for hughesadam_87

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 …

Member Avatar for jlm699
0
351
Member Avatar for Vexten

[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 …

Member Avatar for Vexten
0
100
Member Avatar for billymcguffin

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.

Member Avatar for billymcguffin
0
358
Member Avatar for tehbrozor

It would help the forum members here to answer your question if you provided information regarding what toolkit you're using.

Member Avatar for tehbrozor
0
81
Member Avatar for hunterm

[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].

Member Avatar for scru
0
184
Member Avatar for ithelp

[QUOTE=ithelp;870585]What are old C/C++ programmers supposed to do then ? :([/QUOTE] Learn Python ;)

Member Avatar for Ene Uran
0
188
Member Avatar for bhanu1225

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)

Member Avatar for jlm699
0
94
Member Avatar for dinilkarun

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 …

Member Avatar for dinilkarun
0
149
Member Avatar for kiddo39

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 …

Member Avatar for kiddo39
0
4K
Member Avatar for seriousgeek

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 …

Member Avatar for jlm699
0
199
Member Avatar for hughesadam_87

[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 …

Member Avatar for jlm699
0
139
Member Avatar for mohankumar554
Member Avatar for vegaseat
0
168
Member Avatar for voni86

[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 …

Member Avatar for voni86
0
116
Member Avatar for kenji

[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 …

Member Avatar for kenji
0
134
Member Avatar for kiddo39

[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 …

Member Avatar for kiddo39
0
2K
Member Avatar for David.lewing

[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]

Member Avatar for David.lewing
0
143
Member Avatar for bhanu1225

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 ... …

Member Avatar for jice
0
282
Member Avatar for punjabi

[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.

Member Avatar for jlm699
0
142
Member Avatar for durga84

I thought python was baked into RHEL 4 ? Are the dependencies you're looking for tcl/tk for Tkinter support?

Member Avatar for woooee
0
284
Member Avatar for billymcguffin

Usually complaints of a syntax error on a particular line actually mean that the error is contained on the line before that.

Member Avatar for jlm699
0
98
Member Avatar for gotm

[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 …

Member Avatar for gotm
0
146
Member Avatar for leegeorg07

[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]

Member Avatar for leegeorg07
0
544
Member Avatar for Srinivasa007

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 …

Member Avatar for jlm699
0
76
Member Avatar for mohankumar554

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.

Member Avatar for jlm699
0
57
Member Avatar for ofranko

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 …

Member Avatar for vegaseat
0
110
Member Avatar for daviddoria

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 …

Member Avatar for vegaseat
0
2K
Member Avatar for ithelp

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 …

Member Avatar for jlm699
0
110
Member Avatar for ofranko

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.

Member Avatar for vegaseat
0
123
Member Avatar for hunterm

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]

Member Avatar for hunterm
0
119
Member Avatar for CommanderOne

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 ... >>> …

Member Avatar for woooee
0
137
Member Avatar for txwooley

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, …

Member Avatar for txwooley
0
344
Member Avatar for pvi101

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" …

Member Avatar for supernovicevn
0
199
Member Avatar for Kekalove
Member Avatar for Whelk

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 …

Member Avatar for woooee
0
149
Member Avatar for Prahaai

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 …

Member Avatar for scru
0
281
Member Avatar for dinilkarun
Member Avatar for you2

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': …

Member Avatar for you2
0
120
Member Avatar for samush

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.

Member Avatar for woooee
0
149
Member Avatar for ldk

Use .py instead of .pyw, as .pyw hides the console. .pyw are ran with pythonw.exe, whereas .py are ran with python.exe

Member Avatar for jlm699
0
117
Member Avatar for davhuang

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 …

Member Avatar for jlm699
0
262
Member Avatar for bobstein

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 …

Member Avatar for jlm699
0
110
Member Avatar for applebiz89

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 …

Member Avatar for jlm699
0
240
Member Avatar for scheda

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?

Member Avatar for vegaseat
0
138
Member Avatar for chardson

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 …

Member Avatar for chardson
0
180
Member Avatar for d-bug87
Member Avatar for jlm699
0
71
Member Avatar for MaxVK

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.

Member Avatar for MaxVK
0
9K
Member Avatar for ning2009

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 …

Member Avatar for ning2009
0
178
Member Avatar for leegeorg07

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, …

Member Avatar for jlm699
0
259
Member Avatar for clareypants

Okay, so post your code and tell us what the errors that you're getting are. What are you stuck on?

Member Avatar for jlm699
0
74

The End.