Joined October 2012
·

Lyndsy Simon

Charlottesville, VA
·
·
·

In what circumstance would you use this?

Looks like you have a typo in the title :)

Posted to Pythonic "Switch...Case" over 1 year ago

I've been using the literal notation like that more often these days, but using .get() to provide a default value is slick, and something that I've not had a need for yet.

I've been looking sreiously at GitLab, but so far I've not found a way for it to compete with Github's killer feature: their community.

GitLab works great for hosting my own code, and it's trivial to make it so that others can participate - but actually getting them to you Gitlab instance is kind of a pain.

Unfortunately, Github is closed source and possesses the advantage of the first mover. I don't think a distributed model is going to unseat them any time soon. I'd love to see them go more open, but until they do the situation isn't going to change unless a competitor exists that is both a codebase (a'la Gitlab) and a platform (a'la Github). Just being Open Source isn't good enough, and just having the social aspect isn't good enough.

I've updated the example to fix your catch. I also ended up changing the values of my example list, since saying we're getting even keys and showing odd vlaues messes with my head.

Good catch :) I said "indexes", but I was thinking "values".

You never completely grow out of off-by-one errors, it seems...

Posted to [JS] Not well known link() method over 1 year ago

Wow!

W3Schools says it's supported in "All Major Browsers". A quick test in Firefox, IE7, and Chrome shows it works in all of those.

I never expected a method like that on the String object. It's very Pythonic...

I had no idea that MySQL didn't have a rank() funciton. That's crazy, as it's something that is very widely used.

To be fair, though, it does have powerful LIMIT syntax that allows for easy paging, which is something that requires a couple of levels of nesting to do in SQL Server or Oracle.

I think I'll be sticking with PostgreSQL for my apps, though, to be honest.

IMO, this is usually best done at the database level if possible. For instance - PostgreSQL and most other RDBMSs have rank functions:

select name, score from players order by score desc

      name   |  score  
----------+---------
Jacob     |  10000  
Sophia    |   9900  
Mason     |   9890  
Isabella  |   9890  
William   |   9450  
Emma      |   8725  
Jayden    |   6520  
Olivia    |   4960  
Noah      |     10  
Ava       |      5  

select name, score, rank() as rank from players order by score desc

   name   |  score  | rank 
----------+---------+------
Jacob     |  10000  |    1 
Sophia    |   9900  |    2 
Mason     |   9890  |    3 
Isabella  |   9890  |    3 
William   |   9450  |    5 
Emma      |   8725  |    6 
Jayden    |   6520  |    7 
Olivia    |   4960  |    8 
Noah      |     10  |    9 
Ava       |      5  |   10 

Doing it there allows you to offload the processing to the DB, and even gives you the opportunity to use window functions to split the ranking into groups if you want.

Posted to Python for humans over 1 year ago

Even better, it's open source and hosted on Github: https://github.com/kennethreitz/python-guide

Awesome!

It's amazed me that there isn't a native implementation of Less for some time. This will almost certainly make me switch to Sass :)

I usually use a slightly different syntax to prevent that bug, but it's bitten me in the past.

I use leading commas instead of trailing commas, a habit that I think I picked up from Haskell config files in Linux or something. It's served me well and continues to annoy my coworkers.

Posted to Rulers in Sublime Text over 1 year ago

I have mine set at 79 and 72. The 72 is handy for docstrings in Python.

Now if I could just find a way to change the color of each one separately...

Achievements
154 Karma
4,747 Total ProTip Views