Forum: Python 1 Day Ago |
| Replies: 2 Views: 216 Give your thread a meaningful title and more people will help. |
Forum: Python 1 Day Ago |
| Replies: 3 Views: 182 Maybe you should give your thread a more meaningful title. |
Forum: Python 1 Day Ago |
| Replies: 4 Views: 160 You need to tell us this sort of thing right away!
You could use find() assuming each line has one opening and one closing tag. Here is an example of string function find():
line = '<h1>hi my... |
Forum: Python 1 Day Ago |
| Replies: 6 Views: 214 This will give your program a certain eloquence:
# convert temperatures using Python2 or Python3
def f2c( fahrenheit ):
"""convert Fahrenheit to Celsius"""
return ( fahrenheit - 32 ) *... |
Forum: Python 1 Day Ago |
| Replies: 4 Views: 160 We just discussed that in detail, all you have to do is to slightly modify the solution:
# extract tag names in html code
try:
# Python2
import HTMLParser as hp
except ImportError:
... |
Forum: Python 2 Days Ago |
| Replies: 11 Views: 297 Sorry, I am using Python 3.1.1 and graphics.py does not work with Python3. |
Forum: Python 2 Days Ago |
| Replies: 6 Views: 200 Oh no, what is this? You are using tabs for your Python indentations, a very bad habit. Four spaces are the custom. If you use tabs, then sooner or later you will mix them with spaces and then you... |
Forum: Python 2 Days Ago |
| Replies: 6 Views: 200 Note that recursive functions have a lot of stack overhead and are slow. There is a limit to recursions:
print( sys.getrecursionlimit() ) # --> usually 1000 default setting
which can be changed... |
Forum: Python 2 Days Ago |
| Replies: 11 Views: 297 ... and what kind of GUI toolkit is this? |
Forum: Python 2 Days Ago |
| Replies: 5 Views: 182 Good show! So the question is, can you use your program to compute all the trig functions you wanted (sin, cos, tan, arcsin, etc.). |
Forum: Python 2 Days Ago |
| Replies: 18 Views: 334 I tried Netbeans and found it very awkward, especially for Python code. I have Windows and mostly use PyScripter. I can run code initially from memory and don't have to make a project out of it. |
Forum: Python 2 Days Ago |
| Replies: 9 Views: 206 Just a general example of functions and their parameters/arguments:
# example of passing parameters/arguments to and from functions
def get_data():
"""get the data from the user, from a... |
Forum: Python 2 Days Ago |
| Replies: 78 Views: 14,801 Just testing out some of the many PyQT GUI toolkit widgets:
# explore PyQT QLineEdit, QPushButton, QLabel, QMessageBox,
# QHBoxLayout, QWidget, QMainWindow
# tested with Python 3.1.1 and PyQT... |
Forum: Python 2 Days Ago |
| Replies: 18 Views: 334 The only one that comes to mind is the Wing IDE from:
http://wingide.com/wingide
There might be a trial version you can test drive. |
Forum: Python 5 Days Ago |
| Replies: 10 Views: 455 The first problem could be kind of easy:
n = 11
for odd_number in range(1, n+1, 2):
print( odd_number )
"""
1
3
5
7 |
Forum: Python 5 Days Ago |
| Replies: 1 Views: 300 Here is the code to sort a dictionary of dictionaries:
# sorted display of a dictionary of dictionaries
def dict_of_dict_sort(dd, key):
"""
print out selected items from a dictionary of... |
Forum: Python Sep 29th, 2009 |
| Replies: 22 Views: 947 Something only Microsoft could dream up. I understand that in the European version of Windows the space is avoided. The kludge itself is from a programmer within Microsoft. |
Forum: Python Sep 29th, 2009 |
| Replies: 6 Views: 585 A very simple way:
# create a string where the index gives the grade
grade_str = 'F'*60 + 'D'*10 + 'C'*10 + 'B'*10 + 'A'*11
# ask for grade number input
grade = int(raw_input("Enter the student's... |
Forum: Python Sep 29th, 2009 |
| Replies: 22 Views: 947 This is often referred to as the little-known "Microsoft kludge" |
Forum: Python Sep 29th, 2009 |
| Replies: 9 Views: 417 You can concatenate tuples, the trick is to wrote the one element tuple correctly:
users = ('user1','user2','user3')
# from input ...
new_user = 'user4'
# concatenate tuples, notice the way... |
Forum: Python Sep 29th, 2009 |
| Replies: 22 Views: 947 This problem has been around for a long time and not just with Python:
# the "Microsoft kludge", quoting a string within a string fixes the
# space-in-folder-name problem, tells the OS to use the... |
Forum: Python Sep 28th, 2009 |
| Replies: 20 Views: 575 That is because I made a test file from your posting and put it into the working directory, the same directory the code file is in.
Since you have the real thing you can replace
fname =... |
Forum: Python Sep 28th, 2009 |
| Replies: 5 Views: 293 Those modules are often written by instructors in colleges to keep their students from simply copying existing code, spreading confusion for the rest of us! There is a similar module out called... |
Forum: Python Sep 27th, 2009 |
| Replies: 6 Views: 226 |
Forum: Python Sep 27th, 2009 |
| Replies: 6 Views: 229 Did you use the .msi binary installer to install Python?
How are you trying to open python.exe?
Normally you find the IDE called Idle.pyw somewhere in the Python folders (like... |
Forum: Python Sep 27th, 2009 |
| Replies: 5 Views: 293 cTurtle.py has nothing to do with C. It is simply someones hack of the turtle.py with a few extra methods added. See the beginning of file cTurtle.py for details. You can also run it, as it has a... |
Forum: Python Sep 27th, 2009 |
| Replies: 10 Views: 508 Try something like this:
label = list(range(len(files)))
for k, fname in enumerate(files):
image = Image.open(filedir+"/"+fname)
##((width, height))
... |
Forum: Python Sep 27th, 2009 |
| Replies: 10 Views: 508 You could take each labelobject an append it to a list. |
Forum: Python Sep 27th, 2009 |
| Replies: 7 Views: 793 Try something like:
lineA = fin.readline()[lpa].strip() |
Forum: Python Sep 27th, 2009 |
| Replies: 20 Views: 575 See if something like this will do, but be careful that all the slicing doesn't steal some data:
def extract_number(data_str):
"""
extract the numeric value from a string
(the string... |
Forum: Python Sep 27th, 2009 |
| Replies: 3 Views: 226 Also in Python3 'pg_r' would be a byte string and module re will complain without converting 'pg_r' to a string first. |
Forum: Python Sep 27th, 2009 |
| Replies: 45 Views: 2,701 self.panel everywhere except the most important line 12
panel=wx.Panel(self,-1)
needs to be
self.panel=wx.Panel(self,-1) |
Forum: Python Sep 27th, 2009 |
| Replies: 3 Views: 412 Are you sure you posted in the right place? This is not the Mindreader Forum! |
Forum: Python Sep 27th, 2009 |
| Replies: 10 Views: 508 Hint:
Looks to me like you are creating the same label over and over again. |
Forum: Python Sep 27th, 2009 |
| Replies: 45 Views: 2,701 You don't need the id as a method parameter, but at least try to match the id in the lines above, 202 is not the same as 302.
self.panel will work if you use it throughout the class! Search for... |
Forum: Python Sep 27th, 2009 |
| Replies: 6 Views: 229 Pythons normally don't come with a handle, this must be a new breed. |
Forum: Python Sep 26th, 2009 |
| Replies: 4 Views: 270 In this case you have to set a flag like this:
import sys
# there is a commandline
if len(sys.argv) > 1:
mylist = []
# sys.argv[0] is the program filename, slice it off
flag =... |
Forum: Python Sep 26th, 2009 |
| Replies: 4 Views: 270 Give this a try:
import sys
# there is a commandline
if len(sys.argv) > 1:
mylist = []
# sys.argv[0] is the program filename, slice it off
for element in sys.argv[1:]:
... |
Forum: Python Sep 26th, 2009 |
| Replies: 78 Views: 14,801 There is another Python version called IronPython that uses Python syntax. It runs independent from the normal CPython version and allows access to the large GUI libraries of .NET and Mono. Here is... |
Forum: Python Sep 26th, 2009 |
| Replies: 7 Views: 338 You can trap error details this way:
import datetime as dt
def ObtainDate():
isValid=False
while not isValid:
userIn = raw_input("Type Date dd/mm/yy: ")
try: #... |