Re: PIL cutting off letters

2007-06-19 Thread Mitja Trampus
na.TTF) and it > keeps cutting the bottom part of the the g's q's and y's off. I've had the same problems. What worked for me was to use aggdraw instead of PIL's Draw class. http://effbot.org/zone/aggdraw-index.htm Mitja -- http://mail.python.org/mailman/listinfo/python-list

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 "", line 1, in >> TypeError: cannot concatenate 'str' and 'float' objects >> >> Is this correct for Python to issue this error? > > Th

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 object

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 th

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

2006-11-28 Thread Mitja Trampus
f you explicitly want to leave file descriptors 0-2 present (Do you gain anything by not closing them? If you know, do tell...), but pointing do /dev/null, you could do: null = os.open(os.devnull,os.O_WRONLY) os.dup2(null,0) os.dup2(null,1) os.dup2(null,2) os.close(null) Untested. More info on fil

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
le throw this exception? I thought my sig.signal(sig.SIGSEGV, exceed) would kick in. QUESTION 3: Similarly, if I do the time-expensive stuff inside the python script, why do I receive SIGKILL immediately, instead of one second after SIGXCPU (which the script should catch) TIA, Mitja -- http://mail.python.org/mailman/listinfo/python-list

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 bo

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: 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

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: 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' > ObjectClassIn

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 : > print i*2 Maybe there's been a PEP, don't really know... Currently, the only sensible alternati

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 im

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)>(.*)# >>{ >> $variable = $2; >> } > regexp = re.compile(r"<(tag1)>(.*)") > line = "sometext" > match = regexp.search(line) > if match: >variable = match.group(2) Or, if you pre

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]

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

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('') > > I'm testing it on a page that includes the following source: > >