[CentralOH] _ for variables that are never referenced
jep200404 at columbus.rr.com
jep200404 at columbus.rr.com
Wed Feb 25 01:41:55 CET 2015
- Previous message: [CentralOH] 2015-02-20 道場 Scribbles 落書/惡文? Euler #1, Pascal's triangle, minmaxsums, toolz.curried.pipe, _, Lenovo, termcap, * ipsum, sentiment analysis, jupyter/ipython, ASCII, ggplot/matplotlib, spyre
- Next message: [CentralOH] PythonDotNet
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
On Sat, 21 Feb 2015 11:49:13 -0500, jep200404 at columbus.rr.com wrote:
> for _ in range(n): # For when the loop variable is never referenced.
Python examples
>>> from random import randint
>>> for _ in range(5):
... print randint(0, 10-1)
...
8
4
7
4
1
>>> [randint(0, 10-1) for _ in range(5)]
[0, 9, 2, 2, 9]
>>>
Go
Using _ for name of unused variables is standard practice in Go.
The _ is called the blank identifier.
Joe Shaw address this in his presentation.
For example, see line 267 of
https://github.com/joeshaw/talks/blob/master/cohpy/zen.slide
for _, row := range table { ...
- Previous message: [CentralOH] 2015-02-20 道場 Scribbles 落書/惡文? Euler #1, Pascal's triangle, minmaxsums, toolz.curried.pipe, _, Lenovo, termcap, * ipsum, sentiment analysis, jupyter/ipython, ASCII, ggplot/matplotlib, spyre
- Next message: [CentralOH] PythonDotNet
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the CentralOH
mailing list