[Python] Use curly braces to initialize a Set in Python

Discussão em 'Python' iniciado por Stack, Maio 22, 2025.

  1. Stack

    Stack Membro Participativo

    I'm learning python, and I have a novice question about initializing sets. Through testing, I've discovered that a set can be initialized like so:

    my_set = {'foo', 'bar', 'baz'}


    Are there any disadvantages of doing it this way, as opposed to the standard way of:

    my_set = set(['foo', 'bar', 'baz'])


    or is it just a question of style?

    Continue reading...

Compartilhe esta Página