Best Python code snippet using autotest_python
OrderedSet.py
Source: OrderedSet.py
1# OrderedSet.py2#3# Written by Larry Holder (holder@wsu.edu).4#5# Copyright (c) 2017-2021. Washington State University.6#7# This implementation of OrderedSet maintains the set as both an8# actual (unordered) Python set and an ordered list. The main9# difference from other OrderedSet containers is that equality10# is supported.11class OrderedSet:12 def __init__(self, arg = None):13 if arg is None:14 arg = []15 self.list_container = []16 self.set_container = set()17 elements = []18 if isinstance(arg, (list, set)):19 elements = arg20 if isinstance(arg, OrderedSet):21 elements = arg.list_container22 for x in elements:23 self.add(x)24 25 def __str__(self):26 s = '{'27 firstOne = True28 for x in self.list_container:29 if firstOne:30 firstOne = False31 else:32 s += ', '33 s += str(x)34 s += '}'35 return s36 37 def __iter__(self):38 self.list_index = 039 return self40 41 def __next__(self):42 if self.list_index >= len(self.list_container):43 raise StopIteration44 x = self.list_container[self.list_index]45 self.list_index += 146 return x47 48 def __sub__(self, other):49 diff_set = self.set_container - other.set_container50 elements = [x for x in self.list_container if x in diff_set]51 return OrderedSet(elements)52 53 def __add__(self, other):54 new_set = OrderedSet(self.list_container)55 diff_set = other.set_container - self.set_container56 other_elements = [x for x in other.list_container if x in diff_set]57 for x in other_elements:58 new_set.add(x)59 return new_set60 61 def __eq__(self, other):62 return (self.set_container == other.set_container)63 64 def __ne__(self, other):65 return (self.set_container != other.set_container)66 67 def add(self, x):68 if x not in self.set_container:69 self.list_container.append(x)70 self.set_container.add(x)71 72 def intersect(self, other):73 if self.set_container.intersection(other.set_container):74 return True75 else:76 return False77 78 def intersection(self, other):79 int_set = self.set_container.intersection(other.set_container)80 elements = [x for x in self.list_container if x in int_set]81 return OrderedSet(elements)...
T_OrderedSet.py
Source: T_OrderedSet.py
1# OrderedSet.py2#3# Written by Larry Holder (holder@wsu.edu).4#5# Copyright (c) 2017-2021. Washington State University.6#7# This implementation of OrderedSet maintains the set as both an8# actual (unordered) Python set and an ordered list. The main9# difference from other OrderedSet containers is that equality10# is supported.11class OrderedSet:12 def __init__(self, arg=None):13 if arg is None:14 arg = []15 self.list_container = []16 self.set_container = set()17 elements = []18 if isinstance(arg, (list, set)):19 elements = arg20 if isinstance(arg, OrderedSet):21 elements = arg.list_container22 for x in elements:23 self.add(x)24 def __str__(self):25 s = '{'26 firstOne = True27 for x in self.list_container:28 if firstOne:29 firstOne = False30 else:31 s += ', '32 s += str(x)33 s += '}'34 return s35 def __iter__(self):36 self.list_index = 037 return self38 def __next__(self):39 if self.list_index >= len(self.list_container):40 raise StopIteration41 x = self.list_container[self.list_index]42 self.list_index += 143 return x44 def __sub__(self, other):45 diff_set = self.set_container - other.set_container46 elements = [x for x in self.list_container if x in diff_set]47 return OrderedSet(elements)48 def __add__(self, other):49 new_set = OrderedSet(self.list_container)50 diff_set = other.set_container - self.set_container51 other_elements = [x for x in other.list_container if x in diff_set]52 for x in other_elements:53 new_set.add(x)54 return new_set55 def __eq__(self, other):56 return (self.set_container == other.set_container)57 def __ne__(self, other):58 return (self.set_container != other.set_container)59 def add(self, x):60 if x not in self.set_container:61 self.list_container.append(x)62 self.set_container.add(x)63 def intersect(self, other):64 if self.set_container.intersection(other.set_container):65 return True66 else:67 return False68 def intersection(self, other):69 int_set = self.set_container.intersection(other.set_container)70 elements = [x for x in self.list_container if x in int_set]...
Check out the latest blogs from LambdaTest on this topic:
Before we discuss Scala testing, let us understand the fundamentals of Scala and how this programming language is a preferred choice for your development requirements.The popularity and usage of Scala are rapidly rising, evident by the ever-increasing open positions for Scala developers.
So, now that the first installment of this two fold article has been published (hence you might have an idea of what Agile Testing is not in my opinion), I’ve started feeling the pressure to explain what Agile Testing actually means to me.
Did you know that according to Statista, the number of smartphone users will reach 18.22 billion by 2025? Let’s face it, digital transformation is skyrocketing and will continue to do so. This swamps the mobile app development market with various options and gives rise to the need for the best mobile app testing tools
As a developer, checking the cross browser compatibility of your CSS properties is of utmost importance when building your website. I have often found myself excited to use a CSS feature only to discover that it’s still not supported on all browsers. Even if it is supported, the feature might be experimental and not work consistently across all browsers. Ask any front-end developer about using a CSS feature whose support is still in the experimental phase in most prominent web browsers. ????
The count of mobile users is on a steep rise. According to the research, by 2025, it is expected to reach 7.49 billion users worldwide. 70% of all US digital media time comes from mobile apps, and to your surprise, the average smartphone owner uses ten apps per day and 30 apps each month.
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!