bachpx195 / experience

kiến thức thì vô tận.
1 stars 0 forks source link

EXPERIENCE Python #25

Closed bachpx195 closed 3 years ago

bachpx195 commented 7 years ago

Easy language?

bachpx195 commented 7 years ago

Python functions helper

1. Look inside variable:

object.dict

3. List

pop() Phương thức pop() xóa và trả về phần tử cuối cùng hoặc đối tượng obj có chỉ mục đã cung cấp từ list đã cho.

list = ['bach','nho','hue','nhieu','lam'] list ['bach', 'nho', 'hue', 'nhieu', 'lam'] list.pop(0) 'bach' list ['nho', 'hue', 'nhieu', 'lam']

4. assert

Cách đơn giản nhất để nghĩ về một Assertion là xem nó giống như một lệnh raise-if-no. Một biểu thức được kiểm nghiệm, và nếu kết quả là false, thì một exception được tạo ra.

bachpx195 commented 7 years ago

Lập Trình đa luồng: Các cơ chế đồng bộ trong Python

When I am having a big heated discussion at work, I use a rubber chicken which I keep in my desk for just such occasions. The person holding the chicken is the only person who is allowed to talk. If you don't hold the chicken you cannot speak. You can only indicate that you want the chicken and wait until you get it before you speak. Once you have finished speaking, you can hand the chicken back to the moderator who will hand it to the next person to speak. This ensures that people do not speak over each other, and also have their own space to talk.

Replace Chicken with Mutex and person with thread and you basically have the concept of a mutex.

Of course, there is no such thing as a rubber mutex. Only rubber chicken. My cats once had a rubber mouse, but they ate it.

Of course, before you use the rubber chicken, you need to ask yourself whether you actually need 5 people in one room and would it not just be easier with one person in the room on their own doing all the work. Actually, this is just extending the analogy, but you get the idea.

bachpx195 commented 7 years ago

Cac Khai niem#

Generators

python-iterator