Forum: Python 11 Days Ago |
| Replies: 3 Views: 337 For storing them you can use a dictionary:
lines = text.split("\n")
lineDic = {}
for i,l in enumerate(lines):
lineDic["Line %i"%s] = l
print lineDic
Hope that helps :) |
Forum: Python 18 Days Ago |
| Replies: 2 Views: 236 We can fix that with one character, a lowly comma :)
If you put the comma after the print statement it should work
for x in range(1, len(depend)):
#comma after the whole statement
print... |
Forum: Python 27 Days Ago |
| Replies: 7 Views: 259 Alright. Cheers grib. I was hoping you could help with this :) |
Forum: Python Oct 17th, 2009 |
| Replies: 7 Views: 465 Yes, i think that is what they are trying to do, but at daniweb we try to not give outright answers for the questions and rather steer users in the right direction so that they may learn by... |
Forum: Python Oct 15th, 2009 |
| Replies: 5 Views: 310 If by unparsed HTML via script you mean get the source code for a page. Then you do that by using urllib
import urllib
#This is a file like object.
data = urllib.urlopen("www.daniweb.com")
... |
Forum: Python Oct 5th, 2009 |
| Replies: 4 Views: 368 There are a great many prime number generators in the code snippet sections :)
http://www.daniweb.com/code/forum114.html
Otherwise, i would look at techniques to find primes. Then come back... |
Forum: Python Oct 3rd, 2009 |
| Replies: 1 Views: 222 Okay, sounds fun.
1. What i would do is not change where the buttons are, but what colour they are. This means that in your code you can have a sizer easily but the buttons can still change colour... |
Forum: Python Oct 2nd, 2009 |
| Replies: 4 Views: 253 Check what python version you have, i think you may have python 3.1 which means that you would not have such thing as a raw_input statement.
So instead of raw_input, just replace it with input.... |
Forum: Python Sep 23rd, 2009 |
| Replies: 45 Views: 2,877 It shouldn't be to hard, have a look at the API for the wx.TextCTRL
http://www.wxpython.org/docs/api/wx.TextCtrl-class.html
One of the functon is GetValue() that returns a string of the value in... |
Forum: Python Sep 23rd, 2009 |
| Replies: 2 Views: 463 http://www.daniweb.com/forums/announcement114-2.html Read and understand |
Forum: Python Sep 17th, 2009 |
| Replies: 5 Views: 1,196 Hahaha, woops :P didnt see someone had already done it! :) |
Forum: Python Sep 17th, 2009 |
| Replies: 5 Views: 1,196 Yeah, this was more to give an example of recursion. But some good points :) |
Forum: Python Jul 10th, 2009 |
| Replies: 5 Views: 458 Your code has a couple of issues, if i am not wrong it will not actually start using threading with your code as it is. You need to add a couple of lines
class Thread ( threading . Thread ):
... |
Forum: Python Jun 15th, 2009 |
| Replies: 1 Views: 347 Learn python
http://docs.python.org/tutorial/
Come back when you can do all that and ask a much more specific question |
Forum: Python Jun 8th, 2009 |
| Replies: 4 Views: 506 I would basically put all of this in the main function.
load = RockPaperScissors(3, 0)
#3 is the number of tries to star with, 0 is the number of points
output_rand = load.random() ... |
Forum: Python Jun 7th, 2009 |
| Replies: 6 Views: 368 I dont know if its just me, but that dosent quite make that much sense. Just spend a little more time outlining exactly what you actually want, what your problem is. What you have already tried.
... |
Forum: Python May 20th, 2009 |
| Replies: 2 Views: 230 Then you will probably use something called recursion.
That is when a function calls itself. It is used in these kind of situations.
def recurse(num,count):
if count == 10:
... |
Forum: Python May 19th, 2009 |
| Replies: 9 Views: 537 Showing images is easy with wx.StaticBitmap.
http://www.wxpython.org/docs/api/wx.StaticBitmap-class.html
NOTE:This code is borrowed from the sticky
# show .jpg .png .bmp or .gif image on... |
Forum: Python May 2nd, 2009 |
| Replies: 4 Views: 364 Well this was fun, i made myself a little list comprehension to do this for me :)
#Your list is called f in my case
>>> f = [150,2,16,5,5,1,3,2,1,3,6,6]
>>> print [str(g+1)+" :... |
Forum: Python Apr 27th, 2009 |
| Replies: 1 Views: 330 What GUI engine are you talking about? No-one can help with that little information. Spend a little more time on your question and the answer will come a lot quicker. |
Forum: Python Apr 9th, 2009 |
| Replies: 1 Views: 466 Well then i would have a look at wxStaticBitmap, that will handle your images no worries, then you can look at wx.Media.MediaControl for playing your files. Then you just have to bind the buttons in... |
Forum: Python Mar 23rd, 2009 |
| Replies: 6 Views: 4,075 It checks to see if l is existant, if there are no elelments in l then it will return False because your key cant be in an empty list! Therefore avoiding any unwanted Exceptions! :) |
Forum: Python Mar 17th, 2009 |
| Replies: 17 Views: 697 Well i could be a bit biased, i am very much a wxPython guy, i love it, its a smart, easy to use GUI. Oh and also, wxPython is cross platform
People tend to not use Tkinter, as it is not that... |
Forum: Python Mar 7th, 2009 |
| Replies: 62 Views: 394,756 This is the problem:
self.money - self.deposit = self.bankbalance
Change it to this
self.bankbalance = self.money - self.deposit
Your operations always have to be on the Right side of the... |
Forum: Python Mar 4th, 2009 |
| Replies: 13 Views: 995 You can return it like this:
def returnTwoThings():
return 1,2
a,b = returnTwoThings()
print a
print b
#output
#1 |
Forum: Python Feb 23rd, 2009 |
| Replies: 6 Views: 1,197 there is a really quick way to get a list of even numbers:
list_of_evens= [f for f in range(1,500) if f%2==0]
that should give all the even numbers from 1 to 500 in a list |
Forum: Python Feb 9th, 2009 |
| Replies: 12 Views: 778 Try printing out what the answer is meant to be and what you are getting through the raw_input() that will show what is wrong quite easily. |
Forum: Python Feb 8th, 2009 |
| Replies: 4 Views: 4,224 Wait, i think that in python 3 there is an automatic \n at the end of lines. Here are the default args for print()
print - sep = ' ', end = '\n', file = sys.stdout
So that seems to point... |
Forum: Python Feb 2nd, 2009 |
| Replies: 3 Views: 537 Well i would take a look at wx.ButtonPanel, it does the things you want, it can act like an awesome toolbar as well as having an image/gradient as the background. I would love to attach some code as... |
Forum: Python Jan 20th, 2009 |
| Replies: 12 Views: 782 Well i know that some of them pop up a new windows for a raw_input/input while others ask you to enter it in the debug window down the bottom or something simmilar.
I know that for many people... |
Forum: Python Dec 28th, 2008 |
| Replies: 8 Views: 741 Just an idea but in the regular expression you look for a string that goes "group:" with a colon while in the text file you have it like "group=" so that could be screwing it up. |
Forum: Python Dec 24th, 2008 |
| Replies: 7 Views: 1,379 There is a great module called winsound.
import winsound
winsound.PlaySound("soundFile.wav",SND_ASYNC)
raw_input()
Just make sure to change the name of the file. FOr more reference check out... |
Forum: Python Dec 12th, 2008 |
| Replies: 2 Views: 4,655 Ah, your problem is the following.
You have put in your raw_input() to open the file e:. The problem with that is that you are asking it to open a full directory, not just a file. I had this same... |
Forum: Python Dec 1st, 2008 |
| Replies: 4 Views: 413 Just make sure that both things you want are methods. I think you will want to do something like:
import wx #if using wxPython
import thread
class Frame(wx.Frame):
#all the code stuff
... |
Forum: Python Nov 28th, 2008 |
| Replies: 6 Views: 1,187 Woops, should have called them paramaters. If you have any that are needed then you put them as the second paramater but if there are no paramaters needed for the MeWin method then you dont need to... |
Forum: Python Nov 14th, 2008 |
| Replies: 9 Views: 719 you can also use eval or exec on the text file if it was like this:
if you had this in your program
f = open('variables.txt')
for line in f:
eval(line)
#or exec(line)
That will... |
Forum: Python Nov 5th, 2008 |
| Replies: 40 Views: 2,527 That is because when you go self.weapon.attack it logically goes, well self.weapon is a function in the class and then it looks for the variable attack as part of the method weapon. This is a problem... |
Forum: Python Nov 4th, 2008 |
| Replies: 6 Views: 518 Is this what your talking about?
import random
count = input("How long shall the sequence be?")
seq = ''.join([random.choice('AGTC') for x in range(count)])
print "Length:",count
print ">",seq |
Forum: Python May 30th, 2008 |
| Replies: 209 Views: 98,915 Try this: write a program that tests someones reaction times and records them in a text file and then makes comparisons to see the level of improvment or the lack of. |