Site Sponsors:
Python From Requirements 
Supporting yesterdays skill review session, we added a series of "sub-challenges" to project PR05. The additions were added to the bottom of the document.

Designed to help new students understand how to develop software in the professional software development world, such presentations are being extremely well received.

Those needing extra help with PR05 and / or any of the other activities can find the solutions to these & other projects in our new Python by Requirement book on Amazon.

Sharing is caring!


[ view entry ] ( 13 views )   |  permalink  |  related link
Modern Software Development on Low-end Computers 
If you have an older computer - or a computer sporting a smaller amount of memory / hard drive - you need to know about Lubuntu.

Tiny Brains

While there are several flavors of Linux that will yet work on smaller footprints, those wanting to use modern incarnations of C/C++, Python, Java, PHP, and other technologies would also like to have the latest software development tools.

Yet while always possible for the do-it-yourselfer on just about any Linux 'Distro, even those unafraid of long DIY efforts prefer avoiding such safaris...

Did I mention that I also wanted to use a 32 bit computer?

Mac Mini Support

My A1176 (i5 Core Solo) came with 512MB of RAM, and a 60GB hard drive.

While I had RAM that I could pull from other devices in-the-closet, I did not mind waiting for the upgrade to arrive from China.

'Bagging the requisite 2x1GB DDR2 upgrade on eBay for under $4.oo for the pair (free shipping, of course ;), the game is now afoot.


Whilst waiting on that slow-boat to arrive from China, I went looking for a silver bullet OS for my Mac Mini. We originally opted for Ununtu 10.10.

No longer readily supported for those modern editions of R&D tools however, we resisted the temptation to go "big-game" hunting to instead set our sights on Lubuntu 14.04.

We are presently stalking 14.04.05. Will let you know how it works out!

p.s. If you are looking for a great 'IoT' (lol) server to use for posting content to 'Twitter & elsewhere, discover - at the time of this new-year's undertaking - that one can score an old Mac Mini on eBay for under $50.

While still 32 bits, a T7600 Processor (i5 Dual Core) upgrade for all Intel Mac Minis is under $20.oo.

Once explored, discover also that maxed-out versions of a Mac Mini - which are completely capable of using Ubuntu 17.x - can be proudly brought-down & operationally enthroned in your trophy-case for under $60!


16 days latter, the RAM arrived. With the assistance of some oversized putty knives, the update was relatively (read: 'for an Apple device' ;-) easy to do.

(1) After removing the cover, the most difficult thing was to disconnect that tiny 2-wire power cable to the main board... I could easily see how people might make the mistake of doing that incorrectly. (i.e. It is a socketed, plastic pair. The top of the connector connects to a plastic base, NOT staking pins, so BE SURE TO wiggle it apart, do NOT attempt to pry it off of the mother board!)

(2) Next, the antenna also fell off of the Airport card whilst pulling-apart that 'mobo, but - unlike the power connector (!) - the antenna was easy to replace. (i.e. While I thought the copper snapped-off something, after staring at it in disbelief for a few, it was just a funky, socketed, connector. -Was easy to push the antenna back on the Airport card once the cerebral-shock wore off. (lol))

(3) As fate would have it, version 17.10.1 of Lubuntu was also waiting for us in the wings... Can you say 'Booya?

Happy Apple-Hacking!


[ view entry ] ( 18 views )   |  permalink  |  related link
Pythonic Content Generation & Yield-based Enumeration 
Very few jewels in Python's crown sparkle so brilliantly as the gem of Content Management.

Using 'with'

While ever-confusing to those who know another programming language, those interested in demonstrating genuine Pythonic mastery simply love to make their classes operate like they can "with files!"
        with open("/Projects.txt", "r") as fh:
line = fh.readline()
while len(line) is not 0:
row = line.split('|')
if len(row) is 2:
self._add(row[0], row[1])
line = fh.readline()

While tricky enough to get working properly, the key to using Python's 'with' keyword is understanding the meta-methods (or "magic methods") that are invoked beind the scenes:
    def  __enter__(self):
with open(self.projectFile, "r") as fh:
lines = fh.readlines()
for line in lines:
row = line.split('|')
if len(row) is 2:
self._add(row[0], row[1])
return self

def __exit__(self, type, value, tb):
return False

Using 'yield'

Of course once we have generated our content, what could be more Pythonic than to use Pythons 'yield' capability to serve-up your managed 'info?
    def enumerate(self):
for result in self.files:
yield result[0], result[1]

Real-World Example

The objective was to load file content every time its representational class was used:
""" Context manager designed to serve-up the script titles + file names
as present in an external text-file definition:

Projects.txt Example:

Common Header File | C:/Users/Randall/Desktop/ProdSet/NewGnuActivities/Module3000/Cpp3000d01s01p01/SloType/01_era_hpp
The File Header | C:/Users/Randall/Desktop/ProdSet/NewGnuActivities/Module3000/Cpp3000d01s01p01/SloType/02_file_hpp
The File Implementation | C:/Users/Randall/Desktop/ProdSet/NewGnuActivities/Module3000/Cpp3000d01s01p01/SloType/03_file_cpp
The Test Driver | C:/Users/Randall/Desktop/ProdSet/NewGnuActivities/Module3000/Cpp3000d01s01p01/SloType/04_main_cpp
The Make File | C:/Users/Randall/Desktop/ProdSet/NewGnuActivities/Module3000/Cpp3000d01s01p01/SloType/05_makefile

class ProjectReader:

""" Project file content must be in the above format. """
def __init__(self, projectFile):
self.projectFile = projectFile
self.files = []

""" Internal array is emptied & filled on-demand. Needs to be private. """
def _add(self, title, file_name):
row = [title.strip(), file_name.strip()]

""" Reload the project file each and every time we are asked to manage the File's content """
def __enter__(self):
with open(self.projectFile, "r") as fh:
lines = fh.readlines()
for line in lines:
row = line.split('|')
if len(row) is 2:
self._add(row[0], row[1])
return self

""" Enumerate through the Project File's content. """
def enumerate(self):
for result in self.files:
yield result[0], result[1]

""" Be sure to clean-up after any content-managed activity """
def __exit__(self, type, value, tb):
return False # Exceptions okay

if __name__ == "__main__":
with ProjectReader("./Projects.txt") as inst:
for title, file in inst.enumerate():
print (title, file, sep=' = ')

I hope you will find the example useful! -If this type of mastery is what you are looking for, then you can learn more on-line today.

[ view entry ] ( 21 views )   |  permalink  |  related link

<Back | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | Next> Last>>