Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

I know I can do seq([]), but is there a particular reason seq() isn’t supported?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

EntilZhacommented, Jul 5, 2021

The idea to have a default doesn’t necessarily mean an equivalent way of doing it is bad style-wise. The reason for not doing sequence=[] is because the array is then a singleton across all calls, which leads to very weird behavior. The right way to implement this pattern, is to set sequence=None and then have a if sequence is None check, if so then set sequence = []. In this particular case, I don’t think you’d need to change the Sequence code since the type error is thrown in _parse_args and the Sequence constructor usually isn’t called by users, rather by the library itself.

Back to the question of whether you should be able to call seq() with arguments, I can get behind the argument of mirroring set() and list() in returning an empty sequence. The example stephan gave also seems like a reasonable use case for this.

Given that, I’d welcome a PR that modifies the len(args) == 0 code section to instead initialize to an empty sequence. I think that is probably the only change needed, but its possible I’m missing something

Kachecommented, Jul 8, 2021


Read more comments on GitHub >

github_iconTop Results From Across the Web

Definition:Sequence/Empty Sequence - ProofWiki
An empty sequence is a (finite) sequence containing no terms. Thus an empty sequence is a mapping from ∅ to S, that ...
Read more >
The empty sequence - OeisWiki
The empty sequence (as there is only one empty sequence) is the "solution" (so to speak) of a countably infinite number of unsatisfiable...
Read more >
Chapter 18. Null vs. Empty Sequence - JSONiq
Null and the empty sequence are two different concepts. Null is an item (an atomic value), and can be a member of an...
Read more >
emptySequence - Kotlin Programming Language
Returns an empty sequence. Stay in touch: Contributing to Kotlin · Releases · Press Kit · Security · Blog · Issue Tracker ·...
Read more >
ValueError: max( ) arg is an empty sequence - STechies
We encountered an error in line 5 i.e ValueError: min() arg is an empty sequence . This Is because min( ) method has...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found