Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

코드정리 + collection모듈 사용해보기. #48

Open
YJ-AnthonyJo opened this issue Aug 22, 2021 · 0 comments
Open

코드정리 + collection모듈 사용해보기. #48

YJ-AnthonyJo opened this issue Aug 22, 2021 · 0 comments
Assignees

Comments

@YJ-AnthonyJo
Copy link
Owner

YJ-AnthonyJo commented Aug 22, 2021

namedtuple, userlist
userlist : 보다 쉬운 메소드 재정의 가능.(리스트의 메소드를 override하지 않고 접근 가능하기에)
namedtuple : attribute로 접근 가능. -> immutable, 사용x, 새 class생성.

# Python program to demonstrate
# userlist


from collections import UserList


# Creating a List where
# deletion is not allowed
class MyList(UserList):
	
	# Function to stop deletion
	# from List
	def remove(self, s = None):
		raise RuntimeError("Deletion not allowed")
		
	# Function to stop pop from
	# List
	def pop(self, s = None):
		raise RuntimeError("Deletion not allowed")
	
# Driver's code
L = MyList([1, 2, 3, 4])

print("Original List")

# Inserting to List"
L.append(5)
print("After Insertion")
print(L)

# Deleting From List
L.remove()

image
image

@YJ-AnthonyJo YJ-AnthonyJo self-assigned this Aug 22, 2021
@YJ-AnthonyJo YJ-AnthonyJo changed the title collection모듈 사용해보기. 코드정리 + collection모듈 사용해보기. Aug 25, 2021
YJ-AnthonyJo added a commit that referenced this issue Aug 27, 2021
M	STACK_Viewer.py
M	modules/Command_Autocomplete.py
M	modules/Func.py
M	modules/config.py
M	modules/push.py
A	modules/push_Func.py
A	modules/push_bak.py
YJ-AnthonyJo added a commit that referenced this issue Aug 27, 2021
M	modules/config.py
M	modules/pop.py
YJ-AnthonyJo added a commit that referenced this issue Aug 27, 2021
M	modules/Func.py
M	modules/_print_.py
A	modules/_print_Func.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant