Re: palindrome iteration

2010-08-28 Thread Josh English
This whole conversation got interesting, so I thought I'd run some speed tests: The code: from timeit import Timer def is_palindrome_recursive(s): if len(s) <= 1: return True if s[0] != s[-1]: return False else: return is_palindrome(s[1:-1]) def is_palindrome_

Re: looking for open source python project

2010-08-28 Thread Kushal Kumaran
On Sun, Aug 29, 2010 at 6:20 AM, mo reina wrote: > looking for a python project (preferably something a bit small) that > is looking for contributors. the small bit is because i've never > worked in a team before and haven't really read source code that's > 1000s of lines long, so i'm not too sure

comp.lang.python

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

Re: Problem checking an existing browser cookie

2010-08-28 Thread Νίκος
On 28 Αύγ, 23:07, Peter Otten <__pete...@web.de> wrote: > Νίκος wrote: > > On 22 Αύγ, 10:27, Νίκος wrote: > >> On 16 Αύγ, 14:31, Peter Otten <__pete...@web.de> wrote: > >> > Νίκος wrote: > >> > > # initializecookie > >> > >cookie=Cookie.SimpleCookie() > >> > >cookie.load( os.environ.get('HTTP_COOK

Re: Problem checking an existing browser cookie

2010-08-28 Thread Νίκος
On 28 Αύγ, 23:15, MRAB wrote: > On 28/08/2010 20:37, Íßêïò wrote: > > > > > > > > > > > On 22 Áýã, 10:27, Íßêïò  wrote: > >> On 16 Áýã, 14:31, Peter Otten<__pete...@web.de>  wrote: > > >>> Íßêïò wrote: > # initializecookie > cookie=Cookie.SimpleCookie() > cookie.load( os.environ.get

Re: String substitution VS proper mysql escaping

2010-08-28 Thread Νίκος
On 28 Αύγ, 23:12, MRAB wrote: > On 28/08/2010 20:51, Νίκος wrote: > > > > > > > > > > > On 28 Αύγ, 22:35, MRAB  wrote: > > >> """When there's more than one value you provide a tuple. It's makes sense > >> from the point of view of consistency that you also provide a tuple when > >> there's only on

Re: Tag parsing in python

2010-08-28 Thread Paul McGuire
On Aug 28, 11:14 am, agnibhu wrote: > Hi all, > > I'm a newbie in python. I'm trying to create a library for parsing > certain keywords. > For example say I've key words like abc: bcd: cde: like that... So the > user may use like > abc: How are you bcd: I'm fine cde: ok > > So I've to extract the

Re: Fibonacci: How to think recursively

2010-08-28 Thread Chris Rebert
On Sat, Aug 28, 2010 at 7:25 PM, Steven D'Aprano wrote: > On Sat, 28 Aug 2010 16:12:36 -0700, Baba wrote: >> Level: beginner >> >> I would like to know how to approach the following Fibonacci problem: >> my attempted rough code: >> >> def fibonacci(n): >>     # base case: >>         result = fibo

Re: Fibonacci: How to think recursively

2010-08-28 Thread Mark Tolonen
"Steven D'Aprano" wrote in message news:4c79c510$0$28655$c3e8...@news.astraweb.com... On Sat, 28 Aug 2010 16:12:36 -0700, Baba wrote: There are other techniques, but this will do to get started. Once you realize recursion for Fibonacci numbers is still fairly slow, look up generator func

Re: Functional composition in python

2010-08-28 Thread Dmitry Groshev
On Aug 29, 5:14 am, Steven D'Aprano wrote: > On Sat, 28 Aug 2010 21:30:39 +0400, Dmitry Groshev wrote: > > Hello all. Some time ago I wrote a little library: > >http://github.com/si14/python-functional-composition/, inspired by > > modern functional languages like F#. In my opinion it is quite use

Re: Fibonacci: How to think recursively

2010-08-28 Thread Steven D'Aprano
On Sat, 28 Aug 2010 16:12:36 -0700, Baba wrote: > Level: beginner > > I would like to know how to approach the following Fibonacci problem: > How may rabbits do i have after n months? > > I'm not looking for the code as i could Google that very easily. I'm > looking for a hint to put me on the r

Re: Functional composition in python

2010-08-28 Thread Steven D'Aprano
On Sat, 28 Aug 2010 21:30:39 +0400, Dmitry Groshev wrote: > Hello all. Some time ago I wrote a little library: > http://github.com/si14/python-functional-composition/ , inspired by > modern functional languages like F#. In my opinion it is quite useful > now, but I would like to discuss it. > An e

Re: palindrome iteration

2010-08-28 Thread Steven D'Aprano
On Sat, 28 Aug 2010 15:11:03 +0300, Jussi Piitulainen wrote: [...] > When I said that there could be such a method, I was merely objecting to > a statement, made in response to me, that there could not be such a > method because strings are immutable. You clearly agree with me that > that statemen

looking for open source python project

2010-08-28 Thread mo reina
looking for a python project (preferably something a bit small) that is looking for contributors. the small bit is because i've never worked in a team before and haven't really read source code that's 1000s of lines long, so i'm not too sure i can keep up. my python fu is decent (i think), i recen

Re: Fibonacci: How to think recursively

2010-08-28 Thread Matteo Landi
I suggest you to memoize results in order to prevent overlapping recursion. Regards, Matteo On Sun, Aug 29, 2010 at 2:23 AM, Ben Finney wrote: > Baba writes: > >> my brainstorming so far brought me to a stand still as i can't seem to >> imagine a recursive way to code this: >> >> my attempted r

Re: Fibonacci: How to think recursively

2010-08-28 Thread Ben Finney
Baba writes: > my brainstorming so far brought me to a stand still as i can't seem to > imagine a recursive way to code this: > > my attempted rough code: > > def fibonacci(n): > # base case: > result = fibonacci (n-1) + fibonacci (n-2) > >> this will end up in a mess as it will creat

Re: InteractiveConsole and namespace

2010-08-28 Thread Chris Rebert
On Sat, Aug 28, 2010 at 2:37 PM, David ROBERT wrote: > Hi all, > > I want to use an InteractiveConsole at some stage in a program to > interact with the local namespace: access, but also modify objects. > When the interactive console ends (ctrl-d) I want the program to > continue processing with t

Re: Fibonacci: How to think recursively

2010-08-28 Thread Mel
Baba wrote: > Level: beginner > > I would like to know how to approach the following Fibonacci problem: > How may rabbits do i have after n months? > > I'm not looking for the code as i could Google that very easily. I'm > looking for a hint to put me on the right track to solve this myself > wi

Fibonacci: How to think recursively

2010-08-28 Thread Baba
Level: beginner I would like to know how to approach the following Fibonacci problem: How may rabbits do i have after n months? I'm not looking for the code as i could Google that very easily. I'm looking for a hint to put me on the right track to solve this myself without looking it up. my brai

Helper app for intranet site

2010-08-28 Thread kevinlcarlson
I'm exploring the possibility of developing a helper app for an existing internal company website. Basically, it would automatically scan the current page contents, including prepopulated forms, and provide context-related business rule comments to the user, via a stay- on-top wxPython panel. Any

Re: Tag parsing in python

2010-08-28 Thread Josh English
On Aug 28, 9:14 am, agnibhu wrote: > Hi all, > > I'm a newbie in python. I'm trying to create a library for parsing > certain keywords. > For example say I've key words like abc: bcd: cde: like that... So the > user may use like > abc: How are you bcd: I'm fine cde: ok > > So I've to extract the "

Re: pyxser-1.5r --- Python Object to XML serializer/deserializer

2010-08-28 Thread Josh English
On Aug 26, 10:02 pm, Stefan Behnel wrote: > Josh English, 27.08.2010 01:30: > > > solve a lot of the problems I'm running into in my own attempt to > > build a python Class implementation of an XML Validation object. > > How would object serialisation help here? > > I'm running into the same prob

InteractiveConsole and namespace

2010-08-28 Thread David ROBERT
Hi all, I want to use an InteractiveConsole at some stage in a program to interact with the local namespace: access, but also modify objects. When the interactive console ends (ctrl-d) I want the program to continue processing with the variables that may have been modified interactively. The code

Re: palindrome iteration

2010-08-28 Thread Dave Angel
Jussi Piitulainen wrote: Steven D'Aprano writes: On Sat, 28 Aug 2010 09:22:13 +0300, Jussi Piitulainen wrote: 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

Re: Reading the access attributes of directories in Windows

2010-08-28 Thread Rami Chowdhury
On Sat, Aug 28, 2010 at 05:07, Lawrence D'Oliveiro wrote: > 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 b

Re: Reading the access attributes of directories in Windows

2010-08-28 Thread Rami Chowdhury
On Fri, Aug 27, 2010 at 14:16, Nobody wrote: > 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

Re: Problem checking an existing browser cookie

2010-08-28 Thread MRAB
On 28/08/2010 20:37, Νίκος wrote: On 22 Αύγ, 10:27, Νίκος wrote: On 16 Αύγ, 14:31, Peter Otten<__pete...@web.de> wrote: Νίκος wrote: # initializecookie cookie=Cookie.SimpleCookie() cookie.load( os.environ.get('HTTP_COOKIE', '') ) mycookie =cookie.get('visitor') if ( mycookie and

Re: Problem checking an existing browser cookie

2010-08-28 Thread Peter Otten
Νίκος wrote: > On 22 Αύγ, 10:27, Νίκος wrote: >> On 16 Αύγ, 14:31, Peter Otten <__pete...@web.de> wrote: >> > Νίκος wrote: >> > > # initializecookie >> > >cookie=Cookie.SimpleCookie() >> > >cookie.load( os.environ.get('HTTP_COOKIE', '') ) >> > > mycookie =cookie.get('visitor') >> >> > > if ( myc

Re: String substitution VS proper mysql escaping

2010-08-28 Thread MRAB
On 28/08/2010 20:51, Νίκος wrote: On 28 Αύγ, 22:35, MRAB wrote: """When there's more than one value you provide a tuple. It's makes sense from the point of view of consistency that you also provide a tuple when there's only one value.""" Can you write something that make use of more than one

Re: String substitution VS proper mysql escaping

2010-08-28 Thread MRAB
On 28/08/2010 20:48, Νίκος wrote: On 28 Αύγ, 22:35, MRAB wrote: On 28/08/2010 20:10, Νίκος wrote:> On 20 Αύγ, 09:04, Nik Grwrote: With regard to the "%" operator, it considers the string on the left to be a format string with multiple %blah things in it to replace. The thing on the right

Re: String substitution VS proper mysql escaping

2010-08-28 Thread Rami Chowdhury
2010/8/29 Νίκος : > On 28 Αύγ, 22:35, MRAB wrote: > >> """When there's more than one value you provide a tuple. It's makes sense >> from the point of view of consistency that you also provide a tuple when >> there's only one value.""" > > Can you write something that make use of more than one valu

Re: String substitution VS proper mysql escaping

2010-08-28 Thread Νίκος
On 28 Αύγ, 22:35, MRAB wrote: > """When there's more than one value you provide a tuple. It's makes sense > from the point of view of consistency that you also provide a tuple when > there's only one value.""" Can you write something that make use of more than one value? Perhaps you mena somet

Re: String substitution VS proper mysql escaping

2010-08-28 Thread Νίκος
On 28 Αύγ, 22:35, MRAB wrote: > On 28/08/2010 20:10, Νίκος wrote:> On 20 Αύγ, 09:04, Nik > Gr  wrote: > >> With regard to the "%" operator, it considers the string on the left to > >> be a format string with multiple %blah things in it to replace. The > >> thing on the right is a sequence of item

Re: Problem checking an existing browser cookie

2010-08-28 Thread Νίκος
On 22 Αύγ, 10:27, Νίκος wrote: > On 16 Αύγ, 14:31, Peter Otten <__pete...@web.de> wrote: > > > > > > > > > > > Νίκος wrote: > > > # initializecookie > > >cookie=Cookie.SimpleCookie() > > >cookie.load( os.environ.get('HTTP_COOKIE', '') ) > > > mycookie =cookie.get('visitor') > > > > if ( mycookie a

Re: String substitution VS proper mysql escaping

2010-08-28 Thread MRAB
On 28/08/2010 20:10, Νίκος wrote: On 20 Αύγ, 09:04, Nik Gr wrote: With regard to the "%" operator, it considers the string on the left to be a format string with multiple %blah things in it to replace. The thing on the right is a sequence of items to place into the format string. Can you plea

Re: Functional composition in python

2010-08-28 Thread Peter Otten
Dmitry Groshev wrote: > Hello all. Some time ago I wrote a little library: > http://github.com/si14/python-functional-composition/ , inspired by > modern functional languages like F#. In my opinion it is quite useful > now, but I would like to discuss it. > An example of usage: > > import os > fr

Re: String substitution VS proper mysql escaping

2010-08-28 Thread Νίκος
On 20 Αύγ, 09:04, Nik Gr wrote: > With regard to the "%" operator, it considers the string on the left to > be a format string with multiple %blah things in it to replace. The > thing on the right is a sequence of items to place into the format > string. Can you please clarify what you mean by th

Re: Object containing a list of objects.

2010-08-28 Thread cocolombo
Chris I take good notice of your comments and suggestions. Thanks. -- http://mail.python.org/mailman/listinfo/python-list

Re: Object containing a list of objects.

2010-08-28 Thread cocolombo
Thanks MRAB and Peter Otten that solved the problem. -- http://mail.python.org/mailman/listinfo/python-list

Re: Object containing a list of objects.

2010-08-28 Thread Chris Rebert
On Sat, Aug 28, 2010 at 10:48 AM, cocolombo wrote: > Hello. > > I am putting objects (test) into a container object (tests) and the > test object is also a container for a another list of object > (scores). > > Problem is that all instances of class tests have the same value. > > To illustrate: >

Re: Object containing a list of objects.

2010-08-28 Thread Peter Otten
cocolombo wrote: > Problem is that all instances of class tests have the same value. > > To illustrate: > class tests(object): > listOfTest = [] This makes listOfTest a class attribute. To get one list per instance define it in the initializer: class Tests(object): def __init__(self):

Re: Object containing a list of objects.

2010-08-28 Thread MRAB
On 28/08/2010 18:48, cocolombo wrote: Hello. I am putting objects (test) into a container object (tests) and the test object is also a container for a another list of object (scores). Problem is that all instances of class tests have the same value. To illustrate: class score(object): va

Object containing a list of objects.

2010-08-28 Thread cocolombo
Hello. I am putting objects (test) into a container object (tests) and the test object is also a container for a another list of object (scores). Problem is that all instances of class tests have the same value. To illustrate: class score(object): val = 0 def __init__(self, val):

Re: Tag parsing in python

2010-08-28 Thread Tim Chase
On 08/28/10 11:14, agnibhu wrote: For example say I've key words like abc: bcd: cde: like that... So the user may use like abc: How are you bcd: I'm fine cde: ok So I've to extract the "How are you" and "I'm fine" and "ok"..and assign them to abc:, bcd: and cde: respectively.. For this, you ca

Functional composition in python

2010-08-28 Thread Dmitry Groshev
Hello all. Some time ago I wrote a little library: http://github.com/si14/python-functional-composition/ , inspired by modern functional languages like F#. In my opinion it is quite useful now, but I would like to discuss it. An example of usage: import os from pyfuncomp import composable, c, _ d

Tag parsing in python

2010-08-28 Thread agnibhu
Hi all, I'm a newbie in python. I'm trying to create a library for parsing certain keywords. For example say I've key words like abc: bcd: cde: like that... So the user may use like abc: How are you bcd: I'm fine cde: ok So I've to extract the "How are you" and "I'm fine" and "ok"..and assign the

Re: rouble importing cx_Oracle on HPUX

2010-08-28 Thread Alexander Gattin
Hello, On Sat, Aug 28, 2010 at 09:27:05AM -0400, Cliff Martin wrote: > Yes, our entire toolchain is 64 bit - a mix of > stuff I have downloaded and built and some > packages from HP (in the form of depot files) > GCC was downloaded from HP, for example. I see. I bootstrapped from bundled cc, henc

love me

2010-08-28 Thread love me
1st step add me in like box on my facbook page 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

Re: Walking deeply nested lists

2010-08-28 Thread donn
On 28/08/2010 14:41, Peter Otten wrote: BTW, I didn't expect it but I get different results on different runs. Clever code. I will give it a go soonest. Elec off for the next 24 hours in my neck of the woods. Urgh. Python can't "import electricity" just yet :) \d -- http://mail.python.org/mail

Re: palindrome iteration

2010-08-28 Thread D'Arcy J.M. Cain
On Sat, 28 Aug 2010 09:48:47 +0100 Ian wrote: > > def palindromep(s): > > def reversed(s): > > return s[::-1] > > return s == reversed(s) > I like this. > > s[::-1] is obscure and non-obvious, especially to Python noobs. > > This makes it clear what is going on and why at a co

Re: Trouble importing cx_Oracle on HPUX

2010-08-28 Thread Cliff Martin
Hi, thank you for getting back to me. Yes, our entire toolchain is 64 bit - a mix of stuff I have downloaded and built and some packages from HP (in the form of depot files) GCC was downloaded from HP, for example. I had to manually add -mlp64 to the CC and CXX lines in the Python Makefile to get

Re: Trouble importing cx_Oracle on HPUX

2010-08-28 Thread Alexander Gattin
Hello, On Thu, Aug 26, 2010 at 08:08:42PM -0700, Cliff Martin wrote: > I have just gotten done building Python 3.1.2 on > HPUX 11.31 Itanium (IA64) using gcc 4.4.3, and > have tried building cx_Oracle to go with it. The > build succeeds, but test and importing does not. > I have tried building Pyt

Re: palindrome iteration

2010-08-28 Thread Jon Clements
On Aug 28, 11:55 am, Steven D'Aprano wrote: > On Sat, 28 Aug 2010 09:22:13 +0300, Jussi Piitulainen wrote: > > Terry Reedy writes: > >> On 8/27/2010 3:43 PM, Jussi Piitulainen wrote: > >> > Dave Angel writes: [snip] > Not everything needs to be a built-in method. There is already a standard > way

Re: Queue cleanup

2010-08-28 Thread Aahz
In article <4c78e7a5$0$28655$c3e8...@news.astraweb.com>, Steven D'Aprano wrote: > >On the other hand, the reason that CPython still has reference counting >is that the alternatives tried so far are unacceptably for non-threaded >code. No, it's *a* reason, the other main reason being that refco

Re: Walking deeply nested lists

2010-08-28 Thread Peter Otten
donn wrote: > On 28/08/2010 12:03, Peter Otten wrote: >> But be warned that if you set the limit too high instead of giving you a >> RuntimeError your program will segfault. > Silly question: is there any way to tell the future in this case? I > mean, ask for X recursion limit, and catch an error

Re: Queue cleanup

2010-08-28 Thread Aahz
In article <4c78572c$0$28655$c3e8...@news.astraweb.com>, Steven D'Aprano wrote: >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 unreferen

Re: GSM to ISO / UCS2 to ISO

2010-08-28 Thread Alexander Gattin
Hello, On Mon, Aug 16, 2010 at 08:01:36PM +1000, James Mills wrote: > In an effort to avoid re-inventing the wheel so to speak > I was wondering if anyone's come across libraries/tools, etc > that achieve the same kind of functionality as the tools > library in this java app. unfortunately, no (e

Re: palindrome iteration

2010-08-28 Thread Jussi Piitulainen
Paul Rubin writes: > Ian writes: > > On 27/08/2010 21:51, Jussi Piitulainen wrote: > >> Meanwhile, I have decided to prefer this: > >> > >> def palindromep(s): > >> def reversed(s): > >> return s[::-1] > >> return s == reversed(s) > > I like this. > > s[::-1] is obscure and non-

Re: palindrome iteration

2010-08-28 Thread Jussi Piitulainen
Arnaud Delobelle writes: > Also, I an not aware that it is customary in python to name > predicate functions with a "p" suffix - Python is not Lisp! Just to clarify my position: I did not mean to imply that names like palindromep might be customary in Python - clearly they are not - and I am quit

Re: palindrome iteration

2010-08-28 Thread Jussi Piitulainen
Steven D'Aprano writes: > On Sat, 28 Aug 2010 09:22:13 +0300, Jussi Piitulainen wrote: >> 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

Re: Walking deeply nested lists

2010-08-28 Thread donn
On 28/08/2010 12:03, Peter Otten wrote: But be warned that if you set the limit too high instead of giving you a RuntimeError your program will segfault. Silly question: is there any way to tell the future in this case? I mean, ask for X recursion limit, and catch an error (or something) if tha

Re: Walking deeply nested lists

2010-08-28 Thread donn
On 28/08/2010 11:17, Carl Banks wrote: It's simple. Copy the object to flatten onto your stack. Pop one item off the stack. If the item you popped is a list, push each item of that list onto the stack. Otherwise yield the value. Loop until stack is empty. Nice. The reversed thing was throwing me,

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

2010-08-28 Thread Arnaud Delobelle
kj writes: > Thanks for the pointer, but... > > > The documentation I have found for PIL (at > http://www.pythonware.com/library/pil/handbook) is beyond atrocious. > If this is the only way to learn how to use this library, then I > really don't understand how anyone who is not clairvoyant can d

Re: Queue cleanup

2010-08-28 Thread Steven D'Aprano
On Fri, 27 Aug 2010 18:06:19 -0700, Paul Rubin wrote: > 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 >> pretentiou

Re: ftplib limitations?

2010-08-28 Thread Lawrence D'Oliveiro
In message <4c78cc0d.8050...@sschwarzer.net>, Stefan Schwarzer wrote: > In message , Lawrence D'Oliveiro wrote: >> >> It might not be the fault of the FTP server. If you’re going through a >> router doing NAT, that could be where the timeout is happening. > > Good point, thanks! That may explain

Simple hack to get $5000 to your *Paypal account

2010-08-28 Thread Hot Hot Hot
Simple hack to get $5000 to your *Paypal account At http://ucanget.co.cc i have hidden the Paypal Form link in an image. in that website on Right Side below search box, click on image and enter your name and Paypal ID. -- http://mail.python.org/mailman/listinfo/python-list

Re: palindrome iteration

2010-08-28 Thread Steven D'Aprano
On Sat, 28 Aug 2010 09:22:13 +0300, Jussi Piitulainen wrote: > 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 swapcas

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

2010-08-28 Thread kj
In Benjamin Kaplan writes: >On Fri, Aug 27, 2010 at 8:01 PM, kj wrote: >> >> >> Hi! =A0Does anyone know of an easy way to convert a Unicode string into a= >n 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

Re: palindrome iteration

2010-08-28 Thread Steven D'Aprano
On Sat, 28 Aug 2010 09:48:47 +0100, Ian wrote: > On 27/08/2010 21:51, Jussi Piitulainen wrote: >> Meanwhile, I have decided to prefer this: >> >> def palindromep(s): >> def reversed(s): >> return s[::-1] >> return s == reversed(s) > I like this. It's silly, needlessly complicat

Re: Queue cleanup

2010-08-28 Thread Steven D'Aprano
On Sat, 28 Aug 2010 00:33:10 -0700, Paul Rubin wrote: > Dennis Lee Bieber writes: >> The nice thing about it [reference counting] is that it is sort >> of deterministic -- one can examine code and determine that an object >> is collected at some point in the execution... >> Heap marking

Re: Walking deeply nested lists

2010-08-28 Thread Carl Banks
On Aug 28, 3:03 am, Peter Otten <__pete...@web.de> wrote: > donn wrote: > > On 28/08/2010 08:43, Peter Otten wrote: > >> If you call functions within functions (or methods, it doesn't matter) > >> they consume stack space > > > Right, got it. Darn, but at least there's that setrecursionlimit call.

Re: Walking deeply nested lists

2010-08-28 Thread Peter Otten
donn wrote: > On 28/08/2010 08:43, Peter Otten wrote: >> If you call functions within functions (or methods, it doesn't matter) >> they consume stack space > > Right, got it. Darn, but at least there's that setrecursionlimit call. But be warned that if you set the limit too high instead of givin

Re: palindrome iteration

2010-08-28 Thread Arnaud Delobelle
Paul Rubin writes: > Ian writes: >> On 27/08/2010 21:51, Jussi Piitulainen wrote: >>> Meanwhile, I have decided to prefer this: >>> >>> def palindromep(s): >>> def reversed(s): >>> return s[::-1] >>> return s == reversed(s) >> I like this. >> s[::-1] is obscure and non-obviou

Re: rfile.readline()

2010-08-28 Thread Dave Angel
sarah wrote: i want to know that what this function returns??? and what does this function do?? rfile.readline() No way to tell what the function returns from your subject line. As for what calling it does, that depends entirely on the object rfile. If it's an instance of a class you wr

Re: palindrome iteration

2010-08-28 Thread Paul Rubin
Ian writes: > On 27/08/2010 21:51, Jussi Piitulainen wrote: >> Meanwhile, I have decided to prefer this: >> >> def palindromep(s): >> def reversed(s): >> return s[::-1] >> return s == reversed(s) > I like this. > s[::-1] is obscure and non-obvious, especially to Python noobs.

Re: Walking deeply nested lists

2010-08-28 Thread Carl Banks
On Aug 27, 8:21 pm, donn wrote: > Each Tag has a flatwalk() method. The return from that is a list which > can be deeply nested. As an example, something like this: > L=[1, [2, 3, [4, [5, 6], 7], 8], [9, 10] ] > > (The numbers in the example would actually be Tag Instances.) > > Aim 1 > --- > I'm

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

2010-08-28 Thread Dave Angel
kj wrote: Hi! Does anyone know of an easy way to convert a Unicode string into an image file (either jpg or png)? TIA! ~k The question has no meaning as presently worded. If you have Unicode text that you need to render, so that you end up with an image of the text, as printed in some

Re: palindrome iteration

2010-08-28 Thread Ian
On 27/08/2010 21:51, Jussi Piitulainen wrote: Meanwhile, I have decided to prefer this: def palindromep(s): def reversed(s): return s[::-1] return s == reversed(s) I like this. s[::-1] is obscure and non-obvious, especially to Python noobs. This makes it clear what is goin

Re: ftplib limitations?

2010-08-28 Thread Stefan Schwarzer
Hi Lawrence, On 2010-08-28 01:49, Lawrence D'Oliveiro 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 serv

Re: Walking deeply nested lists

2010-08-28 Thread donn
On 28/08/2010 09:21, Arnaud Delobelle wrote: This flattens the list in the flatwalk method (which IMHO it should do given its name!): Heh, I often name things ahead of my actual capacity to implement them! el is child.flatwalk(): Ah, I see what you mean. I think 'is' is 'in', but I kind of g

Re: Queue cleanup

2010-08-28 Thread Paul Rubin
Dennis Lee Bieber writes: > The nice thing about it [reference counting] is that it is sort > of deterministic -- one can examine code and determine that an object > is collected at some point in the execution... > Heap marking, OTOH, tends to run at indeterminate times, which could >

Re: Walking deeply nested lists

2010-08-28 Thread donn
On 28/08/2010 08:43, Peter Otten wrote: If you call functions within functions (or methods, it doesn't matter) they consume stack space Right, got it. Darn, but at least there's that setrecursionlimit call. Thanks, \e -- http://mail.python.org/mailman/listinfo/python-list

Re: Walking deeply nested lists

2010-08-28 Thread Arnaud Delobelle
donn writes: > 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 meth

Re: rfile.readline()

2010-08-28 Thread Chris Rebert
On Fri, Aug 27, 2010 at 10:57 PM, sarah wrote: > i want to know that what this function returns??? > > and what does this function do?? RTFM: http://docs.python.org/tutorial/inputoutput.html#methods-of-file-objects Honestly, it's the 2nd google hit for "python readline". Regards, Chris -- http

Re: rfile.readline()

2010-08-28 Thread Peter Otten
sarah wrote: > i want to know that what this function returns??? > and what does this function do?? Where do you get rfile from? The readline() function (or method) could read one line from a file (likely) or wipe your harddisk (unlikely). Without some context it is impossible to tell. Peter

Re: palindrome iteration

2010-08-28 Thread Jussi Piitulainen
Richard Arts writes: > On Fri, Aug 27, 2010 at 10:51 PM, Jussi Piitulainen wrote: >> >> Meanwhile, I have decided to prefer this: >> >> def palindromep(s): >>    def reversed(s): >>        return s[::-1] >>    return s == reversed(s) > > That seems like a bit of overkill... Why would you want to