I want someone to type words in the console, and autocomplete from a list when they hit "tab" key. However, raw_input won't return a string until someone hits [Enter].
How do I read characters into a variable until the user hits [Enter]?
*Note: I don't want to use import readline for autocompletion because of OS issues.
...
I would like to implement a Python script which has the same functionality as http://www.greymagic.com/security/tools/decoder/
Is the encoding rule open for this type of javascript code encoding?
Thanks.
An example of this:
<Script LANGUAGE="JScript.Encode">#@~^TBQAAA==-mD~kk9P'8*R0%p\CD,wr[&fP{~xhPz..lH`EFTc+{W*v~Eq!W {*+B~vqZc+GW{E~v8...
I'm unpickling a NetworkX object that's about 1GB in size on disk. Although I saved it in the binary format (using protocol 2), it is taking a very long time to unpickle this file---at least half an hour. The system I'm running on has plenty of system memory (128 GB), so that's not the bottleneck.
I've read here that pickling can be spe...
As per the title, I'm trying to parse an XML file containing an xs:duration data type. I'd like to convert that into a Python timedelta object, which I can then use in further calculations.
Is there any built-in way of doing this, similar to the strptime() function? If not, what is the best way to achieve this?
...
I have a list which contains a number of things:
lista = ['a', 'b', 'foo', 'c', 'd', 'e', 'bar']
I'd like to get the first item in the list that fulfils a predicate, say len(item) > 2. Is there a neater way to do it than itertools' dropwhile and next?
first = next(itertools.dropwhile(lambda x: len(x) <= 2, lista))
I did use [item f...
First of all, I don't think this question is a duplicate of
http://stackoverflow.com/questions/2208828/detect-64bit-os-windows-in-python
because imho it has not been thoroughly answered.
The only approaching answer is:
Use sys.getwindowsversion() or the existence of PROGRAMFILES(X86) (if 'PROGRAMFILES(X86)' in os.environ)
But: ...
Hi, I have server with django on it, this server runs some manage.py commands and update database. Now I need to move some of this tasks to different servers. I don't want to allow remote db access and need some tool\lib to be able to start task on remote servers by main server's command and update tasks code/add new tasks. I have ssh ac...
Hello, I have such code in Python:
def send_start(self, player):
for p in self.players:
player["socket"].send_cmd('<player id="%s" name="%s" you="%s" avatar="*.png" bank="%s" />'%(self.players.index(p)+1, p['name'], int(player["pid"]==p["pid"]), 0))
player["socket"].send_cmd('<game playerid="%s" />'%(self.turnnow))
p...
I have some nested datastructures, each something like:
[ ('foo', [ {'a':1, 'b':2},
{'a':3.3, 'b':7} ]),
('bar', [ {'a':4, 'd':'efg', 'e':False} ]) ]
I need to compare these structures, to see if there are any differences. Short of writing a function to explicitly walk the structure, is there an existing library o...
How would i get the current URL with Python,
I need to grab the current URL so i can check it for query strings e.g
requested_url = "URL_HERE"
url = urlparse(requested_url)
if url[4]:
params = dict([part.split('=') for part in url[4].split('&')])
also this is running in Google App Engine
...
Suppose i want to store 3 lines in a file both in python and C++ .
I want to store it like this
aaa
bbb
ccc ..
But i am giving ccc input first then bbb then aaa. How will I traverse the file from bottom to top and also store from bottom to top/?
...
hi,
i have a simple server/client. and i am using the netcat as the client to test the server. if i stop the server before the client exit, i will not be able to start the server again for a while and i go this error:
"
[Errno 98] Address already in use
"
but if i close the client first, then the server stops, i will not have this issu...
Can anyone tell me how to add the shutdown.exe to python and how . i also want to set and variables like shutdown.exe -f -s -t 60
...
a='aa'
>>> f=open("key.txt","w")
>>> s=str(a)
>>> f.write(s)
and still the key.txt file remains blank .. why?
...
Hello, I have got some code to pass in a variable into a script from the command line. I can pass any value into function for the var arg. The problem is that when I put function into a class the variable doesn't get read into function. The script is:
import sys, os
def function(var):
print var
class function_call(object):
def...
Is there a fast way to check if one set entirely contains another?
Something like:
>>>[1, 2, 3].containsAll([2, 1])
True
>>>[1, 2, 3].containsAll([3, 5, 9])
False
...
I'm a python newbie so I apologize in advance if this question has been asked before.
I am building out an application in GAE and need to generate a report that contains the values for a user-defined subset of fields.
For example, in my db model, CrashReport, I have the following fields:
entry_type
entry_date
instance_id
build_id
cra...
Hello!
I'm working remotely on a machine that's pretty restrictive. I can't install any software, and it won't accept my X11 session, so I have no display. The machine currently has pylab installed, and I'd like to use it to plot something and then save it for viewing on another computer. However, it seems there's no way to even create ...
Hello,
I am trying to pass a variable from a function to a class. Example code is below:
def hello(var):
return var
class test():
def __init__(self):
pass
def value(self):
print var
hello(var)
test = test()
test.value()
I would like to pass var into the class test().
Thanks for any help.
...
I recently discovered Python's property built-in, which disguises class method getters and setters as a class's property. I'm now being tempted to use it in ways that I'm pretty sure are inappropriate.
Using the property keyword is clearly the right thing to do if class A has a property _x whose allowable values you want to restrict; i....