2,646 Posted Topics

Member Avatar for jamesjohnson25

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 ?

Member Avatar for jamesjohnson25
0
440
Member Avatar for RikTelner
Member Avatar for vegaseat

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 …

Member Avatar for vegaseat
2
1K
Member Avatar for lewashby

I hope you checked compatibility of the RAM with the motherboard. I destroyed a motherboard once with incompatible RAM.

Member Avatar for Gribouillis
0
163
Member Avatar for cereal
Member Avatar for joshuawilson11

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

Member Avatar for Josiah_2
0
302
Member Avatar for Xantipius
Member Avatar for Xantipius
0
253
Member Avatar for fonzali
Member Avatar for fonzali
0
569
Member Avatar for Atharva.
Member Avatar for zxz

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 …

Member Avatar for zxz
0
321
Member Avatar for jamesjohnson25

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 …

Member Avatar for jamesjohnson25
0
243
Member Avatar for jamesjohnson25

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 …

Member Avatar for Gribouillis
0
250
Member Avatar for fatalaccidents

It seems to me that this question is solvable by linear programming. The function `scipy.optimize.linprog()` should work with convenient parameters.

Member Avatar for snippsat
0
1K
Member Avatar for vegaseat
Member Avatar for ZZucker
1
909
Member Avatar for matjojo

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 ?

Member Avatar for matjojo
0
196
Member Avatar for matjojo

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)

Member Avatar for matjojo
0
243
Member Avatar for Wojciech_1

@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!

Member Avatar for Reverend Jim
-4
337
Member Avatar for karmstrong

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 …

Member Avatar for Leslie_1
0
632
Member Avatar for Courtney_1
Member Avatar for mattyd

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 …

Member Avatar for Reverend Jim
0
352
Member Avatar for karmstrong
Member Avatar for vegaseat
0
482
Member Avatar for Wojciech_1

@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.

Member Avatar for Gribouillis
-2
442
Member Avatar for XxAaronxX

You can use tuples of integers to store the dice results, for example attacking_values = (random.randint(1,6), random.randint(1,6),)

Member Avatar for XxAaronxX
0
472
Member Avatar for Tcll

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.

Member Avatar for Tcll
0
12K
Member Avatar for RikTelner

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 …

Member Avatar for iamthwee
0
790
Member Avatar for G_S

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

Member Avatar for Gribouillis
0
524
Member Avatar for DaveAmour

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.

Member Avatar for Wojciech_1
1
231
Member Avatar for nuaris

[code=python] from urllib2 import urlopen data = urlopen("http://internetaddress.com/file.txt").read() [/code]

Member Avatar for snippsat
-1
5K
Member Avatar for lewashby

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 …

Member Avatar for mike_2000_17
0
204
Member Avatar for joshuawilson11
Member Avatar for fatalaccidents

Did you run the meshpy examples here ? One of them may resemble your problem https://github.com/inducer/meshpy/tree/master/examples

Member Avatar for fatalaccidents
0
2K
Member Avatar for rinston

Here is a [french site](http://degooglisons-internet.org/) which goal is to ungooglize internet. It is a non-profit organization supporting free software.

Member Avatar for XP78USER
0
441
Member Avatar for iamthwee

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.

Member Avatar for iamthwee
1
225
Member Avatar for geodosch

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.

Member Avatar for Dani
1
252
Member Avatar for Niloofar24
Member Avatar for vegaseat

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

Member Avatar for BustACode
6
932
Member Avatar for Mate_1

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)

Member Avatar for vegaseat
0
984
Member Avatar for <M/>

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 …

Member Avatar for iamthwee
0
500
Member Avatar for BustACode

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)

Member Avatar for vegaseat
1
336
Member Avatar for BustACode
Member Avatar for BustACode

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 …

Member Avatar for vegaseat
0
376
Member Avatar for Gribouillis

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).

0
130
Member Avatar for kamran815
Member Avatar for davidbr

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 …

Member Avatar for davidbr
0
4K
Member Avatar for RikTelner

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.

Member Avatar for Bala_2
0
302
Member Avatar for giancan

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 …

Member Avatar for Gribouillis
0
183
Member Avatar for Rekt

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 …

Member Avatar for Rekt
0
3K
Member Avatar for BustACode

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 ?

Member Avatar for fonzali
1
1K
Member Avatar for BustACode

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 …

Member Avatar for vegaseat
0
395
Member Avatar for BustACode

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 …

Member Avatar for Gribouillis
0
210

The End.