Hello. I'm wondering if I can recv/send data on a raw socket before wrapping it - I've looked through the documentation and searched for it but couldn't find anything specific. What I basically want to do:
client, addr = listeningSocket.accept()
client.recv(32)
client.send(b'hello')
client.setblocking(0)
sslSocket = ssl.wrap_socket(clie...
Since there is a python 3.x, why don't we use it?
Why do we still use 2.x?What's the difference?
...
I am looking to generate passwords using strings typed by the user, the book I am reading recommends using sha over md5 because it is considered stronger.
sha however has been deprecated and I am now using the hashlib module to encrypt me strings in a similar way to that shown here: http://docs.python.org/py3k/library/hashlib.html#modul...
With python 3, I'd like to get a handle to another window (not part of my application) such that I can either:
a) directly capture that window as a screenshot or
b) determine its position and size and capture it some other way
In case it is important, I am using Windows XP.
I found this solution, but it is not quite what I ne...
Hi,
I've some lists and more complex structures containing floats. When printing them, I see the floats with a lot of decimal digits, but when printing, I don't need all of them.
So I would like to define a custom format (e.g. 2 or 3 decimals) when floats are printed.
I need to use floats and not Decimal. Also, I'm not allowed to trunca...
More and more libraries are being ported to Python 3, and I suspect the changes will happen more and more rapidly as time goes on. However, as a non-newbie to Python, there are quite a few 3rd party libraries I use (matplotlib, pygame, pyGTK, Tkinter, among others). I know I should just be able to go to their site(s) to find out if they ...
There are several modules that were renamed in Python 3 and I'm looking for a solution that will make your code work in both python flavors.
In Python 3, __builtin__ was renamed to builtins. Example:
import __builtin__
#...
__builtin__.something # appearing multiple times ("something" may vary)
...
I'd like to make a drag-n-drop function for a widget. The code is this:
from tkinter import *
root = Tk()
root.config(background = "red", width = 500, height = 500)
root.title("root")
def frameDrag(event):
frame.place(x = event.x , y = event.y)
frame = Frame(root, width = 60, height = 30)
frame.place(x=0, y=0)
frame.bind("<B1-Mo...
Like csv.reader() are there any other functions which can read .rtf, .txt, .doc files in Python?
...
In Python 2, converting the hexadecimal form of a string into the corresponding unicode was straightforward:
comments.decode("hex")
where the variable 'comments' is a part of a line in a file (the rest of the line does not need to be converted, as it is represented only in ASCII.
Now in Python 3, however, this doesn't work (I assume ...
I'm working on a series of parsers where I get a bunch of tracebacks from my unit tests like:
File "c:\Python31\lib\encodings\cp1252.py", line 23, in decode
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x81 in position 112: character maps to <undefined>
T...
I'm trying to get OpenCV working with Python 3. A friend showed me ctypes-opencv that appears to work with Python 3. The problem is I totally can not figure out how to "install" or get any code working. I've followed all instructions I could find from a few people mentioning installs on google and none of those seemed to work or I couldn...
The following python code will result in n (14) being printed, as the for loop is completed.
for n in range(15):
if n == 100:
break
else:
print(n)
However, what I want is the opposite of this. Is there any way to do a for ... else (or while ... else) loop, but only execute the else code if the loop did break?
...
I have been programming using Python for slightly more than half an year now and I am more interested in Python internals rather than using Python to develop applications. Currently I am working on porting a few libraries from Python2 to Python3. However, I have a rather abstract view on how to make port stuff over from Python2 to Python...
for python2.x py2app will do the work. But for python3 code which one is alternate to go ahead?
Or any other way to get single .app file?
...
I wish to convert a string to md5 and to base64. Here's what I achieved so far:
base64.urlsafe_b64encode("text..." + Var1 + "text..." +
hashlib.md5(Var2).hexdigest() + "text...")
Python raises a TypeError which says: Unicode objects must be encoded before hashing.
Edit: This is what I have now:
var1 = "hello"
var2 = "world"
b1 ...
i would like to start a python file (.py) with arguments and receive the output of it after it is finished. i have already heard about "popen" and "subprocess.call" but i could not find any tutorials how to use them
does anyone know a good tutorial?
...
Just like the title says...
Example: I have a file called copy.py. That file wants a path to a file/folder which it will move to another directory and will then return "done" if it successfully moved the file. For some reason I have to run my copy.py file from another python program (it's not given that both files are in the same direct...
Usually one comes across this problem in python3.0 while attempting a split() method on a bytes type object.
TypeError: Type str does'nt support the buffer API
This issue can be resolved by using the split method after decoding the bytes type object.
However, I find the error message rather ambiguous. Am I missing some underlying ...
Where can I find an online interpreter for Python 3? I'm learning Python but can't install it at work where I'd like to do some practice.
Thanks!
Sorry to repeat the question; I can't bump earlier posts and was just hoping there is one out there now.
...