-
Replied To a Post in read a .txt and output a .xml in python3.2
Where did you get that code ? Your input file is not a csv file. You'll have to write your own parser for the text file. Perhaps the starting point … -
Replied To a Post in How to merge two binary files
In python, one can execute a program using the subprocess module. For example, you can use [this snippet](https://www.daniweb.com/software-development/python/code/257449/a-command-class-to-run-shell-commands-) to get program output, error messages and exit status. With this, you … -
Replied To a Post in which class structure is better?
You are *wrapping* the `str` class. It means that you want a string, but you don't want the string methods (such as addition or `index()`, etc). Instead, you want your … -
Replied To a Post in Help pls its urgent, new to programming
Add a print statement to start a new line for score1 in list1: for i in range(0,score1): print "*", print -
Replied To a Post in Find the list of elements from arrays
Perhaps you mean if position_x == 375: print position_x ? -
Replied To a Post in Transfer Data b/w Linux machine
It is not a python issue, it is an rsync issue. Solve the problem outside of python, then use the solution in python. There are ways to use rsync without … -
Replied To a Post in Transfer Data b/w Linux machine
Oh well if you only want to run a command from python you can do import subprocess subprocess.call('rsync -rav pi@192.168.2.27:python ~/', shell=True) -
Replied To a Post in Transfer Data b/w Linux machine
Yes, this is the server program. You must run the client program on the other machine. Of course, the client program must use the server's IP address. -
Replied To a Post in Transfer Data b/w Linux machine
An extremely simple way to send data from one computer to another is to use an xml_rpc server. Try to run the example code in the python documentation for the … -
Replied To a Post in IDE
All right, I'm using it in Kubuntu on python 2.7 and it works. As it is written in python, you can perhaps get an exception traceback if you run it … -
Replied To a Post in Add new contents of several lines to a file
A configuration file is usually a reasonably sized file, and you can load its content in memory as a python string or a python list of lines. You could cut … -
Replied To a Post in IDE
I discovered the [enki](http://enki-editor.org/) editor today. It seems worth giving a try ! -
Replied To a Post in Convert .bin dump to .dd or .img
There is a (old) page in french [here](http://doc.ubuntu-fr.org/bchunk) where they explain how to omit the .cue file by writing a small script (which they name biniso). -
Replied To a Post in Convert .bin dump to .dd or .img
Well, as I told you, I never used these tools. The `iat` man page says > iat - converts many CD-ROM image formats to iso9660. but your mobile phone is … -
Replied To a Post in Convert .bin dump to .dd or .img
Use iat my_image.bin > my_new_image.img -
Replied To a Post in help me to convert this code to python??
Well, it could be something like def Similarity(X,Y): for i in range(m+1): SIM[i,0] = ig for j in range(1, n+1): SIM[0,j] = jg for i in range(1, m+1): for j … -
Replied To a Post in need help polishing script
Here is a version using generators. #!/usr/bin/env python3 """This script simulates a monkey on a typewriter trying to come up with one sentence of Shakespeare. Only the lowercase alpha characters … -
Replied To a Post in A Question =)
The line #!/usr/bin/python -tt is not a python thing. It is a unix mechanism named [shebang](https://en.wikipedia.org/wiki/Shebang_(Unix)). If the file is made executable in unix, the first line of the file … -
Replied To a Post in Command Line Editor With Syntax Highlighting
A long time ago, I used Jed in a terminal. It is a nice text editor. -
Gave Reputation to Peter_21 in Translating JavaScript to Python
Use Js2Py ( https://github.com/PiotrDabkowski/Js2Py ). Translation from JavaScript to Python is fully automatic. -
Gave Reputation to Schol-R-LEA in Help pls its urgent, new to programming
We are certainly willing and able to help, but we'd need to know what sort of help you need. What have you done so far, and where are you stuck? … -
Replied To a Post in how do I make a class instance act as a class??
It's OK. Only remember that using python standards help you share your code with other python programmers ! -
Replied To a Post in Multiple Word Replace in Text (Python)
@tim1234 This is a good way to do it. For more sophisticated work in the same direction, I would suggest trying a templating module such as [mako](http://www.makotemplates.org/). -
Replied To a Post in how do I make a class instance act as a class??
I'd like to read your code Tcll, but I don't have much time. I don't think it is a good idea to use a less pythonic statement in order to … -
Replied To a Post in how do I make a class instance act as a class??
Yes you can do that by subclassing type. Here is a simplified example >>> class struct(type): ... def __new__(meta, size, fields): ... name = 'foo' ... bases = (object,) ... … -
Replied To a Post in how do I make a class instance act as a class??
You are trying to do something resembling the `collections.namedtuple` system. `struct()` will be a function which returns a class, as `namedtuple()` returns a new subclass of tuple. Namedtuple's arguments are … -
Replied To a Post in how do I make a class instance act as a class??
At first sight, it seems that you are trying to do some unpythonic design. I'd like to have the code of class `struct`. Is it an ordinary user defined class … -
Replied To a Post in runpy how to get a module object before the module's code is executed??
Yes, `mod.ugeImportModel( ... )` will work as expected after the exec statement. If you stick with python 2, add an encoding string in your module, it may ease things (the … -
Replied To a Post in Convert .bin dump to .dd or .img
I never tried this, but the `iat` tool is a converter to iso9660 (see [here](http://2buntu.com/articles/1436/mounting-bin-and-iso-files-in-linux/) for example), then [here](http://askubuntu.com/questions/388037/how-to-create-an-ubuntu-img-file-from-iso-on-ubuntu) is a discussion about iso and img... -
Replied To a Post in runpy how to get a module object before the module's code is executed??
I don't see where you need the module object. I don't think `run_module()` actually uses a module object. It uses the module mechanism to locate the file. Instead of `run_module()`, … -
Replied To a Post in runpy how to get a module object before the module's code is executed??
Well, let's take an example. We have a module file `foo.py` containing the code print('Hello from foo.py') Can you tell us precisely which statements should be executed and in which … -
Replied To a Post in How to import firefox bookmarks in konqueror
# How to import Konqueror/Rekonq bookmarks in Firefox or QupZilla# This thread would be incomplete without the reversed operation: 1. Create an empty file `~/.netscape/bookmarks.html` 2. Open the Konqueror bookmarks … -
Replied To a Post in looking for random image generator PIL script
This is perhaps a more efficient way to generate the same kind of random image >>> from PIL import Image >>> import os >>> size = (600, 600) >>> im … -
Replied To a Post in try hd 0 0
hm, sourceforge is [back](http://sourceforge.net/projects/boot-repair-cd/). -
Replied To a Post in try hd 0 0
If I were you, I would try the boot-repair disk. It always repaired my broken boots in one click. Unfortunately, sourceforge is currently down, and I'm not sure you can … -
Replied To a Post in good form
I don't agree with that. I think it is very convenient to have a main function. As soon as the code in `if __name__...` has more than a few lines … -
Replied To a Post in good form
Yes, it is excellent style. -
Replied To a Post in Python Newbie
Welcome to Daniweb. -
Replied To a Post in help in string combinations
It is very difficult to understand how the expected output is connected to the input. Can you explain this ? Also why did you post this in four different forums … -
Replied To a Post in two newb questions
I don't know Runestone Interactive. About languages, my personal opinion is that you are wasting your time learning perl at the same time as python. Both languages can be used … -
Replied To a Post in caesar cipher!
We can help, but we cannot do your homework for you. Find the ciphered version of the word `'hello'`, then try to compute it with the dictionary. -
Replied To a Post in space correction
A regex to match more than 1 space character is r' {2,}' To match a dot followed by a letter without consuming the letter, you can use r'\.(?=[a-zA-Z])' Always use raw … -
Replied To a Post in What is the last place you visited?
Marrakech, in october. It was like summer with 35°C (95°F). -
Replied To a Post in comparing a value and a list without using 'in'!
Ooops! My great solution uses 'in' :). Fortunately, we have `map()` def is_member(x, a): return any(map(lambda item: item == x, a)) -
Replied To a Post in Generate Every Possibility
You can avoid many calls to `print()` by printing multiline strings such as banner = ''' _____ ____ | ___|__ ___ | __ ) __ _ _ __ | |_ … -
Replied To a Post in returning a string that's 'n' characters long
Using `itertools.repeat()` from itertools import repeat def generate_n_chars(n, c): return ''.join(repeat(c, n)) print(generate_n_chars(10, 'z')) -
Replied To a Post in returning a string that's 'n' characters long
Here is a recursive solution def generate_n_chars(n, c): if n == 0: return '' n, r = divmod(n, 2) s = generate_n_chars(n, c) return s + s + c if … -
Replied To a Post in comparing a value and a list without using 'in'!
Another solution, using the `any()` builtin function def is_member(x, a): return any(item == x for item in a) -
Replied To a Post in Enum Help
In ubuntu there is a package `python-enum34` for this, together with 3 other enum packages for python. -
Replied To a Post in HP Deskjet F4480 in Arch
This is a link to a page with windows driver. It seems safer to download them from the [HP web site](http://h10025.www1.hp.com/ewfrf/wc/product?cc=us&lc=en&dlc=en&tmp_geoLoc=true&product=3742086) directly. For linux drivers, I would start [here](http://hplipopensource.com) at …
The End.