2,646 Posted Topics
Re: Can you post the whole error message ? Edit: this is unrelated to the issue, but if you want to run the program several times, it would be good to add s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) immediately after calling `socket.socket()`. | |
![]() | Re: What I usually do is to install the *tmux* terminal multiplexer. Type sudo apt-get install tmux in the server terminal, then save this minimal configuration file in $HOME/.tmux.conf # These 3 lines define the prefix F1 pour tmux instead of C-b unbind-key C-b set -g prefix 'F1' bind-key 'F1' send-prefix … |
Re: One way to discourage the user from opening the file with a text editor is to store binary data in the file. You could encrypt the file to produce a binary data file. | |
Re: I don't understand the issue. You're sending and receiving data. You convert the received data to hex, then to integer by calling `int(d, 16)` and you say it confuses you but this is cryptic data and we don't know if it is correct or not so where is the problem … | |
Re: Also `readdir()` is probably meant instead of `readdur()`. The compiler cannot miss this. | |
Re: @Anurag Shekhar See pyTony's question here https://www.daniweb.com/programming/software-development/threads/277522/gui-scientific-calculator-homework#post1197744 and tkpanther's answer | |
Re: The main task of your program is to generate a sequence of pairs `(src, dst)` where src and dst are a path to an existing file or directory and the path to the not yet existing destination. Once the list is correct, you can call `shutil.move()` or `os.rename()` on each … | |
![]() | Re: Nothing is wrong. Only you must call the method if you want it to be executed. So write `p.Sums()`. |
Re: Beside pointers, the real difficulty is memory management. When to call `new()` and `delete()`. Recent languages all come with garbage collection included and this changes everything in pointers management. | |
Re: I suggest this code #include<stdio.h> int minoffset(int n, int* arr){ return n == 1 ? 0 : (*arr <= *(arr + (n = 1 + minoffset(n-1, arr+1))))? 0 : n; } int main(int argc, char const *argv[]) { int n=10; int tab[10] = {7,5,6,8,7,4,8,9,2,3}; int min = *(tab + minoffset(n, … | |
Re: We don't know who Mr Rioch D'lyma is, nor which book or code you're talking about. Can you please post some links to explain all this ? | |
Re: @Shreyaa In principle it works, but it would be written more *pythonically* this way def assignment(a, log, b, l): with(open("3ope.txt",'r')) as insname: for line in insname: a.append(instruction()) # .rstrip() removes white space at the end of the line a[-1].inst = line.rstrip() For python code, configure your editor to insert 4 … | |
Re: Your zip call looks correct. Can you post the whole traceback and code ? | |
Re: The `print()` at line 6 needs a `end=""` argument. Also you could replace all the `end="t"` with `end=""`, and also `" {}"` with `"{:>5}"` which is better because every number will fit in a fixed length zone of 5 characters. | |
Re: @pythonBasic Please don't revive or highjack old threads. Start your own new discussion instead if you have questions. | |
Re: I don't understand the rules. Also there are 2 blue circles in the picture. How are the legal paths defined ? | |
Re: In windows OS, the best solution is often to install a module from Christoph Gohlke's python binaries for windows. PyHook is [<Here>](http://www.lfd.uci.edu/~gohlke/pythonlibs/#pyhook). Edit: Download the wheel file (.whl), then type `pip install <filename.whl>` | |
Re: I've found a `play_again()` function [<here>](http://stackoverflow.com/a/20439490). It can be adapted to your game by returning a boolean. Also the procedure to initialize the maze and the player must be called again, so I write a `reinit()` function to do that. Here is the result. It could be a good starting point. … | |
Re: I don't understand why you need python to install an ftp server (you probably mean an sftp server). There must be a standard way to install an sftp server for your OS. Also I don't understand the "no third party content" part. Can you explain all this. | |
Re: It seems that you are trying to define a query language. What you must do is **parse** that query language. For example, you could allow the user to enter several search terms separated by commas. Then parsing this query means for example split the user request into a list of … | |
This snippets contains a python program to find a shortest solution to the problem of the farmer who whishes to cross a river. The boat can only contain two things, including the rower. The farmer comes with a wolf, a duck and a bag of corn, and he can't leave … | |
Re: RX bytes and TX bytes are not speed measurements, they show the total number of bytes received and transmitted by this interface (eth0). Are you a friend of zero_1 who posted the same question 1 week ago [Click Here](https://www.daniweb.com/programming/threads/504581/upstream-and-downstream-python#post2204463) ? | |
Re: @AssertNull running astyle --style=allman --align-pointer=middle --max-code-length=79 farmer.cpp does a pretty good job on formatting Builder_1's code | |
Re: @happygeek I tried to remove the windows OS from your configuration, but I couldn't reach an acceptable state. What will OP do if he wants to upgrade his OS ? | |
Re: There are many ways to do that, you can use the pickle module or the json module to persist data on disk. A very simple solution is to use Raymond Hettinger's PersistentDict class. Download the code from here [Click Here](http://code.activestate.com/recipes/576642-persistent-dict-with-multiple-standard-file-format/) and save it under the name `persistentdict.py`. You can then … | |
Re: Is there no `join()` method in c# ? | |
Re: Before `print('No entry found')` you could add `print(name)` and `print(firstname)` to see why the `if name in firstname` returned false. | |
Re: There is a great module named [<psutil>](https://pypi.python.org/pypi/psutil) which can tell you all this import psutil for proc in psutil.process_iter(): try: pinfo = proc.as_dict() except psutil.NoSuchProcess: pass else: print(pinfo) break To save the data into tabular format, you could use a simple library such as [<tablib>](https://pypi.python.org/pypi/tablib). | |
Re: This seems to work, I'm looking for a sequence of characters which are not a newline, or a newline followed by a non alphanumeric character. import re content = """ Data: 01 18 01 23 45 67 89 AB CD EF FE DC BA 98 76 54 32 10 01 … | |
Re: This python script may work. Python is very powerful for such tasks #!/usr/bin/env python # -*-coding: utf8-*- '''doc ''' from __future__ import (absolute_import, division, print_function, unicode_literals) from argparse import ArgumentParser import os.path if __name__ == '__main__': p = ArgumentParser(description='change names of some files') p.add_argument('dir', metavar='DIR', help='directory containing files to move') … | |
Re: Astyle [Click Here](http://astyle.sourceforge.net/astyle.html) looks nice. It is even included in ubuntu linux (but it is not coded in java!). | |
Re: The problem is that when a variable appears **on the left hand side** of the `=` operator in a function, such as in def foo(): started = "fubar" then the rule is that this variable is **a local variable** in function foo. It means that if there is another variable … | |
Re: The first rule of thread programming in python is **not to use the thread module**. Use the `threading` module instead. The reason is that the thread module is too low level for your needs. Read [Click Here](https://pymotw.com/2/threading/) first and update your code to use threading. | |
Re: Use module paramiko to connect the ssh server and execute commands. See this code [Click Here](https://www.daniweb.com/programming/software-development/threads/319372/sending-the-password-automatically#post1363982) for connection. Execute commands with `ssh.exec_command()`. See this post [Click Here](http://www.iodigitalsec.com/ssh-sftp-paramiko-python/) for example. | |
Re: Compute how many times the `if` statement is executed. | |
Re: I don't understand the question nor how it is related to python. I understand that you already have a script for Ubuntu, can you post that script or a link to it ? | |
| |
Re: Go [here](http://www.drjava.org/) and click "download jar file via http". Then open a terminal and go to the directory where the file `drjava...` has been downloaded. Then type java -jar drjava* In the window that opens, write public class HelloWorld { public static void main(String[] args) { System.out.println("Hello, World"); } } … | |
Re: Go [here](http://www.drjava.org/) and click "download jar file via http". Then open a terminal and go to the directory where the file `drjava...` has been downloaded. Then type java -jar drjava* In the window that opens, write public class HelloWorld { public static void main(String[] args) { System.out.println("Hello, World"); } } … | |
Re: You need a loop to handle the case where the answer is not yes or no. For example def yesno(question): while True: ans = input(question + ' (Y/n) ') ans = ans.strip().lower() if ans in ('', 'y', 'yes'): return 'yes' elif ans in ('n', 'no'): return 'no' else: print('Please answer … | |
Re: Your code is almost the same as code in this tutorial[Click Here](https://pythonprogramming.net/displaying-images-pygame/). There are missing calls to `arrowimg()` and `pygame.display.update()` at the end of your code. Also it is an error to use the same name `arrowimg` for the image and your function. Use 2 different names. | |
Re: Why do you need python 2.5. The obvious thing to do is to uninstall 2.5 and install 2.7. | |
Re: One problem with OO tutorials is that they teach you a very formal point of vue about OOP, how to carefuly plan subclasses, method overriding etc. After many years of OOP, I tend not to write many subclasses and not to override many methods because carefuly designed class hierarchies are … | |
Re: I think there shouldn't be a `for` loop in `Read()`. Also there is an error in `get_smallest()` #include <cassert> #include <iostream> #include <vector> #include <string> #include <sstream> using namespace std; struct people { string name; int age; }; people Read(people p) { //for (unsigned int i = 0; i < … | |
Re: The most obvious thing in your code is that "Members.txt" will be opened many times, one for each iteration of the lines in "Rules.txt". This is probably not what you want. You don't need to open each file more than once. To make things easier since you are new to … | |
Re: If `X` is a list instance, one can access its members with `X.tail` or `X.next`. On the other hand if `X` is a pointer to a list instance, one writes `X->tail` and `X->next`. It is only the syntax of C++. Notice that in the case of a pointer, there is … | |
Re: It's a lot of code. You could perhaps go to the Job Offers section... | |
Re: Try `int('ff', base=16)` edit: also have a look at standard modules binascii and array. | |
Re: A reasonable way to start good parsing is to write a tokenizer from __future__ import print_function import re from collections import namedtuple regex = re.compile(r'(\w+[.]\w+)|(\w+|[{}\[\],])|(\n)') d1 = { 'sourceFiles': 'SOURCEFILES', 'headerFiles': 'HEADERFILES', 'path': 'PATH', 'header': 'HEADER', 'source': 'SOURCE', '{': 'LB', '}': 'RB', '[': 'LS', ']': 'RS', ',': 'COMMA', } #Token … |
The End.