Is there a better algorithm?

alex goretoy aleksandr.goretoy at gmail.com
Mon Jan 5 22:04:21 EST 2009


>
> class entry:
>  filename = None
>
>  def __init__(self, name, value, filename=None):
>    self.name = name
>    self.value = value
>    if filename is not None:
>      self.filename = filename
>
> [entry('name', 'Gabriel'), entry('age', 18), entry('pic', picture_data,
> 'path/to/file')]


Gabriel thank you for this. I just now realized I've being doing things the
hard way. :)
-Alex Goretoy
http://www.alexgoretoy.com
somebodywhocarez at gmail.com


On Mon, Jan 5, 2009 at 8:58 PM, Gabriel Genellina <gagsl-py2 at yahoo.com.ar>wrote:

> En Sat, 03 Jan 2009 02:55:12 -0200, Kottiyath <n.kottiyath at gmail.com>
> escribió:
>
>  tuples = [(1, 2), (3, 4, 5), (6, 7)]
>>>
>>
>> It is a code to post some data to HTML server.
>> Even though usually the POST values are of type(name, value), if file
>> transfer is involved, then POST values change to (name, filename,
>> value).
>> My view was that since filename is a rare occurance and doesnt make
>> sense in a usual POST, I had not kept it as a full 3 tuple.
>> Since so many programmers (that too much more capable than me) are
>> suggesting that it is code smell, I am reviewing my decision.
>>
>
> What about using another data structure instead - like this:
>
> class entry:
>  filename = None
>
>  def __init__(self, name, value, filename=None):
>    self.name = name
>    self.value = value
>    if filename is not None:
>      self.filename = filename
>
> [entry('name', 'Gabriel'), entry('age', 18), entry('pic', picture_data,
> 'path/to/file')]
>
> --
> Gabriel Genellina
>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20090105/0df3ea9f/attachment.html>


More information about the Python-list mailing list