Hi everyone,
How do I return the index in the original list of the nth largest items of an iterable
heapq.nlargest(2, [100, 2, 400, 500, 400])
output = [(3,500), (2, 400)]
This already cost me a couple hours. I can't figure it out.
...
I have the following structure:
config
|-- groups
|-- rootgroup
|-- group1 (includes rootgroup)
|-- group2 (includes group1)
|-- group3 (includes rootgroup)
|-- users
|-- Fred (includes group3 and group2)
So inheritance tree for Fred will look like:
_Fred_
v v
group2 group3
v v
group1 ...
hello everybody,
I have to consolidate and possibly rewrite a bunch of bash scripts that verify that incoming smime messages are valid (i.e. encrypted with company's private key and signed a certain set of public keys)
This bunch of bash is going to be replaced by a small application, written possibly in Python with the help of M2C...
I'm programming in Python 3 and I'm having a small problem which I can't find any reference to it on the net.
As far as I understand the default string in is utf-16, but I must work with utf-8, I can't find the command that will convert from the default one to utf-8.
I'd appreciate your help very much.
...
I'm using Python's ssl library with an encrypted keyfile. However every time I wrap a socket, I'm prompted for the passphrase.
Enter PEM pass phrase:
How can I give the passphrase just once, and have Python hold the decrypted key open for the lifetime of the process?
I'm very interested in the canonical openssl command line or C equi...
Again, the same question. The reason is - I still can't make it work after reading the following:
http://stackoverflow.com/questions/1085071/real-time-intercepting-of-stdout-from-another-process-in-python
http://stackoverflow.com/questions/527197/intercepting-stdout-of-a-subprocess-while-it-is-running
http://stackoverflow.com/question...
is it possible to use CMYK overprinting without using the CMYKColorSep class, which always generates a new seperate color in the printer settings, i just want to use overprinting with the standard 4 CMYK inks (colour-separated PDF output, as stated in the 2.4 changelog)
here my example code (reportlab 2.4 needed):
from reportlab.graphi...
hi ,
HI
Im Dileep, from india. Im computer science student
I have been using pdf shuffler for merging pdf documents for my
project purposes. The software is very useful and provides a simple
interface . Now i feel to make a simple modification to the software
which will make it more useful to me
At the time of importing now whole pdf...
For any N, let f(N) be the last five
digits before the trailing zeroes in
N!. For example,
9! = 362880 so f(9)=36288
10! = 3628800 so f(10)=36288
20! = 2432902008176640000 so f(20)=17664
Find f(1,000,000,000,000)
I've successfully tackled this question for the given examples, my function can correctly find f(9), f(10),...
i need to write a code in python that will delete the required file from the amazon s3 bucket, i am able to make connections to the amazon s3 bucket and also able to save files, i just want to know how to delete a file? please help if anyone knows.
...
I'm hoping there's no performance or other disadvantage in attempting to avoid long chains of conditional if/elif statements this way:
errstr = {404: "404 Not Found",
405: "405 Method Not Allowed"}
if code in errstr:
print errstr[code];
...
I have a UTF8 string with combining diacritics. I want to match it with the \w regex sequence. It matches characters that have accents, but not if there is a latin character with combining diacritics.
>>> re.match("a\w\w\wz", u"aoooz", re.UNICODE)
<_sre.SRE_Match object at 0xb7788f38>
>>> print u"ao\u00F3oz"
aoóoz
>>> re.match("a\w\w\wz...
I'm looking for a way to implement SSH Dynamic Port Forwarding ('ssh -D') under Python. The problem is that it has to work under Windows, i.e., running SSH with popen/pexec/etc. won't work. Any ideas?
cheers,
Bruno Nery.
...
For python, I could use unpacking arguments as follows.
def hello(x, *y, **z):
print 'x', x
print 'y', y
print 'z', z
hello(1, *[1,2,3], a=1,b=2,c=3)
hello(1, *(1,2,3), **{'a':1,'b':2,'c':3})
x = 1
y = (1, 2, 3)
z = {'a': 1, 'c': 3, 'b': 2}
But, I got an error if I use keyword argument as follows.
hello(x=1, *(1,2,...
Hello,
I need following structure in python.
public class Circle
{
int member1;
int member2;
int member3;
public Circle(member1)
{
this.member1 = member1;
initializeRest();
}
private intializeRest()
{
//do lot of computation to get result1 & result2
this.member2 = resu...
Hello
I have a such code:
for file in file_list:
shutil.copyfile(file,newpath)
#do further actions
And here is the question, at #do further actions I use the copied f iles thus I need to make sure the shutil.copyfile functions finish their task. How can I make sure of this ?
...
I'm in the process of experimenting a bit with the twisted libraries for IRC servers/clients. I've found a few good examples of how to implement an IRC client but seem to find anything good on the server side of things. Could anybody provide some insight into how to create a basic IRC server in twisted?
Edit: What about building off of ...
Dear all,
i am parsing some html form with Beautiful soup. Basically i´ve around 60 input fields mostly radio buttons and checkboxes. So far this works with the following code:
from BeautifulSoup import BeautifulSoup
x = open('myfile.html','r').read()
out = open('outfile.csv','w')
soup = BeautifulSoup(x)
values = soup.findAll('input',...
Not sure if I'm missing something obvious, but here's what is happening:
I have a python 2.4.3 script that contains several RegEx objects. Below one of the regex objects is searching for all matches in a string (tMatchList). Even if tMatchList is not null, it is printing an empty set after the 'if p:' step. This behavior occurs even if i...
Hello,
I am trying to increment a version number using regex but I can't seem to get the hang of regex at all. I'm having trouple with the symbols in the string I am trying to read and change. The code I have so far is:
version_file = "AssemblyInfo.cs"
read_file = open(version_file).readlines()
write_file = open(version_file, "w")
...