3,386 Posted Topics
Re: Does not use full window for plotting, otherwice OK for me. | |
Re: 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. | |
Re: 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] | |
Re: 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. | |
Re: Button is placed in the app window directly. Generally it makes sense to prepare one frame first and put Button in that frame. | |
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 … | |
Re: 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 … | |
Re: [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] | |
Re: 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 … | |
Re: [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 … | |
![]() | Re: 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 … |
Re: 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] | |
Re: Please check older threads before posting: [url]http://www.daniweb.com/forums/thread204301.html[/url] | |
Re: 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 … | |
Re: [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 … | |
Re: [CODE]for j in range(int(Allele[i])): outfile.write(' %s * ' % allelelocus[j])[/CODE] | |
Re: 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. | |
Re: 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 … | |
Re: [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. | |
Re: 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 … | |
Re: 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. | |
Re: 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 … | |
Re: 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] | |
Re: 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 … | |
Re: Prove it yourself: [url]http://puszcza.gnu.org.ua/software/mix/[/url] [url]http://www.menees.com/index.html[/url] | |
Re: 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' ## … | |
Re: See my reply to the old thread: [url]http://www.daniweb.com/forums/post1254961.html#post1254961[/url] | |
Re: 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="". | |
![]() | Re: Use test printing, put before line 10 as test: [CODE]print OutputItem,type(OutputItem)[/CODE] ![]() |
Re: 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] | |
Re: 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 … | |
Re: Generally it means not too many assumptions on underlying computer, for example ltitle or big endian, or operating system services. | |
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. | |
Re: [CODE]import sys,os sys.path.append(os.path.curdir)[/CODE] | |
Re: 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. | |
Re: >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) … | |
Re: 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. | |
Re: 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... | |
Re: Check equal case, if not equal then, if a is older than b declare a oldest otherwise declare b older. | |
Re: You are missing definition [CODE]app_lock=e32.Ao_lock() [/CODE] Then the program gives error undefined global sock. | |
Re: This is my result trying to open the program in IDLE in WindowsXP. | |
Re: 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, … | |
Re: 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 = … | |
Re: You mean: [code] humanlist="\n".join(pythonlist)[/code]?? | |
Re: 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] | |
Re: 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 … | |
Re: Why not: [CODE]import os os.startfile('textversion.py') ## program in same directory as this program[/CODE] | |
Re: 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] | |
Re: See posts in [url]http://www.daniweb.com/forums/post1250774.html#post1250774[/url] for related discussion for stringIO vs catenation. |
The End.