Forum: Python 15 Days Ago |
| Replies: 2 Views: 207 Thanks for letting us know. I would have done it the same way too, since Frame has the convenient borderwidth arg. |
Forum: Python 20 Days Ago |
| Replies: 3 Views: 268 Maybe you should give your thread a more meaningful title. |
Forum: Python 20 Days Ago |
| Replies: 7 Views: 430 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 20 Days Ago |
| Replies: 5 Views: 307 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 21 Days Ago |
| Replies: 9 Views: 453 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 24 Days Ago |
| Replies: 10 Views: 554 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 Sep 29th, 2009 |
| Replies: 22 Views: 1,003 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: 672 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: 1,003 This is often referred to as the little-known "Microsoft kludge" |
Forum: Python Sep 29th, 2009 |
| Replies: 9 Views: 451 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: 1,003 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: 600 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 27th, 2009 |
| Replies: 6 Views: 240 |
Forum: Python Sep 27th, 2009 |
| Replies: 10 Views: 529 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: 529 You could take each labelobject an append it to a list. |
Forum: Python Sep 27th, 2009 |
| Replies: 7 Views: 844 Try something like:
lineA = fin.readline()[lpa].strip() |
Forum: Python Sep 27th, 2009 |
| Replies: 20 Views: 600 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: 235 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: 3,024 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: 10 Views: 529 Hint:
Looks to me like you are creating the same label over and over again. |
Forum: Python Sep 27th, 2009 |
| Replies: 45 Views: 3,024 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 26th, 2009 |
| Replies: 4 Views: 303 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: 303 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: 7 Views: 364 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: #... |
Forum: Python Sep 4th, 2009 |
| Replies: 11 Views: 684 Ouch! Thanks Lingson, I overlooked that range() does not return a list in Python3. So I give you the correct version here:
# exploring multiple Tkinter check buttons
# check buttons allow more... |
Forum: Python Sep 3rd, 2009 |
| Replies: 6 Views: 447 A nice brain teaser to get to know Python, here are some hints:
"""wants dictionary object -->
{'toy301': ('Flying Kite', [('AB339',2),('DC302',2),('FR377',2),... |
Forum: Python Sep 3rd, 2009 |
| Replies: 11 Views: 684 There is a working example of Tkinter's radio buttons and also a comparative look at check buttons at:
http://www.daniweb.com/forums/showpost.php?p=966368&postcount=58 |
Forum: Python Jul 13th, 2009 |
| Replies: 5 Views: 741 If you are specifically looking for the text line:
'you love me'
then sravan953 code works best.
leegeorg07 code using 'in' would also give you a positive with a line like:
'you love me not'... |
Forum: Python Jul 8th, 2009 |
| Replies: 4 Views: 296 Simply use list():
list1 = ['a', 'b', 'c', 'd']
# this will create a new list with a different mem ref
temp_list1 = list(list1)
for i in range(len(list1)):
temp_list1[i] = "1"
print list1; ... |
Forum: Python Jul 7th, 2009 |
| Replies: 7 Views: 498 Might as well go with:
...
background = "C:\\python26\\stuff\\bg.jpg"
background_surface = pygame.image.load(background)
...
Since that kind of directory name is meant for Windows only. |
Forum: Python Jul 7th, 2009 |
| Replies: 5 Views: 376 Where are your FileIn and FileOut strings? |
Forum: Python Jul 7th, 2009 |
| Replies: 6 Views: 382 You mean something like this:
# data string read from a file
data = """\
gnl|dbSNP|rs13484118 gi|62750812|ref|NC_005111.2|NC_005111 95 20 1 0 68 87 31017559 31017578 4.4 32.3
gnl|dbSNP|rs13484118... |
Forum: Python Jul 6th, 2009 |
| Replies: 2 Views: 536 One way to do this is to pad each word with spaces at the end to make the words equal in length (max length + 2):
s = """\
dasj dhsahdwe dhasdhajks ewqhehwq dsajkdhas
edward das dsaw das daswf... |
Forum: Python Jul 6th, 2009 |
| Replies: 3 Views: 451 What do you expect to happen with your test code?
If you test the module properly, it will work:
# create two separate windows with a button on it
# notice that the close button will close both... |
Forum: Python Jul 6th, 2009 |
| Replies: 3 Views: 451 Take the spaces out of "[code = python]" |
Forum: Python Jul 5th, 2009 |
| Replies: 4 Views: 386 @sravan953
also remember that in Python2 ' /' is an integer division by default.
For instance 12/15 gives you a zero. This has changed in Python3. |
Forum: Python Jun 23rd, 2009 |
| Replies: 6 Views: 340 Your problem is too simple to bother with regex:
mylist = ['adam', 'bill', 'jon/juan']
newlist = [item.replace('/', '') for item in mylist]
print(mylist) # ['adam', 'bill', 'jon/juan']... |
Forum: Python Jun 23rd, 2009 |
| Replies: 5 Views: 370 I you are on Windows and have several versions of Python installed, you can write a little batch file to make sure the IDLE of the correct version is runnig:
REM a batch file to force IDLE to use... |
Forum: Python Jun 23rd, 2009 |
| Replies: 6 Views: 354 Maybe something like this:
import random
low = 1
high = 9
mylist = [(random.randint(low, high), ) for k in range(10)]
print(mylist) |
Forum: Python Jun 13th, 2009 |
| Replies: 7 Views: 315 Here is an example:
http://www.daniweb.com/forums/showpost.php?p=890166&postcount=111 |