Seems useless to me. ''.join(s) should return s if s is a string.

Aaron Meurer

On Wed, Nov 16, 2016 at 9:11 AM,  <[email protected]> wrote:
> Hi All,
> I was reading sympy crypto library where I am unable to understand something
> in 'check_and_join' function.
>
> def check_and_join(phrase, symbols=None, filter=None):
>     """
>     Joins characters of `phrase` and if ``symbols`` is given, raises
>     an error if any character in ``phrase`` is not in ``symbols``.
>
>     Parameters
>     ==========
>
>     phrase:     string or list of strings to be returned as a string
>     symbols:    iterable of characters allowed in ``phrase``;
>                 if ``symbols`` is None, no checking is performed
>
>     Examples
>     ========
>
>     >>> from sympy.crypto.crypto import check_and_join
>     >>> check_and_join('a phrase')
>     'a phrase'
>     >>> check_and_join('a phrase'.upper().split())
>     'APHRASE'
>     >>> check_and_join('a phrase!'.upper().split(), 'ARE', filter=True)
>     'ARAE'
>     >>> check_and_join('a phrase!'.upper().split(), 'ARE')
>     Traceback (most recent call last):
>     ...
>     ValueError: characters in phrase but not symbols: "!HPS"
>
>     """
>     rv = ''.join(''.join(phrase))
>     if symbols is not None:
>         symbols = check_and_join(symbols)
>         missing = ''.join(list(sorted(set(rv) - set(symbols))))
>         if missing:
>             if not filter:
>                 raise ValueError(
>                     'characters in phrase but not symbols: "%s"' % missing)
>             rv = translate(rv, None, missing)
>     return rv
>
>>
>
> This maybe very silly but use of join function twice is not clear to me.
> Please if anyone could help. :)
> Thanks in advance.
> Aditya
>
> --
> You received this message because you are subscribed to the Google Groups
> "sympy" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at https://groups.google.com/group/sympy.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sympy/12cfea84-7132-45fd-b236-e45cbc39b956%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sympy.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/CAKgW%3D6J5dPRL%2BkKQpEHaKOWY8rgm2FeAzFibbtwQy8v58aVbDw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to