[patch] make 'bzr ignore' take multiple arguments (bug 29488)
Cheuksan Edward Wang
wang02139 at gmail.com
Tue Oct 10 16:27:06 BST 2006
Thanks. I have modified it. Here is the new changeset.
On 10/10/06, Andrew Bennetts <andrew at canonical.com> wrote:
>
> Cheuksan Edward Wang wrote:
> [...]
> > - def run(self, name_pattern=None, old_default_rules=None):
> > + def run(self, name_pattern_list=[], old_default_rules=None):
>
> It's a good idea to avoid using mutable values as default argument
> defintions.
> If the function is called more than once, and happens to modify the value,
> then
> you get surprising behaviour.
>
> In this case it probably won't cause in problems, but it's an accident
> waiting
> to happen -- a future refactoring of the code might innocently mutate
> name_pattern_list without realising it's not safe. It's a good habit to
> avoid
> mutable args always.
>
> Generally, you can instead default to None, and use "if name_pattern_list
> is
> None: name_pattern_list = []" near the top of the function.
>
> -Andrew.
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://lists.ubuntu.com/archives/bazaar/attachments/20061010/6c48e654/attachment.htm
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ignore_multiple_2.patch
Type: text/x-patch
Size: 7517 bytes
Desc: not available
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20061010/6c48e654/attachment.bin
More information about the bazaar
mailing list