implement a ".join(*args)" method
See original GitHub issueIt would be nice to have a DOMElement.join()
method that mimics the str.join()
method in python.
Ideally, this method would accept a list of things and returns the passed list with the chosen TemPy tag instances between the list elements just like the str.join
method:
Br.join(["pizza", "pasta", "lasagna"])
>>> ["pizza", Br(), "pasta", Br(), "lasagna"]
Hr.join(["pizza", "pasta", "lasagna"])
>>> ["pizza", Hr(), "pasta", Hr(), "lasagna"]
Br.join(["pizza"])
>>> ["pizza"]
I’d make it a classmethod, so both Br.join(["pizza", "pasta", "lasagna"])
and Br().join(["pizza", "pasta", "lasagna"])
sytntaxes are allowed.
In the latter syntax copies of Br()
have to be created.
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (8 by maintainers)
Top Results From Across the Web
Implementing a join function that is being passed 3 arguments
You know the function has three arguments, so just use: ... number of strings to join as long as the separator is the...
Read more >Java Join Strings: String.join Method - Dot Net Perls
In Java, the join method receives a variable number of arguments. It accepts first a delimiter string—characters that are inserted between all joined ......
Read more >Python String join() Method - GeeksforGeeks
join () is an inbuilt string function in Python used to join elements of the sequence separated by a string separator. This function...
Read more >Join in Python: Definition, Usage, Syntax, and Parameters
Join in Python is an in-built method used to join an iterable's elements, separated by a string separator, which is specified by you....
Read more >Allow str.join to take *args in addition to iterable (like min/max)
I want to use str.join to directly construct multi-line strings, i.e.: "\n".join( "line1", "line2", ) but because only an iterable is ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @Navneet78 thanks for taking this. I assigned you this issue. If you have any question just ask on this issue.
Hi,
Yes, this is ok to happen, we don’t want the same instance in between the elements of the input, but several new instances of the same class.
it’s ok to just init the class with no parameters (
cls()
).