Forum: Python 3 Days Ago |
| Replies: 3 Views: 136 Our fellow Pythonian nezachem is correct.
You could also have used the usual
if __name__ == '__main__':
to test your module code ...
#!/usr/bin/python
# ChildScript.py
import tkSimpleDialog... |
Forum: Python 3 Days Ago |
| Replies: 8 Views: 241 Hint, another approach would be to use the function split() ...
text1 = "80,45,34"
if "," in text1:
# split at comma
mylist1 = text1.split(",")
print( mylist1 ) # ['80', '45', '34']... |
Forum: Python 3 Days Ago |
| Replies: 7 Views: 211 In code line
if stemming_word[-1] == leaf_words:
you are trying to compare a character with a tuple.
# this will form a tuple
leaf_words = "s","es","ed","er","ly","ing"
print( leaf_words ) ... |
Forum: Python 5 Days Ago |
| Replies: 14 Views: 427 Again, when you install Python on a Windows computer, Tkinter and Tk that install with it rely on the Windows GUI and not Xlib. |
Forum: Python 5 Days Ago |
| Replies: 2 Views: 125 str(i).split() will give you a list and you cannot use strip("'") on a list object. If your list contains strings, pick one item and then strip it. |
Forum: Python 6 Days Ago |
| Replies: 2 Views: 237 Hide the root window with:
root.withdraw()
Bring the root window back up with:
root.update()
root.deiconify()
Remove root window border and title bar with:
root.overrideredirect(True) |
Forum: Python 10 Days Ago |
| Replies: 3 Views: 190 Take a look at this recent thread:
http://www.daniweb.com/forums/thread241860.html
were we discussed functions and parameter passing. |
Forum: Python 10 Days Ago |
| Replies: 14 Views: 427 Tkinter is Python's wrapper of the GUI toolkit Tk, originally written in a computer language called TCL. Tkinter has the advantage of a small footprint, also IDLE, the IDE that ships with Python, is... |
Forum: Python 10 Days Ago |
| Replies: 14 Views: 427 Don't overlook the fact that the Python installer you use is specific for the Operating System. If you install Python on a Windows OS, the GUI toolkits will use the Windows GUI. A similar thing... |
Forum: Python 11 Days Ago |
| Replies: 9 Views: 395 You pass variables as need as function arguments and/or returns. |
Forum: Python 12 Days Ago |
| Replies: 3 Views: 323 Something like this ...
from Tkinter import *
def exit():
# do cleanup code here
pass
root = Tk()
# respond to window title bar x click |
Forum: Python 12 Days Ago |
| Replies: 9 Views: 395 Here is a rather simple example of a number of functions working together from:
http://www.daniweb.com/forums/post104853.html#post104853
def get_name():
"""this function only returns... |
Forum: Python 12 Days Ago |
| Replies: 7 Views: 383 The function main() can be simplified ...
def main():
while True:
fahrenheit2celsius()
cont = raw_input('Continue converting? (yes/no): ')
if 'n' in cont.lower():
... |
Forum: Python 13 Days Ago |
| Replies: 5 Views: 266 To approximate for instance the sine of x (x in radians) you can use the Taylor series expansion:
x - x**3/3! + x**5/5! - x**7/7! + ...
However, to get even a remotely accurate number the cutoff... |
Forum: Python 14 Days Ago |
| Replies: 5 Views: 240 Ouch!!!!!!!
A couple of hints ...
you still have to start with one function call from main
you need to pass your arguments to and from your functions
variable, function and class names are... |
Forum: Python 14 Days Ago |
| Replies: 15 Views: 479 For old stuff like that I recommend a careful study of the source of graphics.py you can get it from:
http://mcsp.wartburg.edu/zelle/python/graphics.py
Also study the elaborate documentation from:... |
Forum: Python 15 Days Ago |
| Replies: 7 Views: 334 Python relies on indentations for it's code blocks. Other computer languages use braces, begin, end and so on. So yes, if you want to code in Python, then poorly done indentations can be a real... |
Forum: Python 15 Days Ago |
| Replies: 9 Views: 450 To my knowledge the latest release version of PyQT is 4.6, so I doubt that any IDE will work on code completion for your super advanced version (4.9 ?). |
Forum: Python 16 Days Ago |
| Replies: 10 Views: 358 According to your code fname is just the filename and b is the full pathname. Still, it will work with os.rename(fname, b).
My question was, what happens if someone enters a directory like this:... |
Forum: Python 16 Days Ago |
| Replies: 9 Views: 450 I tried the latest version of Eric (4.3.9). It assiste with PyQT syntax, but does not accept the newer connect style used with PyQT 4.5+. Somewhat irritating! |
Forum: Python 16 Days Ago |
| Replies: 10 Views: 358 I modified the program slightly for testing, but this work just fine ...
#!/usr/local/bin/python
import re, os
from os.path import join as pjoin, isdir
while True:
#targetfolder =... |
Forum: Python 17 Days Ago |
| Replies: 2 Views: 218 __str__() does operator overloading in a class and "hijacks" str() in any class instance operation that uses str(). So print crit1 will use it, because it uses str() to make it printable. Whereas... |
Forum: Python 17 Days Ago |
| Replies: 3 Views: 263 You are using old style Python code! Long ago it used to be like this ...
import string
a = "Why does string.split() not work?"
x = string.split(a)
print("SUCCESS!", x)
... now it's like this... |
Forum: Python 17 Days Ago |
| Replies: 10 Views: 391 You can use function exec() ...
# create variables num1, num2, num3 and num4 and set to 77
for n in range(1, 4):
exec( "%s = %d" % ('num' + str(n), 77) )
print(num1) # 77
print(num3) #... |
Forum: Python 17 Days Ago |
| Replies: 1 Views: 413 Take a look at the example at:
http://www.daniweb.com/forums/post1056184.html#post1056184 |
Forum: Python 18 Days Ago |
| Replies: 9 Views: 380 Will be less complex with a for loop and range(start, end, step) starting at the high value, ending at the low value (exclusive) and stepping -1 ...
n = 3
for x in range(n, 0, -1):
print... |
Forum: Python 18 Days Ago |
| Replies: 10 Views: 526 I assume the question is:
Who is foolish enough to do my homework for me? |
Forum: Python 18 Days Ago |
| Replies: 3 Views: 239 Also take a look at:
http://www.daniweb.com/forums/post1055261.html#post1055261
for a mildly more general version. |
Forum: Python 18 Days Ago |
| Replies: 10 Views: 385 You have to put your increase calculation in the loop. |
Forum: Python 19 Days Ago |
| Replies: 6 Views: 308 No need to be sorry, that kind of thing happens easily on any forum. |
Forum: Python 19 Days Ago |
| Replies: 6 Views: 308 When you use a.extend(b) or a.sort() then list a is changed, since both are inplace functions. Also when you pass a list to a function argument, be aware that the list is a mutable object and... |
Forum: Python 21 Days Ago |
| Replies: 3 Views: 284 If you make the regular polygon a square with side length = 1.0, you should get an area of 1.0. A simple test to see if the area formula is correct. |
Forum: Python 21 Days Ago |
| Replies: 4 Views: 253 You can play with this ...
# test Python command line arguments
import sys
if (len(sys.argv) >= 2):
# skip sys.argv[0]
commandline_args = sys.argv[1:]
print( commandline_args ) |
Forum: Python 21 Days Ago |
| Replies: 3 Views: 536 If you have a dictionary in your program and want to save and later reload it as a dictionary object, you have to use module pickle. Here is an example ...
# use module pickle to save/dump and load... |
Forum: Python 22 Days Ago |
| Replies: 5 Views: 291 A dictionary will serve you better ...
# create a large number of spheres referencing them
# with a (x, y):sphere_object dictionary pair
import visual as vs
spheres = {}
for x in range (0,... |
Forum: Python 23 Days Ago |
| Replies: 8 Views: 348 I assume your error is here ...
def print_list(names):
print 'Here are the names in the original order:'
for names in name_list: # <--------
print names
names.sort()
... |
Forum: Python 23 Days Ago |
| Replies: 9 Views: 318 Python3 will tolerate adding (object) to your class for a while at least.
After that just write a little Python utility that removes it. |
Forum: Python 23 Days Ago |
| Replies: 4 Views: 240 Here is the story:
In Python2 Tkinter is a Python module file named Tkinter.py a wrapper for the TCL code Tkinter is written in.
With the advent of Python3 Tkinter became a more modern package... |
Forum: Python 23 Days Ago |
| Replies: 6 Views: 321 If you want to start with the population after 1/2 year, then every year you have to change your code to this (Python2 or Python3) ...
def populationGrowth():
x = int(input("What is the current... |
Forum: Python 23 Days Ago |
| Replies: 5 Views: 274 In this case you have to create a new parent frame (size it for the image) for wx.StaticBitmap(frame, wx.ID_ANY, image)
Would be nice if I could test it out, but I simply don't have all the... |