Forum: Python 16 Days Ago |
| Replies: 17 Views: 399 You can use the observer pattern.
class Observed(object):
def register_observer(self,observer):
self.observer=observer
def notify(self):
self.observer.update(self)
... |
Forum: Python 16 Days Ago |
| Replies: 4 Views: 193 Could not reproduce it on python 2.6.2 linux either.
Maybe you have run the pyc version, which was older. |
Forum: Python 16 Days Ago |
| Replies: 3 Views: 553 Your description is incorrect. This function will never return 'radar' on any string input, because it needs another parameter.
Your loop does not exit. You increment num, but the loop's exit... |
Forum: Python Jun 8th, 2009 |
| Replies: 1 Views: 156 Please use code tags (http://www.daniweb.com/forums/announcement114-3.html), even if it is quick.
What exactly is your question? |
Forum: Python Jun 7th, 2009 |
| Replies: 1 Views: 199 We do not make private attributes in python, except in very rare cases. You can shadow the attribute access with "property" decorator later.
The Item and the Project class is trying to reimplement... |
Forum: Python Jun 2nd, 2009 |
| Replies: 2 Views: 178 I would try this one:
http://docs.python.org/library/signal.html |
Forum: Python Jun 1st, 2009 |
| Replies: 1 Views: 247 This is not a python issue.
However...
This oracle error comes out, when in some expression an implicit or explicit conversion fails on some line and field value.
Most likely your :DATAI and... |
Forum: Python May 29th, 2009 |
| Replies: 2 Views: 244 Let me give you an example.
There are two files. The first is compute.py and has the code:
def sumup(a,b):
return a+b
And there is your program, main.py
import compute |
Forum: Python May 29th, 2009 |
| Replies: 3 Views: 486 First of all, please read this (http://www.daniweb.com/forums/announcement114-3.html). It is on the very beginning of the forum. Your indent cannot be reconstructed from your post, so your code can... |
Forum: Python May 29th, 2009 |
| Replies: 2 Views: 333 A classic error in python3. You are concatenating a byte array (rawdata) to a string(data).
Try converting the data to bytes with encoding or do not convert it to string.
Try googling the error... |
Forum: Python May 29th, 2009 |
| Replies: 7 Views: 465 Your code is not intended in the function.
try:
def getText(inFile):
text=[ ]
file = open( inFile, "r" )
for line in wholefile:
line = line.strip() |
Forum: Python May 27th, 2009 |
| Replies: 6 Views: 265 You unnecessary use the list.
def columns(infile, outfile):
f = open(infile,'r')
o = open(outfile,'w')
col = raw_input('Please select a column from your input file, %s:' %... |
Forum: Python May 27th, 2009 |
| Replies: 2 Views: 213 Pyexcelerator is is abandoned and forked.
Use xlrd and xlwt. |
Forum: Python May 27th, 2009 |
| Replies: 5 Views: 307 Well. If you have 10**6 lines with the structure of:
number;number;characters;number
Then, if the 10**6+1 th line contains a data like:
1;2;asd;jkle;3
Then your program will most likely crash. |
Forum: Python May 27th, 2009 |
| Replies: 5 Views: 307 Yes there is a smart way. Try-catch.
for count,line in enumerate(fileobject):
try:
do your stuff
catch:
print("Some error occured on line %s" % count)
print("The... |
Forum: Python May 27th, 2009 |
| Replies: 5 Views: 307 I am running file processing with larger (>1G) files on a fare more weaker machine. I hardly believe your case ran into a limitation. In my experience the never ending program is more possible, than... |
Forum: Python May 27th, 2009 |
| Replies: 2 Views: 340 I would read in the first csv into a dictionary with title- url key-value pairs. Then go through the second large one line by line, and append the looked up values, and write it to a new file.
The... |
Forum: Python May 26th, 2009 |
| Replies: 5 Views: 327 Have you checked the firewall?
Try open the server port higher (>5000).
Check out if minimal (http://www.prasannatech.net/2008/07/socket-programming-tutorial.html) implementations are working. |
Forum: Python May 26th, 2009 |
| Replies: 3 Views: 399 A pragmatic one time solution:
The test.txt contains the above string.
st=open("test.txt").read()
delimiter="><"
tokens=st.split(delimiter)
fo=open("test_out.txt","w")
count=1
for line in... |
Forum: Python May 26th, 2009 |
| Replies: 7 Views: 465 If you simply drop the else part, then you will have all lines in the text, which do not begin with "<" and do not end with ":>"
for line in wholefile:
line = line.strip()
if... |
Forum: Python May 26th, 2009 |
| Replies: 7 Views: 465 Please (http://www.daniweb.com/forums/announcement114-3.html) use code tag.
I see two problems with your code:
1. No data will be written to the text list. Its a logical thing, you know.:) If... |
Forum: Python May 24th, 2009 |
| Replies: 7 Views: 301 I think this is, what you need:
http://www.pygame.org/docs/ref/key.html#pygame.key.get_pressed
Look at the comments, too. |
Forum: Python May 24th, 2009 |
| Replies: 4 Views: 358 Maybe I do not see your problem clearly.
I thought the problem was, that your blue riflemen does not move.
In my previous post, I showed you how you can move it.
I took this answer from the... |
Forum: Python May 23rd, 2009 |
| Replies: 1 Views: 277 The question is far too general. You need to be more specific.
You can (in decreasing difficulty):
mount other systems directory - via smb, nfs etc - and import from there
download - via... |
Forum: Python May 23rd, 2009 |
| Replies: 4 Views: 358 Maybe reading a tutorial is helpful. I have never written a pygame game, all my answers come from googling pygame tutorial and getting the code from there.
For example, the problem in this thread is... |
Forum: Python May 23rd, 2009 |
| Replies: 1 Views: 414 In your other thread (http://www.daniweb.com/forums/thread193501.html) the image shows up. I've checked. |
Forum: Python May 23rd, 2009 |
| Replies: 4 Views: 358 You should check the type first, and if it is a keyboard event, than get the key pressed.
while True:
clock.tick(60)
p.update()
for event in pygame.event.get():
... |
Forum: Python May 22nd, 2009 |
| Replies: 8 Views: 367 I am not sure I understand your "weird" question.
You either put the index into the csv file, or use some natural index, ie the line count.
In both cases you need to get the last index from the... |
Forum: Python May 22nd, 2009 |
| Replies: 8 Views: 367 Well, if you want the hard part...
Coming from a financial background I can assure you, that saving entries into a csv file permanently is a a bad idea. Unless the only purpose for this file is to... |
Forum: Python May 21st, 2009 |
| Replies: 7 Views: 541 This is not true, or you did not show us that. Your code does not produce the desired output, and it is not, that it has numbers instead of characters.
I think the problem:
is solved.
Please... |
Forum: Python May 21st, 2009 |
| Replies: 5 Views: 465 o.write(temp[i])
o.write("\n"*2) |
Forum: Python May 21st, 2009 |
| Replies: 7 Views: 541 You can use the magic of ascii:)
ord("a")==97
chr(97)=="a" |
Forum: Python May 20th, 2009 |
| Replies: 6 Views: 396 Good luck with it.
May I recommend (http://www.daniweb.com/forums/post870435-10.html) my thoughts on another guessing game? |
Forum: Python May 18th, 2009 |
| Replies: 16 Views: 1,023 you make a Hints instance with the call:
hint = Hints(guess, colors)
So hint.guess will be colors and hint.secretCode will be guess.
Obviously you mean the other way around.
When you try to... |
Forum: Python May 17th, 2009 |
| Replies: 16 Views: 1,023 No problem with my name error.
I am sad, my code could not speak for myself, so I try to write down my thoughts on that.
IMHO you do not use classes just to use classes, l'art pour l"art. You... |
Forum: Python May 16th, 2009 |
| Replies: 16 Views: 1,023 Well, I would say it is because you do not wait for user input.
Anyway, this game not so complicated to implement. No need to separate files and so on...
To prove my opinion I made one, in 10... |
Forum: Python May 14th, 2009 |
| Replies: 13 Views: 739 If you can provide the external file loaded in the code, I will look into it. |
Forum: Python May 14th, 2009 |
| Replies: 6 Views: 728 http://docs.python.org/library/site.html |
Forum: Python May 12th, 2009 |
| Replies: 13 Views: 739 First of all, I don't know what the code does.
From a merely technical point of view, I say the followings.
I think you should improve the code before improving the speed.
The majority of the... |
Forum: Python May 12th, 2009 |
| Replies: 2 Views: 221 Honestly I do not know the answer. I think it is more difficult than it seems.
Why do you need that? Maybe there is another way to solve the problem. |