Bring Your Logic using Python
341 subscribers
109 photos
1 video
4 files
544 links
Logic building using Python : Materials, links, e-books and Code snippets
Download Telegram
#Tips Here are 2 ways to download a file in #Python:
Use faker to generate random test data:

#Python #Tips #Django
How to check whether two strings are...

a) anagrams
>>> sorted(s1) == sorted(s2)

b) consist of the same characters
>>> set(s1) == set(s2)

c) the first of them is a palindrome
>>> s1[::-1] == s1

#Tips #Python
#Tips

You can use type() to dynamically create a new class:

NewType = type("NewType", (object,), {"a": 1, "b": 2})
n = NewType()

is the same as

class NewType(object):
a = 1
b = 2

n = NewType()