Skip to content

First try - Pavlovskaya Daria#11

Open
dashavpav wants to merge 3 commits into
kib-courses:masterfrom
dashavpav:homework1
Open

First try - Pavlovskaya Daria#11
dashavpav wants to merge 3 commits into
kib-courses:masterfrom
dashavpav:homework1

Conversation

@dashavpav
Copy link
Copy Markdown

No description provided.

Comment thread homework1/ArrayList.py
class ArrayList():
def __init__(self, *args):
if args.__len__() == 0:
self._RList = array('i',)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

А если захочется пустой инстанс, с другим типом?

Comment thread homework1/ArrayList.py Outdated
self._RList += array('u', item)

def __getitem__(self, index):
return self._RList[index]
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Добавь поддержку слайсов.
Извлеки из него начало-конец-шаг, и сформируй циклом результат

Comment thread homework1/ArrayList.py Outdated
return False

def __iter__(self):
return iter(self._RList)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Нужен свой итератор, работающий от начала массива, или от конца (для __reverse__).

Comment thread homework1/ArrayList.py
buf_l = ArrayList()
buf_r = ArrayList()
if type(elem) is not list:
if type(elem) == float:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

А что будет если массив int-овый?

Comment thread homework1/ArrayList.py
buf_l._RList = array('u', )
buf_r._RList = array('u', )
for i, el in enumerate(self._RList):
if i < index:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Если подать отрицательный индекс?

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