Pythonin’ – Sortin’, Tuples, Dicts…

We are here in Week 1 of learning Python! So far, it is going well. I feel I am picking up things pretty quickly. Just a recap, in the last post we learned a little intro and about strings and lists. Today we are going to talk about sorting, tuples (??), dicts, & del.

Sorting

Sorting a list can easily be done with the sorted(list) function. FYI: This doesn’t actually change the original list. You can pass through arguments to say, reverse the list like this: print sorted(list, reverse=True). The Python Wiki will tell you more. You can also use custom sorting with key=. Basically you would first use a predefined function and pass it through: print sorted(list, key=MyFn).

Tuples

I’m going to take these first lines directly from the Google Python Class (thank you license agreement!) because it sums these tuples up well: “A tuple is a fixed size grouping of elements, such as an (x, y) co-ordinate. Tuples are like lists, except they are immutable and do not change size.” You can create a tuple by just using parentheses. Because it is fixed size, remember to have the appropriate holding spaces separated by commas or you will get some errors. You can deal with tuples similarly to list except for things like append or things that assign indices or slices. I’d read up on them on say WikiBooks or the Python Docs.

Dicts

Dict (Dictionary) is Python’s key/value hash table structure. Side note: I had a hard time with hash tables and arrays in Ruby. I kept confusing them. Probably my roughest hours were working with multiple APIs and thus hash tables in my first major class project and I seriously just wanted to throw out my computer. I’m at a better place now. BACK TO PYTHON DICT. I think this is easier to explain in code:

Dict

 

 

 

 

 

There was a section on % formatting basically that for an integer if you say had hash[‘count’] = 27 and a string hash[‘fruit’] you could write it in in a string as string = ‘There are %(count)d %(fruit)s in the bucket’. Self explanatory.

Del

So that variable, list element, or dict entry is giving you some trouble and you just want to get rid of it. Del that thing!

 

Del

 

 

 

 

 

 

WHOOOHOO.

So we got through week 1 of Python! Over the last week we learned about Strings, Lists, Sorting, and Dicts plus the little parts that go along with them. At this point I am going to take a break from the Google Python Class to do Team Treehouse’s new Python Basic course as it goes over using Python, strings, numbers, lists, and control structures and functions. Plus I get to build a little game! FUN!!

Teaching myself Python – Day 1

I’m a Rubyist, I love that language. It is so fun and makes me happy. Regardless, I keep seeing jobs at companies that excite me but require or majorly emphasize Python. It has been getting me down and I finally (with the help of awesome YKat) decided, why don’t I just teach myself another language! So we begin today.

Python definitely beats RoR on install…my mac already was all setup for Python. Boom. Did I tell you I just had to re-setup my whole system because I spilt coffee on my computer and fried it? *cries*. RIP MacBook Air. Anyways, back to Python.

I’m following Google’s Python Class for people with some programming experience. It is FREE online. They do it as a 2-day intensive on campus. It includes written lessons, exercises, and lecture videos. It is a bit outdated but the core concepts should all be good.

Day 1 – Intro, Strings, Arra…I mean lists,

Google’s Python Class comes from a “you probably came from a C++/Java background” stance and even though it has been 10 years since I coded in those languages, it helps to get those pointers. I will mainly just be focusing on Python vs Ruby though. *Reminder to create/find Ruby/Python Cheat-Sheet*. Formatting is imperative with Python ie. the end of the line marks the end of the statement, indentations are used to express meaning, no need for semi-colons, etc. Concise and clean. Reminds me of CoffeeScript, which I enjoy. Mmm Coffee.

Strings-known as str. The len(str) function gets the length of the string and if you are doing the Google Python Class, be prepared to use it over and over. There are a bunch of string methods found here which you should keep handy until memorized. To me, I thought of all the string exercises as math “in a good way” and that made it pretty easy for me.  Speaking of exercises, you best get on to them!

Lists-So I see the example and am like, oh arrays, cool I just spent 2 weeks doing this in JavaScript..again. But then it says they are called Lists in Python. So LISTS. These work similarly to strings, awesome. One of the key things to learn are FOR and IN, I’m told to learn this syntax as I will use it a lot. FOR is a way to look at items in a collection such as WORD in WORDS. IN is a way to look if an item is in a collection.  Also learned about Range and While loops. Got those in Ruby. There are a bunch of list methods you can use, check them out.

Overall, I feel like I am getting it pretty fast especially compared to other languages.  The exercises went well, I had some formatting issues (to be expected) but otherwise I did pretty good. Excited to return to the Google Python Class tomorrow. Also, just saw that Team Treehouse JUST launched a Python course…I think I might do that next.

New project! MyChillPill

Hello! I have returned. I just finished up General Assembly’s Web Development Immersive which was a total of 12 weeks of Ruby on Rails, Javascript, HTML/CSS, TDD, Git, and everything related. It was intense but awesome.

For my final project I did a Mental Health focused app that uses drawing and writing as modes of escape and processing. I wanted to provide a free resource for people as it really is lacking in the mental healthcare system. I lost two friends last year so the topic was really close to my heart. Anyways, I built it using Ruby on Rails, Javascript, Jquery, this amazing JS library Drawingboard.js, HTML5 (especially Canvas), CSS, RSpec, & Devise. You can find it at mychillpill dot me.

NOTE: New Landing Page coming soon!

Draw

Drawing section with Prompts

Worksheets

Worksheets

Dashboard

Dashboard with completed Writings & Worksheets

There is also a Writing section with prompts (not pictured). Stay tuned for my other projects.

Web Dev Link Love: Code As Craft – Etsy Engineering Blog

Web Dev Link Love: Code As Craft – Etsy Engineering Blog

I happened upon Etsy’s Engineering blog, Code as Craft, while looking for one of their past projects, a gift giving suggestion engine, and boy what a gold mine I found! Even if you aren’t a lover of Etsy this blog is great if you want to learn about the journey (both good and bad!) of scaling up, the inner workings of a fabulous team, and overall just want to nerd out. The more I read Code as Craft the more it seems like the dream job for me…NYC in the future for me? 😉

Product Feature Fail: iOS7 Accessibility Invert Colors

I spent a bit today playing with the Settings iOS7 as I know my mom is going to have some issues with the new UI aka the colors & contrast. In the Accessibility Settings there is a setting called Invert Colors that appeared to be the golden ticket but what I found was…well you will see.

Image

Background turns to black and text to white as expected

At first, I was pretty excited as everything was pretty easy to read. Let’s go back into regular functions.

Image

Homescreen – 80’s stylin

True to their words, the colors are inverted as you can tell with all my green icons being purplish now. Even my background image is inverted! I now have an albino monkey giving a thumbs up! I thought this was cool so went to text YKAT and attach a photo but then got this:

ios7fail

iOS7 Accessibility Setting – Invert Colors displays photos inverted as well

FAIL.

On a positive note, all your images return to normal when you turn off Invert Colors as it is just a display setting. I’d recommend changing to Bold Text or Large Type for now.

Breaking (pretty) things to make even prettier things

My first live solo RoR project is a brunch finding app called Brunchover.  The backend still is looking good*. I wrote all the CSS from scratch and it was semi-okay on mobile devices but I knew I could do better. I promised myself (and friends) I would fix it, especially the JS capabilities, but life happened and thus IT did not happen. This morning I did a bit of breaking to try to make things happen. It can be a bit frightening to see a bunch of your hard work break or be deleted but sometimes that is what you need to do in order to make a better or even a working product.

Brunchover.com GitHub

Brunchover.com GitHub Repo Pushes

I personally get a joy of hacking my own code and getting things to a better place, I think that is why I like back-end coding so much. It definitely goes back to when I was a child, I was always taking things apart just so I could put them back together. Don’t be afraid to clear your code and rewrite, sometimes a blank slate is all that is needed to get those coding juices flowing again.  Make sure to push to GitHub first though ;-)

*Looks like I pissed off Foursquare with hitting their API so many times on reload :-$ I guess this project is to be continued…

Gorgeous user profile design: Three Day Rule

Gorgeous user profile design

So I am on this (so they say) elite online dating site Three Day Rule and wow, they have an amazing UX and front-end. I especially love their profile view as seen here.  I love how my main photo and name are front and center along with some quick facts. It is interesting to note that occupation is written first…but really, TDR is based in SF so that isn’t too odd. What other site’s have fantastic profile designs?
*yeah I know, I have a pic of my friends AND my dad on my profile (apparent cardinal sin of dating profiles) but they are a huge part of my life.