Re: Writing byte stream as jpeg format to disk

2010-08-27 Thread Bryan
Robert Kern wrote: > Please > follow our advice. Split using b'\r\n\r\n' and use the maxsplit=1 argument to > make sure that you do not split on spurious b'\r\n\r\n' sequences inside the > JPEG body. Do not decode the bytes. Correct, and I'll add that this is a case where we might want to be bette

Re: Reading the access attributes of directories in Windows

2010-08-27 Thread Rami Chowdhury
On Wed, Aug 25, 2010 at 05:04, Lawrence D'Oliveiro wrote: > In message , Nobody wrote: > >> Having this as a separate permission allows normal users to add entries to >> log files but not to erase existing entries. > > Unix/Linux systems can do this already. Ooh, I didn't know that -- what combin

Re: Reading the access attributes of directories in Windows

2010-08-27 Thread Nobody
On Fri, 27 Aug 2010 13:28:46 +0600, Rami Chowdhury wrote: >>> Having this as a separate permission allows normal users to add entries >>> to log files but not to erase existing entries. >> >> Unix/Linux systems can do this already. > > Ooh, I didn't know that -- what combination of permissions wo

Re: Writing byte stream as jpeg format to disk

2010-08-27 Thread Nobody
On Thu, 26 Aug 2010 23:56:26 -0700, Bryan wrote: >> follow our advice. Split using b'\r\n\r\n' and use the maxsplit=1 >> argument to make sure that you do not split on spurious b'\r\n\r\n' >> sequences inside the JPEG body. Do not decode the bytes. > > Correct, and I'll add that this is a case wh

palindrome iteration

2010-08-27 Thread Baba
level: beginner the following code looks ok to me but it doesn't work. I would like some hints as to where my reasoning / thought goes wrong def i_palindrome(pal): while len(pal)>1: if pal[0] == pal[-1]: pal=pal[1:-1] return True print i_palindrome('annab') my reasoning: - i check the l

Re: palindrome iteration

2010-08-27 Thread Xavier Ho
One possible reason I can think of - "- exiting this loop means all compared chars were identical hence it is a palindrome and i return True" is probably incorrect reasoning. Think again. Also, you may consider posting your code in a way that preserves the whitespace characters. Cheers, Xav On

Re: palindrome iteration

2010-08-27 Thread Peter Otten
Baba wrote: > level: beginner > > the following code looks ok to me but it doesn't work. I would like > some hints as to where my reasoning / thought goes wrong > > def i_palindrome(pal): > while len(pal)>1: > if pal[0] == pal[-1]: >pal=pal[1:-1] > return True Do yourself a favour and u

Re: palindrome iteration

2010-08-27 Thread Bruno Desthuilliers
Baba a écrit : level: beginner the following code looks ok to me but it doesn't work. "doesn't work" is about the most useless description of a problem. Please specify what you expected and what actually happens. I would like some hints as to where my reasoning / thought goes wrong def i_

Re: palindrome iteration

2010-08-27 Thread Richard Arts
> Now there is another solution. A palindrom is made of two symetric halves, > with (odd len) or without (even len) a single char between the symetric > halves, ie : > > * odd : ABCBA ('AB' + 'C' + 'BA') > * even : ABCCBA ('ABC' + 'CBA') > > So you just have to extract the symetric halves, reverse

Re: pil and reportlab: image compression

2010-08-27 Thread steph
On 26 Aug., 13:16, steph wrote: > Hi group, > > I've written a small application that puts images into a pdf document. > It works ok, but my problem is that the pdf-files become quite huge, > bigger than the original jpegs. The problem seems to arise because I > use PIL to resize the pictures - an

Re: palindrome iteration

2010-08-27 Thread Matteo Landi
> Yes, this is a correct observation, but it is not necessary to compare > the halves; Simply compare the complete string with its reverse. If > they match, it is a palindrome. I've always used to implement the is_palindrome function as you suggest, i.e. comparing the original string with the reve

Re: palindrome iteration

2010-08-27 Thread Dave Angel
Bruno Desthuilliers wrote: Baba a écrit : level: beginner the following code looks ok to me but it doesn't work. "doesn't work" is about the most useless description of a problem. Please specify what you expected and what actually happens. I would like some hints as to where my reasonin

Re: Writing byte stream as jpeg format to disk

2010-08-27 Thread Bryan
Nobody wrote: > Bryan wrote: > > this is a case where we might want to be better > > than correct. BaseHTTPRequestHandler in the Python standard library > > accommodates clients that incorrectly omit the '\r' and end header lines > > with just '\n'. Such apps have been seen in the wild. Since bare

Re: palindrome iteration

2010-08-27 Thread Bruno Desthuilliers
Richard Arts a écrit : Now there is another solution. A palindrom is made of two symetric halves, with (odd len) or without (even len) a single char between the symetric halves, ie : * odd : ABCBA ('AB' + 'C' + 'BA') * even : ABCCBA ('ABC' + 'CBA') So you just have to extract the symetric halve

Re: palindrome iteration

2010-08-27 Thread Bruno Desthuilliers
Dave Angel a écrit : (snip) or (untested) def is_palindrom(s): s = s.lower() return s == s[::-1] Right, go on, make me feel a bit more stupid :-/ Who's next ? -- http://mail.python.org/mailman/listinfo/python-list

Re: Confused: Newbie Function Calls

2010-08-27 Thread Aahz
In article <2dd74ab4-5ed6-40ac-aea7-705977b61...@g21g2000prn.googlegroups.com>, fuglyducky wrote: > >I am a complete newbie to Python (and programming in general) and I >have no idea what I'm missing. Below is a script that I am trying to >work with and I cannot get it to work. Side note: while

Re: palindrome iteration

2010-08-27 Thread D'Arcy J.M. Cain
On Fri, 27 Aug 2010 11:49:42 -0400 "D'Arcy J.M. Cain" wrote: > is_palindrome = lambda x: x == x.lower()[::-1] Oops. Simple and wrong. is_palindrome = lambda x: x.lower() == x.lower()[::-1] -- D'Arcy J.M. Cain | Democracy is three wolves http://www.druid.net/darcy/|

Re: palindrome iteration

2010-08-27 Thread Mark Lawrence
On 27/08/2010 15:43, Bruno Desthuilliers wrote: Dave Angel a écrit : (snip) or (untested) def is_palindrom(s): s = s.lower() return s == s[::-1] Right, go on, make me feel a bit more stupid :-/ Who's next ? It could be worse, try responding to issue 9702. :) Cheers. Mark Lawrence. -- h

layer geld verdienen , leicht geldverdienen , wie kann ich onlinespiele geld gewinnen , geldgewinnspiele , zu geld machen , geld machen beim , pennergame geld verdienen , schnell geld vedienen , ohne

2010-08-27 Thread marianne rosen
layer geld verdienen , leicht geldverdienen , wie kann ich onlinespiele geld gewinnen , geldgewinnspiele , zu geld machen , geld machen beim , pennergame geld verdienen , schnell geld vedienen , ohne geld online , geld mit online casino , * * * +++ SOFORT GEWINN +++ REICH WERDEN +++ * http://WWW.S

Re: palindrome iteration

2010-08-27 Thread Ian
On 27/08/2010 09:53, Baba wrote: level: beginner the following code looks ok to me but it doesn't work. I would like some hints as to where my reasoning / thought goes wrong def i_palindrome(pal): while len(pal)>1: if pal[0] == pal[-1]: pal=pal[1:-1] return True print i_palindrome(

numpy is not installed with Python2.

2010-08-27 Thread justin
My university has a cluster computer, on which I want to run my python program that uses numpy. I am installing my Python2.7 locally separated from the main system, and trying to install numpy, attach it with Python2.7. I used many different versions of numpys to make it happen, but I got stuck wit

Re: palindrome iteration

2010-08-27 Thread D'Arcy J.M. Cain
On Fri, 27 Aug 2010 16:43:16 +0200 Bruno Desthuilliers wrote: > Dave Angel a écrit : > > def is_palindrom(s): > >s = s.lower() > >return s == s[::-1] > > > Right, go on, make me feel a bit more stupid :-/ > Who's next ? How about a one-liner? is_palindrome = lambda x: len(x)> 0 and x =

Re: Queue cleanup

2010-08-27 Thread Aahz
In article , MRAB wrote: > >An object will be available for garbage collection when nothing refers >to it either directly or indirectly. If it's unreferenced then it will >go away. This isn't actually garbage collection as most people think of it. Refcounting semantics mean that objects get reap

Re: palindrome iteration

2010-08-27 Thread MRAB
On 27/08/2010 17:20, Mark Lawrence wrote: On 27/08/2010 15:43, Bruno Desthuilliers wrote: Dave Angel a écrit : (snip) or (untested) def is_palindrom(s): s = s.lower() return s == s[::-1] Right, go on, make me feel a bit more stupid :-/ Who's next ? It could be worse, try responding to is

Re: numpy is not installed with Python2.

2010-08-27 Thread Robert Kern
On 8/27/10 11:40 AM, justin wrote: My university has a cluster computer, on which I want to run my python program that uses numpy. I am installing my Python2.7 locally separated from the main system, and trying to install numpy, attach it with Python2.7. I used many different versions of numpys t

Re: palindrome iteration

2010-08-27 Thread Mark Lawrence
On 27/08/2010 17:53, MRAB wrote: On 27/08/2010 17:20, Mark Lawrence wrote: On 27/08/2010 15:43, Bruno Desthuilliers wrote: Dave Angel a écrit : (snip) or (untested) def is_palindrom(s): s = s.lower() return s == s[::-1] Right, go on, make me feel a bit more stupid :-/ Who's next ? It co

Re: palindrome iteration

2010-08-27 Thread Terry Reedy
On 8/27/2010 4:53 AM, Baba wrote: level: beginner the following code looks ok to me but it doesn't work. I would like some hints as to where my reasoning / thought goes wrong def i_palindrome(pal): while len(pal)>1: if pal[0] == pal[-1]: pal=pal[1:-1] return True print i_palindrome(

Re: palindrome iteration

2010-08-27 Thread MRAB
On 27/08/2010 18:28, Mark Lawrence wrote: On 27/08/2010 17:53, MRAB wrote: On 27/08/2010 17:20, Mark Lawrence wrote: On 27/08/2010 15:43, Bruno Desthuilliers wrote: Dave Angel a écrit : (snip) or (untested) def is_palindrom(s): s = s.lower() return s == s[::-1] Right, go on, make me feel

Re: palindrome iteration

2010-08-27 Thread Jussi Piitulainen
Ian writes: > If you want to or must do it recursively. > (Shown in pseudo code to make the logic clearer) > > def isPalindrome(pal) > ''' test pal (a list) is a palindrome ''' > if length of pal = 1 > return True # all one letter strings are palindromes. > if first equal

Re: mailbox.mbox not locking mbox properly

2010-08-27 Thread Chris Jewell
Even if you replace the python mbox code with something that uses fcntl.flock() to protect against concurrent updating, you should also understand that NFS does *not* provide full Unix filesystem semantics. In particular, Unix flock(2) (which Python's fcntl.flock() wraps) doesn't work over NFS. Th

Re: numpy is not installed with Python2.

2010-08-27 Thread justin
On Aug 27, 12:10 pm, Robert Kern wrote: > On 8/27/10 11:40 AM, justin wrote: > > > > > > > My university has a cluster computer, on which I want to run my python > > program that uses numpy. > > I am installing my Python2.7 locally separated from the main system, > > and trying to install numpy, a

Re: palindrome iteration

2010-08-27 Thread Dave Angel
Jussi Piitulainen wrote: Ian writes: If you want to or must do it recursively. (Shown in pseudo code to make the logic clearer) def isPalindrome(pal) ''' test pal (a list) is a palindrome ''' if length of pal = 1 return True # all one letter strings are palindromes.

Re: numpy is not installed with Python2.

2010-08-27 Thread Robert Kern
On 8/27/10 1:38 PM, justin wrote: On Aug 27, 12:10 pm, Robert Kern wrote: On 8/27/10 11:40 AM, justin wrote: My university has a cluster computer, on which I want to run my python program that uses numpy. I am installing my Python2.7 locally separated from the main system, and trying to i

Re: palindrome iteration

2010-08-27 Thread D'Arcy J.M. Cain
On Fri, 27 Aug 2010 12:02:39 -0400 "D'Arcy J.M. Cain" wrote: > On Fri, 27 Aug 2010 11:49:42 -0400 > "D'Arcy J.M. Cain" wrote: > > is_palindrome = lambda x: x == x.lower()[::-1] > > Oops. Simple and wrong. > > is_palindrome = lambda x: x.lower() == x.lower()[::-1] slightly more efficient I thi

Re: palindrome iteration

2010-08-27 Thread Jussi Piitulainen
Dave Angel writes: > Jussi Piitulainen wrote: >> Ian writes: >>> Of course, the simpler way is to use the definition of a >>> Palindrome as the same backwards and forwards. >>> >>> def isPalindrome(pal) >>> return pal == pal.reverse >> >> Agreed. But is there any nicer way to spell .reverse t

Re: Queue cleanup

2010-08-27 Thread John Nagle
On 8/11/2010 1:26 PM, EW wrote: On Aug 11, 2:52 pm, Paul Rubin wrote: EW writes: Well I cared because I thought garbage collection would only happen when the script ended - the entire script. Since I plan on running this as a service it'll run for months at a time without ending. So I thoug

Re: palindrome iteration

2010-08-27 Thread MRAB
On 27/08/2010 20:43, Jussi Piitulainen wrote: Dave Angel writes: Jussi Piitulainen wrote: Ian writes: Of course, the simpler way is to use the definition of a Palindrome as the same backwards and forwards. def isPalindrome(pal) return pal == pal.reverse Agreed. But is there any nicer

Re: mailbox.mbox not locking mbox properly

2010-08-27 Thread John Nagle
On 8/10/2010 2:25 AM, Chris Rebert wrote: On Tue, Aug 10, 2010 at 2:01 AM, wrote: Tim Roberts wrote: tinn...@isbd.co.uk wrote: I'm using the python mailbox class in a script that processes incoming mail and delivers it to various mbox format mailboxes. It appears that, although I am callin

Re: palindrome iteration

2010-08-27 Thread Jussi Piitulainen
MRAB writes: > On 27/08/2010 20:43, Jussi Piitulainen wrote: >> Dave Angel writes: >>> Jussi Piitulainen wrote: Agreed. But is there any nicer way to spell .reverse than [::-1] in Python? There is .swapcase() but no .reverse(), right? >>> There can't be a .reverse() method on string,

Re: palindrome iteration

2010-08-27 Thread Terry Reedy
On 8/27/2010 3:43 PM, Jussi Piitulainen wrote: Dave Angel writes: There could easily be a .reverse() method on strings. It would return the reversed string, like .swapcase() returns the swapcased string. Could be, but the main use case seems to be for palindrome testing ;-) Given that slicin

Re: palindrome iteration

2010-08-27 Thread Richard Arts
On Fri, Aug 27, 2010 at 10:51 PM, Jussi Piitulainen wrote: > MRAB writes: >> On 27/08/2010 20:43, Jussi Piitulainen wrote: >>> Dave Angel writes: Jussi Piitulainen wrote: > Agreed. But is there any nicer way to spell .reverse than [::-1] > in Python? There is .swapcase() but no .rever

Re: palindrome iteration

2010-08-27 Thread Richard Arts
On Fri, Aug 27, 2010 at 11:47 PM, Richard Arts wrote: > On Fri, Aug 27, 2010 at 10:51 PM, Jussi Piitulainen > wrote: >> MRAB writes: >>> On 27/08/2010 20:43, Jussi Piitulainen wrote: Dave Angel writes: > Jussi Piitulainen wrote: >> Agreed. But is there any nicer way to spell .reverse

Re: Writing byte stream as jpeg format to disk

2010-08-27 Thread Lawrence D'Oliveiro
In message , Navkirat Singh wrote: > I receive a jpeg file with the POST method.The file (.jpeg) is encoded in > bytes, I parse the bytes by decoding them to a string. I wanted to know > how i could write the file (now a string) as a jpeg image on disk. I assume the JPEG data is received along wi

Re: Writing byte stream as jpeg format to disk

2010-08-27 Thread Lawrence D'Oliveiro
In message , Navkirat Singh wrote: > The image bytes are a part of a HTTP header content ( not the message body > ). In which case, won’t they be in some encoding like Base-64? I don’t think you’re allowed arbitrary binary bytes in an HTTP header. -- http://mail.python.org/mailman/listinfo/pyt

Re: Reading the access attributes of directories in Windows

2010-08-27 Thread Lawrence D'Oliveiro
In message , Rami Chowdhury wrote: > On Wed, Aug 25, 2010 at 05:04, Lawrence D'Oliveiro > wrote: > >> In message , Nobody wrote: >> >>> Having this as a separate permission allows normal users to add entries >>> to log files but not to erase existing entries. >> >> Unix/Linux systems can do this

Re: Writing byte stream as jpeg format to disk

2010-08-27 Thread Robert Kern
On 8/27/10 5:58 PM, Lawrence D'Oliveiro wrote: In message , Navkirat Singh wrote: I receive a jpeg file with the POST method.The file (.jpeg) is encoded in bytes, I parse the bytes by decoding them to a string. I wanted to know how i could write the file (now a string) as a jpeg image on disk.

ANN: ActivePython 2.6.6.15 is now available

2010-08-27 Thread Sridhar Ratnakumar
ActiveState is pleased to announce ActivePython 2.6.6.15, a complete, ready-to-install binary distribution of Python 2.6.6. http://www.activestate.com/activepython What's New in ActivePython-2.6.6.15 === *Release date: 25-Aug-2010* New Features & Upgrades -

ANN: ActivePython 2.7.0.2 is now available

2010-08-27 Thread Sridhar Ratnakumar
ActiveState is pleased to announce ActivePython 2.7.0.2, a complete, ready-to-install binary distribution of Python 2.7. http://www.activestate.com/activepython What's New in ActivePython-2.7.0.2 == *Release date: 25-Aug-2010* New Features & Upgrades --

Re: ftplib limitations?

2010-08-27 Thread Lawrence D'Oliveiro
In message <4c74e604.6090...@sschwarzer.net>, Stefan Schwarzer wrote: > Now it may be that the data connection, after having started > the transfer, works as it should, but the control connection > times out because the duration of the transfer is too long. It might not be the fault of the FTP se

How to convert (unicode) text to image?

2010-08-27 Thread kj
Hi! Does anyone know of an easy way to convert a Unicode string into an image file (either jpg or png)? TIA! ~k -- http://mail.python.org/mailman/listinfo/python-list

Re: Overload print

2010-08-27 Thread genxtech
On Aug 25, 5:18 pm, Ross Williamson wrote: > Hi All > > Is there anyway in a class to overload the print function? > > >> class foo_class(): > >>      pass > >> cc = foo_class() > >> print cc > > Gives: > > <__main__.foo_class instance at > > > Can I do something like: > > >> class foo_class()

Re: Queue cleanup

2010-08-27 Thread Steven D'Aprano
On Fri, 27 Aug 2010 09:16:52 -0700, Aahz wrote: > In article , MRAB > wrote: >> >>An object will be available for garbage collection when nothing refers >>to it either directly or indirectly. If it's unreferenced then it will >>go away. > > This isn't actually garbage collection as most people

Re: How to convert (unicode) text to image?

2010-08-27 Thread Benjamin Kaplan
On Fri, Aug 27, 2010 at 8:01 PM, kj wrote: > > > Hi!  Does anyone know of an easy way to convert a Unicode string into an > image file (either jpg or png)? > Do you mean you have some text and you want an image containing that text? PIL's ImageDraw module can do that. -- http://mail.python.org/

Re: Queue cleanup

2010-08-27 Thread Paul Rubin
Steven D'Aprano writes: > I've repeatedly asked, both here and elsewhere, why reference counting > isn't "real" garbage collection. Nobody has been able to give me a > satisfactory answer. As far as I can tell, it's a bit of pretentiousness > with no basis in objective fact. Well, it's a bit o

comp.lang.python

2010-08-27 Thread roshini begum
www.127760.blogspot.com -- http://mail.python.org/mailman/listinfo/python-list

love me

2010-08-27 Thread love me
1st step like me on facbook at this link http://www.facebook.com/pages/loveme/145529285481739 2nd step visit this link http://www.kqzyfj.com/click-3778203-10786395 -- http://mail.python.org/mailman/listinfo/python-list

Walking deeply nested lists

2010-08-27 Thread donn
This is all about walking trees, recursion and generators. None of which fit my brain at all! From an XML tree (an SVG file) I build a bunch of Tag objects. [I use lxml, but I am combining multiple svg files into a 'forest' of trees, so I can't use the lxml walking methods because they all sto

Re: Reading the access attributes of directories in Windows

2010-08-27 Thread Lawrence D'Oliveiro
In message , Tim Golden wrote: > Can you run Python from within a Run-As-Administrator command > prompt? Kind of worrying, isn’t it, when the answer to “my program won’t work” is “give it more privileges”? Defeats the point of having such a complex security system, doesn’t it, when people are

rfile.readline()

2010-08-27 Thread sarah
i want to know that what this function returns??? and what does this function do?? -- http://mail.python.org/mailman/listinfo/python-list

Re: palindrome iteration

2010-08-27 Thread Jussi Piitulainen
Terry Reedy writes: > On 8/27/2010 3:43 PM, Jussi Piitulainen wrote: > > Dave Angel writes: > > > There could easily be a .reverse() method on strings. It would return > > the reversed string, like .swapcase() returns the swapcased string. > > Could be, but the main use case seems to be for palin

Re: Walking deeply nested lists

2010-08-27 Thread Peter Otten
donn wrote: > * If an Instance calls a method on another Instance of the same > class, is this still recursion? And how does this 'stack up'? I mean, > literally, on the stack. Does each instance get its own stack, or does > all the push, call, pop stuff happen in one main stack? > (I worry about