Hi all,
I am curious about whether there is function to fransform pure List to
pure Tuple and pure Tuple to pure List?
For example,
I have list L = [[1,2,3],[4,5,6]]
something list2tuple() will have T=list2tuple(L)=((1,2,3),(4,5,6))
And the tuple2list()
Any suggestions are welcome!
Best regards,
Davy 3 1867
On Nov 6, 11:18 am, Davy <zhushe...@gmail.comwrote:
Hi all,
I am curious about whether there is function to fransform pure List to
pure Tuple and pure Tuple to pure List?
For example,
I have list L = [[1,2,3],[4,5,6]]
something list2tuple() will have T=list2tuple(L)=((1,2,3),(4,5,6))
And the tuple2list()
Assuming you only want to look inside the types that you're
replacing...
def transform(source, from_type, to_type):
if not isinstance(source, from_type):
return source
else:
return to_type(transform(x, from_type, to_type)
for x in source)
def list2tuple(source):
return transform(source, list, tuple)
def tuple2list(source):
return transform(source, tuple, list)
--
Paul Hankin
Davy wrote:
Hi all,
I am curious about whether there is function to fransform pure List to
pure Tuple and pure Tuple to pure List?
For example,
I have list L = [[1,2,3],[4,5,6]]
something list2tuple() will have T=list2tuple(L)=((1,2,3),(4,5,6))
And the tuple2list()
Any suggestions are welcome!
D = { list : tuple, tuple : list }
F = lambda x : D[type(x)](map(F,x)) if type(x) in D else x
list2tuple = tuple2list = F
Davy wrote:
Hi all,
I am curious about whether there is function to fransform pure List to
pure Tuple and pure Tuple to pure List?
Isn't that just the same topic as in your other thread? I think it is
somewhat unfriendly that you ignore that one. It makes me feel that you
see this group as some sort of helpdesk.
Which it isn't (strictly).
/W This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Fuzzyman |
last post by:
Pythons internal 'pointers' system is certainly causing me a few
headaches..... When I want to copy the contents of a variable I find
it impossible to know whether I've copied the contents *or*...
|
by: Yomanium Yoth Taripoät II |
last post by:
HI,
1) what are the differences between list and tuple?
2) how to concatenate tuple and list? no method, no opérator?
3) im looking the fucking manual, and cant add value in my tuple, when it...
|
by: GrelEns |
last post by:
hello,
i wonder if this possible to subclass a list or a tuple and add more
attributes ? also does someone have a link to how well define is own
iterable object ?
what i was expecting was...
|
by: Ishwar Rattan |
last post by:
I am a little confused about a list and a tuple.
Both can have dissimilar data-type elements, can be returned
by functions. The only difference that I see is that list is
mutable and tuple is...
|
by: flyaflya |
last post by:
a = "(1,2,3)"
I want convert a to tuple:(1,2,3),but tuple(a) return ('(', '1', ',',
'2', ',', '3', ')') not (1,2,3)
|
by: Xah Lee |
last post by:
suppose i'm going to have a data structure like this:
,
,
,
,
....
]
should i use (width,height) or ?
|
by: fdu.xiaojf |
last post by:
Hi all,
I can use list comprehension to create list quickly. So I expected that I
can created tuple quickly with the same syntax. But I found that the
same syntax will get a generator, not a...
|
by: beginner |
last post by:
Hi,
I am wondering how do I 'flatten' a list or a tuple? For example, I'd
like to transform or ] to .
Another question is how do I pass a tuple or list of all the
aurgements of a function to...
|
by: Hatem Nassrat |
last post by:
on Wed Jun 13 10:17:24 CEST 2007, Diez B. Roggisch deets at nospam.web.de wrote:
Well I have looked into this and it seems that using the list
comprehension is faster, which is...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM).
In this month's session, the creator of the excellent VBE...
|
by: MeoLessi9 |
last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
|
by: DolphinDB |
last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation.
Take...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: Aftab Ahmad |
last post by:
Hello Experts!
I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
| |