4,305 Posted Topics

Member Avatar for carpenoctem

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.

Member Avatar for vegaseat
0
313
Member Avatar for Archenemie

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, …

Member Avatar for vegaseat
0
294
Member Avatar for leegeorg07

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 …

Member Avatar for vegaseat
0
491
Member Avatar for joshua91

[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. …

Member Avatar for Hummdis
0
158
Member Avatar for LarZ

What happens if you put all your controls on a Panel and then destroy the Panel?

Member Avatar for Dixtosa
0
4K
Member Avatar for lllllIllIlllI

Well, thank you for the many contributions to the Python forum. Those were well done posts!

Member Avatar for bumsfeld
10
248
Member Avatar for python.noob

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!

Member Avatar for MikaelHalen
0
1K
Member Avatar for capson

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, …

Member Avatar for TrustyTony
0
122
Member Avatar for toll_booth

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 = …

Member Avatar for TrustyTony
0
268
Member Avatar for joegarside90

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, …

Member Avatar for vegaseat
0
412
Member Avatar for TrustyTony

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() …

Member Avatar for vegaseat
0
219
Member Avatar for jozz3

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 …

Member Avatar for vegaseat
0
823
Member Avatar for toll_booth

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 …

Member Avatar for vegaseat
0
176
Member Avatar for rasizzle

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.

Member Avatar for rasizzle
0
182
Member Avatar for vegaseat

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]

Member Avatar for TrustyTony
4
110
Member Avatar for ITgirl2010
Member Avatar for ITgirl2010
0
118
Member Avatar for lebron

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 …

Member Avatar for lebron
0
4K
Member Avatar for kur3k
Member Avatar for JordanWalcaraz

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.

Member Avatar for hondros
0
142
Member Avatar for dpswt

Not sure what you would gain from using buttons activating panels instead of notebook pages with tabs.

Member Avatar for dpswt
0
178
Member Avatar for mahela007

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.

Member Avatar for mahela007
0
359
Member Avatar for ultimatebuster

[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 …

Member Avatar for vegaseat
0
80
Member Avatar for SgtMe

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]

Member Avatar for SgtMe
0
82
Member Avatar for jonymanolo

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, …

Member Avatar for vegaseat
0
305
Member Avatar for SoulMazer

Could be one of the many rather childish security features of Vista. That's why nobody likes this OS.

Member Avatar for vegaseat
0
230
Member Avatar for jcao219

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.

Member Avatar for hondros
0
208
Member Avatar for Soren Werk

On Windows OS this behaves like double-clicking on the Python code file name ... [code] import os os.startfile("manage.py") [/code]

Member Avatar for TrustyTony
0
116
Member Avatar for gunbuster363
Member Avatar for zandiago

In some states marginal students are simply forced out to increase the test scores. What do we do with all those uncounted dropouts?

Member Avatar for diafol
2
382
Member Avatar for Stev0

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.

Member Avatar for Stev0
0
164
Member Avatar for Hoban

Code snippets are for fully functioning code only!!!! Ask questions in the regular Python forum!

Member Avatar for vegaseat
0
114
Member Avatar for OffbeatPatriot

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 …

Member Avatar for jwenting
1
212
Member Avatar for leviaeon
Member Avatar for JJBallanger
Member Avatar for JJBallanger
0
231
Member Avatar for alabay2010

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.

Member Avatar for TrustyTony
0
624
Member Avatar for ihatehippies

[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) ) …

Member Avatar for ihatehippies
0
76
Member Avatar for ultimatebuster

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'> …

Member Avatar for ultimatebuster
0
567
Member Avatar for mister-fett
Member Avatar for jpob

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

Member Avatar for jpob
0
262
Member Avatar for ithelp
Member Avatar for lmnopt

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.

Member Avatar for lmnopt
0
1K
Member Avatar for jjrrmm

Try [B]turtle._root.geometry('%dx%d' % (w, h))[/B] However: AttributeError: 'module' object has no attribute '_root'

Member Avatar for vegaseat
0
178
Member Avatar for kjock002

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: …

Member Avatar for vegaseat
0
185
Member Avatar for nichedge
Member Avatar for nichedge
0
598
Member Avatar for toll_booth

You might need to use self.update() or self.square.update() Would be nice to know what [B]self.square[/B] is.

Member Avatar for toll_booth
0
489
Member Avatar for snake03

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]

Member Avatar for ultimatebuster
0
282
Member Avatar for Felulah

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]

Member Avatar for Felulah
0
2K
Member Avatar for vegaseat

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.

Member Avatar for mitrmkar
2
232
Member Avatar for daemion
Member Avatar for kjock002

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 …

Member Avatar for The_Kernel
0
3K

The End.