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
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
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
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 = [
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
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