4,305 Posted Topics
Re: Make your life easier by using the IDLE editor to write, save and run your programs from. IDLE usually comes with the Python installation or you can get it from the repository. | |
Re: Look through this modified code ... [code]#!/usr/local/bin/python # Authour - Rhys # Version - 1.00 import re, os, wx class RenamerMacro(wx.Frame): def __init__(self, parent, id): wx.Frame.__init__(self, parent, id, 'Renaming Macro', size=(300, 350)) panel = wx.Panel(self) self.exitbotton = wx.Button(panel, label="Close", pos=(210, 230),size=(50, 30)) self.exitbotton.Bind(wx.EVT_BUTTON, self.onClose) self.doit = wx.Button(panel, label="Do it", pos=(20, … | |
![]() | Re: Start experimenting with Python module decimal ... [code]# high accuracy calculations with Python module decimal # tested with Python 3.1.2 import decimal as dc # regular float calculation sqrt1 = 2 ** 0.5 print(type(sqrt1)) print(sqrt1) print(sqrt1 * sqrt1) # set decimal precition dc.getcontext().prec = 60 # using module decimal sqrt2 … |
Re: [QUOTE=Hummdis;1190066]This is my opinion of having a yes/no question with a default, but you should capitalize the default letter and leave the other lowercase. You also need to take into account that the raw_input() function will provide you with a line break as well (\n) and therefore should be striped. … | |
Re: What happens if you put all your controls on a Panel and then destroy the Panel? | |
Re: Well, thank you for the many contributions to the Python forum. Those were well done posts! | |
Re: 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! | |
Re: This does not make much sense. If you have ... [code]v1 = 3 v2 = 1 v3 = 7 v4 = 6 v5 = 5 mylist1 = [v1, v2, v3, v4, v5] print(mylist1) # [3, 1, 7, 6, 5] print(sorted(mylist1)) # [1, 3, 5, 6, 7] [/code]List [v1, v2, v3, … | |
Re: Make the changes indicated by #!!!!!!!!!!!!!! ... [code]'''Minesweeper.''' from Tkinter import * import Tkinter as tk import random BEGINNER = 1 INTERMEDIATE = 2 EXPERT = 3 OFFSET = 2 BUTTON_SIZE = 2 class Board(Frame, object): def __init__(self, master, difficulty, photo): #!!!!!!!!!!!!!! Frame.__init__(self, master) if difficulty == BEGINNER: self.x = … | |
Re: Just a little experiment, you can go from there ... [code]from graphics import * def diamonds(): win = GraphWin("Lines", 200, 200) #Line(Point(0, 0), Point(200, 200)).draw(win) # test x = 0 for y in range(0, 190, 20): x1 = x y1 = y x2 = 200 y2 = 200 print x1, … | |
Re: It has never made much sense to sort mixed type lists. So it's nice to see that Python3 put a stop to it ... [code]mixed_list = [3, 2, 'a', (5, 2,), 'd', 'c'] print(sorted(mixed_list)) """my result --> Python2 [2, 3, 'a', 'c', 'd', (5, 2)] Python3 TypeError: unorderable types: str() … | |
Re: In simple terms, to form the triangle you can draw 3 lines of the same length. To connect the lines, you turn the turtle by 360/3 = 120 degrees after each line has been drawn. Example ... [code]import turtle as tu tu.forward(200) tu.right(120) tu.forward(200) tu.right(120) tu.forward(200) tu.right(120) tu.done() [/code]You can … | |
Re: When you use ... [code]from PIL import Image im = Image.open("1.gif") im.show() [/code]The PIL function show() works this way: PIL will save a random_file.bmp in a temporary file and then use the image viewer associated with .bmp files to show the image. You may not have an image viewer associated … | |
Re: The idea of [B]portable python[/B] is to run it from the usb drive, but it will run a little slower. Try out the great IDEs that come with it, like pyscripter or SPE. | |
A little late for April 1, but here is the secret code ... [code]searchEngineNames = [] for c in range(ord('A'), ord('Z')+1): name = chr(c)+'ing' searchEngineNames.append(name) # pick #1 print(searchEngineNames[1]) [/code] | |
Re: Do you want to do several road trips and keep petrol price and economy the same? | |
Re: All you have to do is to take the line [B]cost = distance / 100 * litresPer100K * pricePerLitre[/B] and put it into a function like [B]def calculateCost(distance, litresPer100K, pricePerLitre):[/B] the function has to return cost Now in function main() replace the line [B]cost = distance / 100 * litresPer100K … | |
Re: Some folks are waiting for "3rd party modules" like PIL or the wxPython GUI toolkit to come out for Python3. :) These modules are not developed by the Python organization but other developers. | |
Re: Not sure what you would gain from using buttons activating panels instead of notebook pages with tabs. | |
Re: You can also use a dictionary with index tuple keys, as shown in this snippet: [url]http://www.daniweb.com/code/snippet275835.html#post1189150[/url] This makes look-up and changing very easy. | |
Re: [QUOTE=ultimatebuster;1190424][CODE] # What exactly is the difference between: class Test: pass # and class Test2(object): pass [/CODE][/QUOTE]If you use Python3 there is no difference other than the name of the class. That means class Test will automatically inherit objects. In Python2 you can use for instance __slots__ to restrict class … | |
Re: This works, but you will exceed the maximum recursion depth quickly ... [code]class Main: def add(self): print '1 + 2 = 3' self.add() main = Main() main.add() [/code] | |
Re: Here is a code example ... [code]# using the module ctypes you can access DLLs written in C/C++ # ctypes converts between Python types and C types # there are two ways to write DLLs: # most common uses cdecl, import with cdll # Win and VB may use stdcall, … | |
Re: Could be one of the many rather childish security features of Vista. That's why nobody likes this OS. | |
Re: Get used to Python3. Where the difference between Python2 and Python3 hits you hard, is in unicode applications and the fact that many functions expect and return byte strings rather than strings. | |
Re: On Windows OS this behaves like double-clicking on the Python code file name ... [code] import os os.startfile("manage.py") [/code] | |
Re: Python has module [B]profile[/B] | |
Re: In some states marginal students are simply forced out to increase the test scores. What do we do with all those uncounted dropouts? ![]() | |
Re: My guess is that [B]time.sleep(2)[/B] interferes with the event-loop of PyQT. You may have to use QTimer to accomplish your delay. | |
Re: Code snippets are for fully functioning code only!!!! Ask questions in the regular Python forum! | |
Re: Gee, I am so glad that you don't have anything more important to worry about. :) Well, Geico is part of Warren Buffet's empire. He has always known what to do. Stupid commercials on TV get the attention of the average TV watcher in the US. Actually, I am amazed … | |
Re: Try [B]print str(i) +"th SMS backed up"[/B] | |
Re: Sometimes adding a temporary test print will show you where the problem is. | |
Re: tonyjv, very nice code! Unfortunately somewhat wasted on a [B]do my homework for me[/B] character. Please stay in touch with this forum, your skills are much needed. | |
Re: [code]# check if an object is a class or a method of that class instance import inspect print( inspect.isclass(str) ) # True class test(str): def unique(self): pass x = test() # how to test for difference between # x.unique print( inspect.ismethod(x.unique) ) # True # and x.lower print( inspect.ismethod(x.lower) ) … | |
Re: Here is one way to check this ... [code]class C(): pass a = 77 print(type(a)) # <type 'int'> b = 'hello' print(type(b)) # <type 'str'> c = C() print(type(c)) # <type 'instance'> d = { 'one': 1, 'two': 2 } print(type(d)) # <type 'dict'> f= 3.14 print(type(f)) # <type 'float'> … | |
Re: Take a look at the approach taken in: [url]http://www.daniweb.com/forums/post1122938.html#post1122938[/url] The word [B]the[/B] will give you a real problem since it can translate to [B]der, die or das[/B] If you use lower case only: the cat --> die katze the dog --> der hund the house --> das haus | |
Re: Finding the ideal spot for a vacation means a lot of 'googling.' | |
Re: I would agree with SgtMe. Even though you are running Windows7-64bit, you are better of to install the 32bit versions of Python and PyQt at this time. | |
Re: Try [B]turtle._root.geometry('%dx%d' % (w, h))[/B] However: AttributeError: 'module' object has no attribute '_root' | |
Re: Modify your program to use if/else statements ... [code]# PURPOSE: to see if a user entered number (n) is prime or not prime # # INPUT(S): a number greater than 2. (n>2) # # OUTPUT(S): prime or not prime depending on what (n) is. # # EXAMPLES:input: ;output: # input: … | |
| |
Re: You might need to use self.update() or self.square.update() Would be nice to know what [B]self.square[/B] is. | |
Re: Here is an example how our friend [B]LaMouche[/B] coded a dungeon style RPG: [url]http://www.daniweb.com/forums/thread68013.html[/url] For MUD (Multi-User Dungeon) programming see: [url]http://en.wikipedia.org/wiki/MUD[/url] | |
Re: To extract the sentences of a text into a list, you have to establish some rules. A simple rule may be that all sentences end with one of these characters '.' or '?' or '!' Now you can extract the text's sentences, for a typical example see: [url]http://www.daniweb.com/forums/showthread.php?p=1175950#post1175950[/url] | |
Looking at the First In First Out (FIFO) data situation. Just like a line at the grocery store check-out. Its counterpart FILO would be like a stack of dinner plates. | |
Re: import os os.chdir(path) --> change directory to the one in path | |
Re: Just change your range(start, stop, step) parameters ... [code]n = 15 total = 0 # start at 1 in steps of 2 to get odd numbers for i in range(1, n + 1, 2): total += i print i, total # test """my result --> 1 1 3 4 5 … |
The End.