how can I get the list of cross product pairs from a list of arbitrarily long lists in python? e.g.
a = [1,2,3]
b = [4,5,6]
crossproduct(a,b) should yield [[1,4], [1, 5], [1,6], ...]
thanks.
hi,
in python, how can a custom format-specification be added, to a class ? for example, if i write a matrix class, i would like to
define a '%M' (or some such) which would then dump the entire contents of the matrix...
thank you
kind regards
anupam
Mechanize (Python) is failing with 401 for me to open http digest URLs. I googled and tried debugging but no success.
My code looks like this.
import mechanize
project = "test"
baseurl = "http://trac.somewhere.net"
loginurl = "%s/%s/login" % (baseurl, project)
b = mechanize.Browser()
b.add_password(baseurl, "user", "secret", "some Realm")
b.open(loginurl)
Hello.
I need a recommendation for a pythonic library that can marshall python objects to XML(let it be a file).
I need to be able read that XML later on with Java (JAXB) and unmarshall it.
I know JAXB has some issues that makes it not play nice with .NET XML libraries so a recommendation on something that actually works would be great.
In python the function random() generates a random float uniformly in the semi-open range [0.0, 1.0). In principle can it ever generate 0.0 (i.e. zero) and 1.0 (i.e. unity)? What is the scenario in practicality?
hi;
i need grab to firefox address bar. how to get address bar url for python ? (i need second part other browsers chrome and safari grabbing address bar but firefox is urgently).
Thanks.
Hello.
Are there any modules for python, that can be used as tftp server? I tried Tftpy, but when I try to upload something, it says:
ERROR:tftpy:Write requests not implemented at this time.
In fact, it's the only function that I need.
Hi,
Does anybody know if there is a free python chess moves validation function available somewhere?
What I need. I have a diagram stored as a string, and move candidate. What I need is to see if move candidate is valid for the diagram.
Would be really interested to see examples, if possible.
What is the most concise code you can write for dos2unix and unix2dos (CR/LF conversion) using Python 2.6+? These functions must accept a filename argument and do an in-place replacement.
I'm learning perl and everytime I search for perl stuff in the internet I get some random page with people saying that perl should die because code written in it looks like a lesson in steganography. Then they say that python is clean and stuff like that. Now, I know that those comparisons are always stupid and made by fellows that feel that languages are a extension of their boring personality so, let me ask instead: can you give me the implementation of a widely known algorithm to deal with a data structure like red-black trees in both languages so I can compare?
I'm writing a cross-platform python script that needs to know if and where Cygwin is installed if the platform is NT. Right now I'm just using a naive check for the existence of the default install path 'C:\Cygwin'. I would like to be able to determine the installation path programmatically.
The Windows registry doesn't appear to be an option since Cygwin no longer stores it's mount points in the registry. Because of this is it even possible to programmatically get a Cygwin installation path?
in a.txt i have the text(line one after the other)
login;user;name
login;user;name1
login;user
in b.txt i have the text
login;user
login;user
login;user;name2
after comparing it should display in a text file as
login;user;name
login;user;name1
login;user;name2....
How can it be done using python?
I'm learning perl and everytime I search for perl stuff in the internet I get some random page with people saying that perl should die because code written in it looks like a lesson in steganography. Then they say that python is clean and stuff like that. Now, I know that those comparisons are always stupid and made by fellows that feel that languages are a extension of their boring personality so, let me ask instead: can you give me the implementation of a widely known algorithm to deal with a data structure like red-black trees in both languages so I can compare?
I'm looking to reimplement some Tcl code that uses the socket -server construct [1].
What's the best option in Python for a small, industrial strength multi-user network-based server that includes event loop processing/integration?
[1] http://www.tcl.tk/man/tcl8.4/TclCmd/socket.htm
Hi
I have a python file that has functions and classes. now I am writting another program (in another file). and I want to start the new file with running the old file (with the function and classes). I have tried using exec(path_2_oldFile.pyw) but it didn't work.
thanks for any help
Ariel
Hi, I'm new here and on python too, and i need a code to login an HTTPS webpage
the page is: ritaj.birzeit.edu
and how can i know if its correct username or password , can you help in this :)
Does Python have a pool of all strings and are they (strings) singletons there?
More precise, in the following code one or two strings were created in memory:
a = str(num)
b = str(num)
?
Following up to Regular expression to match hostname or IP Address?
and using Restrictions on valid host names as a reference, what is the most readable, concise way to match/validate a hostname/fqdn (fully qualified domain name) in Python? I've answered with my attempt below, improvements welcome.
In Python, if I want to get the first n characters of a string minus the last character, I do:
output = 'stackoverflow'
print output[:-1]
I can do the above in Ruby with:
output = 'stackoverflow'
output.reverse[1..output.length]
Is there another way to perform this action in Ruby?
Hello everybody!
Please advise library for working with soap in python.
Now, i'm trying to use "suds". And i can't undestand how get http headers from server reply
Code example:
from suds.client import Client
url = "http://10.1.0.36/money_trans/api3.wsdl"
client = Client(url)
login_res = client.service.Login("login", "password")
variable "login_res" contain xml answer and doesnt contain http headers. But i need to get session id from them.
Thank you.
What's the easiest way to count the longest consecutive repeat of a certain character in a string? For example, the longest consecutive repeat of "b" in the following string:
my_str = "abcdefgfaabbbffbbbbbbfgbb"
would be 6, since other consecutive repeats are shorter (3 and 2, respectively.) How can I do this in Python?
thanks.
How do I download a file with progress report using python but without supplying a filename.
I have tried urllib.urlretrieve but I seem to have to supply a filename for the download.
As a maintenance issue I need to routinely (3-5 times per year) copy a repository that is now has over 20 million files and exceeds 1.5 terabytes in total disk space. I am currently using RICHCOPY, but have tried others. RICHCOPY seems the fastest but I do not believe I am getting close to the limits of the capabilities of my XP machine.
I am toying around with using what I have read in The Art of Assembly Language to write a program to copy my files. My other thought is to start learning how to multi-thread in Python to do the copies.
I am toying around with the idea of doing this in Assembly because it seems interesting, but while my time is not incredibly precious it is precious enough that I am trying to get a sense of whether or not I will see significant enough gains in copy speed. I am assuming that I would but I only started really learning to program 18 months and it is still more or less a hobby. Thus I may be missing some fundamental concept of what happens with interpreted languages.
Any observations or experiences would be appreciated. Note, I am not looking for any code. I have already written a basic copy program in Python 2.6 that is no slower than RICHCOPY. I am looking for some observations on which will give me more speed. Right now it takes me over 50 hours to make a copy from a disk to a Drobo and then back from the Drobo to a disk. I have a LogicCube for when I am simply duplicating a disk but sometimes I need to go from a disk to Drobo or the reverse. I am thinking that given that I can sector copy a 3/4 full 2 terabyte drive using the LogicCube in under seven hours I should be able to get close to that using Assembly, but I don't know enough to know if this is valid. (Yes, sometimes ignorance is bliss)
The reason I need to speed it up is I have had two or three cycles where something has happened during copy (fifty hours is a long time to expect the world to hold still) that has caused me to have to trash the copy and start over. For example, last week the water main broke under our building and shorted out the power.
Hi
i wont to store connection tu soap server in python session.
When i try to do this,
session['all']=Client(url)
I getting error:
MethodNotFound: Method not found: 'server.___getinitargs___'
How to store suds connection in session?
When debugging in PHP I frequently find it useful to simply stick a var_dump($foo, $bar, ...) in my code to show me the the what a variable is, what is value is, and the same for anything that it contains.
What is a good python equivalent for this?
I have seen several things in my Google searching that are somewhat equivalent, but nothing that is the same or better.