I need to make a script to read images from a directory, rename them, resize them to a MAX_HEIGHT, MAX_WIDTH, put a watermark logo and save them in JPG.
I was thinking on doing this with an interpreted language, like Ruby, PHP, Perl, Python, or any with the image manipulation capabilities.
Which language would you recommend for this?
...
I installed a couple of pythons in different versions with macports, and the apple python 2.6 is also working. Now I need to run a program which requires MySQLdb package support in python, and this package was installed to the python I installed by macports. The program tells me that there is no MySQLdb installed, so I guess it is the ap...
I am using pynotify and this is the code I am trying to get to work:
#! /usr/bin/python
try:
import pynotify
if pynotify.init("Telebrama Alert"):
n = pynotify.Notification('Message','This is test message')
n.set_urgency(pynotify.URGENCY_CRITICAL)
n.show()
else:
print 'There was a problem in in...
RDF is a schema-free system to represent data. However, most of the time I find myself writing a sort of well-known graph structure, and I have to build triple by triple.
In the more general case, this well known graph structure is of course not guaranteed to be complete nor fixed (e.g. something else can be added). However, if a more o...
My Questions is
Is there any regular expression engine which do Just-In-Time compiling during regex pattern parsing and use when matching/replacing the texts? or where can I learn JIT for i386 or x64 architecture?
Why I need that is,
I recently trying to benchmark python's built-in regex engine with normal C codes with around 10M da...
I would like to create web page which will print simple message
x minutes to shutdown
where 'x' would decrease once a minute automatically without clicking 'refresh' in web browser. The value will be counted from data downloaded from SNMP source (that is why I wanted to use Python). AFAIK I should use Javascript (am I right ?).
Is it...
#!/usr/bin/env python
import math
def primeTest(isPrime):
print(' {0}=testnum'.format(testnum))
if testnum%2 == 0 and testnum != 2: #if divisible by 2 and not 2
isPrime = False
print('{0} a'.format(isPrime))
print('a')
else:
numroot = round(math.sqrt(testnum))
i = 2
while i <= numroot:
if testnum%i == 0:
isPrime = False...
Is there a python script or tool available which can remove comments and docstrings from python source?
it should take care of cases like
"""
aas
"""
def f():
m = {
u'x':
u'y'
} # faake docstring ;)
if 1:
'string' >> m
if 2:
'string' , m
if 3:
'string' > m
Edit:
So a...
What are the uses for **kwargs in Python?
I know you can do an objects.filter on a table and pass in a **kargs argument.
Can I also do this for specifying time deltas i.e. timedelta(hours = time1)?
How exactly does it work? Is it classes as 'unpacking'? Like a,b=1,2?
...
Using Python2.4.5 (don't ask!) I want to parse a query string and get a dict in return. Do I have to do it "manually" like follows?
>>> qs = 'first=1&second=4&third=3'
>>> d = dict([x.split("=") for x in qs.split("&")])
>>> d
{'second': '4', 'third': '3', 'first': '1'}
Didn't find any useful method in urlparse.
...
In VIEW I want to resize uploaded image and save 2 copies of it in model real and changed
...
Long story short:
# this works as expected:
logging.error(my_object.__unicode__())
# this doesn't:
logging.error(my_object)
Same result with __str__(self).
Why?
EDIT: __str__ actually works.
...
I don't understand what these are used for, particularly the self argument? Could some please explain this to me and why on earth you would want to pass this in?
Also, I've always thought __init__ was for 'initialisation', but it didn't occur to me that I've never had to put anything in here before. Could someone give me an easy example...
I am writing a GAE application and have run into an import problem.
My app.yaml has the following lines:
- url: /py/classes/
static_dir: py/classes
- url: /py/lib
static_dir: py/lib
- url: /py/bin/signin
script: py/bin/signin.py
I am keeping a python file, titled employee.py, containing the class employee, in the classe...
I want to make a little web-frontend for copying (rsync) and encoding (ffmpeg) files for my Server using Django.
And I want to keep track of the progress of the processes.
I saw a few jquery-scripts, but they are designed to be used with uploads, and I don't know enough javascript to modify these scripts for my needs.
I want to write a ...
I've got a long running, daemonized Python process that uses subprocess to spawn new child processes when certain events occur. The long running process is started by a user with super user privileges. I need the child processes it spawns to run as a different user (e.g., "nobody") while retaining the super user privileges for the parent...
In Moc10.6, I want to put a active application to de-active, or minimize by Python
I know I could use sendKey in Windows with Python, then what about in Mac?
Thanks, guys!
...
Hi, could someone help me with a Python problem. I cant seem to find any code examples for the following scenario:
Read in user specified csv file.
Then for each row in file, calculate the mean & stddev for all numeric values in that row & print to screen.
I know csv rows are read in a string so would need to be converted to a float pr...
I have a time in ISO 8601 ( 2009-11-19T19:55:00 ) which is also paired with a name commence. I'm trying to parse this into two. I'm currently up to here:
import re
sColon = re.compile('[:]')
aString = sColon.split("commence:2009-11-19T19:55:00")
Obviously this returns:
>>> aString
['commence','2009-11-19T19','55','00']
What I'd li...
Is there a way to flag class declarations so that later you can get a list of them flagged?
Or a way to get all classes starting with a certain string ?
Or all classes that are a subclass of a specific class?
...