904 Posted Topics
Re: Steve Ballmer is stepping down because he is running MS into the ground with a lot of me-too ware and a management style of forced ranking. He most likely was not aware of the spy portion of Windows8. | |
Re: Children should be told to be in a sport rather than watch it. It takes a couch potato to raise a couch spud. | |
Re: I use Microsoft's SkyDrive and they give you 7GB free. Works well with the MS file manager. | |
Re: Here is a hint: sum3 = 0 for n in range(0, 1000, 3): #print(n) # test sum3 += n print(sum3) | |
Re: pythondevguy do this: import random x = random.randint(1, 100) print(x) x = random.randint(1, 100) print(x) | |
Re: I would use the length of string. Works well in most languages. | |
Re: Let's not forget that WxPython is just the wrapper for WxWindows which is written in C++. The wrapper seems to ignore the C++ error handling. It could have been done, but wasn't. I don't think there is any GUI toolkit that is written in pure Python, bummer. On the other … | |
Re: Quick looky shows an indentation problem. | |
Re: Give us some code! | |
![]() | Re: I use this little batch file to force IDLE to work with Python 3.1.1 [code=text]REM batch file to force IDLE to run with Python 3.1 REM save as IDLE31.bat C:\Python31\Pythonw.exe -u C:\Python31\Lib\idlelib\idle.pyw [/code] For discussion on 32bit versus 64bit see: [url]http://www.daniweb.com/forums/thread267106.html[/url] |
In my journey to find a new programing language to learn, I found Nimrod. According to the spiel on its web page: "Nimrod combines Lisp's power with Python's readability and C's performance." Just curious to know if anbody here has used it? Nimrod's home is at: http://nimrod-code.org/ | |
Re: Your example answer is wrong. | |
Re: Here is one example: import pprint as pp mydic = { 'a123': [1, 2, 2, 4], 'a124': [1, 2, 3, 4], 'a125': [1, 2, 2, 4], 'a126': [1, 2, 4, 5] } newdic = {} val_list = [] for key, val in mydic.items(): if val not in val_list: newdic[key] = … | |
Re: Or reverse your vector: import math p1 = (0.0, 0.0) p2 = (1.0, 1.0) # use vector from p2 to p1 dx = p2[0] - p1[0] dy = p2[1] - p1[1] angle = math.atan2(dy, dx) angle = math.degrees(angle) print(angle) # 45.0 | |
Re: You could potentially us a label as a spacer: try: # Python2 import Tkinter as tk except ImportError: # Python3 import tkinter as tk root = tk.Tk() root['bg'] = 'yellow' # use label as spacer, match background color spacer = tk.Label(root, width=20, bg='yellow') spacer.grid(row=1, column=1) button = tk.Button(root, text="Button1") # … | |
Re: The other question is, does your hex string convert back to decimal? a = 255 hx = hex(a) print(hx) print(int(hx, 16)) hx = hex(a)[2:] print(hx) print(int(hx, 16)) ''' output --> 0xff 255 ff 255 ''' | |
Re: If you execute python.exe, it comes up with the black console window. If you execute pythonw.exe, nothing will show. It is used for GUI programs where the black console window would interfere. Actually, if you use one of the many IDE (like IDLE), to run your code, then you don't … | |
Re: cx_Freeze works with both versions of Python http://www.blog.pythonlibrary.org/2010/08/12/a-cx_freeze-tutorial-build-a-binary-series/ | |
| |
Re: Age is an issue of mind over matter. If you don't mind, it doesn't matter. (MT) | |
Re: The Tkinter GUI toolkit's equivalent to raw_input() is the Entry widget. Here is an example: # simple Tkinter code # using two labels, an entry and a button # make tk the name space regardless of Python version try: # Python2 import Tkinter as tk except ImportError: # Python3 import … | |
Re: Since you are not passing any args, this will do: `self.bd4 = Tkinter.Button(self.frame, text="D4", command=self.roll_dice)` also self.sticky_all = 'ewns' | |
| |
Re: The reason your instructor is using cs1graphics module is so that outside people can not help you as easily as with common Tkinter GUI toolkit. Most likely your module is limited wrapper of Tkinter. A number of these Tkinter wrappers have appeared over the years, usually from folks that want … | |
Re: Line 11 may give you error if you use Python3, change to: print(item) | |
I was trying to come up with a dictionary of functions, but get it not to work. | |
Re: A somewhat updated version: ''' pyttsx_speech_test102.py speaks the present time in English, for instance "Sat Apr 27 15:10:59" as "Saturday April 27th 15 hours 10 minutes and 59 seconds" download pyttsx-1.1.tar.gz from https://pypi.python.org/pypi/pyttsx also needs setuptools-0.6c11.win32-py2.7.exe from https://pypi.python.org/pypi/setuptools#files install setuptools first then unpack the tar file and run (using Python27) … | |
Re: Do what Microsoft does, create a new and improved version. | |
Re: If you ever have to maintain somebody else's program code, then goto's are one horror. | |
Re: Unfortunately the two bombers were Muslims, so there will be quite a bit of hatred going around. | |
Re: Luckily Henri and Henry are pronounced the same in America. | |
Re: I don't smoke, but you smokers please keep smoking so my Altria stock can pay the good dividend it does. | |
Re: In Python3 you can specify the end of the print funtion: `print("hello", end='\n') # end='\n' is the default` Similar to C++ cout << "hello" << endl; | |
Re: Try the Python dictionary with name:[age, weight, sex, ... ] pairs. | |
Re: Another approach: ''' re_search_replace1.py replace second 'bad' with 'good' ''' import re s = 'bad1234567bad12345678bad123456789' print(s) # test m = re.search('bad', s) # apply slicing s1 = s[:m.end()] s2 = s[m.end():] print(s1) # test print(s2) # test s3 = s2.replace('bad', 'good', 1) print(s3) # test print(s1+s3) ''' bad1234567bad12345678bad123456789 bad 1234567bad12345678bad123456789 … | |
Re: Check the preample of: [url]http://wiki.python.org/moin/BitwiseOperators[/url] | |
Re: Also be aware that in Python2 you might get an integer division unless you force a float: def average(q): ''' cast a float for Python2 ''' return float(sum(q))/len(q) q = [1, 2, 3, 4] avg = average(q) print(avg) # 2.5 | |
Re: You can do it this way: class starfighter(): strength = 20 pilot = 55 intelli = 40 stamina = 35 print(starfighter.strength) # 20 print(starfighter.intelli) # 40 | |
Re: Python packs a lot of power, take a close look at this: from string import punctuation from collections import Counter data = """\ I love the python programming How love the python programming? We love the python programming Do you like python for kids? I like Hello World Computer Programming … | |
Re: entropic310500 you need to show us some of your code! | |
Re: You also have to do your indentations properly: class Rectangle(object): def __init__(self, x, y): self.x = x self.y = y def area(self): return self.x*self.y def perimeter(self): return self.x*2 + self.y*2 def main(): print("Rectangle a:") a = Rectangle(5, 7) print("area: %d" % a.area()) print("perimeter: %d" % a.perimeter()) ''' print("") print("Rectangle b:") … | |
Re: Sounds like a fun project. My advice, do not hijack **old** solved threads, but start your own new thread, it's more polite and people are more willing to help. Give your new thread a meaningful title like "Making a stick figure class". Give us a hint what OS and Python … | |
Re: I assume you are going to use the Python Image Library (PIL). Look at their documentation. | |
Re: I like high tech gadgets, so I must be one geek. Even though some are nerdy gadgets too. | |
Re: Here is one well commented example: ''' data4_expand.py data4.csv looks like that: date,time,v1,v2 03/13/2013,11.23.10,12.3,3.4 03/13/2013,11.23.13,12.7,5.1 03/13/2013,11.23.16,15.1,8.3 03/13/2013,11.23.19,17.8,9.8 03/13/2013,11.23.22,19.6,11.4 03/13/2013,11.23.25,21.3,14.6 03/13/2013,11.23.28,24.2,18.3 ''' # read the csv file and process with open("data4.csv") as fin: data_list = [] for ix, line in enumerate(fin): # strip off trailing new line char line = line.rstrip() … |
The End.