Código
SECTION_LINKS = 'LINKS' SECTION_NOTES = 'NOTES' SECTION_EXAMPLES = 'EXAMPLES' SECTION_DATA = 'DATA' SECTION_RELATED = 'RELATED' SECTION_DEFINITIONS = 'DEFINITIONS' COMMON_SECTIONS = [SECTION_LINKS, SECTION_NOTES, SECTION_EXAMPLES,\ SECTION_DATA, SECTION_RELATED, SECTION_DEFINITIONS] SECTION_ALGORITHM = 'ALGORITHM' SECTION_CONTENT = 'CONTENT' # - Structure AL_STRUCTURE = COMMON_SECTIONS.append(SECTION_ALGORITHM) print(AL_STRUCTURE) DE_STRUCTURE = COMMON_SECTIONS.extend(SECTION_CONTENT) print(DE_STRUCTURE)
En este caso, la salida de print para ambos es None.
El problema ya lo solucioné de la siguiente manera:
Código
Y funciona... Pero mi duda es la siguiente:
AL_STRUCTURE = [SECTION_ALGORITHM] AL_STRUCTURE.extend(COMMON_SECTIONS) DE_STRUCTURE = [SECTION_CONTENT] DE_STRUCTURE.extend(COMMON_SECTIONS)
¿Por qué en el primer caso AL_STRUCTURE y DE_STRUCTURE pasan a ser de tipo None?
By the way... ¿tienen una manera mas compacta y pythónica de hacer lo anterior?
