Skip to content

Iterators#14

Open
ipsemenov wants to merge 6 commits into
mainfrom
iterators
Open

Iterators#14
ipsemenov wants to merge 6 commits into
mainfrom
iterators

Conversation

@ipsemenov
Copy link
Copy Markdown
Owner

No description provided.

@krglkvrmn
Copy link
Copy Markdown

Норм, +2 балла за оформление

Copy link
Copy Markdown

@krglkvrmn krglkvrmn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А не, стоп, у тебя класс во 2 задании не поддерживает интерфейс итератора.

# some check for valid format
with open(path_to_file, 'r') as handle:
for line in handle:
if line[0] != '>':
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if line[0] != '>':
if not line.startswith('>'): # Защита от пустой строки

Comment on lines +40 to +43
alphabet_nt = ['A', 'T', 'C', 'G']

alphabet_aa = ['A', 'R', 'N', 'D', 'C', 'E', 'Q', 'G', 'H', 'I',
'L', 'K', 'M', 'F', 'P', 'S', 'T', 'W', 'Y', 'V']
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Лучше tuple

:return: generator
'''

iterable = list(iterable)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Этой строчкой ты уничтожаешь весь смысл использования итераторов. Допустим, в iterable был генератор на 10^9 итераций. На этой строке он превратится в список, заняв много памяти и времени.

Comment on lines +150 to +154
if iterable:
yield iterable.pop(0)
yield from iter_append(iterable, item)
else:
yield item
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Суть верная, но можно проще

Suggested change
if iterable:
yield iterable.pop(0)
yield from iter_append(iterable, item)
else:
yield item
yield from iterable
yield item

'''

generator = my_generator(iterable=iterable)
return [i for i in generator]
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return [i for i in generator]
return list(generator)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants