2,190 Posted Topics

Member Avatar for EAnder

Add "Solved" or "Ignore This" to the thread title and in a day or two it will be too far down the list to notice.

Member Avatar for woooee
0
98
Member Avatar for JA5ONS

Use the datetime module. Note that using the separate variable, start_time, is not necessary. start_time = datetime.datetime(2008, 06, 03, 12, 30, 00) diff_time = datetime.datetime(2008, 06, 03, 12, 50, 00) - start_time print diff_time.seconds, type(diff_time) print "duration in minutes =", diff_time.seconds/60 [url]http://effbot.org/librarybook/datetime.htm[/url] [url]http://blog.doughellmann.com/2008/03/pymotw-datetime.html[/url]

Member Avatar for JA5ONS
0
119
Member Avatar for Potty391

Start with defining the public and private members. You should also read your own post. There is duplication re defining the class named "Corvette". Rework it so that things are clear and only defined once.

Member Avatar for woooee
0
100
Member Avatar for dinilkarun

"Bold" is a function of the program displaying the text. In postscript it is /Helvetica-Bold findfont % Get the basic font 11 scalefont % Scale the font setfont % Make it the current font You can use this if you are printing the file to a printer. For a word …

Member Avatar for woooee
0
105
Member Avatar for bf2loser

[QUOTE]an someone show me some code to convert rankine temperature to kelvin? rankine is in the same scale as fahrenheit, but it starts at absolute zero. so 0R = -459.67F, heres is what I have[/QUOTE]So rankine would be fahrenheit -459.67 the way I read what you have said[CODE]def to_rankine_from_celsius( tempC …

Member Avatar for jrcagle
0
1K
Member Avatar for turnerca902

[QUOTE]I have a .dbf file which contains three fields: an id (1), a Mapsheet # (455626) and finally a Mapsheet Name that corresponds to the Mapsheet# ( Big Lake ).[/QUOTE]I assume you are using something like dbfpy to read the file, so populating the dictionary would be fairly simple. The …

Member Avatar for woooee
0
154
Member Avatar for ccandillo

This will traverse all of the subdirectories and do what I think you want it to do. I have added some print statements which is probably enough by itself to answer your question as is shows what the root, dirs, and files contain. If you want to limit it to …

Member Avatar for woooee
0
1K
Member Avatar for stabler_rocks

[QUOTE]create a counter that counts how many weeks a certain value gets exceeded[/QUOTE]I would suggest using a function for simplicity. Return a "True" or one if the value is exceeded. This also only returns one positive. If it is possible that the value is exceeded more than once in a …

Member Avatar for woooee
0
98
Member Avatar for lllllIllIlllI

One advantage of the class structure is that you don't use globals but self.var_name.[CODE]import random class Cards(object): def __init__(self): self.cards = {2:4,3:4,4:4,5:4,6:4,7:4,8:4,9:4,10:16,'ace':4} self.player = [] self.playert = 0 self.comp_tot=0 self.comp = [] print self.playert,'hi' print "The Game is Blackjack" def draw(self): f = self.cards.keys() a = random.choice(self.cards.keys()) self.cards[a]-=1 if self.cards[a] …

Member Avatar for lllllIllIlllI
0
181
Member Avatar for ABSOR

Not nearly enough info. You'll have to include the code (using code tags because whitespace counts in python-see the "Please use BB Code and Inlinecode tags" thread) and a complete error message For starters, your code should read[CODE]def X(a,b): c = a+b ## note that the backslash is not necessary …

Member Avatar for ABSOR
0
94
Member Avatar for saywell

You can also use the var.find("-s") method for strings and then slice it. It depends on if -s"password" is the only thing in that record or not.

Member Avatar for saywell
0
81
Member Avatar for sreelatha

We had a topic like this a short while ago. The easiest/most efficient method is to use two sets and compare with set1.difference(set_2) and vice-versa. Also, python has difflib which may or may not be more than you want. [url]http://docs.python.org/lib/differ-examples.html[/url]

Member Avatar for sreelatha
0
3K
Member Avatar for Miyuki

Since you enter the Python interpreter, run the program, and then exit the interpreter, I don't think there is a way. The interpreter will always return you to the original directory when it exits. Perhaps someone else will have other ideas on this.

Member Avatar for jrcagle
0
207
Member Avatar for ChrisP_Buffalo

Add some print statements to see what is going on and it should become obvious. [CODE]for ID1, begin1, end1 in file_1: print "file_1 =", ID1, begin1, end1 for ID2, begin2, end2 in file_2: print " file_2 =", ID2, begin2, end2[/CODE]

Member Avatar for ChrisP_Buffalo
0
124
Member Avatar for frijole

A link to a Tkinter tutorial/reference [url]http://infohost.nmt.edu/tcc/help/pubs/tkinter/[/url]

Member Avatar for frijole
0
184
Member Avatar for ivy47469

Also, this will not work. You have two separate blocks of memory. I have reduced your code so it only tests the year variable. The value at memory block #2 never changes so that snippet only prints once, (i.e it is initialized as year[memory block #1]+1 = 0+1 at a …

Member Avatar for kdoiron
0
124
Member Avatar for Tyrfing

OpenOffice will import comma delimited text files, or any other delimiter that you care to choose. If there are commas in the data then use something like comma+space+space as the delimiter. Here is a dated link for creating the spreadsheet in python. It refers to StarOffice (or something like that), …

Member Avatar for kdoiron
0
168
Member Avatar for athirar

"list index out of range" has nothing to do with the size of the list AFAIK. If the list were too large there would be some sort of out of memory message.[QUOTE]Is there any other efficient datastructure other than lists and dictionary to serve the purpose ?[/QUOTE]SQLite can be used …

Member Avatar for kdoiron
0
118
Member Avatar for tondeuse34

It might be helpful to take a look at the "Starting Python" at the top of this forum. There are 5 pages, so don't have to wade through 100's of pages to get you started.

Member Avatar for tondeuse34
0
130
Member Avatar for Mackjan

Obviously this is not a list of numbers, so you want to take a look at the function that returns this. Add print statements to see what is going on throughout the program until you understand what is happening

Member Avatar for woooee
0
157
Member Avatar for jascase901

If you want to run this program file by itself, put the following at the bottom. You can then run the program from the command line with "python program_name". Take a look at the "Starting Python" thread at the top of this forum. [CODE]if __name__ == "__main__": opener[/CODE]

Member Avatar for woooee
0
92
Member Avatar for alivip

You best bet would be to ask the person on python-forum.org who wrote this program. They would understand it better than anyone else. No one wants to spend their time answering a question that has already been answered on another forum.

Member Avatar for Freaky_Chris
0
244
Member Avatar for Seagull One

You may have more than one block of memory named "LawRecite". If you assign True in a loop or function then it is local to that loop/function and will be destroyed when you exit unless you return the value from the function. Change any variable names that are in a …

Member Avatar for Seagull One
0
143
Member Avatar for cwolfraven

[QUOTE]The problem is I need to take the names of the images in Directory A and apply them to the images in Directory B.[/QUOTE]What does this mean? Rename a file with some unknown name combination? See if a name in is both dirs?

Member Avatar for Freaky_Chris
0
99
Member Avatar for alivip

There has to be better code to copy. Unless you have to modify that specific program, I would suggest finding program without the Tkinter stuff and copy that. You can add a GUI later after the rest of it is working. Also, when you copy a program and are trying …

Member Avatar for alivip
0
129
Member Avatar for callie_360

And apparently a variable as well readLines = readLines(line,lines,lineNumber) isPageValid = isPageValid(testLine,validPages) Try this instead[CODE]def isPageValid(testLine, validPages_list): ##isPageValid = False <----- Not Used for valid_page in validPages_list: if testLine in valid_page: ## or do you want ## if valid_page in testLine ? return True return False[/CODE]

Member Avatar for woooee
0
125
Member Avatar for Azurea

If you are not changing the contents of one or both of the lists, then use a tuple instead:[CODE]tuple1 = tuple(list2)[/CODE]

Member Avatar for Azurea
0
92
Member Avatar for SUBHABRATAIISC

To copy a list you would use a3 = a[:] print a3 If you don't want an exact copy you would append to another list[CODE]a=['city','village','town','capital'] a3=[] for x in a: print "x in a =", x if x.startswith( "c" ): print " appending", x, "to a3" a3.append(x) print a3[/CODE]

Member Avatar for Ene Uran
0
86
Member Avatar for Mackjan

Deleting new_num from x does nothing useful. You are using num and deleting new_num which may or may not be in x. You want to append to y if num > 0[CODE]for num in x: if num > 0: ## eliminate if num-1 <= zero y.append(num-1) b+=1[/CODE]

Member Avatar for Mackjan
0
110
Member Avatar for jmroach

New entries are not being over-written. You are initializing to an empty dictionary with the statement results[p] = {}. Perhaps (and just perhaps) a dictionary of classes would serve better. Note that SQLite can also be used in memory, i.e you can store and lookup '2.0' + 'Conditions' + 'Vane2INLET', …

Member Avatar for jmroach
0
153
Member Avatar for lllllIllIlllI

It's something along the lines of os.system("firefox http://www.google.com")

Member Avatar for lllllIllIlllI
0
123
Member Avatar for harakiri1976
Member Avatar for woooee
0
118
Member Avatar for Mackjan

Some modifications to your code. First you have to test for zero, and second, the variable "b" is not necessary as you can just use len(x). Hopefully this is what you want to do. [CODE]def kopi(x): y = [] for num in x: new_num = num - 1 if new_num …

Member Avatar for Mackjan
0
80
Member Avatar for Igor_MK

I'm not sure comparing words will give the best results. If two articles use "and", "the", "a", "of", "to", etc. a lot then they will be deemed similar. If you want to do it that way, then go through each of the two files and place unique words in a …

Member Avatar for woooee
0
168
Member Avatar for lllllIllIlllI

And if you mean something very simple to time some program once, use datetime. [CODE]import datetime import time start_time = datetime.datetime.now() time.sleep(2) print datetime.datetime.now() - start_time[/CODE]

Member Avatar for woooee
0
84
Member Avatar for s_jmp

See the second entry here at effbot [url]http://www.google.com/search?ie=UTF-8&oe=UTF-8&q=python+from+import[/url]

Member Avatar for sneekula
0
157
Member Avatar for angelxu

Use code tags and submit some sample data in raw form and how you want it to appear after formatting. There is not enough information in your post.

Member Avatar for kdoiron
0
136
Member Avatar for sbrown2594

You will have to identify the global variables, bet et al. Otherwise, you will be using a second block of memory that is also named bet but local to the function.[CODE] if bet == "quit": break elif float(bet) <= 0 or float(bet) > x: print "Invalid bet." else: print x, …

Member Avatar for woooee
0
118
Member Avatar for tondeuse34

See 7.2 at this link, "Reading and Writing Files". [url]http://docs.python.org/tut/tut.html[/url]

Member Avatar for tondeuse34
0
117
Member Avatar for pazoo

Add a print statement at the beginning of who wins to see if you actually enter it or not. If the value of turnTuple is not found, nothing will happen. And this definitely should be a class IMHO. It's time to learn classes. It will make coding a lot easier.[CODE]def …

Member Avatar for woooee
0
130
Member Avatar for ChrisP_Buffalo

Insert some print statements to see what is happening. You may have a LF, "\n", at the end of each aPol_data item in which case you will see an extra empty line when printing old, so it doesn't match any word without one. If this is true, you will have …

Member Avatar for woooee
0
100
Member Avatar for Edwards8

The Python Imaging Library has tiff routines. Before beating your head against the wall, see if you can use it. If not, post back with an example or two of what you want to put into the metadata. Image formats have become very optionated.

Member Avatar for Edwards8
0
162
Member Avatar for Mr NiceGuy

If this is a line of data from the file 28.618382 27.631520 44, followed by 28.618382 27.631520 22 etc, then you can use split() instead of checking for tabs. Also, you can pass a string as a parameter to file open() [CODE]## simulate a file read data = [ "28.618382 …

Member Avatar for SUBHABRATAIISC
0
110
Member Avatar for Mackjan

1) You don't return x from the function so it is not visible outside the function. 2) You have multiple variables named "i" (Please don't use, i, l, or o as they look like numbers and there as 23 other letters that work just as well) for i in range …

Member Avatar for vegaseat
0
110
Member Avatar for ChrisP_Buffalo

If you want both verb and prep to be found in count created by the existing code [CODE]from collections import defaultdict total_found_dic = defaultdict(int) if (verb in count) and (prep in count): total_found_dic[(verb, prep)] += 1[/CODE] Note that you want to test sub-words and print the results to see what …

Member Avatar for woooee
0
94
Member Avatar for dilbert_here00

Have you tried sys.stdout.flush()? I don't know if that will work or not. Also, you want to begin to move over to the subprocess module. Theoretically, it should flush the buffer whenever you issue a read stdout using subprocess. I guess no one else has much to offer on this. …

Member Avatar for dilbert_here00
0
119
Member Avatar for wyno

A) Stop feeding it your brains B) Hint, it's a __carpet__ python. BTW watt is spelled "watt", not wat, and python's don't eat watts, lightbulbs do.

Member Avatar for Ene Uran
0
88
Member Avatar for tico

Are you on a Mac or Linux? Libfmodex if available for both. It appears that you don't have it installed although it could be installed someplace that is not in the path. Try searching/installing fmodex or libfmodex.

Member Avatar for woooee
0
100
Member Avatar for blade321

I think Blade321 also wants to ask for input if the numbers don't agree and assign it to the variable x (instead of printing it)[CODE]x=0 y= 1234 n=0 while x <> y: x = int(raw_input("Enter a number " )) n += 1 if n > 10: break[/CODE]

Member Avatar for jrcagle
0
109
Member Avatar for Acidburn

Append everything to c[CODE]a = [ "is", "cool"] b = ["Peter", "James", "John"] c = [] for name in b: c.append( [name, a] ) print c [['Peter', ['is', 'cool']], ['James', ['is', 'cool']], ['John', ['is', 'cool']]][/CODE]

Member Avatar for woooee
0
80

The End.