Skip to content

Relax Uniqueness Constraint for Write-only Variables #1477

Description

@PetterS

Description

I am hoping to be able to define cells like this, which is a common pattern in existing notebooks.

cell1:

fig, ax = plt.subplots()
ax.plot(...)

cell2:

fig, ax = plt.subplots()
ax.plot(...)

This is a pretty common pattern and the multiple definitions are not a problem since the variables are never read before they are assigned to in any cell.

Suggested solution

Allow multiple definitions of a variable if it is never read before being assigned to in any cell.

Alternative

One alternative is

_fig, _ax = plt.subplots()
_ax.plot(1, 2)

another is (e.g.):

def _():
  fig, ax = plt.subplots()
  ax.plot(1, 2)
_()

But neither is very pretty imo.

Additional context

No response

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions