Search Results

Showing results 1 to 40 of 564
Search took 0.04 seconds.
Search: Posts Made By: bumsfeld ; Forum: Python and child forums
Forum: Python 10 Days Ago
Replies: 78
Views: 14,748
Posted By bumsfeld
Here is modified (also added needed delay) and commented code from the pygame tutorial that shows how to load one image onto rectangle object and move the object:
# use pygame to bounce/move loaded...
Forum: Python 10 Days Ago
Replies: 7
Views: 251
Posted By bumsfeld
If you use m==0 it will give you False unless m is zero.
Forum: Python 10 Days Ago
Replies: 5
Views: 248
Posted By bumsfeld
You can create myarray[x][y][z], but you still have to associate with the sphere object, that is where the dictionary mapping comes in handy.
Forum: Python 10 Days Ago
Replies: 5
Views: 248
Posted By bumsfeld
You can include coordinate z into your key tuple by simply expanding vegaseat's code:
# create a large number of spheres referencing them
# with a (x, y, z):sphere_object dictionary pair

import...
Forum: Python 10 Days Ago
Replies: 3
Views: 246
Posted By bumsfeld
Your area formula for regular polygons should be:

area = ((length**2) * numSides)/(4 * (math.tan(math.pi/numSides)))
Your result will be square units of whatever units of measurement your sides...
Forum: Python 10 Days Ago
Replies: 2
Views: 215
Posted By bumsfeld
Vegaseat left this ttk code somewhere showing you the way module ttk should be imported and applied:
# exploring the Tkinter expansion module ttk notebook
# tested with Python 3.1 and Tkinter 8.5 ...
Forum: Python 11 Days Ago
Replies: 3
Views: 204
Posted By bumsfeld
Be aware that Python25 and Python26 use different MS C compilers and so do the modules they use. The C code syntax has to match these compilers, as they are not compatible.
Forum: Python 11 Days Ago
Replies: 7
Views: 251
Posted By bumsfeld
Looking at your code you have quite a nightmare of errors in there and on top of that the all important indentations are all screwed up.

!) use the customary 4 space indentations, avoid tabs!!!!
...
Forum: Python 16 Days Ago
Replies: 2
Solved: GetBestSize()??
Views: 188
Posted By bumsfeld
Try self.SetSizerAndFit(sizer)
Forum: Python 16 Days Ago
Replies: 5
Views: 265
Posted By bumsfeld
Are you usng Python2 or Python3?
Are your positive numbers integers or floats?
Forum: Python 16 Days Ago
Replies: 4
Views: 173
Posted By bumsfeld
Why so complicated?
Using a similar english dictionary file:
# mydict.txt has one English word per line
# about 74500 in total
mydict = open("mydict.txt", "r").readlines()

print(mydict[:10])...
Forum: Python 16 Days Ago
Replies: 11
Views: 457
Posted By bumsfeld
The reason you want to make something private to the class is to keep it from easily spilling out into external code. So pseudo-private will do one good job. Remember it's called private, not...
Forum: Python Oct 20th, 2009
Replies: 12
Views: 636
Posted By bumsfeld
import os
# works on windows nt (also xp and vista) or linux
os.system(['clear','cls'][os.name == 'nt'])
If [os.name == 'nt'] is True then this becomes effectively 1. So it picks item at index 1...
Forum: Python Oct 20th, 2009
Replies: 9
Views: 302
Posted By bumsfeld
Read vegaseat's comment:


You need to move all those lines to the right by 4 spaces.
Forum: Python Oct 20th, 2009
Replies: 3
Views: 398
Posted By bumsfeld
You may not want to add letters to the list that have zero count.
Forum: Python Oct 20th, 2009
Replies: 7
Solved: python 2. to 3
Views: 268
Posted By bumsfeld
Also with Python3 you don't have to use
fahrenheit = (9.0 / 5.0) * celsius + 32
you can just use
fahrenheit = (9 / 5) * celsius + 32
since '/' is now floating point division and '//' is integer...
Forum: Python Oct 20th, 2009
Replies: 3
Views: 696
Posted By bumsfeld
If you are curious, also check this out:
http://www.daniweb.com/code/snippet216539.html
Forum: Python Oct 20th, 2009
Replies: 9
Views: 302
Posted By bumsfeld
Did you download the code or retype it manually yourself?
There are some errors due to indentations and typos.

The return outside function error is really indentation error!
Forum: Python Oct 20th, 2009
Replies: 4
Views: 3,105
Posted By bumsfeld
Seems to me that you also have to consider the time that re.compile() needs.
Forum: Python Oct 19th, 2009
Replies: 5
Views: 384
Posted By bumsfeld
Some corrections:
num = 0
mylist = []

while num < 10:
num = num + 1
mylist.append(num)

print(mylist)
Forum: Python Oct 19th, 2009
Replies: 4
Solved: Ipart - Fpart
Views: 229
Posted By bumsfeld
Asking questions is never stupid! :)
Forum: Python Oct 19th, 2009
Replies: 3
Solved: numtolet
Views: 181
Posted By bumsfeld
This will also trap number exceeding the index:
import string

def numtolet(num):
if num > 25: return
return string.ascii_uppercase[num]

print( numtolet(0) ) # A
print( numtolet(5)...
Forum: Python Oct 19th, 2009
Replies: 6
Views: 296
Posted By bumsfeld
# staticmethod() and classmethod()
# make it easier to call one class method

class ClassA(object):
def test(this):
print this
test = staticmethod(test)

ClassA.test(4) # 4
Forum: Python Oct 19th, 2009
Replies: 8
Solved: List help...
Views: 210
Posted By bumsfeld
One of the solutions is pretty straight forward, with easy logic:
list1 = [[1,2,3],[4,5,6],[7,8,9],[10,11,12]]
list2 = [1,2,3,4,11]

list3 = []
# q1 is each sublist in list1
for q1 in list1:
...
Forum: Python Oct 12th, 2009
Replies: 5
Views: 404
Posted By bumsfeld
As performance is concerned, the file read from disk will be the slowest part by far!
Forum: Python Oct 12th, 2009
Replies: 5
Views: 6,901
Posted By bumsfeld
Do you mean highest frequency first?

Simply add this to the end of the code:
print '-'*30

print "sorted by highest frequency first:"
# create list of (val, key) tuple pairs
freq_list2 =...
Forum: Python Oct 12th, 2009
Replies: 3
Views: 376
Posted By bumsfeld
You are close:
fname = raw_input("enter a text file name: ")

fread = open(fname, "r")
# read the whole file into one string
text = fread.read()
fread.close()

# split the whole text string...
Forum: Python Oct 12th, 2009
Replies: 22
Views: 180,163
Posted By bumsfeld
Vary bad manners to hijack this thread for such question.

Start your own thread and give more info!
Forum: Python Oct 12th, 2009
Replies: 5
Views: 1,065
Posted By bumsfeld
You are in the wrong forum. Many of us went away from low level C to high level Python to solve such problems easily.
Forum: Python Oct 12th, 2009
Replies: 5
Views: 1,646
Posted By bumsfeld
However, pyHook and pythoncom work only on Windows systems. Not too bad, since most computers in this world are using Windows. Tkinter is more cross-platform for the few odd folks that user other...
Forum: Python Oct 11th, 2009
Replies: 7
Views: 295
Posted By bumsfeld
Similar to jice's code:
# simply ignore index zero
pos = [' '] * 11
print( pos )

POS = 1

pos[POS] = '->'
print( pos )
Forum: Python Oct 5th, 2009
Replies: 6
Solved: python help
Views: 266
Posted By bumsfeld
At least for some time, it would be very nice if people indicated which version of Python they are using.
Forum: Python Oct 5th, 2009
Replies: 13
Views: 495
Posted By bumsfeld
If this is truly your text file, I feel sorry for you!
Forum: Python Oct 5th, 2009
Replies: 4
Views: 335
Posted By bumsfeld
I think you need to develop mask of your image to make this work.
Forum: Python Aug 27th, 2009
Replies: 6
Views: 452
Posted By bumsfeld
Extension .pyd is used for C compiled library files for Python.
Forum: Python Aug 26th, 2009
Replies: 5
Views: 371
Posted By bumsfeld
What is more efficient?

1) import math
2) from math import *
3) from math import sin, cos
Forum: Python Aug 25th, 2009
Replies: 78
Views: 14,748
Posted By bumsfeld
It's like putting single image on PyGame "liquid canvas" giving an eerie visual effect. Here is short code:
# PyGame liquid effect on single image
# just old PyGame example modified
# module...
Forum: Python Aug 25th, 2009
Replies: 2
Views: 226
Posted By bumsfeld
If you are familiar with C++, Java would be the way to go. Python is simply too uncomplicated.
Forum: Python Aug 25th, 2009
Replies: 2
Views: 251
Posted By bumsfeld
Since you are already used to C++ I would say use Java.
Forum: Python Aug 24th, 2009
Replies: 7
Views: 530
Posted By bumsfeld
Looks like Sneekula wasted his time on you then.
I assume you also know all about img.getdata(), then you can put it together with img.putpixel().
Showing results 1 to 40 of 564

 


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

©2003 - 2009 DaniWeb® LLC