Dear All,
I'm working on a Python project that retrieves an image from MSSQL. My code is able to retrieve the images successfully but with a fixed size of 63KB. if the image is greater than that size, it just brings the first 63KB from the image!
The following is my code:
#!/usr/bin/python
import _mssql
mssql=_mssql.connect('<ServerIP...
Apologies for the noob Python question but I've been stuck on this for far too long.
I'm using python sockets to receive some data from a server. I do this:
data = self.socket.recv(4)
print "data is ", data
print "repr(data) is ", repr(data)
The output on the console is this:
data is
repr(data) is '\x00\x00\x00\x01'
I want...
I want to use something like this:
os.path.split("C:\\a\\b\\c")
With this kind of output:
('C:\a\b', 'c')
However I want it to work on other delimiters like this:
method ('a_b_c_d')
With this kind of output:
('a_b_c', 'd')
...
In spirit of the existing "what's your most useful C/C++ snippet" - thread:
Do you guys have short, monofunctional Python snippets that you use (often) and would like to share with the StackOverlow Community? Please keep the entries small (under 25
lines maybe?) and give only one example per post.
I'll start of with a short snippet i ...
Ex.
If I have something like this:
class C(object):
@classmethod
def f(cls, x):
return x + x
This will work:
c = C()
c.f(2)
4
But is that bad form?
Should I only call
C.f()
or
c.__class__.f()
Obviously, this would only make sense in cases where f doesn't interact with self/cls expecting it to be class.
?
...
I want to automate playing a video game with Python. I want to write a script that can grab the screen image, diff it with the next frame and track an object to click on. What libraries would be useful for this other than PIL?
...
Upgraded my laptop to Ubuntu 9.04 and runing latest trunk of django and my test suite has tripled in time to run.
Python2.6
Mysql
Django 1.1 beta 1 SVN-10137
...
Hi ,
I am a newbie to python. I do have two modules. Model M1 and module m2.
From m2 , i need to refer m1 and m2 and m1 resides at two different locations in disk.
When I am trying to import m1 before executing m2 , of course it's saying can't find m1.
How I can point my interpreter to m1's location.
Thanks
J
...
Duplicate:
Cross-platform gui toolkit for deploying Python applications
I want to create a GUI application in python. Which library is best one ?
...
So you've got some legacy code lying Python around in a fairly hefty project. How can you find and delete dead functions?
I've seen these two references: Find unused code and Tool to find unused functions in php project, but they seem C# and PHP specific, respectively.
Is there a Python tool that'll help you find functions that aren't ...
I was able to configure NetBeans for 2.6.1 by going to to the Python Platform Manager, creating a new platform, and pointing NetBeans at python.exe where I installed 2.6.1. However, when I follow the exact same steps for 3.0, I get an error in the NetBeans console that says "SyntaxError: invalid syntax".
If it matters, Python is install...
Let's say I have a list like:
my_list = [[1,2,3],[4,5,6],[7,8,9]]
How do I alter every value in the list without doing?:
for x in range(0, 3):
for y in range(0, 3):
my_list[x][y] = -my_list[x][y]
I have tried to simplify this by doing
my_list = [[[-a, -b, -c] for [a, b, c] in d] for d in my_list]
but the values remai...
I want to make some python scripts to create an "Appliance" with VirtualBox. However, I can't find any documentation anywhere on making calls to VBoxService.exe. Well, I've found stuff that works from OUTSIDE the Machine, but nothing from working from inside the machine.
Does anyone know anything about this? If there's a library for ano...
I'm planning on learning Python, and I have a copy of O'Reilly Learning Python 3rd Ed. which covers Python 2.5. However, I seem to remember reading that Python 3 introduced fairly significant changes. Would it be in my best interest then to start out with a book that covers Python 3?
Related
To learn python 2 then 3, or 3 from the sta...
I want to allow users to validate their email address by clicking on a link. The link would look something like
http://www.example.com/verifyemail?id=some-random-string
When I am sending this email, I want to be able to easily generate this 'some-random-string' from row id of user, an integer. and when user clicks on this link, generat...
I hope this is a simple python question.
When I try the following in the python interpreter:
>>> import process
>>> def test(cmd):
... p = subprocess.Popen(cmd)
...
>>> test(['ls', '-l'])
It will run the ls -l, but I need to hit "return" to get a new >>> prompt.
However, when I try the following:
>>> import process
>>> def test(c...
I'm working on a problem which uses a python class and has a constructor function to give the number of sides to one die and a function to roll the die with a random number returned based on the number of sides. I realize the code is very basic, but I'm having troubles understanding how to sum up the total of three rolled dice with diffe...
Hi, I have been using a flash card program called Mnemosyne which uses python script. A short time ago my database of flash cards became inaccessible after my computer froze and I had to shut it down manually. Whenever I try to load the data base containing my cards I get this error.
Invalid file format
Traceback(innermost last):
Fi...
I need to know which key is being pressed right now. I'm not looking to capture some specific keys to trigger an event or anything like that,
I want to know which keys are pressed now and display a list of them.
I also need to capture special keys like F1 ... F12, shift, alt, home, windows, etc. Basically all keys on the keyboard.
Ho...
For academic and performance sake, given this crawl recursive web-crawling function (which crawls only within the given domain) what would be the best approach to make it run iteratively? Currently when it runs, by the time it finishes python has climbed to using over 1GB of memory which isn't acceptable for running in a shared environme...