[PATCH 2 of 2 v6] releasenotes: add similarity check function to compare incoming notes

Yuya Nishihara yuya at tcha.org
Sun Jul 30 11:46:04 EDT 2017


On Sun, 30 Jul 2017 20:08:33 +0530, Rishabh Madan wrote:
> On Sun, Jul 30, 2017 at 11:05 AM, Yuya Nishihara <yuya at tcha.org> wrote:
> > So converttitled() takes
> >
> >  a) a list of (title, paragraphs) tuples
> >  b) a list of paragraphs
> >
> > Which is the valid use?
> >
> 
> The first one is what it takes as input.
> 
> >
> > > +def converttitled(iterable):
> > > +    """
> > > +    Convert titled paragraphs to strings
> > > +    """
> > > +    string_list = []
> > > +    for titledparagraphs in iterable:
> > > +        str = ""
> > > +        for paragraphs in titledparagraphs:
> > > +            if isinstance(paragraphs, basestring):
> > > +                continue
> >
> > Maybe this isinstace() is necessary because the type of the given iterable
> > is
> > unstable?
> >
> I need to iterate to iterate through a data like `('Title fix ', [['adds
> fix to notes']])`. So for this case, title is a string but notes is a list,
> hence I'm using isinstance to check if the value is a string or not. In
> case it is, that means it's a list, so I just continue iterating.

If titledparagraphs is [(str, [str])], you can simply destructure the type.

  for title, paragraphs in titledparagraphs:
      ...


More information about the Mercurial-devel mailing list