Forum: Python 18 Days Ago |
| Replies: 12 Views: 536 import os
# works on windows nt (also xp and vista) or linux
os.system(['clear','cls'][os.name == 'nt'])
If [os.name == 'nt'] is True then this becomes effectively 1. So it picks item at index 1... |
Forum: Python 18 Days Ago |
| Replies: 9 Views: 269 Read vegaseat's comment:
You need to move all those lines to the right by 4 spaces. |
Forum: Python 18 Days Ago |
| Replies: 3 Views: 287 You may not want to add letters to the list that have zero count. |
Forum: Python 18 Days Ago |
| Replies: 7 Views: 229 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 18 Days Ago |
| Replies: 3 Views: 518 If you are curious, also check this out:
http://www.daniweb.com/code/snippet216539.html |
Forum: Python 18 Days Ago |
| Replies: 9 Views: 269 Did you download the code or retype it manually yourself?
There are some errors due to indentations and typos.
The return outside function error is really indentation error! |
Forum: Python 18 Days Ago |
| Replies: 4 Views: 3,036 Seems to me that you also have to consider the time that re.compile() needs. |
Forum: Python 19 Days Ago |
| Replies: 5 Views: 269 Some corrections:
num = 0
mylist = []
while num < 10:
num = num + 1
mylist.append(num)
print(mylist) |
Forum: Python 19 Days Ago |
| Replies: 4 Views: 198 Asking questions is never stupid! :) |
Forum: Python 19 Days Ago |
| Replies: 3 Views: 165 This will also trap number exceeding the index:
import string
def numtolet(num):
if num > 25: return
return string.ascii_uppercase[num]
print( numtolet(0) ) # A
print( numtolet(5)... |
Forum: Python 20 Days Ago |
| Replies: 6 Views: 260 # 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 20 Days Ago |
| Replies: 8 Views: 198 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: Geeks' Lounge 26 Days Ago |
| Replies: 1,361 Views: 143,093 Can Halloween be far away?
I like apple dumplings and fritters! Apple cider only if it's hard cider. |
Forum: Python 26 Days Ago |
| Replies: 5 Views: 366 As performance is concerned, the file read from disk will be the slowest part by far! |
Forum: Python 26 Days Ago |
| Replies: 5 Views: 6,544 Do you mean highest frequency first?
Simply add this to the end of the code:
print '-'*30
print "sorted by highest frequency first:"
# create list of (val, key) tuple pairs
freq_list2 =... |
Forum: Python 26 Days Ago |
| Replies: 3 Views: 324 You are close:
fname = raw_input("enter a text file name: ")
fread = open(fname, "r")
# read the whole file into one string
text = fread.read()
fread.close()
# split the whole text string... |
Forum: Python 26 Days Ago |
| Replies: 22 Views: 173,984 Vary bad manners to hijack this thread for such question.
Start your own thread and give more info! |
Forum: Python 26 Days Ago |
| Replies: 5 Views: 966 You are in the wrong forum. Many of us went away from low level C to high level Python to solve such problems easily. |
Forum: Python 26 Days Ago |
| Replies: 5 Views: 1,561 However, pyHook and pythoncom work only on Windows systems. Not too bad, since most computers in this world are using Windows. Tkinter is more cross-platform for the few odd folks that user other... |
Forum: Python 27 Days Ago |
| Replies: 7 Views: 259 Similar to jice's code:
# simply ignore index zero
pos = [' '] * 11
print( pos )
POS = 1
pos[POS] = '->'
print( pos ) |
Forum: Geeks' Lounge 27 Days Ago |
| Replies: 1,361 Views: 143,093 Toasted plain bagel with lots of butter and fresh cup of black tea. |
Forum: Geeks' Lounge 27 Days Ago |
| Replies: 58 Views: 2,946 I think this is correct, because as my father explained to me, in those days C compilers had the inline assembly language option. This allowed access to the very low levels of the computer chips. |
Forum: C 33 Days Ago |
| Replies: 5 Views: 238 What are you going to do to the user after 3 tries? |
Forum: Python 33 Days Ago |
| Replies: 6 Views: 233 At least for some time, it would be very nice if people indicated which version of Python they are using. |
Forum: Python 33 Days Ago |
| Replies: 13 Views: 449 If this is truly your text file, I feel sorry for you! |
Forum: Python 33 Days Ago |
| Replies: 4 Views: 304 I think you need to develop mask of your image to make this work. |
Forum: Python Aug 27th, 2009 |
| Replies: 6 Views: 425 Extension .pyd is used for C compiled library files for Python. |
Forum: Python Aug 26th, 2009 |
| Replies: 5 Views: 343 What is more efficient?
1) import math
2) from math import *
3) from math import sin, cos |
Forum: Python Aug 25th, 2009 |
| Replies: 74 Views: 12,087 It's like putting single image on PyGame "liquid canvas" giving an eerie visual effect. Here is short code:
# PyGame liquid effect on single image
# just old PyGame example modified
# module... |
Forum: Python Aug 25th, 2009 |
| Replies: 2 Views: 213 If you are familiar with C++, Java would be the way to go. Python is simply too uncomplicated. |
Forum: Python Aug 25th, 2009 |
| Replies: 2 Views: 241 Since you are already used to C++ I would say use Java. |
Forum: Python Aug 24th, 2009 |
| Replies: 7 Views: 499 Looks like Sneekula wasted his time on you then.
I assume you also know all about img.getdata(), then you can put it together with img.putpixel(). |
Forum: Python Aug 24th, 2009 |
| Replies: 3 Views: 361 niek_e is correct, successful compression depends on the source and the compression algorithm. Here is one example of large repeating text that the zip algorithm fails with, but bz2 compression... |
Forum: Python Aug 22nd, 2009 |
| Replies: 3 Views: 289 I would say yes, unless your Operating System uses disk space as virtual memory. |
Forum: Python Aug 22nd, 2009 |
| Replies: 12 Views: 1,029 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: 612 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: 612 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: 297 There is example at:
http://www.daniweb.com/forums/showpost.php?p=947978&postcount=46
that might work. |
Forum: Python Aug 13th, 2009 |
| Replies: 74 Views: 12,087 Retrieve the text from Tkinter Text widget line by line:
# explore the Tkinter Text() widget
# getting text 'line by line' from the widget
# use ctrl+c to copy, ctrl+x to cut selected text,
#... |
Forum: Python Aug 13th, 2009 |
| Replies: 74 Views: 12,087 In the previous example I meant 'Tkinter' rather than 'Tinter'. This however is PyQT example looking at the tooltip widget and some colored text:
# pqt_tooltip1.py
# exploring PyQT's tooltip and... |