Re: PIL cutting off letters

2007-06-19 Thread Mitja Trampus
Matt Haggard wrote: I'm using PIL (Python Imaging Library) to generate button images. They consist of a left end image, a middle, repeating image and a right side image anyway, that's not important I'm using a TTF font for the text of the button (Verdana.TTF) and it keeps cutting the

Re: Correct behavior?

2007-04-27 Thread Mitja Trampus
[EMAIL PROTECTED] wrote: On Apr 26, 8:34 pm, asker [EMAIL PROTECTED] wrote: But: print %15.2f % a+b Traceback (most recent call last): File stdin, line 1, in module TypeError: cannot concatenate 'str' and 'float' objects Is this correct for Python to issue this error? The % operator

Re: Inconsistency in dictionary behaviour: dict(dict) not calling __setitem__

2006-12-12 Thread Mitja Trampus
Fredrik Lundh wrote: Almad wrote: However, when constructing dictionary with dictionary in constructor like d = RegisterMap({'k':'v'}), __setitem__ is not called why should it do that? dict() is a concrete implementation, not a template class for the creation of dict-like objects. I

Re: best way to align words?

2006-11-30 Thread Mitja Trampus
Robert R. wrote: Hello, i would like to write a piece of code to help me to align some sequence of words and suggest me the ordered common subwords of them a trouble i have if when having many different strings my results tend to be nothing while i still would like to have one of the, or

Re: Really closing stdout (was: fork and exit needed?)

2006-11-28 Thread Mitja Trampus
Nick Craig-Wood wrote: open STDOUT, '/dev/null'; sys.stdout = open(os.devnull, 'w') $ ls -l /proc/32004/fd total 4 lrwx-- 1 ncw ncw 64 Nov 28 09:55 0 - /dev/pts/17 lrwx-- 1 ncw ncw 64 Nov 28 09:55 1 - /dev/pts/17 lrwx-- 1 ncw ncw 64 Nov 28 09:55 2 - /dev/pts/17 l-wx-- 1

Re: Random image text generation?

2006-11-12 Thread Mitja Trampus
[EMAIL PROTECTED] wrote: Is there a module out there that will generate an image with a random text string such as the confirmation images you see on various websites? They're called captcha images or captchas for short. Googling for python captcha returns several hits; see what you like... --

Confusion with resource.setrlimit() and subprocesses

2006-07-05 Thread Mitja Trampus
I am trying to run a subprocess within given time and memory restrictions. The resource module kind of works for me, but I do not understand why and am seeking an explanation. Also, the signal module is not behaving as I'd expect it to. Demo code with questions: == import subprocess as

Re: Python in HTML

2006-06-23 Thread Mitja Trampus
[EMAIL PROTECTED] wrote: Does anyone know of a way to embed python scripts into html, much like you would javascript or php? Two very different things, JS and PHP... First make sure you know what you're after. If you want PHP-like embedding of code, google for python server pages. Several

Re: Reuseable iterators - which is better?

2006-06-23 Thread Mitja Trampus
zefciu wrote: In the tutorial there is an example iterator class that revesrses the string given to the constructor. The problem is that this class works only once, unlike built-in types like string. How to modify it that it could work several times? I have tried two approaches. They both

Re: a string problem

2006-06-13 Thread Mitja Trampus
John Salerno wrote: [EMAIL PROTECTED] wrote: hi if i have a some lines like this a ) here is first string b ) here is string2 c ) here is string3 When i specify i only want to print the lines that contains string ie ... And I'm actually ashamed to admit that I know the RE way, but not

Re: Sampling a population

2006-06-02 Thread Mitja Trampus
Brian Quinlan wrote: The fastest algorithm that I have been able to devise for doing so is: O(n * log(len(lst))). Can anyone think or a solution with a better time complexity? If not, is there an obviously better way to do this (assuming n is big and the list size is small). If list is

Re: maximum() efficency

2006-03-26 Thread Mitja Trampus
Steve R. Hastings wrote: I was looking at a Python function to find the maximum from a list. The original was more complicated; I simplified it. The built-in max() function can replace the simplified example, but not the original. But you forgot to shuw us the original... [snip several

Re: For loop and list comprehension similarity

2006-03-26 Thread Mitja Trampus
[EMAIL PROTECTED] wrote: On more than one occasion, I found myself wanting to use a conditional loop like this (with Invalid syntax error, of course): for i in c if test: print i*2 Maybe there's been a PEP, don't really know... Currently, the only sensible alternative

Re: object references

2006-03-26 Thread Mitja Trampus
DrConti wrote: class ObjectClass: Test primary Key assignment if __name__ == __main__: ObjectClassInstantiated=ObjectClass() ObjectClassInstantiated.AnAttribute='First PK Elem' ObjectClassInstantiated.AnotherOne='Second PK Elem'

Re: help in converting perl re to python re

2006-03-03 Thread Mitja Trampus
i have some regular exp code in perl that i want to convert to python. if $line =~ m#(tag1)(.*)/\1# { $variable = $2; } regexp = re.compile(r(tag1)(.*)/\1) line = tag1sometext/tag1 match = regexp.search(line) if match: variable = match.group(2) Or, if you prefer

Re: Shortest prime number program

2006-02-11 Thread Mitja Trampus
swisscheese wrote: I figured someone out there must have written a minimal code size prime number generator. I did not find one after a bit of searching around. For primes up to 100 the best I could do was 70 characters (including spaces): r=range(2,99) m=[x*y for x in r for y in r] [x

Re: tricky regular expressions

2006-02-07 Thread Mitja Trampus
[hint: posting the same question in newsgroups generally does not help to get responses any quicker] Ernesto wrote: The string I'm getting data from looks like this: [USELESS DATA] Request : Play [USELESS DATA] Title: Beethoven's 5th [USELESS DATA] Request : next [USELESS DATA]

Re: Trying to find regex for any script in an html source

2005-12-21 Thread Mitja Trampus
28tommy wrote: Hi, I'm trying to find scripts in html source of a page retrieved from the web. I'm trying to use the following rule: match = re.compile('script [re.DOTALL]+ src=[re.DOTALL]+') I'm testing it on a page that includes the following source: script language=JavaScript1.2

Re: python cgi script not understood as html

2005-10-24 Thread Mitja Trampus
Philippe C. Martin wrote: Hi, The following code outputs the actual HTML text to the browser, not the interpreted text. Any idea ? html_ok = Content-Type: text/html\n html ... Avoid the starting newline (before content-type). Add at least TWO newlines after content-type. Or

Re: Python cgi

2005-10-21 Thread Mitja Trampus
jbrewer wrote: I'm currently writing my first CGI script (in Python), and I keep getting an error I don't know how to address. I'm not sure if this is a Python or Apache error, but I suspect it's an Apache config thing. I suspect it's neither :) Make sure your HTML form looks like form