Skip to main content

Posts

Showing posts with the label basic

Raspberry Pi first steps and basic network configuration on a Mac

Here are my first steps. And I hope you will find something useful here, while configuring your Pi... First of all. Mine have been bought on ebay, from resellers. And were delivered a while ago. Main purpose of this purchase war to attach a headless server to my router. I have 2 external HDD's and would like to have torrents, Time Mashine fro my macs and so on. So buying a handheld computer like this would be a bargain for me. As for built in decisions like some kinds of NAT devices and different routers with external HDD features... They are either cost a lot or lack some kinds of desired functionality. So the goal is to make some kind http/api manageable server in my local network with Time Mashine and file storage/backup. Just for fun. And to have only laptop on my work table. SO back to the Pi. If you are buying "device only" configuration, like I did. First of all you'll need some different kind of things many computer fans usual...

Python sort() patterns

Python has a lot of sorting patterns. Let's make a short a list. 1. Sorting list by it's element. Simple case. Should simply do: > > > exmpl_list = [ 'a' , 'c' , 'B' , 'd' ] > > > exmpl_list . sort ( ) [ 'a' , 'B' , 'c' , 'd' ] However this example does not take locale into account and works only for ASCII characters. 2. Sorting list of sub elements. exmpl_list = [ { 'name' : 'Homer' , 'age' : 39 } , { 'name' : 'Bart' , 'age' : 10 } ] # Sorting by 'name' newlist = sorted ( exmpl_list , key = lambda k : k [ 'name' ] ) # Better way to use itemgetter(): from operator import itemgetter newlist = sorted ( exmpl_list , key = itemgetter ( 'name' ) ) Note that it is equivalent to: exmpl_list . sort ( key = lambda k : k [ 'name' ] ) # OR: exmpl_list . sort ( key = ite...