Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: =?UTF-8?Q?Dirk_B=c3=a4chle?= Newsgroups: comp.lang.python Subject: Re: Design: Idiom for classes and methods that are customizable by the user? Date: Fri, 13 May 2016 00:42:17 +0200 Lines: 37 Message-ID: References: <5734ECDF.7070006@gmx.de> <87futnaqb2.fsf@elektro.pacujo.net> <573506C9.3070206@gmx.de> Reply-To: dl9obn@darc.de Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de UM30rC50bzvZWGZ04h05QwX9ZSJ60ooQkfnrGK3yPcqw== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.007 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'happen,': 0.07; 'received:gmx.net': 0.09; 'skip:= 70': 0.10; 'subject: \n ': 0.15; 'user.': 0.15; '"key"': 0.16; 'from:addr:gmx.de': 0.16; 'guess.': 0.16; 'key?': 0.16; 'message-id:@gmx.de': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'subject:user': 0.16; 'wrote:': 0.16; 'translation': 0.16; 'exceptions': 0.22; 'ok.': 0.22; 'parameter': 0.22; 'pass': 0.22; 'select': 0.23; 'bit': 0.23; 'header:In-Reply-To:1': 0.24; 'header:User-Agent:1': 0.26; 'idea': 0.28; 'actual': 0.28; 'looks': 0.29; 'subject:that': 0.29; 'sure,': 0.29; 'classes': 0.30; 'code': 0.30; 'task': 0.30; 'though,': 0.32; 'point': 0.33; 'class': 0.33; "i'll": 0.33; 'behind': 0.35; 'reply.': 0.35; 'too': 0.36; 'to:addr:python- list': 0.36; 'subject:?': 0.36; 'subject:: ': 0.37; 'thank': 0.38; 'why': 0.39; 'subject:the': 0.39; 'easily': 0.39; 'received:192': 0.39; 'to:addr:python.org': 0.40; 'some': 0.40; 'your': 0.60; 'header:Reply-To:1': 0.67; 'reply-to:no real name:2**0': 0.71; 'surprise': 0.72; 'subject:Design': 0.79 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.4.0 In-Reply-To: <87futnaqb2.fsf@elektro.pacujo.net> X-Provags-ID: V03:K0:soHqHPuiLXc68O7EGH5SNSLq8UnpqhcUlJWEAjitsdUayhl6Art mjbFTyhYTogbpjEeHcdRki7rD6s3HDS+e8WUvcIUyyJg/pB7Y8iLUh6oIPqCPbsxCXJXNfD AyiFQtwqMtczRcgkzLKGHZb2gxFobtmEleC/4jC22WhjJXJR5aoML43XaKgjq83EKhchCf1 Q16m++RflYPXBgu6PkeUg== X-UI-Out-Filterresults: notjunk:1;V01:K0:2PNMzA/MtJg=:g6kMeRc88jt+1lpnsdQ1fz wOlMNR+GNM80kER+b7iNij9RNnKWgW0lESiIJwZ8xDzHcOvnTrJY+cfIfKncJ45sxpe6DIDtY k2+fLJ9Vwy2r0YvKufK0AwMXgGAeiqJYh+27BC5nmxBT10Ol/r5fI6aQ0zbK/Tb6X0ISqRZ9W Qo1xt4sEcg0TU+8hT5yXMvWagc+1gkjY+hwvgIN9euFR1l5OqyXeuOmQ62wez/WeToa6+Mn3A lDA4zbD40v+ZGGg84gO5se8FMQ3CEsTzLhk7oj7CmI34Ke24VFtpH6NmU0hUQshgJpiJxMbKh f1HEaudlizBrSLp4PY+rBcHJ01iX5LU0pnUjyuh56ddHZ7zBdU8sFd2Ve/qPme7r/pJhVWgtw Tz5gMKrPhOJmK4eAgEnle994pa3VjmuR41a2e5B0oC8eF/NRfXwscGEGJPkvx4nDRTBTD1U60 65p2cdMSZspiFl7Pnl+hdu2XSZ8uWh7VfY7b2clc7X1QMXRfFhWSy7oMRwFamfWtXJj3OjM7I gyXCIKNifYAZBXu9copUXZxOSQKii967ONP8ta9NTCq0AJSUk7yRtKuzTMq0S8tbPqrWGm3lo 85GzCN6bicSlDBsgpsKGMmDA4qn3SizE15RmbCmErr3adZm1wdhOm/DbsjARlUN9RqUh/M6TK TgSRrnsBuHIWcsRp4xzdEnppGOe9wmNitCAQn/Qc2H10sT6gwTCnCNmsvGBTJVn5p79PRIwhV ld1qUykRiC1zkzg/q5wbyVfM0/OTeeUEyME8flST2VwBcwfvmtcLrk5SE85AfSTpdL6eE4kkR N853d4i X-Mailman-Approved-At: Fri, 13 May 2016 01:05:53 -0400 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: <573506C9.3070206@gmx.de> X-Mailman-Original-References: <5734ECDF.7070006@gmx.de> <87futnaqb2.fsf@elektro.pacujo.net> Xref: csiph.com comp.lang.python:108577 Hi Marko, thank you very much for your quick reply. On 13.05.2016 00:01, Marko Rauhamaa wrote: >> >> [...] >> >> - Is this a good approach > > As an approach, that looks ok. The code looks a bit too lenient, though, > which can easily surprise and baffle the user. I think it would be > better to fail: > > ======================================================================== > class AlreadyExistsError(Exception): > pass > > [...] > Sure, I'll have exceptions in mind for the final implementation. > > [...] > > For example, why do you need a key? Couldn't you simply pass the task > master class as an argument? > The idea behind this is, to be able to select classes by giving a parameter on the command-line. So at some point a translation from a given "key" to its actual class has to happen, I guess. Regards, Dirk