Search Results

Showing results 1 to 40 of 65
Search took 0.02 seconds.
Search: Posts Made By: woooee ; Forum: Python and child forums
Forum: Python 17 Hours Ago
Replies: 27
Views: 730
Posted By woooee
What type of objects does the query return? You may have to convert to a list to access it in this way. query = db.GqlQuery("SELECT *" .....etc.
print type(query)
ctr = 0
for q in query:
if...
Forum: Python 4 Days Ago
Replies: 2
Views: 229
Posted By woooee
I don't use regex as a rule and it is not necessary in this case. found = False
fp = open(fname, 'r')
for num, line in enumerate(fp):
line = line.strip()
if line.startswith(search_term):...
Forum: Python 4 Days Ago
Replies: 4
Solved: help open()
Views: 172
Posted By woooee
One thing, you can not open a directory, so you should test that it is a file. import os
a = []
a = os.listdir('.')
for t in a:
if os.path.isfile(t):
f = open(t,'r')
print...
Forum: Python 4 Days Ago
Replies: 6
Views: 228
Posted By woooee
if option==3:
active<>"on"This will print "True" if active != 'on' and print "False" otherwise. <> has been deprecated so use "!=" instead. I think you want if option==3:
...
Forum: Python 10 Days Ago
Replies: 1
Views: 262
Posted By woooee
effbot's tutorial turns up as the first hit for a Google of "tkinter scrollbars". Since we don't know what you want to attach it to, effbot would be the place to start. This is effbot's code for a...
Forum: Python 12 Days Ago
Replies: 5
Views: 206
Posted By woooee
It would generally be something in this ballpark file_pointer = open("Handylist.csv", "r")

name_in = raw_input("Enter the name")
for rec in file_pointer:
substrs = rec.split()
name =...
Forum: Python 12 Days Ago
Replies: 6
Views: 245
Posted By woooee
Just read it, line by line, as a normal file, unless it is not a text file, in which case you would have to read and convert to text. See 2.4.5 here...
Forum: Python 12 Days Ago
Replies: 6
Views: 245
Posted By woooee
It's pretty straight forward, and since I'm sick and not doing much today... test_data = [ "c The random seed used to shuffle this instance was seed=1755086696",
"p cnf 1200 4919",
...
Forum: Python 22 Days Ago
Replies: 3
Solved: Flip
Views: 220
Posted By woooee
The first two posts found in a search of this forum, after your post which is the first/latest, have working solutions that you should be able to adapt.
Forum: Python 27 Days Ago
Replies: 4
Views: 416
Posted By woooee
A quick example of a spiral using deque. It still has a few problems (works best with a square and prints too many) but shows the general concept. from collections import deque
...
Forum: Python 30 Days Ago
Replies: 2
Views: 205
Posted By woooee
It is easier to code than to explain. This will only work if you use a fixed width font. A proportional font would require more work. It is a little bit tricky in that you want to print one...
Forum: Python 30 Days Ago
Replies: 10
Views: 563
Posted By woooee
if "EMERGENCY" or "Help" or "!" in heading:
pass
elif ("no idea" in body) or (not Code() in body):
pass
Forum: Python 31 Days Ago
Replies: 2
Views: 502
Posted By woooee
I think you could check for a number in the second position, if I understand correctly that overlays use numbers and updates/adds use a letter. if len(line.strip()) and \
not...
Forum: Python 31 Days Ago
Replies: 3
Views: 344
Posted By woooee
So you are obviously using PyQT4 built for Python 2.6. The error message confirms it. Ask how to install PyQT for both 2.6 and 3.x on the Ubuntu or PyQt forum. Some one has done this and if there...
Forum: Python 33 Days Ago
Replies: 4
Views: 344
Posted By woooee
Python does not have static variables, but does have global variables, which those are not. They are class objects and would be called using
Atom.cartesian
both inside and outside the class. In...
Forum: Python 34 Days Ago
Replies: 4
Views: 344
Posted By woooee
You have both class instances and class objects. The variables
cartesian = dict()
bondList = list()
atomName = str()
atomicNum = int()
would point to the same variable (block...
Forum: Python Nov 6th, 2009
Replies: 9
Views: 879
Posted By woooee
There are several online pages to do that.
http://primes.utm.edu/curios/includes/primetest.php
is one found on this very good page
http://primes.utm.edu/

Your program works correctly, at least...
Forum: Python Oct 27th, 2009
Replies: 5
Views: 417
Posted By woooee
Google came up with this site which has a link to download source code. I hope you didn't pay $99.95 for the book! http://www.jbpub.com/catalog/9780763746025/
Forum: Python Oct 22nd, 2009
Replies: 2
Views: 265
Posted By woooee
You can set the encoding for the file
fp = codecs.open('test', encoding='utf-8', mode='w')

Or you can change the default encoding for the system
sys.setdefaultencoding('utf-8')

You may have...
Forum: Python Oct 19th, 2009
Replies: 8
Solved: List help...
Views: 228
Posted By woooee
Using for() loops is easier. This is somewhat of a brute force method but works fine for smaller lists. L1=[[1,2,3],[4,5,6],[7,8,9],[10,11,12]]
L2=[1,2,3,4,11]
L3=[]

for number in L2:
...
Forum: Python Oct 16th, 2009
Replies: 6
Code Snippet: Roman Numerals (Python)
Views: 3,423
Posted By woooee
Roman to integer. Note that it will take something like XXIXV and convert it. If someone already has a routine to check for valid input, please post it. And I'm afraid we've just eliminated one...
Forum: Python Oct 15th, 2009
Replies: 12
Views: 508
Posted By woooee
Dictionaries are indexed via a hash and so make it easy to look up things, in this case the stock symbol, without going through the sub-strings in each list. Also, they provide a convenient way to...
Forum: Python Oct 15th, 2009
Replies: 6
Views: 277
Posted By woooee
Can you use a list instead of all of those variables? Otherwise, try the code below which tests each button individually instead of the confusing and, and, or, etc. in your code. Speaking of...
Forum: Python Oct 14th, 2009
Replies: 13
Views: 1,049
Posted By woooee
You would have to step through the unicode and count the number of actual letters, and then add enough spaces to the string to make it the length you want. This appears to work, but you'll have to...
Forum: Python Oct 11th, 2009
Replies: 1
Views: 301
Posted By woooee
That's not a good example to copy (although the book ultimately solves that problem if memory serves.). Find one using the canvas widget as it uses a top left corner (x,y) and a bottom right corner....
Forum: Python Oct 10th, 2009
Replies: 2
Views: 272
Posted By woooee
You would generally use a for loop to iterate through a list. I'm creating one output string, but you could also print within the for loop. Also, please do not use "i", "l" or "o" as single letter...
Forum: Python Oct 2nd, 2009
Replies: 4
Views: 268
Posted By woooee
A dictionary with the letter as the key is the straight forward way to do this. Otherwise use a function with a for loop to pass the letter and the string to the function.import string
...
Forum: Python Oct 1st, 2009
Replies: 3
Views: 312
Posted By woooee
Your problem is here for n in range(num_iterations):
print "n before =", n
n = B*10
print "n after =", n You use "n" twice and are always multiplying the same number,...
Forum: Python Sep 15th, 2009
Replies: 4
Views: 923
Posted By woooee
For exactness, use the decimal class. My take on the program using decimal. Note that decimal.Decimal is imported as "dec" to avoid confusion with the variable names. Also, I am not a decimal...
Forum: Python Sep 14th, 2009
Replies: 5
Views: 333
Posted By woooee
There is an error on this line, no colon
for line in objconfigfile.readlines()

I would suggest that you print every line because
if line == None:
will probably never be true, but you will have...
Forum: Python Sep 12th, 2009
Replies: 6
Views: 665
Posted By woooee
For future coding conundrums, an "or" can be viewed as an if / elif, and "and" can be viewed as two nested if statements, which you would adapt to while() statements.
while overwrite != 'Y'.lower()...
Forum: Python Sep 3rd, 2009
Replies: 29
Views: 1,294
Posted By woooee
My attempt. Once again, if not correct, post back with more info. The trick (I think) is to split each string on the "\n" to create individual rows, and is similiar to Gribouillis' solution but...
Forum: Python Aug 12th, 2009
Replies: 3
Views: 288
Posted By woooee
Use the codebox
"Display some text in a monospaced font, with no line wrapping.
This function is suitable for displaying code and text that is
formatted using spaces.

The text parameter should...
Forum: Python Jun 24th, 2009
Replies: 1
Views: 414
Posted By woooee
You use a StringVar and include the function in the class. Here is a simple example. Note that the same StringVar is used for the second label and the entry box. Take a look at this page...
Forum: Python Jun 23rd, 2009
Replies: 2
Solved: my text game
Views: 319
Posted By woooee
You can do this two different ways.items = {'sword':['sword', 3, 15],
'axe':['axe', 5, 25],
'bow and arrow':['bow and arrow', 4, 20]}

##---- the easiest to understand...
Forum: Python Jun 15th, 2009
Replies: 5
Views: 257
Posted By woooee
Yes that should have been one to get the next value. A good example of why we don't use "i".
Forum: Python Jun 15th, 2009
Replies: 9
Views: 1,018
Posted By woooee
A google will yield a lot of hits. The python wiki is always a good place to start. http://wiki.python.org/moin/GuiProgramming
Forum: Python Jun 2nd, 2009
Replies: 4
Solved: Jumble solver
Views: 20,564
Posted By woooee
The standard solution for anagrams is to sort on the letters. So 'ogd' sorted is 'dgo', and a lookup of the 'dgo' key in the dictionary yields the list ["dog", "god"]. Your code would only return...
Forum: Python May 21st, 2009
Replies: 4
Views: 495
Posted By woooee
Please don't spam this site or someone will report you and you will be banned. Since the OP didn't say which toolkit or OS was involved, it is obvious that there is no way to recommend anything,...
Forum: Python May 21st, 2009
Replies: 5
Views: 663
Posted By woooee
This was the second entry from a Google for "python list write"
http://www.daniweb.com/forums/thread173615.html

and effbot is usually in search results. This explains writelines(), but...
Showing results 1 to 40 of 65

 


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

©2003 - 2009 DaniWeb® LLC