Odoo Help

1

how to remove the duplicate number of elements in list?

By
Demirel yakito
on 1/20/15, 4:39 AM 2,173 views

iam hving list with repeated elements. so in this case how to delete the duplicate elements in the list using python?

1
Yenthe
On 1/20/15, 4:40 AM

For example:

def formatList(seq):
    seen = set()
    seen_add = seen.add
    return [ x for x in seq if not (x in seen or seen_add(x))]

There are loads of topics about this on stackoverflow and Google. This example is taken from http://stackoverflow.com/questions/480214/how-do-you-remove-duplicates-from-a-list-in-python-whilst-preserving-order and also keeps the order of your list!

 

A second option could be to create a second list, which only contains the clean values. In case you would like to keep both lists.

for i in mylist:
     if i not in newlist:
          newlist.append(i)

list = set(list) is this correct?

Demirel yakito
on 1/20/15, 4:49 AM
1
Ivan
On 1/20/15, 6:16 AM

I usually used list_wo_no_duplicate = list(set(list_with_ducplicates))  to remove duplicates.  Although I think there is no harm for not setting the variable to list again as set in most cases.

0
Odoo For Beginners
On 6/14/17, 1:41 PM

Take a look at this blog 

How to hide an options from 'More' button?
 
https://odooforbeginnersblog.wordpress.com/2017/06/11/how-to-hide-an-options-in-more-button/

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Register

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)

Stats

Asked: 1/20/15, 4:39 AM
Seen: 2173 times
Last updated: 6/14/17, 1:41 PM