3,386 Posted Topics

Member Avatar for vegaseat
Member Avatar for aernie
1
2K
Member Avatar for gangster88

Something strange in your code. It would only input one string and not using the value. Figure out where it should be used, pass the value to function in the parameters.

Member Avatar for gangster88
0
183
Member Avatar for capson

You misindented blocks. If and else same indent, the code blocks one indent also same line. The prompt does not count. In interactive mode: [CODE]>>> VList=[0,0,1,0,1,1,0,0] >>> if VList.count(1) < 5: print('Yes') else: print('No') Yes [/CODE]

Member Avatar for capson
0
96
Member Avatar for Simes

You have not function definations in second version, you have else instead of elif in some conditions and you have not taken out the self parameters.

Member Avatar for TrustyTony
0
281
Member Avatar for lewashby

Button is placed in the app window directly. Generally it makes sense to prepare one frame first and put Button in that frame.

Member Avatar for TrustyTony
0
73
Member Avatar for TrustyTony

As I told before here is second implementation of one word anagrams, which prepares lookup table for all available words, if it is not generated and afterwards uses it for fast lookup. The implementation of lookup table generation is quite unoptimized, but it is only done once per vocabulary. If …

Member Avatar for TrustyTony
0
810
Member Avatar for lllllIllIlllI

Formatted solution as: [CODE]# show mouse position as mouse is moved and create a hot spot # based on http://www.daniweb.com/forums/post616327.html#post616327 by ZZucker import Tkinter as tk def showxy(event): xm, ym = event.x, event.y str1 = "mouse at x=%d y=%d" % (xm, ym) # show cordinates in title root.title(str1) # switch …

Member Avatar for TrustyTony
0
2K
Member Avatar for frogy

[url]http://bonsai.ims.u-tokyo.ac.jp/~mdehoon/software/cluster/software.htm[/url] says: [QUOTE]Python users can access the clustering routines by using Pycluster, which is an extension module to Python.[/QUOTE]

Member Avatar for TrustyTony
0
55
Member Avatar for frankinaround

What is template file ps9.py? I think the set should contain Triangle, Square etc objects, values of those come from the implementation of those classes. If two of the shapes are not ever same as mentioned in description, it enables you to use regular set. So for me this looks …

Member Avatar for TrustyTony
0
263
Member Avatar for muthulazmi

[QUOTE=muthulazmi;1259630]import MySQLdb db = MySQLdb.connect(host = "localhost",user = "root",passwd = " ",db = "TESTDB" ) cursor = db.cursor() sql = """CREATE TABLE CRAWLER ( FIRST_NAME CHAR(20) NOT NULL, LAST_NAME CHAR(20), AGE INT, SEX CHAR(1), INCOME FLOAT )""" cursor.execute(sql) db.close() when i execute this code there is an error occure like …

Member Avatar for muthulazmi
0
91
Member Avatar for sravan953

Why such a complicated way for simple calculation (directly 2**power). If you multiply by two, you get each concecutive power of two. I do not know why you say huge either, as numbers you give are quite small. Here is my code (with alternative in commented form) for smallest powers …

Member Avatar for TrustyTony
0
198
Member Avatar for tiddster

Here is example code: [CODE]from time import clock,sleep duration=5 time_to_change=clock()+duration while True: if clock()<time_to_change: print('Action 1') else: print('Something else') sleep(0.1) [/CODE]

Member Avatar for TrustyTony
0
63
Member Avatar for mahesham

Please check older threads before posting: [url]http://www.daniweb.com/forums/thread204301.html[/url]

Member Avatar for mahesham
0
94
Member Avatar for echellwig

It is very difficult or error prone to do assignment to list elements so often I prefer to use dicts. [CODE] # elements of list are mutable and can be variable reference, not values L='10' allthelists = [[] for x in range(int(L))] #... j=5 newitem=['abc'] allthelists[j]=newitem ## wrong, or more …

Member Avatar for TrustyTony
0
48K
Member Avatar for ITgirl2010

[QUOTE=woooee;1254725]Python does not require a "main" function. I would be better the say that no instance of the class has been called/created. This is a link to the instant python tutorial which includes classes [url]http://hetland.org/writing/instant-python.html[/url] If you copied this program and want to modify it, I would suggest you find …

Member Avatar for TrustyTony
0
121
Member Avatar for echellwig
Member Avatar for echellwig
0
153
Member Avatar for aframe

I would approach this by looking documentation for way to generate restore window event in Tkinter. The program would behave the same as user had clicked the program unminimized (restored). Should be portable also.

Member Avatar for woooee
0
2K
Member Avatar for mastermoo420

Could you include small part of each file processed or real log. Did you try putting test prints in various places in code to see what is being processed and if the intended control flow is accomplished and intended input is read? Include indication of place in code, not only …

Member Avatar for mastermoo420
0
110
Member Avatar for tiddster

[CODE]from urllib2 import urlopen print(urlopen('http://www.daniweb.com/forums/').read()) [/CODE] Maybe my between code snippet would be handy to pick out the info you want.

Member Avatar for Tech B
0
152
Member Avatar for ryan461

I would read and think deeply article like this and would really do a use case first, maybe a basic. Isolate objects and attributes/methods and code those. __init__ is just to put initial data to attributes, maybe any automatic method call to take care of calculated initializations. Do some simplest …

Member Avatar for ryan461
0
127
Member Avatar for Simes

You put function inside method by adding to def line as first parameter self and by calling it with self.func() instead of func(). I do not see in assignment that you must not write functions, they should only be used inside class.

Member Avatar for Simes
0
109
Member Avatar for tiddster

I assume your internet connection is broken, so you can not use Google and your IDLE help file is deleted, so you can not use IDLE's help menu. :P So, jokes aside, this kind of OS spesific, but generally available function are in os module. So IDLE interactive use: [CODE]Python …

Member Avatar for raj_developer
0
218
Member Avatar for appunu

I would do: [CODE]import urllib2 print('Loading...') file=urllib2.urlopen('http://heanet.dl.sourceforge.net/project/numpy/NumPy/1.4.1/numpy-1.4.1-win32-superpack-python2.6.exe').read() print('Ready') [/CODE]

Member Avatar for TrustyTony
0
96
Member Avatar for sandorlev

You are creating Label in the function that looks like will be used repeatedly, looks very strange for me. What happens with those Labels. Could you give ScreenShot of your program without the problem. Any pseudo code from the design of program? Program have working text based version, or did …

Member Avatar for TrustyTony
0
10K
Member Avatar for MikexDetroit
Member Avatar for arthurav

Prove it yourself: [url]http://puszcza.gnu.org.ua/software/mix/[/url] [url]http://www.menees.com/index.html[/url]

Member Avatar for TrustyTony
0
98
Member Avatar for Greyhelm

This my code of parsing various dates in string format and finding next day could help you: [CODE]## request: possibility to parse dates with various separators from datetime import timedelta,date for datestring in ['01/23/2010','01.12.2020','1.1.1976', '2 2 2000', ## if you do not make extra limitations this goes also '3d2m1998' ## …

Member Avatar for Greyhelm
0
527
Member Avatar for angraca

See my reply to the old thread: [url]http://www.daniweb.com/forums/post1254961.html#post1254961[/url]

Member Avatar for vegaseat
0
939
Member Avatar for chavanak

I assume that you are using Python 3 from the function style prints. You can give end keyword parameter the letter you want inserted after print, if you want print right after previous one for example end="".

Member Avatar for Beat_Slayer
0
1K
Member Avatar for DerKleineDude
Member Avatar for DerKleineDude
0
463
Member Avatar for redyugi

Do you mean, that you want to do this: [CODE]class Test: def __init__(self, number): self.number = number def getnumber(self): return self.number x = Test(54) y = 'number' print x.getnumber() print getattr(x,y) [/CODE]

Member Avatar for redyugi
0
138
Member Avatar for saima.H

What have you tried to do yourself? This is assignment only, no question asked. It is Daniweb policy not to give direct answers for home work but give help in debugging. You have clear description to do, what kind of structure you would like to use to solve it (it …

Member Avatar for saima.H
0
356
Member Avatar for SJP99

Generally it means not too many assumptions on underlying computer, for example ltitle or big endian, or operating system services.

Member Avatar for 0x69
0
139
Member Avatar for TrustyTony

I made this program during forum discussion for accessing configuration relative to module directory, not main program's position (which can be accessed by sys.argv[0]'s directoryname). As the thread is closed I post my proves as code snippet.

0
1K
Member Avatar for lrh9
Member Avatar for sureronald

Does the code run without the readlines and how fast for 1 GB (compared to 750 MB before)? i.e.[iCODE]for line in open(data.txt,'r'):[/iCODE] Could you post main code, maybe we could optimize it together? Usually it is best to use generator for huge data files.

Member Avatar for mahesham
0
4K
Member Avatar for gangster88

>I would like to be ablt to display 25 circles with alternating colours of red and white? But the code I produced does not work.. plz help. Code tags please: from graphics import * w = 300 h = 300 win = GraphWin("Red Circle", w, h) center = Point(150, 150) …

Member Avatar for Beat_Slayer
0
2K
Member Avatar for vegaseat

I do not understand the rule: [CODE]for c in 'umop apisdn': print c,'upside down'.find(c) u 0 m -1 o 8 p 1 6 a -1 p 1 i 3 s 2 d 4 n 10[/CODE] So 'm' and 'a' is not in other string at all.

Member Avatar for TrustyTony
0
1K
Member Avatar for PatMcC

Icon is quite nice but as development environment it is clumsy. So I end up using Python, which has some influence from Icon. Dreaming to implement sometimes more Iconisms for Python...

Member Avatar for PatMcC
0
83
Member Avatar for KultChyld

Check equal case, if not equal then, if a is older than b declare a oldest otherwise declare b older.

Member Avatar for rahul8590
0
126
Member Avatar for laithlaithlaith

You are missing definition [CODE]app_lock=e32.Ao_lock() [/CODE] Then the program gives error undefined global sock.

Member Avatar for TrustyTony
0
652
Member Avatar for Kruptein
Member Avatar for Kruptein
0
92
Member Avatar for Pinchanzee

What is moves? Module, package or object. How about movesCustom? If you are trying just to use Pascal struct, I think that simple way to replace that it by tuple. Like this: [CODE]import random def move1(): print('move1') def move2(): print('move2') def move3(): print('move3') def move4(): print('move4') moves = (move1,move2, move3, …

Member Avatar for Pinchanzee
0
159
Member Avatar for runit

I think you need only sequence, do not need explicit saved question numbers. It is maybe worthwhile to check out the itertools module: [url]http://docs.python.org/library/itertools.html[/url] [CODE]def combinations(iterable, r): # combinations('ABCD', 2) --> AB AC AD BC BD CD # combinations(range(4), 3) --> 012 013 023 123 pool = tuple(iterable) n = …

Member Avatar for ultimatebuster
0
261
Member Avatar for G_S
Member Avatar for happymadman

Don't know the module myself, but maybe it is helpful to study with tutorial like: [url]http://codespeak.net/lxml/tutorial.html#the-element-class[/url]

Member Avatar for happymadman
0
229
Member Avatar for arthurav

I interpret this so that there is integer which is the fraction part of number and the whole part is 1 ( 1<=x<2 ). Of course if shift to right happens that highest bit should by shifted in so shift one or highest bit set and shift rest for the …

Member Avatar for TrustyTony
0
161
Member Avatar for G_S

Why not: [CODE]import os os.startfile('textversion.py') ## program in same directory as this program[/CODE]

Member Avatar for G_S
0
376
Member Avatar for WildBamaBoy

What escape codes are \P and \D, they are new to me? Maybe they are unknown, and pass through, but safe way is to for example say: [CODE]archive.extract(name, modDir + r"\DCCache")[/CODE]

Member Avatar for Beat_Slayer
0
264
Member Avatar for shavais

See posts in [url]http://www.daniweb.com/forums/post1250774.html#post1250774[/url] for related discussion for stringIO vs catenation.

Member Avatar for snippsat
0
121

The End.