Re: stacks and queus: This isn't as complicated as the lack of information made it sound. It's just an order concept:
stack
An ordered list (or array, if you're coming from other languages) where items are added and deleted in Last-In-First-Out (LIFO) order. In other words, when you add an element to a stack, you push it into the first position (index 0); when you remove an element, you pop it from the last position (index length-1).
queue
An ordered list (or array, if you're coming from other languages) where items are added and deleted in First-In-First-Out (FIFO) order. When you add an element to a queue, you append it. It becomes the last index. When you remove an element, you leftpop it; this removes the item at index 0.
Stacks and queues are ways of adding and removing items from a list rather than objects in and of themselves.
Re: unpacking tuples. jetamors gave one example. I can see where it would be especially helpful in a configuration case. Once set, configuration data should generally be immutable. This way, you don't have to worry about the data stored in the tuple being changed, but you can assign each piece of it its own meaningful name.
A trivial example: Suppose you had a tuple that stored a person's last name, first name and birth date:
person = 'Smith', 'John', '01.16.80'
If you don't unpack it, you have to refer to each of those things by index: person[0], person[1], person[2]. Most people find the typing of brackets rather awkward because of their location. It's a lot simpler to do this:
last, first, birth = person
That way, you can use meaningful names to refer to each piece of data and they're simpler and quicker to type.
From a programming standpoint, since the tuple data can't be changed, if you want to change the data and use it several times in its changed form in the app, the only way to do that is to assign it to a variable that can accept the changes you want to make.
no subject
Re: stacks and queus: This isn't as complicated as the lack of information made it sound. It's just an order concept:
Stacks and queues are ways of adding and removing items from a list rather than objects in and of themselves.
Re: unpacking tuples.
jetamors gave one example. I can see where it would be especially helpful in a configuration case. Once set, configuration data should generally be immutable. This way, you don't have to worry about the data stored in the tuple being changed, but you can assign each piece of it its own meaningful name.
A trivial example: Suppose you had a tuple that stored a person's last name, first name and birth date:
If you don't unpack it, you have to refer to each of those things by index: person[0], person[1], person[2]. Most people find the typing of brackets rather awkward because of their location. It's a lot simpler to do this:
That way, you can use meaningful names to refer to each piece of data and they're simpler and quicker to type.
From a programming standpoint, since the tuple data can't be changed, if you want to change the data and use it several times in its changed form in the app, the only way to do that is to assign it to a variable that can accept the changes you want to make.