Ali Shakiba - 1 year ago 119

Python Question

How can I create a tuple consisting of just an empty tuple, i.e.

`(())`

`tuple(tuple())`

`tuple(tuple(tuple()))`

`tuple([])`

`tuple(tuple([]))`

`()`

The reason that I use such a thing is as follows: Assume you have

`n`

`m`

`tuple`

`n`

`()`

Recommended for you: Get network issues from **WhatsUp Gold**. **Not end users.**

Answer Source

The empty tuple is `()`

, and a tuple with just one item (such as the integer `1`

), called a singleton (see here and here) is `(1,)`

. Therefore, the tuple containing only the empty tuple is

```
((),)
```

Here are some results showing that works:

```
>>> a=((),)
>>> type(a)
<type 'tuple'>
>>> len(a)
1
>>> a[0]
()
>>> type(a[0])
<type 'tuple'>
>>> len(a[0])
0
```

Recommended from our users: **Dynamic Network Monitoring from WhatsUp Gold from IPSwitch**. ** Free Download**