Hacker Newsnew | past | comments | ask | show | jobs | submit | bearfrieze's commentslogin

Thanks for the excellent explanation and your great work on Python.


Thanks for pointing this out along with some folks over in the comments on GitHub. I've updated the Gist.


I like the replace method. It's a great way of doing the same thing.

I considered using the [::-1] syntax to reverse the list, but decided that there was enough "cute" stuff in the examples already.


[::-1] is an idiomatic way to reverse a string in Python that is the obvious way for a habitual user of the language to do it e.g.:

  def palindrome(s):
      return s == s[::-1]
It could be discussed whether ''.join(reversed(s)) is more readable for a novice programmer learning Python. In general, Python prefers words over punctuation.

Also, there are objects that can be reversed() that are not sequences.

http://stackoverflow.com/questions/931092/reverse-a-string-i...


1: Seems pretty clear that The Force Awakens is an "...origin story of a female Jedi." [1]

2: At some point while writing this I realised I would spend all evening if I had to round up all the planets, and chose to note that the lists are "non-exhaustive" instead :)

[1]: http://www.wga.org/content/default.aspx?id=6130


Nice bonus info. I didn't know about this (haven't spent much time with Python 2.x).


Author here. Thanks for this brilliant comment. May the force be with you.


Defining authorisation rules as part of your application sounds fine to me. Aim for making compilation and deployment of your application trivial.

Sounds like you want a linear hierarchy of roles. Attaching a number to each role and making rules based on that number might be all you need. For example:

  Superadmin : 100
  Admin      : 90
  Manager    : 80

  if (a.number > b.number) a can delete b


I had a hybrid system at one point that included this "access level" in addition to the roles system. So a person could have multiple roles, but only one access level. The access level was only for admin things like this, so most people were just "users."

It works fine, but you need to document what is going on, or at least put some good comments in. You are definitely going to confuse future developers (including yourself) as to why you sometimes check one set of constraints and sometimes another.

I got rid of this once the system got more heavily used though, as it's just too much overhead to keep track of two systems. So if you really do plan on staying small it's fine, but if you think this might grow, just stick to roles.


And if you want to make that readable, you could use enums or something similar in your language of choice.




First and foremost, "light" and "shocking" are references to the word which Litenin imitates: Lightning. I see a mysterious moderator has changed the title – I do not mind, but find it pretty curious.

When I started building Litenin I often found myself waiting several seconds for Feedly to load. My colleagues at work had desktop readers that were equally sluggish. In that perspective it seems rather fast.

I find that Feedly has improved significantly recently. I just loaded my feeds in ~1 second which isn't terrible considering it has a wealth of features that Litenin lacks.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: