2,646 Posted Topics
Re: No it will be very fast. I suppose your data is stored in a file. Can you send such a file with say 10 lines of data ? | |
| |
Re: Your method can be called *optimization by scanning*. It has the advantage of requiring nothing but elementary python code to work. In applications, one would use an existing solver such as solvers found in scipy. For example >>> from scipy import pi >>> import scipy.optimize as opt >>> >>> def … | |
Re: I hope you checked compatibility of the RAM with the motherboard. I destroyed a motherboard once with incompatible RAM. | |
Re: I don't understand what `q` and `g` are in your code. If you want to add a number to every value in a list, you can do mylist = [83, 111, 109] offset = 22 mylist[:] = [value + offset for value in mylist] # mylist is now [105, 133, … | |
| |
Re: Do you already have some code for the calculator ? Are you using a GUI toolkit ? | |
| |
Re: The expression `i & 1` is true only if i is odd. This will happen only if i equals 3 in the loop. In that case `fork()` is executed and creates a child process. Let A be the main process and B the child process created at this moment. The … | |
Re: We don't know what `n` is. The easiest way is to make it an attribute of a `TheShuttles` instance. class TheShuttles: def __init__(self): self.n = 0 def getLeastCost(self, baseCost, seatCost, cnt): def cost(x): self.n = sum(m / x + (m % x != 0 ) for m in cnt) return … | |
Re: The if condition looks if the dictionary `tm` contains a key which is a tuple of length 1 containing the `word` as sole item. If it does not, a value is associated to this key in this dictionary. It seems strange to me that you don't work with unicode strings … | |
Re: It seems to me that this question is solvable by linear programming. The function `scipy.optimize.linprog()` should work with convenient parameters. | |
Re: @pytony it says HELLO OWLR, there must be something wrong. | |
Re: The `while True` loop runs forever unless it contains a `break` or `return` statement, or an exception is raised. It means that your code repeats indefinitely the statement `whichcode = 1`. This is probably not what you meant. Why do you need the while loop ? | |
Re: There are many syntax errors in your code. The documentation explains the syntax of the for statement https://docs.python.org/3/reference/compound_stmts.html#the-for-statement Schematically it is for SPAM in HAM: EGGS of course, `HAM` must support the `in` operator (so do lists, dicts and tuples for example) | |
Re: @Wojciech I think you have two options: * You can create Wojciechweb and program your own forum application the way it should be done, * OR you can convince Dani to hire you as a web programmer! | |
Re: If you want to start at position 2, you only need for idx in range(2, key_length): Do you have a variable `m_keyCode` ? The body of the for loop depends on this. If you are with python 3 and m_keyCode is a bytes instance, it is easy because the values … | |
Re: Let's try cereal's technique def paire(x): return sqrt(-x**2+3*x+4), abs(x-2) for x in (-0.5, 1, 3.7): print x, paire(x) In kubuntu, I selected code in an editor with ^c, then pasted it in daniweb's editor with ^v, then selected it with a mouse and pressed TAB. It works, but I'd like … | |
Re: Very good. It can be improved with `n = len(mylist) % 4`. | |
Re: @Wojciech Really I don't understand why you don't start your own forum project with your own features. Obviously, you have many ideas about how to improve existing software, so why not host a new engine on github ? When it works, you could perhaps attract webmasters' interest in your project. | |
Re: You can use tuples of integers to store the dice results, for example attacking_values = (random.randint(1,6), random.randint(1,6),) | |
Re: You could use my snippet to restart the program https://www.daniweb.com/software-development/python/code/260268/restart-your-python-program- . From `action_reload()`, you can call `restart_program()`. Before that, you can try to compile the main program in order to eliminate possible syntax errors. | |
Re: The history of the unix system is tightly bound to the history of the C programming language, so I would say that a genuine linux application is written in C, with the help of the GNU tools. However, C is a little bit outdated, so I think C++ can be … ![]() | |
Re: I think you can follow the simple rule that code which is nearly the same in 2 classes is a good candidate to be written in a common superclass for these 2 classes. You can build a hierarchy based on this principle. The principle can be applied to attributes too, … | |
Re: I had this problem too. My solution is to refresh between c) and d) (with ^R). I'm using Qupzilla 1.8.6. I think it is always better to refresh before editing an existing post. | |
Re: [code=python] from urllib2 import urlopen data = urlopen("http://internetaddress.com/file.txt").read() [/code] | |
Re: It depends on what you call *good*. I have a Epson XP-700 at home and it works very well with linux kubuntu. Epson publishes free drivers for the printer and the scanner. Avoid certain brands such as Lexmark which have a tradition of poor linux support (it may have changed … | |
Re: Try L[:] = [(' ' if x == '32' else x) for x in L] | |
Re: Did you run the meshpy examples here ? One of them may resemble your problem https://github.com/inducer/meshpy/tree/master/examples | |
Re: Here is a [french site](http://degooglisons-internet.org/) which goal is to ungooglize internet. It is a non-profit organization supporting free software. | |
![]() | Re: I would not use another OS by my free will. On the other hand, linux must have serious drawbacks to fill so little space in the OSes market share statistics. Its main drawback may be incompatibility with microsoft based software. ![]() |
Re: You can zip it and attach the zip file to a post. We'll be able to see if there is anything special about it. | |
Re: Isn'it if `word.startswith('A')` ? | |
Re: This example shows how to use the `__format__` method to fine tune the format of an instance (here a dice) in formatting statements. #-*-coding: utf8-*- python 2 or 3 from __future__ import (absolute_import, division, print_function, unicode_literals) from random import choice try: chr = unichr except: pass class Dice(object): _values = … | |
Re: You can define a color with for example fillcolor('green') Then you can fill a domain with fill(True) #... Here draw a domain as you did before fill(False) | |
Re: My mother tongue is French, I studied English and German at school, but I hardly can speak German. May be one day I'll learn Italian: one of my friends used to cite verses of Dante Alighieri, and it's unbelievably beautiful to hear. Of course, it's very old. @mike_2000_17 Quebecois looks … ![]() | |
Re: If you are working in number theory, you might be interested in the python interface to the [PARI GP calculator](http://pari.math.u-bordeaux.fr/doc.html) system: [pari-python](http://code.google.com/p/pari-python/). It contains many functions for number theory (it probably does not work with python 3 however) | |
Re: Why not use `math.floor()` and `math.ceil()` ? | |
Re: Here is how you can code the same thing by using a [PEP8](https://www.python.org/dev/peps/pep-0008/) compliant coding style # -*-coding: utf8-*- # python 2 or 3 def get_middle_factors(factor_list): """Return a list of the term(s) in the middle of a list A list of length 1 or 2 is returned, depending on the … | |
Some unicode characters such as dice symbols or chess symbols (see https://en.wikipedia.org/wiki/Miscellaneous_Symbols) dont display properly anymore in the forums. What's going on ? there are examples here [Click Here](https://www.daniweb.com/software-development/python/code/492854/another-visit-to-string-formatting-python#post2155656) and here [Click Here](https://www.daniweb.com/software-development/python/code/423640/unicode-chessboard-in-a-terminal#post1814200). | |
Re: There is a better way: you can disable 2C when 1A is on. In the following code, I added a callback method, which is called when one of the options is selected. It is a very good way to prohibit some choices. It is completely configurable. This code needs to be … | |
Re: I suggest to use the boot-repair disk as Slavi did in [this thread](https://www.daniweb.com/hardware-and-software/linux-and-unix/threads/488911/try-hd-0-0). In principle, it should work. It seems strange to me that you don't have a linux swap partition. | |
Re: You need to add the group number, for example import datetime as dt import itertools as itt import operator as op def todatetime(string): return dt.datetime.strptime(string, '%H:%M:%S') def enhanced_sequence(seq): """yields pairs (group number, time string) Arguments: seq: sequence of ordered time string 'HH:MM:SS' """ seq = iter(seq) prev = next(seq) dtprev … | |
Re: Yes because Vegaseat uses import tkinter as tk while you are using from tkinter import * Usually, people prefer to avoid `import *` because there is no way to see which names are imported in the current namespace. With the first import, only the variable `tk` is added to the … | |
Re: As there is no issue, you could post this as a code snippet (select the appropriate article type when the article is created). Why not add a call to` main()` at the end so that it does something when we try it ? | |
Re: You might be interested in my `print_multicolumn()` code snippet https://www.daniweb.com/software-development/python/code/468373/print-a-list-in-multicolumn-format and also by module `prettytable` in general. Here is what it does >>> L = ['a', 'b', 'c', 'a', 'b', 'c', 'a', 'bbbbbbbbbbbbbbbbbbb', 'c', 'k', 'k', 'l', 'a', 'b', 'c'] >>> print_multicolumn(L, 3, vertically=False) a b c a b c … | |
Re: I think the program should create a backup of itself before attempting to rewrite itself and restore the backup if anything goes wrong. It would be a minimal security feature if one wants to develop this. IMHO, the main issue is that it is not very useful. A more standard … |
The End.