Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Yonathan Ayenew
    @yonayen
    here.
    Matthew Conquergood
    @kristjin
    If anyone is driving to and from West Seattle I'd love to throw some cash for a carpool arrangement. Cheers!
    Alicija Bulota
    @alibulota
    Gitter download for Apple devices https://gitter.im/apps
    Joshua Frailey
    @jefrailey
    Joshua Frailey
    @jefrailey
    @nbeck90 I'm responding to your email now. The upshot is, try git push origin master
    Dhawal Nagpal
    @violetcontamination
    hi guys, i am having difficulty doing task 2 to customize shell and sublime text 2, i could install a few packages, but the rest did-is it possible to get some help before the class starts on task 2? thanks
    Joshua Frailey
    @jefrailey
    @violetcontamination Yep, I'll be in the class room by 6:30 (likely earlier, but 6:30 for sure).
    Matthew Conquergood
    @kristjin
    Is there anyone available to help me out with the command line setup?
    Joshua Frailey
    @jefrailey
    @kristjin I can help during the break, via e-mail, or here--I just don't want to distract anyone from the lecture
    Matthew Conquergood
    @kristjin
    @jefrailey PM'ed, thank you.
    Cris Ewing
    @cewing
    Good day, Pythonistas! I am online and eager to help if you need it.
    Joshua Frailey
    @jefrailey

    @cewing Let's say I have a dictionary that represents a unique customer. Something like:

    customer = {
        'first_name': first_name,
        'last_name': last_name,
        'phone_number': phone_number,
        # ...
    }

    and that I want to write a function that only needs access to one or two of the values in the dictionary. What should I consider when trying to decide whether the function should accept the entire dictionary or just the values it needs access to? So, this:

    def foo(customer_dict):
        first_name = customer_dict['first_name']
        # do something with first_name
    
    foo(customer)

    or:

    def bar(customer_first_name):
        #do something with customer_first_name
    
    bar(customer['first_name'])
    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