2

In various languages (void)foo is used to note that the variable foo is not used instead of forgotten, especially when writing a callback function whose arguments are restricted by other functions, like

static int callback(const char *path, void *buf, fuse_fill_dir_t filler,
                    off_t offset, struct fuse_file_info *fi)
{
    (void) offset;
    (void) fi;
...

How can this be properly done in Python? Say, when iterating a table by rows and there is an unneeded column func, what is the Python manner of claming that func is not demanded here? Code below:

for no, msg, func in TABLE:
    print(f'[{no}] {msg}')
user26742873
  • 919
  • 6
  • 21

1 Answers1

2

I believe you are looking for the underscore, which pretty much serves the purpose you're thinking of.

In the following example, _ indicates that the variable is not important in the loop.

for _ in range(10):
     print("Hello world")

You can take a look at this question for more details

Yusuf
  • 98
  • 2
  • 14