I'm trying to declare a few simple variables as part of a function in a very basic collision detection programme. For some reason it's rejecting my variables (although only some of them even though they're near identical). Here's the code for the function;
def TimeCheck():
timechecknumber = int(time.time())
timecheckdiv = backco...
Does anyone know how I can determine the server and share name of a mapped network drive?
For example:
import win32file, win32api
for logDrive in win32api.GetLogicalDriveStrings().split("\x00"):
if win32file.GetDriveType(logDrive) != win32file.DRIVE_REMOTE: continue
# get server and share name here
Is there a handy api call for ...
If you invoke the cpython interpreter with the -i option, it will enter the interactive mode upon completing any commands or scripts it has been given to run. Is there a way, within a program to get the interpreter to do this even when it has not been given -i? The obvious use case is in debugging by interactively inspecting the state w...
I'm building a relatively simple programme to test collision detection, it's all working fine at the moment except one thing, I'm trying to make the background colour change randomly, the only issue is that it appears to be completely skipping the function to do this;
import pygame
from pygame.locals import *
import random, math, time, ...
The prefuse visualization toolkit is pretty nice, but for Java. I was wondering if there was something similar for python. My primary interest is being able to navigate dynamic graphs.
...
Python provides several methods to create threads. Which provides
the best API and the most control?
Thanks.
...
I realize "fast" is a bit subjective so I'll explain with some context. I'm working on a Python module called psutil for reading process information in a cross-platform way. One of the functions is a pid_exists(pid) function for determining if a PID is in the current process list.
Right now I'm doing this the obvious way, using EnumProc...
I don't expect to need much more than basic CRUD type functionality. I know that SQLAlchemy is more flexible, but the syntax etc of sqlobject just seem to be a bit easier to get up and going with.
...
Coming from the .NET world over to Python and PyQt4. Was wondering if anyone is familiar with any functionality that would allow me to bind data to Qt widgets? For example (using sqlalchemy for data):
gems = session.query(Gem).all()
list = QListWidget()
list.datasource = gems
Is such a thing possible?
...
Say I have a variable named choice it is equal to 2. How would I access the name of the variable? Something equivalent to
In [53]: namestr(choice)
Out[53]: 'choice'
for use in making a dictionary. There's a good way to do this and I'm just missing it.
EDIT:
The reason to do this is thus. I am running some data analysis stuff where I...
How can I use beautiful soup and selectorgadget to scrape a website. For example I have a website - (a newegg product) and I would like my script to return all of the specifications of that product (click on SPECIFICATIONS) by this I mean - Intel, Desktop, ......, 2.4GHz, 1066Mhz, ...... , 3 years limited.
After using selectorgadget I ...
There is a questions asking how to simulate static variables in python.
Also, on the web one can find many different solutions to create static variables. (Though I haven't seen one that I like yet.)
Why doesn't Python support static variables in methods? Is this considered unpythonic or has it something to do with Python's syntax?
Ed...
We have a new for a fairly simple workflow system, specifically focused upon business documents. It essentially accepts different types of documents (purchase requests, invoices, etc) and routes them to different roles and flows based on variables attached to them (total dollar amount, etc).
I'm open to either using an existing one or w...
I need to deliver one and half hour seminar on programming for students at the department of mathematics.
I have chosen python as language.
What should be content of my presentation ?
What are good resources available ?
What is necessity of programming for maths students?
How will knowledge of programming will help them?
Thank you...
I have a lot of images in a folder, and I would like to find images with a similar color to a pre chosen image.
I would like to be able to do something like:
python find_similar.py sample.jpg
and have that return something like:
234324.jpg
55.jpg
9945.jpg
345434.jpg
104.jpg
Is this doable?
...
How can I (easily) take a string such as
'sin(x)*x^2'
which might be entered by a user at runtime and produce a python function that could be evaluated for any value of x? Does anyone know of any libraries or modules that takes care of this sort of thing?
...
What would be the best way to go about getting a function that returns a random English word (preferably a noun), without keeping a list of all possible words in a file before hand?
Edit: Sorry for the failure of wording. After the tiniest amount of thought i suppose i am after some sort of online list or api that would not require me t...
I recently read the questions that recommend against using switch-case statements in languages that do support it. As far as Python goes, I've seen a number of switch case replacements, such as:
Using a dictionary (Many variants)
Using a Tuple
Using a function decorator (http://code.activestate.com/recipes/440499/)
Using Polymo...
I've been using Ipython for my command line on XP for, oh... ages! However, being a sucker for the eye-candy I always wanted the console window to be a little cooler e.g. like a Terminal window on Linux.
Today I found Console2 and my heart was filled with joy...
However, there is something rotton in the state of large / multi-line outp...
My application is written in python. What I am doing is I am running a script on each email received by postfix and do something with the email content. Procmail is responsible for running the script taking the email as input. The problem started when I was converting the input message(may be text) to email_message object(because the lat...