Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Cris Ewing
    @cewing
    That's a great question, @jefrailey
    I think it's largely going to be a matter of style and opinion, but in my case, I'd err toward passing only what is needed by the function
    It's probable that a function like bar above is going to refer to the 'name' that comes in, and that would be much clearer to read than something like "customer['name']" within the context of that function
    besides, if the function is really only about handling a name, who's to say what kind of object that name comes from? It might be a customer, or a client, or a friend, or a spouse, or anything, really
    so I would say, simply pass the value from the dictionary you are intending to use, and allow the function to deal only with the data it needs.
    Joshua Frailey
    @jefrailey

    @cewing Thanks. I'll keep your recommendation in mind. I can see an argument for both: Passing exactly what the function needs increases reusability, but passing an entire collection of things streamlines function call. I realized i was using both styles in one project, so I wanted to know what reasons you might have for picking one over the other. My trend seems to be to pass just what the function needs for functions that transform a single value such as:

    sanitize_id(id_):
        u"""Remove invalid username characters.
    
        Characters are removed here instead of being labled
        as invalid at username generation because the API    
        for one service automatically adds a special character
        to the id that another service does not allow.
        """

    but I also tend to pass entire collections to helper functions if the calling function accepts a collection: get_or_create_customer() needs to accept a collection of customer attributes in case it needs to create a customer, so _get_customer() accepts the same type of collection.

    Cris Ewing
    @cewing
    That's a reasonable argument and totally supportable.
    Cris Ewing
    @cewing
    Oh, nice. Now I can be here on my IRC client too!@
    Excellent
    cewing @cewing rubs hands together w/ glee
    Joshua Frailey
    @jefrailey
    How's the formatting via an IRC client?
    Cris Ewing
    @cewing
    @jefrailey: thanks for the pointer to joining on IRC
    was just about to test it out
    I don't see channel history, for one thing :(
    but perhaps that's because I just logged in via this transport for the first time
    let's see what happens going forward
    ```python
    def some_fun(arg):
    print arg
    ```
    blech
    not good here in textual
    doesn't look like it translates well to the http client either
    wonder if there's some multi-line input ability
    Cris Ewing
    @cewing
    foo

    this is a heading

    yeah, @jefrailey can you type a bit of formatted stuff so I can see what it looks like arriving at me?
    Joshua Frailey
    @jefrailey

    No, this is a heading

    def function(argument):
        u"""Docstring."""
        return argument += 1
    Cris Ewing
    @cewing
    yep, looks like poop here :)
    ah well.
    nothing in life is perfect
    Joshua Frailey
    @jefrailey
    I thought it might. I wonder if there's a hook on message send so that a function to autogenerate a link to a properly formatted snippet could be added
    Not ideal, but it could work as a band aid
    Cris Ewing
    @cewing
    maybe
    might also be a matter of improving the textual IRC theme
    this is, after all, just an HTML view
    Maybe some appropriate css and such might be able to fix the formatting issues.
    cewing @cewing wonders if someone has written such a thing yet
    Nathan Hubbell
    @lnhubbell
    @jefrailey its hard to say if I can see the entire history, but I can see things from before I joined.
    jefrailey @jefrailey is waiting for the trout slap wars
    Joshua Frailey
    @jefrailey
    @lnhubbell Good to know. Thanks! The earliest message I can see is from @cewing on the 24th.
    Cris Ewing
    @cewing
    I believe that message is the first in the channel
    Nathan Hubbell
    @lnhubbell
    @jefrailey yerp, Thats my first message as well
    its pretty sweet that this thing suggests rooms based on your github repos
    Joshua Frailey
    @jefrailey
    @/all Some of you may see labels on your pull requests that say scary things like, "question," or "invalid." They don't necessarily mean there's something wrong with your pull request--one of us will comment on the request if there is a problem. I'm using them to track requests that I've looked at, but are not yet ready to be merged. "Invalid," means that only some of the files in the pull request have been graded; "question" means that there's either a merge conflict or an out of place file.
    tlcunni
    @tlcunni
    Class was fun
    Cris Ewing
    @cewing
    It was a pleasure teaching you @tlcunni
    Nathan Hubbell
    @lnhubbell
    hello