Python Morsels (@pythonmorsels) 's Twitter Profile
Python Morsels

@pythonmorsels

Giving life-long learners a low-stress way to hone their #Python skills. 🐍🍪 Write beautiful code. ✨ Made by @treyhunner 💖

ID: 957073877787529217

linkhttp://pythonmorsels.com calendar_today27-01-2018 02:12:48

1,1K Tweet

7,7K Followers

5 Following

Python Morsels (@pythonmorsels) 's Twitter Profile Photo

"Turn a regular function into a generator function by replacing append calls with yield statements." 🐍 #Python pym.dev/how-to-create-…

Python Morsels (@pythonmorsels) 's Twitter Profile Photo

"A singleton class is a class that only allows creating one instance of itself." 1️⃣ #Python youtube.com/watch?utm_camp…

Python Morsels (@pythonmorsels) 's Twitter Profile Photo

"Just like with reader objects, we can loop over DictReader objects to get the rows within our file. But unlike reader objects, instead of getting back lists representing each row, we'll get back dictionaries." #Python pym.dev/csv-reading/?u…

Python Morsels (@pythonmorsels) 's Twitter Profile Photo

"If you'd prefer to think in terms of the headers in your file, rather than in terms of the indexes of each data column, you could use csv.DictReader instead of csv.reader." 📚 #Python pym.dev/csv-reading/?u…

Python Morsels (@pythonmorsels) 's Twitter Profile Photo

The built-in str function actually calls the __str__ method on the object that we give it. #Python youtube.com/watch?utm_camp…

Python Morsels (@pythonmorsels) 's Twitter Profile Photo

If we want to start counting at a different number, we can set the start keyword argument when calling enumerate. for n, fruit in enumerate(favorite_fruits, start=1): print(n, fruit) #Python pym.dev/looping-with-i…

Python Morsels (@pythonmorsels) 's Twitter Profile Photo

"In #Python, you can customize what happens when you ask objects whether they're equal to each other." 🐍🟰 pym.dev/overloading-eq…

Python Morsels (@pythonmorsels) 's Twitter Profile Photo

"For a very simple command-line program, you could just rely on #Python to close the file automatically when your Python program exits." youtube.com/watch?index=1&…

Python Morsels (@pythonmorsels) 's Twitter Profile Photo

If something is important, it deserves a name. #Python's for loops names the items themselves, not indexes. pythonmorsels.com/writing-a-for-…

Python Morsels (@pythonmorsels) 's Twitter Profile Photo

"We've exhausted our generator object; we've fully consumed all the items within it." 🏁 #Python youtube.com/watch?utm_camp…

Python Morsels (@pythonmorsels) 's Twitter Profile Photo

"Note that csv.reader doesn't know or care about the headers in our file: it treats every row equally." #Python pym.dev/csv-reading/?u…

Python Morsels (@pythonmorsels) 's Twitter Profile Photo

"Creating a singleton class might seem a little bit misleading to someone using this class." 😖 #Python youtube.com/watch?utm_camp…

Python Morsels (@pythonmorsels) 's Twitter Profile Photo

"We can only tell it's a generator function by the presence of a yield statement." #Python pythonmorsels.com/what-is-a-gene…

Python Morsels (@pythonmorsels) 's Twitter Profile Photo

"When we loop over a csv.reader object, the reader will loop over the file object that we originally gave it and convert each line in our file to a list of strings." 🔄💱 #Python pym.dev/csv-reading/?u…

Python Morsels (@pythonmorsels) 's Twitter Profile Photo

"When we call this generator function, it doesn't actually run the code in that function!" 🤯 #Python youtube.com/watch?utm_camp…

Python Morsels (@pythonmorsels) 's Twitter Profile Photo

You don't need third-party libraries to read CSV files in #Python! Python's csv module includes helper functions for reading CSV files, tab-delimited files, and other delimited data files. 👀💻🔍 pym.dev/csv-reading/?u…

Python Morsels (@pythonmorsels) 's Twitter Profile Photo

You'll almost always see tuple unpacking used whenever enumerate is used. for n, fruit in enumerate(favorite_fruits, start=1): print(n, fruit) #Python pym.dev/looping-with-i…