Forum: Python 30 Days Ago |
| Replies: 5 Views: 313 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 30 Days Ago |
| Replies: 5 Views: 313 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 30 Days Ago |
| Replies: 3 Views: 311 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 30 Days Ago |
| Replies: 3 Views: 282 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 Nov 13th, 2009 |
| Replies: 2 Views: 213 Try self.SetSizerAndFit(sizer) |
Forum: Python Nov 13th, 2009 |
| Replies: 5 Views: 348 Are you usng Python2 or Python3?
Are your positive numbers integers or floats? |
Forum: Python Nov 13th, 2009 |
| Replies: 4 Views: 211 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 Nov 13th, 2009 |
| Replies: 11 Views: 539 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: 7 Views: 294 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 19th, 2009 |
| Replies: 6 Views: 332 # 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 Views: 225 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: 22 Views: 185,231 Vary bad manners to hijack this thread for such question.
Start your own thread and give more info! |
Forum: Python Oct 11th, 2009 |
| Replies: 7 Views: 320 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 Views: 272 At least for some time, it would be very nice if people indicated which version of Python they are using. |
Forum: Python Aug 27th, 2009 |
| Replies: 6 Views: 478 Extension .pyd is used for C compiled library files for Python. |
Forum: Python Aug 22nd, 2009 |
| Replies: 3 Views: 308 I would say yes, unless your Operating System uses disk space as virtual memory. |
Forum: Python Aug 22nd, 2009 |
| Replies: 12 Views: 1,385 One rude awakening with Python3 will be the frequent use of bytearrays instead of strings. It does this to handle international unicode better.
Here is how you deal with this:
# get code of... |
Forum: Python Aug 22nd, 2009 |
| Replies: 4 Views: 942 Also the online book "dive into python" has been mostly
rewritten for Python3 (check appendix A for 2to3 diffs):
http://diveintopython3.org/ |
Forum: Python Aug 22nd, 2009 |
| Replies: 4 Views: 942 Swaroop C.H. has rewritten his excellent beginning Python tutorial for Python3:
http://www.swaroopch.com/notes/Python_en:Table_of_Contents |
Forum: Python Aug 13th, 2009 |
| Replies: 4 Views: 309 There is example at:
http://www.daniweb.com/forums/showpost.php?p=947978&postcount=46
that might work. |
Forum: Python Aug 5th, 2009 |
| Replies: 7 Views: 470 I like wxPython. However, if you use the newer Python 3.1, it could take long time for wxPython to be available. So now I am learning PyQT.
Again, Tkinter isn't bad to learn in the beginning,... |
Forum: Python Jul 30th, 2009 |
| Replies: 2 Views: 443 Function raw_input() would force the user to type in the entire XML code. I don't think you want this.
Normally the XML code would come from file, something like this:
fin = open("Myxml.xml",... |
Forum: Python Jul 30th, 2009 |
| Replies: 14 Views: 437 You got the right idea, but if you insist on recursion, you have to follow certain rules:
#s=raw_input("Enter a number to simplify: ")
s = '123456789' # for test
def loop(s, p=0):
for i in... |
Forum: Python Jul 29th, 2009 |
| Replies: 3 Views: 316 You can use 32x32 Windows .bmp file instead of .ico file. |
Forum: Python Jul 29th, 2009 |
| Replies: 14 Views: 437 Hint, in while loop turn the number string into list of individual digits and sum the list until the sum is less than 10, then break.
Careful here, you are using strings(characters) and integers. ... |
Forum: Python Jul 25th, 2009 |
| Replies: 3 Views: 360 I have Python2.5.4 and Python3.1 working on the same XP machine.
Programming editors (IDE) like IDLE may have to be convinced with batch file to use the correct Python version.
Here is example:... |
Forum: Python Jul 19th, 2009 |
| Replies: 4 Views: 405 Only potential problem with place() is, that it does not resize with window. |
Forum: Python Jul 19th, 2009 |
| Replies: 14 Views: 559 The Tkinter GUI toolkit has data input dialogs that will validate your input, as shown here:
# Python GUI toolkit Tkinter has three different data input dialogs:
# tkSimpleDialog.askstring(title,... |
Forum: Python Jul 19th, 2009 |
| Replies: 4 Views: 405 Yes, instead of using geometry manager pack() or grid(), use place(x, y) for layouts. Note that place(x, y) is absolute, and coordinates x or y can go negative to shift the widget out off the... |
Forum: Python Jul 19th, 2009 |
| Replies: 4 Views: 181 You can use this:
mylist = [
[1, 9, 22, 28, 0.69887889000000003, 0.98993399999999998, 2],
[4, 27, 6, 22, 0.81186093999999998, 1.1221458099999999, 2],
[4, 27, 100, 30, 0.74796748000000002,... |
Forum: Python Apr 18th, 2009 |
| Replies: 6 Views: 370 Pick your project and use C++ to write your code. There will be the time that is rather obvious when you want to switch to Python. |
Forum: Python Apr 13th, 2009 |
| Replies: 3 Views: 340 Python version 3.0 has modernized the language and much of the old code examples will not work. You can use a little utility program called 2to3.py to change old syntax to new syntax. |
Forum: Python Oct 17th, 2008 |
| Replies: 4 Views: 695 This perhaps shows how you can do this:
http://www.daniweb.com/forums/showpost.php?p=714874&postcount=100 |
Forum: Python Sep 22nd, 2008 |
| Replies: 6 Views: 780 There is usually info in the MS-HTML-Help file
wx.chm
if wxPython does not have one particular feature.
Also look at:
http://wiki.wxpython.org/index.cgi/FrontPage
This is the API ref, very... |
Forum: Python Sep 21st, 2008 |
| Replies: 14 Views: 1,770 As far as I understand, steganography would be to change each byte of image file just one small amount, so the picture essentially looks the same. Comparing it with the original picture would reveal... |
Forum: Python Sep 21st, 2008 |
| Replies: 4 Views: 483 Something like this will do:
for line in wordlistfile:
wordlist.append(line.strip()) |
Forum: Python Aug 26th, 2008 |
| Replies: 9 Views: 2,252 Simply use this:
# list all the modules Python currently knows about ...
help("modules") |
Forum: Python Aug 26th, 2008 |
| Replies: 2 Views: 582 At first blush i would say this might do:
# compare these two list set and convert
# w_b into [0.5, 0, 0.5, 0]
a = ['a', 'b', 'c', 'd']
w_a = [0.25, 0.25, 0.25, 0.25]
b = ['a', 'c']
w_b =... |
Forum: Python Aug 15th, 2008 |
| Replies: 10 Views: 1,121 Proof that [::-1] works for spelling string in reverse:
s1 = "racecar"
s2 = "kayak"
print s1, s1[::-1]
print s2, s2[::-1]
:) |
Forum: Python Aug 15th, 2008 |
| Replies: 6 Views: 613 Functions sort() and sorted() reside in the core of the Python interpreter which is written in C and compiled. On Windows the Python core is for instance in the dynamic link library called... |