Re: Question on keyword arguments

2016-02-18 Thread Tim Chase
On 2016-02-18 10:57, grsm...@atlanticbb.net wrote: > Tim, the 'crazy-other-result format' is the > result returned by the database, nothing > I can do about that :) then, much like converting byte-strings to unicode strings as early as possible and converting them back to byte-strings as late as p

Re: Question on keyword arguments

2016-02-18 Thread grsmith
ython-list@python.org Subject: Re: Question on keyword arguments On Fri, Feb 19, 2016 at 2:39 AM, Dan Strohl wrote: So, define a return object like: from collections import UserList class TestResponse(UserList): def __str__(self): return '\0xfe%s' % '\0xfe'.join(self.da

Re: Question on keyword arguments

2016-02-18 Thread Chris Angelico
On Fri, Feb 19, 2016 at 2:39 AM, Dan Strohl wrote: > So, define a return object like: > > from collections import UserList > class TestResponse(UserList): > def __str__(self): > return '\0xfe%s' % '\0xfe'.join(self.data) > > ...and return that object. Out of interest, why UserList rat

RE: Question on keyword arguments

2016-02-18 Thread Dan Strohl
ably minor performance tuning.) Dan Strohl > -Original Message- > From: Python-list [mailto:python-list-bounces+d.strohl=f5@python.org] On > Behalf Of Peter Otten > Sent: Thursday, February 18, 2016 6:37 AM > To: python-list@python.org > Subject: Re: Question on keyword argum

Re: Question on keyword arguments

2016-02-18 Thread Tim Chase
On 2016-02-18 09:00, grsm...@atlanticbb.net wrote: > Would this be the correct way to return > a list as a default result. > > Also, would the list be the preferable result (to a python > programmer) ? > > def test(command, return_type='LIST'): > """ Go to database and return data""" > if

Re: Question on keyword arguments

2016-02-18 Thread Peter Otten
grsm...@atlanticbb.net wrote: > Would this be the correct way to return > a list as a default result. If it does what you want it to do it is "correct" as in "complies with specification". > Also, would the list be the preferable result (to a python programmer) ? A list as a return value is O

Question on keyword arguments

2016-02-18 Thread grsmith
Would this be the correct way to return a list as a default result. Also, would the list be the preferable result (to a python programmer) ? def test(command, return_type='LIST'): """ Go to database and return data""" if return_type == 'LIST': result = ['ONE', 'TWO', 'THREE']