304 Posted Topics

Member Avatar for emma.parsons

From your code it appears, that you want to allow the following formats: yyyy,mm,dd yy,mm,dd -> 20yy,mm,dd yyyy,m,d-> yyyy,0m,0d You either allow only strict format or face the consequences... [code] import datetime def event(): ''' ask user a date and returns it in a yyyy/mm/dd format User input format: year,month,day …

Member Avatar for snippsat
0
505
Member Avatar for meisterluv

Can you isolate the problem in a code that can be run on its own? I think using global statement in python is unfortunate. 99% of the cases, it is bad design. Most basic books on programming suggest the same and not only in python. [URL="http://stackoverflow.com/questions/146557/do-you-use-the-global-statement-in-python"]See stackoverflow[/URL] Try setting up …

Member Avatar for slate
0
213
Member Avatar for calccrypto

Maybe look at [url]http://code.activestate.com/recipes/496737/[/url] I think the C implementation of addition is other in python than in C.

Member Avatar for calccrypto
0
157
Member Avatar for shyami

If your php file is pure html and javascript, then theoretically you can include it into the template you are using in python. How you do that, depends on the templating system, you are using. Since you are not asking of a specific templating system (mako, genshi, cheetah..), you are …

Member Avatar for slate
0
77
Member Avatar for txwooley

Have you read this: [url]http://www.oreillynet.com/onlamp/blog/2007/08/pymotw_subprocess_1.html[/url] ?

Member Avatar for txwooley
0
84
Member Avatar for GoBlue

Your comment sais: # TODO: compute the percentage of filler words to total words # lower percentage is more compact # students to fill this in; not provided So you get out the punctuation from the text, you make the tokens (words) and store it in the variable "tokens". You …

Member Avatar for slate
0
95
Member Avatar for mahela007
Member Avatar for mahela007
0
285
Member Avatar for drboring
Member Avatar for slate
0
39
Member Avatar for yemu

All I can propose, that you use a database. The ordered dictionary is only usable, if you know the queries beforehand or you have hardly any data. I have made, a diagram about, how I understand your data structure, but Dia crashed and I have lost it. If you are …

Member Avatar for vegaseat
1
125
Member Avatar for sandorlev

[URL="http://coding.derkeiler.com/Archive/Python/comp.lang.python/2003-12/3091.html"]http://coding.derkeiler.com/Archive/Python/comp.lang.python/2003-12/3091.html[/URL]

Member Avatar for Stefano Mtangoo
0
103
Member Avatar for shrikant.rails

Do not use "is", unless you really mean object identity, which you obviously don't. Use: system == 'Conferences' community == 'Arts' I do not know what in communities is. If it is a list, then a copy of a list will never be equal or identical with a string literal. …

Member Avatar for shrikant.rails
0
142
Member Avatar for SgtMe

Most pygame tutorial give you an implementation of simple bouncing. An ideal round ball hits on an ideal straight wall without spinning and losing energy. For example: [url]http://www.pygame.org/docs/tut/intro/intro.html[/url] [url]http://www.penzilla.net/tutorials/python/pygame/[/url] I am not sure I know what an air hockey game is. The only difference I can think of, can be …

Member Avatar for SgtMe
0
1K
Member Avatar for kbalamuk
Member Avatar for slate
0
10K
Member Avatar for danibootstrap

Something like this? [CODE=python] gpsstring='''the string you have just mentioned''' gpgaline=None gprmcline=None for line in gpsstring: if line.startswith('$GPGGA,'): gpgaline=line [/CODE]

Member Avatar for slate
0
120
Member Avatar for checker

[CODE]print "%-14s|%-10s|%-5s" % header[:3][/CODE] BTW Your comment is not accurate. The header is already read in that line.

Member Avatar for checker
0
104
Member Avatar for theweirdone

Instead of: subject = subjects[0][1] Try: subject.append(subjects[0][1])

Member Avatar for slate
0
137
Member Avatar for Dmc15

Hello Dmc! First, there are bugs and small mistakes in your code. mazefile.close is not a function call, so it does not close the file. It makes no problem because the file is automatically closed at python exit. Correctly: mazefile.close() You do not initialize the x variable in start function. …

Member Avatar for slate
0
201
Member Avatar for Democles

Hello Democles! Where is your sword? ;) Or was that Damocles? I think it is a difficult question, how someone learns a programming language. I (and the Somerville book) would say, there are two main phases of the process. First you have to build the necessary mindset. This includes understanding …

Member Avatar for slate
0
284
Member Avatar for Garee

What is the expected output for sings? The empty string? If you remove s,ing and s from the word in that order, the empty string remains... If that is so.... I would make a stem_word function, that would look like: [CODE] def stem_word(word): word_new=None for e in endings: if word.endswith(e): …

Member Avatar for masterofpuppets
0
142
Member Avatar for npn_

I would look up the wget manual. If that does not help, you can peek into the file, extract the date from it, and put the file wherever you want. [CODE] import os from os.path import join import re s=re.compile('.*?<meta name=\"OriginalPublicationDate\" content=\"(.*?)" />.*?',re.M|re.S) _dir="news.bbc.co.uk/2/hi/business/" for f in os.listdir(_dir): #print open(_dir+"/"+f).read() …

Member Avatar for slate
0
122
Member Avatar for thehivetyrant

You can use the observer pattern. [CODE] class Observed(object): def register_observer(self,observer): self.observer=observer def notify(self): self.observer.update(self) class Observer(object): def update(self,other): print(self,"gets that ",other," has moved") #decide what to do pass class Something(Observer,Observed): def __init__(self,x,y): self.x=x self.y=y #super(Something,self).__init__() def move_to(self,x,y): self.x=x self.y=y self.notify() def update(self,other): super(Something,self).update(other) if other.x<self.x: self.move_to(self.x-1,self.y)# or whatever o1=Something(1,2) …

Member Avatar for thehivetyrant
0
863
Member Avatar for dads

Could not reproduce it on python 2.6.2 linux either. Maybe you have run the pyc version, which was older.

Member Avatar for slate
0
113
Member Avatar for pyprog

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 expression does not depend on it. It possibly exits on index error if num becomes too large. At first …

Member Avatar for vegaseat
0
903
Member Avatar for slate

A brute force method. Finds the FIRST and SHORTEST periodicity in the input list.

1
164
Member Avatar for jen638

Please use [URL="http://www.daniweb.com/forums/announcement114-3.html"]code tags[/URL], even if it is quick. What exactly is your question?

Member Avatar for slate
0
161
Member Avatar for Wraithan

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 the [URL="http://docs.python.org/dev/library/collections.html#namedtuple-factory-function-for-tuples-with-named-fields"]named tuple[/URL], which is present in python 2.6 or later. From a design point of view …

Member Avatar for slate
0
1K
Member Avatar for ararik

First of all, please read [URL="http://www.daniweb.com/forums/announcement114-3.html"]this[/URL]. It is on the very beginning of the forum. Your indent cannot be reconstructed from your post, so your code can only be guessed. I think your problem is not, that you are new to python. In any language there would be a problem …

Member Avatar for ararik
0
3K
Member Avatar for RDCooter
Member Avatar for tombatista

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 [code]:DATAI[/code] and [code]:DATAF[/code] bind variables are not in the format 'yyyy-mm-dd hh24:mi:ss'

Member Avatar for slate
0
155
Member Avatar for gujjar19

[URL="http://www.daniweb.com/forums/announcement114-3.html"]Please[/URL] 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 you exit the loop when a line starts with "<" or ends with ":>", and you do not process a line otherwise, …

Member Avatar for gujjar19
0
3K
Member Avatar for pydude94

Let me give you an example. There are two files. The first is compute.py and has the code: [code=python] def sumup(a,b): return a+b [/code] And there is your program, main.py [code=python] import compute print compute.sumup(2,3) [/code] The question is, how will python know where to find this compute module? The …

Member Avatar for pydude94
0
266
Member Avatar for poeticinsanity

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 code to get the notion.

Member Avatar for poeticinsanity
0
224
Member Avatar for mg0959

Have you checked the firewall? Try open the server port higher (>5000). Check out if [URL="http://www.prasannatech.net/2008/07/socket-programming-tutorial.html"]minimal[/URL] implementations are working.

Member Avatar for mg0959
0
153
Member Avatar for betatype

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 code goes something like this (not tested): [code=python] import csv urlReader …

Member Avatar for betatype
0
126
Member Avatar for hughesadam_87

You unnecessary use the list. [code=python] def columns(infile, outfile): f = open(infile,'r') o = open(outfile,'w') col = raw_input('Please select a column from your input file, %s:' % (infile)) col = int(col) - 1 for line in f: line = line.strip() if line: # Split each line into columns line = …

Member Avatar for jlm699
0
352
Member Avatar for hughesadam_87

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 the one running out of memory. Try catching the exception that occurs, and print out …

Member Avatar for hughesadam_87
0
151
Member Avatar for Joe Hart
Member Avatar for slate
0
127
Member Avatar for adamdidthis

A pragmatic one time solution: The test.txt contains the above string. [code=python] st=open("test.txt").read() delimiter="><" tokens=st.split(delimiter) fo=open("test_out.txt","w") count=1 for line in tokens: if line.startswith("ARG") and line.endswith("ARG"): firstarg=line.find("ARG")+3 line=line[:firstarg]+str(count)+line[firstarg:]+str(count) count+=1 fo.write(line) fo.write(delimiter)#FIXME last delimiter is too much fo.close() [/code]

Member Avatar for slate
0
76
Member Avatar for tomtetlaw

I think this is, what you need: [url]http://www.pygame.org/docs/ref/key.html#pygame.key.get_pressed[/url] Look at the comments, too.

Member Avatar for tomtetlaw
0
454
Member Avatar for tomtetlaw

You should check the type first, and if it is a keyboard event, than get the key pressed. [code=python] while True: clock.tick(60) p.update() for event in pygame.event.get(): if event.type == pygame.KEYDOWN: if event.key == pygame.K_q: pygame.quit() return elif event.key == pygame.K_LEFT: p.walk_left() elif event.key == pygame.K_RIGHT: p.walk_right() elif event.key == …

Member Avatar for slate
0
298
Member Avatar for mohankumar554

The question is far too general. You need to be more specific. You can (in decreasing difficulty): [LIST] [*]mount other systems directory - via smb, nfs etc - and import from there [*]download - via smb, ftp, http etc - other systems directory and import it locally [*]Use import hooks …

Member Avatar for slate
0
89
Member Avatar for tomtetlaw

In [URL="http://www.daniweb.com/forums/thread193501.html"]your other thread[/URL] the image shows up. I've checked.

Member Avatar for slate
0
137
Member Avatar for aparadox

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 import it to something more robust. Deleting transactions looks like a bad …

Member Avatar for comprookie2000
0
175
Member Avatar for kiddo39
Member Avatar for hughesadam_87
Member Avatar for punjabi

Good luck with it. May I [URL="http://www.daniweb.com/forums/post870435-10.html"]recommend[/URL] my thoughts on another guessing game?

Member Avatar for jlm699
0
142
Member Avatar for hunterm

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 minutes. Most of the time went debugging the match_guess method. It …

Member Avatar for _Nestor
0
2K
Member Avatar for daviddoria
Member Avatar for vegaseat
0
2K
Member Avatar for ning2009

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 code seems to be copy-pasted. All the "cases" can possibly merged into one codeblock …

Member Avatar for ning2009
0
218
Member Avatar for Deman

I do not know the TK library ( It is disturbing to me, that the application is a frame object, too), but syntactically: [code] class Application(Frame): def __init__(self, master,player1, player2): [/code] should do the trick.

Member Avatar for woooee
0
157

The End.