761 Posted Topics

Member Avatar for sneekula

This was the first result from googling "ubuntu install pygame": [URL="http://www.pygame.org/wiki/kubuntu"]http://www.pygame.org/wiki/kubuntu[/URL] One of the best things about Ubuntu(Linux in general) is that it has such a huge open-source user base that almost every question you have has a detailed guide online of how somebody else did it.

Member Avatar for MaxVK
0
332
Member Avatar for Rahul1123

The communicate method "reads all of the output and waits for child process to exit before returning" [[URL="http://blog.doughellmann.com/2007/07/pymotw-subprocess.html"]Source[/URL]], so in order to work with a program that expects multiple inputs you'll need to communicate with the stdin of the process as such: [code=python] proc = Popen('./Ex.sh', shell=True, stdin=PIPE, stdout=PIPE) proc.stdout.readline() …

Member Avatar for jlm699
0
4K
Member Avatar for shar123

Use code tags when posting code in this forum, or else nobody will be willing to help you: [noparse][code=python] # Code goes in here [/code][/noparse] When using the [icode]__str__[/icode] method you have to make sure that you are returning a string. Here's an example of proper usage: [code=python] >>> class …

Member Avatar for jlm699
0
280
Member Avatar for Zanbi

Maybe it would be easiest to uninstall and re-install Python. Perhaps you should look at adopting a new IDE as well (I'm sorry I just can't stand IDLE!)

Member Avatar for lllllIllIlllI
0
1K
Member Avatar for funkyfresh

I suggest learning the basics of Python before trying to use it as a web platform. I highly recommend [URL="http://diveintopython.org"]dive into python[/URL], which is a free book online that is geared for programmers that already know the basics of writing code in general (control flow, data structures, etc.) Python wasn't …

Member Avatar for jlm699
0
139
Member Avatar for ihatehippies

I don't believe that there is... startfile simply launches the program as if it had been executed from the command prompt/shell... It doesn't return anything as far as I can tell, so my answer would be no. But perhaps there is a way.

Member Avatar for ihatehippies
0
88
Member Avatar for MaxManus

This isn't necessarily appropriate for the Python forum but: [code] len_x = size(x) for i = 1:len_x x(i) end [/code] Now forgive me, I haven't used Matlab in years; however if you need more help you'll find the [URL="http://www.mathworks.com/access/helpdesk/help/techdoc/matlab_product_page.html"]MATLAB docs here[/URL].

Member Avatar for MaxManus
0
75
Member Avatar for Joe Hart

To use code tags: [noparse][code=python] # This is my PYTHON code # It goes between the code(=syntax) brackets [/code][/noparse] If you use code tags your question will be easier to read, thus easier to answer by our forum members

Member Avatar for shadwickman
0
167
Member Avatar for lorayyne

[QUOTE=lorayyne;856567][code] N = int(raw_input('Welcome to the HTH-HTT Head-to-Head! How many times do you want to flip the coin per trial? I recommend at least 20: ')) trials = int(raw_input('How many trials do you want to run?: ')) while x < trials: coinflip.htthth(N) if coinflip.htthth('hthCount') == 1: hth += 1 x …

Member Avatar for woooee
0
213
Member Avatar for drfcool

Please follow the forum guidelines when posting, most importantly when you post code. If you don't use code tags the code turns out as it did above and nobody wants to look at the crazy wall of unformatted text. Use code tags like this when posting code in this forum: …

Member Avatar for faniryharijaona
0
356
Member Avatar for Undermine

[QUOTE=Undermine;857549]Would i just do something like if choice ==1 : do this if choice ==2: do this ect?[/QUOTE] Yeah pretty much. That's the most straight forward way to approach this problem [code=python] usr_inp = raw_input( 'Enter your choice (1-3): ' ) if usr_inp == '1': # do something for 1 …

Member Avatar for Gribouillis
0
124
Member Avatar for Joe Hart

You're more likely to get help if you follow the posting guidelines for this forum, including but not limited to using code tags, showing effort, and providing simple examples of reproducible errors. After skimming over your crazy long post I'll give you an example of asking the user for input …

Member Avatar for jlm699
0
432
Member Avatar for daviddoria

Yeah, sure thing. I don't know if generating it will be as easy as your [icode]zeros[/icode] but here's an example: [code=python] >>> mtrx = [[(0,0),(0,1),(0,2),(0,3)], ... [(1,0),(1,1),(1,2),(1,3)], ... [(2,0),(2,1),(2,2),(2,3)], ... [(3,0),(3,1),(3,2),(3,3)]] >>> mtrx[2][1] (2, 1) >>> mtrx[2][1][0] 2 >>> mtrx[2][1][1] 1 >>> [/code] HTH

Member Avatar for vegaseat
0
103
Member Avatar for harsha_kusam

Have you followed [URL="http://trac.edgewall.org/wiki/TracGuide#TheTracUserandAdministrationGuide"]the Guide[/URL] with step-by-step instructions of how to setup and use TRAC? There's a link to it right there on the first page.

Member Avatar for jlm699
0
106
Member Avatar for gbrokaw

If you simply double click on a [icode].py[/icode] or a [icode].pyw[/icode] icon Python will open and run the script in a command window, just as vega mentioned above... Keep in mind however that if your program has bugs and crashes, the command window will close as soon as Python is …

Member Avatar for gbrokaw
0
137
Member Avatar for apollo1492

[QUOTE=adam1122;851692][icode]height = principal * 0.02 TypeError: unsupported operand type(s) for *: 'NoneType' and 'float'[/icode] 0.02 is your float and * is your operand. That only leaves principal to be your NoneType. At another point, you are setting principal equal to the return value of a function that doesn't return anything. …

Member Avatar for apollo1492
0
141
Member Avatar for blair.mayston

Yeah I think [icode]split()[/icode] would probably be your best bet. Either that or [icode]replace[/icode]: [code=python] >>> some_text = '"http://www.nzherald.co.nz/nz/news/article.cfm?c_id=1&objectid=10568455&ref=rss" Man arrested after pointing fake gun at police (A 59-year-old man has been arrested after pointing an imitation gun at police from his car in Paekakariki, north of Wellington, this morning.\r\n\r\nWhen …

Member Avatar for targ
0
187
Member Avatar for Siaa

Sure, we can help! Just remember to follow the [URL="http://www.daniweb.com/forums/faq.php?faq=daniweb_policies"]forum rules[/URL], and pay attention to the posted announcements ([URL="http://www.daniweb.com/forums/announcement114-3.html"]here[/URL] and [URL="http://www.daniweb.com/forums/announcement114-2.html"]here[/URL]), and there won't be any problems. [URL="http://www.daniweb.com/forums/post822799-3.html"]This post[/URL] by vegaseat should get you started...

Member Avatar for Nick Evan
0
117
Member Avatar for rainobw

You'll have to adapt your code to the website's new layout/API/whatever. Maybe you could provide more details and a little code so that we have some idea of what you're talking about.

Member Avatar for jlm699
-1
299
Member Avatar for DaveF0223

If a call to the DLL returns '2' then that's not a Python error code, that's just what the DLL is returning. I'd suggest using the DLL in another language in the same way to see if you get the same error code.

Member Avatar for jlm699
0
174
Member Avatar for nonang

You'll have to write those sort algorithms yourself. Or search google. To sort a list in Python: [code=python] my_list = [1,5,2,8,3,4,7,6] my_list.sort() [/code]

Member Avatar for jlm699
0
117
Member Avatar for Joe Hart

Please use code tags when posting code. [noparse][code=python] # Put your code inside here [/code][/noparse] As far as Python input methods you can use raw_input to prompt the user for input: [code=python] usr_inp = raw_input( 'Please enter a directory: ' ) print 'The user entered:', usr_inp [/code]

Member Avatar for Mearah
0
181
Member Avatar for harrykokil

[QUOTE=harrykokil;851366]i want to integrate the above code in this tkinter a window but its not working.[/QUOTE] What's not working? Are you getting an error? Your "tkinter a window" doesn't work for me. It never generates any windows and just hangs, so I'm not sure what you're looking for.

Member Avatar for jlm699
0
118
Member Avatar for gotm

[QUOTE=gnujohn;846401]# we should not be a service to solve interesting lab projects. This one clearly is just that, a request for help in CS 380.[/QUOTE] This is true, but thankfully the OP came with example code and exactly what his difficulty is. Most people come into this forum and simply …

Member Avatar for gotm
0
142
Member Avatar for Trav580

I think that you overlooked what adam was saying in his first post. If two straight lines are not parallel and are not the same line, then they must intersect as some point. Unless you need to figure out the exact point of intersection, you can simply use if-else logic …

Member Avatar for Trav580
0
453
Member Avatar for daviddoria

[QUOTE=daviddoria;850764]thanks, that's a good start for now, but eventually it would be nice to do [code] --files *.txt --Size 4.2 --Duration 5 [/code] Dave[/QUOTE] I'm not entirely clear on what you're trying to do, but if you want to get all files in a directory that are *.txt you can …

Member Avatar for daviddoria
0
197
Member Avatar for daviddoria

[QUOTE=daviddoria;850691]Also, how do you handle required options? I saw a lot of threads about a philosophical debate of if options can be required, but no information on how to actually use them. Dave[/QUOTE] This is from the [URL="http://docs.python.org/library/optparse.html"]optparse doc[/URL]: [QUOTE]required option an option that must be supplied on the command-line; …

Member Avatar for jlm699
0
111
Member Avatar for mhangman

You need to change the definition of con() to support the event details that get automatically passed to any bound method. The new definition should look like this: [code=python] def con(self, event=None): [/code] Note that I initialized event to None so that you can still call it yourself without needing …

Member Avatar for mhangman
0
102
Member Avatar for Buckets78

You should be using return values instead of global variables... see if this makes any sense, and if not ask questions. [code=python] >>> import random >>> def get_ran(): ... return random.randint(1,10) ... >>> get_ran() 5 >>> get_ran() 10 >>> get_ran() 4 >>> hp = 100 >>> hp -= get_ran() >>> …

Member Avatar for Buckets78
0
89
Member Avatar for max.yevs

Well first problem is that you're never clearing the contents of your list [icode]b[/icode]. Also, you should move the summation of b outside of the for loop so that it only happens once you've found all the factors of the desired number... That should get you pointed in the right …

Member Avatar for max.yevs
0
207
Member Avatar for alicem
Member Avatar for jlm699
0
80
Member Avatar for planetPlosion

[QUOTE=planetPlosion;850479]So, apparently the for statement makes my guesses worse. Thanks in advance[/QUOTE] Look at what [icode]range(15)[/icode] and [icode]range(1,15)[/icode] produce: [code=python] >>> range(15) [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14] >>> range(1,15) [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, …

Member Avatar for jlm699
0
156
Member Avatar for daviddoria

The "built in" module would be Tkinter, but if you're looking for something simple that will generate native-looking GUIs with minimal effort I would suggest wxPython. There's a wealth of tutorials and sample code in this forum that you are welcome to use (refer to the sticky wxPython samples thread …

Member Avatar for jlm699
0
109
Member Avatar for phillip1882

[QUOTE=phillip1882;850127][code]def fibonacci(a,b,n): [COLOR="Red"] a =a+b b = a+b[/COLOR] n= n-2 if n ==0: [COLOR="Red"] print b return b[/COLOR] elif n ==1: [COLOR="Red"] print a return a[/COLOR] else: fibonacci(a,b,n) x = fibonacci(1,1,7) print x [/code] i get none as the x value but a legitimate integer as the a or b …

Member Avatar for leegeorg07
0
104
Member Avatar for taboyo22

You use [icode]print[/icode] to print anything in Python. Since your functions are returning values, you can use [icode]print[/icode] to output those values.

Member Avatar for jlm699
0
87
Member Avatar for max.yevs

[QUOTE=max.yevs;849624]my apologies, once again i've found the answer before anyone could reply [code]x = [] for n in range(5): x.append(n)[/code][/QUOTE] You're taking the long way here. Look: [code=python] >>> x = range(5) >>> x [0, 1, 2, 3, 4] >>> [/code]

Member Avatar for max.yevs
0
108
Member Avatar for seamonkie

The problem is that since you have [icode]elif guesscount == 4:[/icode] as a condition in an if/elif/else block, it never gets evaluated. The first two conditions are absolute: [code=python] if guess in word: print 'Yes' elif guess not in word: print 'No' [/code] The user's choice is either going to …

Member Avatar for jlm699
0
779
Member Avatar for max.yevs

You need to stop recursing your main function, it's going to get you in trouble. Here's an example using a while loop. [code=python]import time def main(): a = 0 while True: print (a) time.sleep(5) a += 1 main()[/code] EDIT: I didn't notice the other thread about this same problem, in …

Member Avatar for max.yevs
0
137
Member Avatar for khozamtho

[QUOTE=khozamtho;847984]how to compile and run a python file,and how to change a directory in Python25.what should i import first in order to run a python code.like import math and ......[/QUOTE] If you are trying to run a python script that is titled [icode]my_script.py[/icode] from the command line (you could alternately …

Member Avatar for woooee
0
206
Member Avatar for ning2009

Here's a way to avoid printing the empty line: [code=python] for line in my_text: line = line.strip() if line: print line # The 'else' condition here is an empty line, which we don't print [/code]

Member Avatar for amitattri1987
0
415
Member Avatar for Crinkly
Member Avatar for Crinkly
0
81
Member Avatar for max.yevs

I don't understand your first question.. can you clarify what you mean by non-unique random numbers? That being said, I find the best way to have a program run continuously is a super loop. Example: [code=python] import time def main(): print "I'm the main function!" # Do some other stuff …

Member Avatar for max.yevs
0
128
Member Avatar for max.yevs

Instead of sleeping for the user to see the end message you can place an input at the end of your program so that the user has to hit <Enter> to quit like this: [code=python] # This is the last line of code raw_input( "Press <Enter> to exit..." ) [/code]

Member Avatar for adam1122
0
108
Member Avatar for -obol-

[QUOTE=-obol-;847982]how to split a string of words into pieces [/QUOTE] Use the [icode]split()[/icode] method like so: [code=python] >>> my_phrase = "the sun is shining" >>> my_phrase.split() ['the', 'sun', 'is', 'shining'] >>> [/code] [QUOTE=-obol-;847982]and print on separate lines[/QUOTE] As you can see from above, [icode]split()[/icode] returns a list containing each word …

Member Avatar for jlm699
0
276
Member Avatar for leegeorg07
Re: 2to3

[QUOTE=leegeorg07;847599]i tried that in the cmd promt and it said that 'python wasnt a proper command'[/QUOTE] You need to use the full path to python.exe if it's not in your PATH variable... So instead of [icode]python path_to_2to3 my_program.py[/icode] you would need [icode]C:\\Python26\\python.exe path_to_2to3 my_program.py[/icode] Or which ever version of Python …

Member Avatar for leegeorg07
0
197
Member Avatar for flip121

Try removing the following two lines from your board() function and placing them between num_players and board() at the bottom of your script like so: [code=python] Num_Humans() root = Tkinter.Tk() root.attributes('-topmost', True) Board() [/code] I hope that's what you were looking for EDIT: As far as tips here's my first: …

Member Avatar for flip121
0
1K
Member Avatar for katamole

Each tuple in that list has an instance of scrobble.Track, which contains an instance of scrobble.Artist; however the tuple itself does not have those attributes. I'm not entirely sure on the specifics of the scrobble module, but a way to unpack the tuple would be like this: [code=python] for tracks …

Member Avatar for katamole
0
103
Member Avatar for docesam

[QUOTE=Mearah;846573] "cross platform (windows + linux)" This is possible. What you have to keep in mind, that if you are creating some GUI (with TkInter e.g) then it looks quite differentwith windows and linux, so you maybe could test the "look&feel" of your work with both os [/QUOTE] I'd go …

Member Avatar for Mearah
0
168
Member Avatar for pong pong

[QUOTE=pong pong;846801]hi I want to write this code in do while or if else, or any other way except for loop. here is the code [CODE]for i in range(65,90): for j in range(65,90): for k in range(65,90): token=chr(i)+chr(j)+chr(k) block = ((i<<16)+(j<<8)+(k)) cblock = pow(block,e,n) table[token]=cblock[/CODE] can anyone please help me …

Member Avatar for leegeorg07
0
114
Member Avatar for max.yevs

[QUOTE=max.yevs;847064]anyone know the command to define n?[/QUOTE] [code=python] n = #something # For user input use: n = raw_input( 'This is a prompt: ' ) [/code]

Member Avatar for jlm699
0
115

The End.