I want to read the primary and secondary dns addresses from the system and want to change it to any user given address.
Is this possible through some library.
An alternative approach is that I read the /etc/resolv.conf and do the changes, which is what I've done.
BTW the current solution I have is for Ubuntu OS, and for now if I get ...
I have file with contents in list form such as
[1,'ab','fgf','ssd']
[2,'eb','ghf','hhsd']
[3,'ag','rtf','ssfdd']
I want to read that file line by line using f.readline and assign each line to a list.
I tried doing this:
k=[ ]
k=f.readline()
print k[1]
I expected a result to show 2nd element in the list in first line, but it showe...
I need to be able to create forms from admin panel. Process would look like this:
I click on "Add form" then I enter email to which the form should be sent and of course several fields (probably thanks to inlines) consisting of field name, type and if it is required. User should be able to view and fill the form and submit it and the dat...
I have a series of python scripts with execute permissions in Linux. They are stored in SVN.
If I then run svn up to update them, the overwritten files are back to 644 - ie no execute permissions for anyone.
Yes I could just script it to chmod +x * afterwards, but surely there's a way to store permissions in SVN or to maintain them wh...
The following code snippet in a Django template (v 1.1) doesn't work.
{{ item.vendors.all.0 }} ==> returns "Test"
but the following code snippet, doesn't hide the paragraph!
{% ifnotequal item.vendors.all.0 "Test" %}
<p class="view_vendor">Vendor(s): {{item.vendors.all.0}} </p><br />
{% endifnotequal %}
Any tips on what's wrong...
Very simple question, hopefully. So, in Python you can split up strings using indices as follows:
>>> a="abcdefg"
>>> print a[2:4]
cd
but how do you do this if the indices are based on variables? E.g.
>>> j=2
>>> h=4
>>> print a[j,h]
Traceback (most recent call last):
File "<stdin>", line 1, in ?
TypeError: string indices must be i...
What are the differences between these built-in Python data types: list, sequence and slice? As I see it, all three essentially represent what C++ and Java call array.
...
Hi all I have to do a little script in Python.
In this script I have a variable (that represents a coordinate) that is continuously updated to a new value.
So I have to draw a red point over a image and update the point position every time the variable that contains the coordinate is updated.
I tried to explain what I need doing somethi...
Hello,
In some Python unit tests of a program I'm working on we use in-memory zipfiles for end to end tests. In SetUp() we create a simple zip file, but in some tests we want to overwrite some archives. For this we do "zip.writestr(archive_name, zip.read(archive_name) + new_content)". Something like
import zipfile
from StringIO import ...
Hello all,
I am looking to do something really simple. Merely convert a string, such as 'december' into something I can use with MySQL (such as '12').
At the moment I use a dict,
month_map = {
'december': '12',
'november': '11',
'october': '10',
'september': '09',
'august': '08',
'july': '07',
'june': '06',...
Hi,
I'm looking for a package / module / function etc. that is approximately the Python equivalent of Arc90's readability.js
http://lab.arc90.com/experiments/readability
http://lab.arc90.com/experiments/readability/js/readability.js
so that I can give it some input.html and the result is cleaned up version of that html page's "main t...
Having following Python code:
>>> from lxml import etree
>>> root = etree.XML("<a><b></b></a>")
>>> etree.tostring(root)
'<a><b/></a>'
How can I force lxml to use "long" version?
Like
>>> etree.tostring(root)
'<a><b></b></a>'
...
For my current job I am writing some long-running (think hours to days) scripts that do CPU intensive data-processing. The program flow is very simple - it proceeds into the main loop, completes the main loop, saves output and terminates: The basic structure of my programs tends to be like so:
<import statements>
<constant declaration...
instead of User.
def myview(request):
return render_to_response('tmpl.html', {'user': User.objects.get(id=1})
works fine and passes User to template.
But
def myview(request):
return render_to_response('tmpl.html', {}, context_instance=RequestContext(request))
with a context processor
def user(request):
from djang...
Hello,
I have a strange wird problem with a trigger:
I set up a trigger for update other tables after an insert in a table.
If i make an insert from mysql console, all works fine, but if i do inserts from external python script, trigger does nothing, as you can see bellow.
When i insert from console, works fine, but insert THE SAME D...
I'm trying to learn and understand more about mapping and displaying values on a map. (GIS)
At the moment I'M looking to take some values and apply those values to a tile or bin on a map.
Ideally I'd like the tile sizes to be uniform, like 100 meters, 500 meters, etc.
Is there a standard method for creating uniform tile sizes?
Or
Are ...
Is there any fast method to make a transposition of a rectangular 2D matrix in Python (non-involving any library import).? Say, if I have an array X=[[1,2,3], [4,5,6]] I need an array Y which should be a transposed version of X, so Y=[[1,4],[2,5],[3,6]].
...
(using Python-Sphinx Documentation tool)
I have a .txt log file I'd like to build into _build/html unaltered. What do I need to alter in conf.py, index.rst, etc.
Here is the layout:
src/
index.rst
some_doc.rst
somefile.txt
How do I get somefile.txt into the html build? I tried adding a line like this
to index.rst:
Con...
I have a bunch of HTML files I downloaded using HTTPLIB2 package in Python. ' ' are showing as 'Â '.
<font color="#ff0000">02/12/2004Â </font> is showing while <font color="#ff0000">02/12/2004 </font> is the desired format.
How do I replace the 'Â ' with ' ' in Python? Thanks a lot!
...
Possible Duplicate:
What does *args and **kwargs mean?
What does the * operator mean in Python, such as in code like zip(*x) or f(**k)?
How does it work internally in the interpretor?
Is it fast or not?
When is it useful and when is it not?
Should it be used in a function declaration or in a call?
...