Re: [Tutor] Wrapping with list

2013-09-16 Thread Dotan Cohen
Thank you to everyone who commented! I've refactored the code and I'm looking into "duck typing" to see if it fits this usage scenario. Thank you very much! -- Dotan Cohen http://gibberish.co.il http://what-is-what.com ___ Tutor maillist - Tutor@pyt

Re: [Tutor] Wrapping with list

2013-09-13 Thread Alan Gauld
On 13/09/13 11:24, Dotan Cohen wrote: A function that I wrote works on a list or on a string. If the function is passed a string, then it wraps the string in a list at the top of the function. Is it bad form to wrap the string in place? It depends what your function does. In most cases the stri

Re: [Tutor] Wrapping with list

2013-09-13 Thread Steven D'Aprano
On Fri, Sep 13, 2013 at 12:24:40PM +0200, Dotan Cohen wrote: > A function that I wrote works on a list or on a string. If the > function is passed a string, then it wraps the string in a list at the > top of the function. Is it bad form to wrap the sting in place? > > if not isinstance(someVar, li

Re: [Tutor] Wrapping with list

2013-09-13 Thread Dave Angel
On 13/9/2013 06:24, Dotan Cohen wrote: > A function that I wrote works on a list or on a string. If the > function is passed a string, then it wraps the string in a list at the > top of the function. Is it bad form to wrap the sting in place? > > if not isinstance(someVar, list): > someVar = [

Re: [Tutor] Wrapping with list

2013-09-13 Thread Oscar Benjamin
On 13 September 2013 11:24, Dotan Cohen wrote: > A function that I wrote works on a list or on a string. If the > function is passed a string, then it wraps the string in a list at the > top of the function. Is it bad form to wrap the sting in place? > > if not isinstance(someVar, list): > som

[Tutor] Wrapping with list

2013-09-13 Thread Dotan Cohen
A function that I wrote works on a list or on a string. If the function is passed a string, then it wraps the string in a list at the top of the function. Is it bad form to wrap the sting in place? if not isinstance(someVar, list): someVar = [someVar] To avoid that, I am creating a list then