Forum: Python 6 Hours Ago |
| Replies: 5 Views: 133 def status():
print "\nThe total number of critters is", Critter.total
status = staticmethod(status)
This allows class function status() to be called with the class name... |
Forum: Python 7 Hours Ago |
| Replies: 9 Views: 194 You pass variables as need as function arguments and/or returns. |
Forum: Python 7 Hours Ago |
| Replies: 3 Views: 110 If you have Windows you can use this ...
# get disk information on Windows
# using the win32 extension module from:
# http://sourceforge.net/projects/pywin32/files/
# tested on Windows XP with... |
Forum: Python 8 Hours Ago |
| Replies: 3 Views: 215 And another page ...
http://en.wikibooks.org/wiki/Python_Programming/Email |
Forum: Python 1 Day Ago |
| Replies: 3 Views: 157 Something like this ...
from Tkinter import *
def exit():
# do cleanup code here
pass
root = Tk()
# respond to window title bar x click |
Forum: Python 1 Day Ago |
| Replies: 9 Views: 194 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 1 Day Ago |
| Replies: 6 Views: 197 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 2 Days Ago |
| Replies: 5 Views: 171 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 2 Days Ago |
| Replies: 5 Views: 158 i was under the mistaken impression that you had to use functions |
Forum: Python 2 Days Ago |
| Replies: 2 Views: 113 use temp = self.set_greyLevel(grayScale) |
Forum: Python 3 Days Ago |
| Replies: 5 Views: 158 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 3 Days Ago |
| Replies: 195 Views: 86,289 Here is an example of how you can create a C type switch/case construct using a Python dictionary ...
# a simple reverse polish notation calculator
def do_operation(a, b, op):
"""
here... |
Forum: Python 3 Days Ago |
| Replies: 2 Views: 209 I think there are a number of so called Reverse Polish Notation calculator examples on this forum. |
Forum: Python 3 Days Ago |
| Replies: 1 Views: 220 You can write a small Python utility program to do that for you! |
Forum: Python 3 Days Ago |
| Replies: 13 Views: 297 I tend to agree with Gribouillis. As your program grows you can split out some classes in a linear fashion. Later on, as the bugs are worked out, turn them into modules |
Forum: Python 3 Days Ago |
| Replies: 15 Views: 357 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 4 Days Ago |
| Replies: 6 Views: 230 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 4 Days Ago |
| Replies: 6 Views: 37,943 after pylab.show() I don't get the >>> in IDLE!
The program stalls on that last pylab.show() statement.
For heaven sake don't run the code from the Python shell!
Run it from the editor!
The... |
Forum: Python 4 Days Ago |
| Replies: 4 Views: 204 You really don't need a queue, a list will do fine. Here is a more simple version of Gribouillis' code that actually works in Python2 or Python3 ...
# extract tag names in an html code file
#... |
Forum: Python 4 Days Ago |
| Replies: 9 Views: 310 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 4 Days Ago |
| Replies: 4 Views: 169 Can you tell us in detail what you understand under advanced code completion?
Note (so you don't waste your time): bpython uses Linux's curses and does not work with Windows. |
Forum: Python 5 Days Ago |
| Replies: 10 Views: 283 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 5 Days Ago |
| Replies: 9 Views: 310 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 5 Days Ago |
| Replies: 10 Views: 283 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 6 Days Ago |
| Replies: 11 Views: 360 @masterofpuppets:
I like the overall tutorial, so simply make your corrections and post it here. Mark it clearly as (first line):
CORRECTED TUTORIAL
I will replace the first version for you.... |
Forum: Python 6 Days Ago |
| Replies: 11 Views: 360 Also note ...
eng2sp = { "one":"uno", "two":"dos", "three":"tres" }
# works in Python2, but not Python3
# Python3 gives error ...
# AttributeError: 'dict' object has no attribute 'has_key'... |
Forum: Python 6 Days Ago |
| Replies: 3 Views: 168 Good! Just a note, Python3 no longer allows the old style coding! |
Forum: Python 6 Days Ago |
| Replies: 2 Views: 151 __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 6 Days Ago |
| Replies: 3 Views: 168 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 6 Days Ago |
| Replies: 11 Views: 360 I truly frown on folks using Python Shell code for tutorials, it looks ugly, messy, confusing to beginners, and not Pythonic at all! Python prides itself on readable syntax.
Thanks for the update... |
Forum: Python 6 Days Ago |
| Replies: 10 Views: 327 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 6 Days Ago |
| Replies: 1 Views: 318 Take a look at the example at:
http://www.daniweb.com/forums/post1056184.html#post1056184 |
Forum: Python 6 Days Ago |
| Replies: 127 Views: 46,903 This simple wxPython slide show uses the wx.PaintDC surface as a canvas that can be cleared between pictures ...
# create a simple image slide show using the
# wx.PaintDC surface as a canvas and
#... |
Forum: Python 7 Days Ago |
| Replies: 78 Views: 14,757 Tkinter can be used to write programs that use pop-up dialogs for input and output. The nice thing is that the input dialogs can restrict data input to integer, float or string input with options... |
Forum: Python 7 Days Ago |
| Replies: 9 Views: 306 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 7 Days Ago |
| Replies: 10 Views: 445 I assume the question is:
Who is foolish enough to do my homework for me? |
Forum: Python 7 Days Ago |
| Replies: 3 Views: 173 Also take a look at:
http://www.daniweb.com/forums/post1055261.html#post1055261
for a mildly more general version. |
Forum: Python 7 Days Ago |
| Replies: 78 Views: 14,757 A simple way to add color highlighted text to the Tkinter Text() widget ...
# multiple color text with Tkinter using widget Text() and tags
# vegaseat
try:
# Python2
import Tkinter as... |
Forum: Python 7 Days Ago |
| Replies: 10 Views: 339 You have to put your increase calculation in the loop. |
Forum: Python 8 Days Ago |
| Replies: 2 Views: 167 What does the trace-back look like? |