#πŸ”’ how do i annotate this?

28 messages Β· Page 1 of 1 (latest)

round oar
#

i got a parameter where i take

tuple[tuple[tuple[int]*x, str, bool]]
so like a tuple of tuples where the first any are tuples of int and the last to are str and bool in this order

how do i annotate this?

upper grailBOT
#

@round oar

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

round oar
#
automat = (
    ((1,), (5,), "-0", True),
    ((0,), (2,), "+0", True),
    ((3,), (1,), "-1", False),
    ((2,), (4,), "+1", False),
    ((5,), (3,), "-2", False),
    ((4,), (0,), "+2", False)
)

example input for that arg

#

the tuples with only 1 number are so i can define undeterministic ones too

proud warren
#

Keep in mind in your exampe (1)Β is not a tuple, it's just a number.

round oar
#

added a , since

reef flower
#

Yeah tuple is (1,1)

#

Lol

proud warren
#

This would be a tuple[tuple[int, int, str, bool], ...]

round oar
#

deited in the fix

proud warren
#

Are those always 1-tuples, or they can have more elements?

round oar
proud warren
#

Should be a tuple[tuple[tuple[int, ...], tuple[int, ...], str, bool], ...]it is a very wonky type though

proud warren
#

I'd recommend not using tuples for collections of variable size (unless it's necessary for some reason)

round oar
#

would help so that i dont accidentaly change it

proud warren
#

And using NamedTuples or Dataclasses can help reduce the cognitive load of complex tuples types.

round oar
#

its a table where the 1st coordinate is which node the second is which letter and the collection at the end is which nodes we can go from there

round oar
dusky rivet
#

what's your current version? still troubles?

upper grailBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.