Search Results

Showing results 1 to 40 of 122
Search took 0.02 seconds.
Search: Posts Made By: slate
Forum: Python 29 Days Ago
Replies: 17
Views: 453
Posted By slate
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 29 Days Ago
Replies: 4
Views: 218
Posted By slate
Could not reproduce it on python 2.6.2 linux either.
Maybe you have run the pyc version, which was older.
Forum: Python 29 Days Ago
Replies: 3
Views: 590
Posted By slate
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: 160
Posted By slate
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: 204
Posted By slate
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: 182
Posted By slate
I would try this one:
http://docs.python.org/library/signal.html
Forum: Python Jun 1st, 2009
Replies: 1
Views: 257
Posted By slate
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: 257
Posted By slate
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: 500
Posted By slate
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: 342
Posted By slate
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: 469
Posted By slate
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: 271
Posted By slate
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: 221
Posted By slate
Pyexcelerator is is abandoned and forked.
Use xlrd and xlwt.
Forum: Python May 27th, 2009
Replies: 5
Views: 315
Posted By slate
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: 315
Posted By slate
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: 315
Posted By slate
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: 368
Posted By slate
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: 330
Posted By slate
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: 415
Posted By slate
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: 469
Posted By slate
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: 469
Posted By slate
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: 310
Posted By slate
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: 374
Posted By slate
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: 287
Posted By slate
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: 374
Posted By slate
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: 452
Posted By slate
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: 374
Posted By slate
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: 378
Posted By slate
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: 378
Posted By slate
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: 555
Posted By slate
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: 526
Posted By slate
o.write(temp[i])
o.write("\n"*2)
Forum: Python May 21st, 2009
Replies: 7
Views: 555
Posted By slate
You can use the magic of ascii:)

ord("a")==97
chr(97)=="a"
Forum: Python May 20th, 2009
Replies: 6
Views: 421
Posted By slate
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,085
Posted By slate
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,085
Posted By slate
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,085
Posted By slate
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: 758
Posted By slate
If you can provide the external file loaded in the code, I will look into it.
Forum: Python May 14th, 2009
Replies: 6
Views: 773
Posted By slate
http://docs.python.org/library/site.html
Forum: Python May 12th, 2009
Replies: 13
Views: 758
Posted By slate
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: 226
Posted By slate
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.
Showing results 1 to 40 of 122

 


About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC