
Learn #Python programming from scratch through practical exercises.
Joined December 2018
- Tweets51
- Following1K
- Followers779
- Likes82
Python Principles retweeted
Hey, that's a neat #python trick!
Python Principles retweeted
#pythontip from @singhjayp:
Use shlex.split() to get shell-like splitting:
>>> import re
>>> re.split('\s', "this is 'my string'")
['this', 'is', "'my", "string'"]
>>> import shlex
>>> shlex.split("this is 'my string'")
['this', 'is', 'my string']
teapawt.org/singhjayp/status/10809β¦
Replying to @python_tip
@python_tip Python standard library's shlex.split function can be used to split the string while preserving the sub-strings in single/double quotes (phrases), unlike str.split where all the strings are separated including the phrases. Here is an example to show the difference:
Python Principles retweeted
#python lists have the count() method that returns the number of occurrences of an element:
>>> lst = [1, 1, 2, 3, 4, 5, 1, 3, 3, 3, 7, 9, 3]
>>> lst.count(2)
1
Most common item:
>>> max(lst, key=lst.count)
3
Python Principles retweeted
An A-Z of useful Python tricks
medium.freecodecamp.org/an-aβ¦
Python Principles retweeted
#pythontip from @singhjayp:
Use difflib.SequenceMatcher to compare strings.
docs.python.org/3/library/diβ¦
Example:
Python Principles retweeted
** How to write Beautiful Python Code ** realpython.com/python-pep8/
Python Principles retweeted
How to Send Emails with Python smtplib pybit.es/python-smtplib.htmlβ¦ #Python β at Sydney, New South Wales









