Python> tuple> tuple unpacking

@ Introducing Python: Modern Computing in Simple Packages by Bill Lubanovic (No. 1466 / 12833)

This is sometimes called tuple unpacking.

Example

>>> marx_tuple = ( 'Groucho', 'Chico', 'Harpo' )
>>> a, b, c = marx_tuple
>>> a
'Groucho'
>>> b
'Chico'
>>> c
'Harpo'

Is it useful for checking the Nth item of tuple?

http://ideone.com/vuW96Q

marx_tuple = ( 'Groucho', 'Chico', 'Harpo' )
print(marx_tuple)

_, item2nd, _ = marx_tuple
print(item2nd)

if 'co' in item2nd:
	print('co inside')

result


Success	time: 0 memory: 23304 signal:0
('Groucho', 'Chico', 'Harpo')
Chico
co inside

Recommended Posts

Python> tuple> tuple unpacking
[Introduction to Udemy Python 3 + Application] 22. Tuple unpacking
Python
Story when iterating python tuple
python> tuple> data, address = s.recvfrom (10000)
[Python] Tuple version of prefecture pull-down
Python tuple comprehensions and generator expressions
Python 3 indexer and sequence unpacking (unpacking substitution)
Python> tuple> Convert double tuple to single tuple
kafka python
Python Summary
Built-in python
Python comprehension
Python technique
Studying python
Python 2.7 Countdown
Python FlowFishMaster
Python service
python tips
python function ①
Python basics
Python memo
ufo-> python (3)
Python comprehension
install python
Python basics ④
Python Memorandum 2
python memo
Python Jinja2
Python increment
atCoder 173 Python
[Python] function
Python installation
python tips
Installing Python 3.4.3.
[Introduction to Udemy Python3 + Application] 21. Tuple type
Python memo
Python iterative
Python algorithm
Python2 + word2vec
[Python] Variables
Python functions
Python sys.intern ()
Python tutorial
Python decimals
python underscore
Python summary
Start python
[Python] Sort
Note: Python
Python basics ③
python log
Python basics
python> Convert tuple to list> aList = list (pi_tuple)
[Scraping] Python scraping
Python update (2.6-> 2.7)
python memo
Python memorandum
Python # sort
ufo-> python
Python nslookup