2,646 Posted Topics
![]() | Re: Is this blue enough ? self.btnClear = Button( self.frame, text="Clear Test", relief = FLAT, bg = "blue",highlightbackground="blue", fg="white") ![]() |
Re: This is clearly homework. You must post your python code. Without code, there is no issue to solve. | |
Re: Probably the worst `isPrime()` function I've ever seen. If num is above 1000000, you are going to stack 1000000 recursive calls ! Python comes with a recursion limit >>> import sys >>> sys.getrecursionlimit() 1000 which means that your code will fail. The limit can be changed, but in every day programming, … | |
Re: I dont think there is a *good ratio*. I used this code import numpy as np import matplotlib import matplotlib.pyplot as plt data = """ 37 - 16 - good 21 - 12 - good 18 - 10 - good 19 - 8 - bad 26 - 12 - good … | |
Re: It looks very much like homework. Start with a program to print the letters of each word in alphabetic order. | |
Re: Hi! Welcome to daniweb and the python forum! You can use a single Label import sys, random, tkinter # sample items without replacement L = list(range(1,60)) random.shuffle(L) g = L[:5] g.sort() f = L[5:6] drawing = ''.join([' '.join(str(G) for G in g),' ',str(f[0])]) print(drawing) app=tkinter.Tk() app.geometry('700x400+420+420') app.title(string=" LOTTO ") label5=tkinter.Label(app,text … | |
Re: Add `print('Current item is:', repr(item))` between lines 3 and 4. | |
Re: Use `u'à1'` and `u'é1'` or even better from __future__ import (absolute_import, division, print_function, unicode_literals) Currently, I even use from __future__ import (absolute_import, division, print_function, unicode_literals) from future import standard_library from future.builtins import * in python 2.7, where future is [this](http://python-future.org/) module. | |
Re: Use row = [ ['3'], ['7', '4'], ['2', '4', '6'], ['8', '5', '9', '3'], ] | |
Re: This error occurs when one tries to use a variable before it is defined at the left side of an `=`. The problem in your function `determine_loan_rate()` is that the ifs and elifs don't cover all the possible cases. In certain circumstances, the program can reach `return interest_rate` with none … | |
Re: It's an ill-posed problem, as mathematicians say. Why do you need your ip address ? Why doesn't 127.0.0.1 suffice ? Do you want the ip address on the local network (you should know it), or your public ip address ? There is an old trick [code=python] import urllib2 ip = … | |
Re: I don't use macosx, but don't you miss some python development headers ? For example can you locate the file `Python.h` ? | |
Re: I suggest this if module `games.food` contains function `food()`, etc from importlib import import_module import games # games package has all modules to be used. The modules include color, food etc GAMES = ('color', 'food', 'car', 'toy') while True: question = input('Please enter your question: ').lower() if not question: break … | |
Re: You can write searched = ['onetouch at', 'linkrunner at', 'aircheck'] def does_match(string): stringl = string.lower() return any(s in stringl for s in searched) for row in reader: if any(does_match(col) for col in row): writer.writerow(row[:2]) # write only 2 first columns | |
Re: Perhaps try [this code snippet](http://www.daniweb.com/software-development/python/code/238387/really-simple-plugins-loader-import-all-modules-in-a-folder-in-one-swoop). Also please post code with correct syntax, preferably runable code. | |
Re: I don't know this subject but did you try to connect using the standard module `smtplib` ? Also do you have a way to check that the server is running ? | |
Re: First, use the `threading` module instead of `thread`, so start a thread with t = threading.Thread(target = runner, args = (list(previous_moves), processing, i)) t.start() I wrote `list(previous_moves)` because this creates a clone of the list. I don't think all the threads can share the same list object, or may be … | |
Re: I have a starting point using module bitstring (from pypi) and the wikipedia page import bitstring test_data = [ ("0 01111 0000000000", 1), ("0 01111 0000000001", 1.0009765625), ("1 10000 0000000000", -2), ("0 11110 1111111111", 65504), ("0 00001 0000000000", 2.0 ** (-14)), ("0 00000 1111111111", 2.0**(-14) - 2.0**(-24)), ("0 00000 0000000001", … | |
Re: I think the first thing to do is avoid the `import *` expression as much as possible. For example, use from tkinter import * from tkinter.messagebox import * from tkinter import Image import Tetrisino import colorfill import Simulation import os Then def Button3CallBack():#Caling the main function of the Tetrisino game … | |
Re: After line 3, add print(repr(password)) print(repr(userguess)) then you can compare visually the two strings. | |
Re: Normally, you can't do that and you should not be doing that. However this is python and most things happen to be possible. A trick is to replace the module in `sys.modules` by a pseudo module object with the same dict and a `__call__()` method. Here is module `lemodule.py` in … | |
Re: It seems that you must use the LIMIT keyword in the SELECT statement, as described in the [mysql documentation](http://dev.mysql.com/doc/refman/5.0/en/select.html). For example SELECT * FROM tbl LIMIT 5,10; # Retrieve rows 6-15 See also [this](http://www.phpsimplicity.com/tips.php?id=1). I dont know how it will interact with your ORDER BY clause. | |
Re: As always, your code violates every rule of good design. It is possible, in theory, with a statement such as C.__class__ = B However you may find more help if you post the code of bu32, deref, bu() etc. | |
Re: For the `cos(x)`, add `pi/2` to x, then compute `sin(x)`. For this use the Taylor series as ddanbe said above, but for faster convergence you can replace x with `x - 2*k*pi`, where k is chosen so that this new x is in the interval `[-pi, pi]`. Again you can … | |
Re: I think you are trying to do something completely impossible. The first argument in Popen() must be a valid command line (either a string or a list, see the doc) which you could write in a terminal and execute. You can't write open(os.path.join(os.getcwd(), "foo.txt") "w") in a terminal and expect … | |
This python script prints all the columns of an sqlite database which path is given as argument. | |
Re: This works for me with sqlalchemy from sqlalchemy import create_engine from sqlalchemy.engine import reflection engine = create_engine('sqlite:///menus.sqlite') # //// for abs path insp = reflection.Inspector.from_engine(engine) print insp.get_table_names() # print list of table names print insp.get_columns(u'menu') # print list of dicts, each containing info about a column in table 'menu' [reflection](http://docs.sqlalchemy.org/en/rel_0_9/core/reflection.html#fine-grained-reflection-with-inspector) … | |
![]() | Re: I suggest that you translate [wikipedia's pseudo-code](https://en.wikipedia.org/wiki/Graham_scan) into python. It looks like 20 lines of code ... |
Re: Replace last line with words[:] = [word for count, word in vow_count] This will replace the contents of list 'words' by your result. Also the line count = 0 should be inside the for loop. *Print* the result at the end of your function to see what happens. | |
Re: I don't know web2py but did you explore the database with an external tool (phpmyadmin, sqliteman, ... depending on your db) to see if the data is still there ? | |
Re: *Optimizing* is different from reducing code size. Optimizing usually means change the code in order to reduce the execution time. Changing the code in order to have a better looking and shorter code is part of *refactoring*. The first criterion is code repetition. The functions `side_1()`, `side_2()`, `side_3()` are almost … | |
Re: One thing is clear: the `__new__()` method is *not* the place where this should be implemented. The role of the `__new__()` method is to create an instance before this instance is initialized. Normally, you don't need to use it unless you subclass a builtin type or you are playing with … | |
Re: Consider a combination `(c,t,b)` with `n-4` tyres, if any. Add a car: you get a combination with `n` tyres. This covers all combinations having at least one car. It remains to generate the combinations without car. Consider all such combinations with `n-3` tyres and add a tricycle. This gives all … | |
Re: The assignment statement r.size = 150, 100 is equivalent to r.size = (150, 100) As far as python's syntax is concerned, a single value is assigned, which is a tuple with 2 elements. Also note the use of decorators to declare properties: class Rectangle: def __init__(self): self.width = 0 self.height … | |
Re: Try [PyInstaller](http://www.pyinstaller.org/) perhaps. Notice that most linux distributions ship with python 2 or 3 installed or both, or the other one can be installed with a few keystrokes, so I don't think a stand alone executable is very useful. | |
Re: If you're using [openpyxl](http://packages.python.org/openpyxl/) instead of xlrd to read excel files, you must use .xlsx or .xlsm extension. | |
Re: It is not python code. It looks like javascript. See in the [JavaScript / DHTML / AJAX](http://www.daniweb.com/web-development/javascript-dhtml-ajax/117) forum. | |
Re: Hm, a few visible issues: 1. Indentation of lines 8 and 9 is incorrect. 2. match is not a string, but a *match object*. Line 9 should probably be `f2.write(match.group(0))` (or 1 depending on what you want) 3. Always use raw strings in regex, such as `re.findall(r'...' ...)`. Raw strings … | |
Re: It's probably GetUserName() or GetUserNameEx() in the [win32api](http://timgolden.me.uk/pywin32-docs/win32api.html) module. The code in your post is very nice, but it is purely linux, and there is some work if you want to port this to windows. | |
Re: I think Mandela is sanctified today because everybody, and particularly world leaders, want to promote peaceful coexistence of the different human races. As he spent 28 years in prison, I see him as a victim rather than a saint. He is a *dissident* in the sense used for dissidents of the … | |
Re: Use [the python tutorial](http://docs.python.org/3/tutorial/controlflow.html#if-statements) for correct syntax. | |
Re: It could be John Zelle's module [graphics.py](http://mcsp.wartburg.edu/zelle/python/). | |
| |
Re: Use a datetime.timedelta instance to represent the difference between two dates yA, mA, dA = 1969,7, 21 yB, mB, dB = 2013, 12, 22 import datetime as dt dateA = dt.date(yA, mA, dA) dateB = dt.date(yB, mB, dB) diff = dateB - dateA # a timedelta object print ("diff is … | |
Re: I think it is a parity error. Basically, you are looking for 2 consecutive words. Take the sequence `foo inhibited bar baz gated qux`. There are 3 pairs of consecutive words, `(foo, inhibited)`, `(bar, baz)`, `(gated, qux)`. Gated is not removed because it is not in second position in its … | |
Re: Did you try `ftps = FTP_TLS('xxx.xx.xxx.xx', 'myuname', 'mypwd')` ? | |
Re: I don't understand what you want to hide. Is it something visible on the screen, like a cmd console, or is `some.exe` a GUI program ? ![]() | |
Re: > BTW in my Python at least he scandinavian letters are not allowed for names of Python objects. In my python 3.3.1, french accented letters are allowed, as in >>> incrément = 1 >>> hôte = '127.0.0.1' >>> | |
Re: Use the [csv](http://docs.python.org/2/library/csv.html#module-csv) module (standard lib) [discussion here](http://pymotw.com/2/csv/index.html#module-csv). |
The End.