• BladeDecember 31, 2017, 11:54 PM
    Happy new year!
  • cococoreDecember 31, 2017, 8:42 PM
    if would problem with tk documentation i have some links to different sites
  • shadyJanuary 1, 2018, 12:00 AM
    Happy new year!
  • gdudeJanuary 1, 2018, 12:03 AM
    \o/
  • joeJanuary 1, 2018, 12:01 AM
    Happy new year <@!145475247074705408> <@140605665772175361> <@!109040264529608704>
  • jerbobJanuary 1, 2018, 1:26 AM
    Happy new year all you English people
  • ChristopherJanuary 1, 2018, 1:36 AM
    I would be happy if my cold would go away at 12:01am
  • jerbobJanuary 1, 2018, 1:26 AM
    Ayy
  • ChristopherJanuary 1, 2018, 1:36 AM
    
     def randomize( r, seed=None ):
        if seed is not None:
            r.seed(a=seed)
        return r.random()
    
  • lemonJanuary 1, 2018, 1:44 AM
    the only way to really make sense of that is that the `r` argument you pass in is the python `random` module
  • ChristopherJanuary 1, 2018, 1:39 AM
    I'm trying to understand this piece of code for the longest time; I understand that `r` is an argument in the function but what is `r.seed(a=seed)` is it applying the `seed` function to the `r` argument followed by assigning `seed` to `a` ? At the end `returning` the argument `r` as `random()` ?
  • lemonJanuary 1, 2018, 1:44 AM
    as you can see from the documentation, the `random` module has both a .seed and a .random methodhttps://docs.python.org/3/library/random.htmland the .seed method does take an optional keyword argument `a`so with that in mind,
    import random
    
    random_float = randomize(random, "someseed")
    
    this would work fine, but it's a stupid way to make that function. I don't see why you should have to send in the random module at all, it should just use it.
  • Deleted UserJanuary 1, 2018, 1:48 AM
    Is there any equivalent to the ` async for log in client.logs_from(message.channel, limit=100):` I see in the discord.py docs.im using 3.4 😒
  • lemonJanuary 1, 2018, 1:50 AM
    haha, aww. yeah that's a 3.5 feature :(
  • Deleted UserJanuary 1, 2018, 1:50 AM
    so I have no hope?>.<
  • lemonJanuary 1, 2018, 1:50 AM
    there's probably a way
  • Deleted UserJanuary 1, 2018, 1:50 AM
    lol im just gonna upgrade
  • lemonJanuary 1, 2018, 1:50 AM
    let me see if I can dig one up
  • Deleted UserJanuary 1, 2018, 1:50 AM
    it's fine
  • lemonJanuary 1, 2018, 1:50 AM
    you really should.
  • Deleted UserJanuary 1, 2018, 1:50 AM
    haha
  • lemonJanuary 1, 2018, 1:51 AM
    why would you use 3.4
  • Deleted UserJanuary 1, 2018, 1:52 AM
    c9.ioit's what it comes with
  • lemonJanuary 1, 2018, 1:53 AM
    and can that be upgraded at all?I remember I tried it before amazon bought itoh rightI just explained how
  • ChristopherJanuary 1, 2018, 1:54 AM
    <@95872159741644800> How is it known that `r` is for random ?
  • lemonJanuary 1, 2018, 1:55 AM
    because the function runs methods on the `r` argument, and those methods match the `random` module perfectlyeven to the point where the keyword argument provided for the .seed method is the same.
  • ChristopherJanuary 1, 2018, 1:56 AM
    I don't see that in the docs.
  • lemonJanuary 1, 2018, 1:56 AM
    if you pass that function a string or something instead of passing it the random module, it will crash.what docs
  • ChristopherJanuary 1, 2018, 1:56 AM
    for the random modulespecifying the use of `r` for random
  • lemonJanuary 1, 2018, 1:57 AM
    that's.. whatdon't see whatnoyou misunderstandhas an argument called `r`. what it's called is irrelevant.your function
  • ChristopherJanuary 1, 2018, 1:57 AM
    yeah I know that
  • lemonJanuary 1, 2018, 1:57 AM
    it could be called `shuttlecock` for all I careand that argument uses `r.seed(a=seed)`, right?so what do we know of that has a method called `seed()` with a keyword argument called `a` ?the random module!see here?https://docs.python.org/3/library/random.html#random.seed
  • ChristopherJanuary 1, 2018, 1:58 AM
    yup
  • lemonJanuary 1, 2018, 1:58 AM
    so it's not documented anywhere that `r` is the random modulebutfrom that method callyou can deduce itof course, you shouldn't have to deduce things, so that function you showed us sucksthere's all sorts of stuff wrong with it imo.
  • ChristopherJanuary 1, 2018, 1:59 AM
    yeah it's not mine but it was the only answer to a problem so I sorta have to use itI tried asking the guy to explain his code but he is a bit of a jerk to be honest
  • lemonJanuary 1, 2018, 2:02 AM
    def randomize(r, seed=None ): # r is a terrible variable name for this
      """ why is there no docstring?"""
      if seed is not None: # this should just be "if seed"
        # why is the function taking r as an argument instead of just calling random directly?
        r.seed(a=seed)
      return r.random()
    
    because, look
  • ChristopherJanuary 1, 2018, 2:03 AM
    His code is a confusing mess 😦`because the function runs methods on the r argument, and those methods match the random module perfectly even to the point where the keyword argument provided for the .seed method is the same.` I still don't get how it matches the random module perfectly; 🤔
  • lemonJanuary 1, 2018, 2:03 AM
    def randomize(seed=None):
      if seed:
        random.seed(a=seed)
      return random.random()
    
  • ChristopherJanuary 1, 2018, 2:03 AM
    So he looks smart in the forumAs to undermine me
  • lemonJanuary 1, 2018, 2:03 AM
    here, all I've done is replace r with `random`and it worksthis will do what the function is probably supposed to dobut without the hassle of having to pass the random module into itthat's why I can say it matches it perfectly
  • ChristopherJanuary 1, 2018, 2:04 AM
    He would say, I'm using the `functools` *partial* so I have to do it that waythe last bit of code uses *partial*
  • lemonJanuary 1, 2018, 2:06 AM
    just consider the last piece of code I wrote for you there
  • ChristopherJanuary 1, 2018, 2:06 AM
    `r` is an argument and it passes random
  • lemonJanuary 1, 2018, 2:06 AM
    that's what it should have looked like.that's easy to read and understandthat's what it does.
  • ChristopherJanuary 1, 2018, 2:07 AM
    
     def randomize( r, seed=None ):
        if seed is not None:
            r.seed(a=seed)
        return r.random()
    
  • lemonJanuary 1, 2018, 2:07 AM
    I haven't really changed anything, I've just simplified.
  • ChristopherJanuary 1, 2018, 2:07 AM
    ohhh I think I seereturn `r.random()`r is anything within the random modulewhy he does the other argument `seed=None`
  • lemonJanuary 1, 2018, 2:09 AM
    because he puts that seed into the seed method call
  • ChristopherJanuary 1, 2018, 2:08 AM
    therefore, `seed` as well
  • lemonJanuary 1, 2018, 2:09 AM
    so that you can call `randomize(random, "someseed")`and it will use `"someseed"` when it calls random.seed()
  • ChristopherJanuary 1, 2018, 2:16 AM
    🤔
  • lemonJanuary 1, 2018, 2:19 AM
    this piece of code really isn't that complicatedas the `a` keyword argwhat is it you don't understand
  • ChristopherJanuary 1, 2018, 2:24 AM
    `seed=None` as the method argument, when returning `r` as `random` which returns randomize it will return `a=seed`
  • lemonJanuary 1, 2018, 2:24 AM
    because it's optionalit takes seed=None as an argumentif you _do_ provide a seedline 2 will be Trueso it will run r.seed(a="whatever you sent in")
  • ChristopherJanuary 1, 2018, 2:25 AM
    yeah it will be `a=seed`
  • lemonJanuary 1, 2018, 2:25 AM
    which seeds the output of random.random()so it changes what is returnedit sort of primes the random generator with that seedyou follow?
  • ChristopherJanuary 1, 2018, 2:26 AM
    yeah, I suppose for now 😉
  • lemonJanuary 1, 2018, 2:26 AM
    ¯\_(ツ)_/¯if you don't understand it at this point, you should do some python basic syntax tutorialsthis should be very straight forward if you fully understand how functions and arguments in python work.
  • ChristopherJanuary 1, 2018, 2:27 AM
    I do understand but for some reason this code regardless how easy it is, threw me a curve ball
  • lemonJanuary 1, 2018, 2:28 AM
    that can happen
  • ChristopherJanuary 1, 2018, 2:28 AM
    funny how you can look at huge lines of code and understand then a few lines throw you a curve ball
    def f(a,b,c,x):
    return 10*a + 10*b + 10*c + 10*x
    k = partial(f,3,1,4)
    print(k(2))
    100
    
    How does it return `100` again ?`functools`
  • Deleted UserJanuary 1, 2018, 3:51 AM
    partial ?`partial(f,3,1,4)(2)==f(3,1,4,2)==10*3+10*1+10*4+10*2==30+10+40+20==100`
  • katlynJanuary 1, 2018, 5:09 PM
    Sure, I'll give it a go
  • DoubleVJanuary 1, 2018, 4:50 PM
    Does anyone want a fun and very simple challenge? 😄Il put it in challenges actuallyNope I won’t actually
  • jerbobJanuary 1, 2018, 5:14 PM
    done
  • DoubleVJanuary 1, 2018, 5:10 PM
    This task is from an interview for a person who applied to Google. They have a youtube video, but I thought it would be fun to write the solution in Python instead. If you’re an experienced programmer, the thinking part will be the most fun part. Otherwise it can be a big help to see half the code in c++ and the idea. ***So here’s the task:*** There’s a list of integers (example: [1, 2, 4, 4]) and you have to create a program that can determine whether 2 of the integers in the list can add up to a given sum (for example: sum = 8). It should return a boolean. You can choose a difficulty under :P **Easy**: Integers are in ascending order. **Normal**: Integers are in a randomized order within the list. **Hard**: Integers are randomized and the code should return a boolean and the addends used to get the sum.
  • jerbobJanuary 1, 2018, 5:14 PM
    this seems suspiciously easy for an interview for google
  • DoubleVJanuary 1, 2018, 5:15 PM
    Also, in the video they said you should do it in a different way than checking each number with every other one in the list
  • jerbobJanuary 1, 2018, 5:15 PM
    # Hard solution:
    from itertools import permutations
    def check_sum(list_,sum_):
        sums = permutations(list_,2)
        for pair in sums:
            if sum(pair)==sum_:
                return pair
    
    huh
  • DoubleVJanuary 1, 2018, 5:16 PM
    Hmm actually this could be hard to explainBut wow that was pretty simple anyways.... probably right lol
  • PyButtJanuary 1, 2018, 5:18 PM
  • DoubleVJanuary 1, 2018, 5:18 PM
    Here’s my “translation” from what the person interviewed did. https://code.sololearn.com/cFoMWk0ToYmd/ Not 100% sure if you can see it but I’m guessing you can
    SoloLearn
    Pairchecker (PYTHON)Embed imageCheck out what EricMcDerrick has created on SoloLearn
    https://code.sololearn.com/cFoMWk0ToYmd/
    The way he though atleast
  • jerbobJanuary 1, 2018, 5:19 PM
    Oh, I see
  • DoubleVJanuary 1, 2018, 5:19 PM
    Thought*Anyways. I’ll link the video too if you want 😛Sorry if I explained bad 😛I’m not that good and experienced tbh just found it cool myself and wanted to share it 😛
  • jerbobJanuary 1, 2018, 5:20 PM
    Yeah, that looks a little more efficientnp:Punknown.png
  • DoubleVJanuary 1, 2018, 5:22 PM
    Yep 😛😂https://m.youtube.com/watch?v=XKu_SEDAykw
  • jerbobJanuary 1, 2018, 5:26 PM
    This is getting a little <#291284109232308226>
  • ChristopherJanuary 1, 2018, 5:26 PM
    What is the point of working at Google when your paycheck isn't enough to live in Silicon Valley.I've watched three videos on operation overloading and I think I slightly understand 😦
  • gdudeJanuary 1, 2018, 7:48 PM
    Operator overloading?It's not super complicatedhttps://docs.python.org/3/reference/datamodel.htmlHave you looked at the data model docs <@!279865757460856833>?let's say you had a `Number` classspecifically, https://docs.python.org/3/reference/datamodel.html#emulating-numeric-typesand you wanted to be able to do `x + y` where `x` and `y` are instances of `Number`so, `x + y` would end up being `x.__add__(y)`then your `Number` class would need to have a function called `__add__`that's more or less all there is to itoperators in python are just syntactic sugarthey map directly to functions on the objects
  • MickJanuary 1, 2018, 8:00 PM
    til python calls the imaginary number j instead of i
  • gdudeJanuary 1, 2018, 7:53 PM
    well, aside from the assignment operator, `=`
  • MickJanuary 1, 2018, 8:00 PM
    as in `3j`, `1.5j`, `2-0.3j`
  • gdudeJanuary 1, 2018, 8:05 PM
    <@173511573674000384> because i is used for so many other things
  • Mango 🥭January 1, 2018, 8:04 PM
    Is this a good deal? https://www.humblebundle.com/books/python-by-packt-book-bundle
  • lemonJanuary 1, 2018, 8:05 PM
    it's probably a good deal just because it's a ton of stuff for practically nothing
  • gdudeJanuary 1, 2018, 8:05 PM
    <@95729236731494400> humble bundle is almost always a great deal
  • Mango 🥭January 1, 2018, 8:05 PM
    I meant those books
  • lemonJanuary 1, 2018, 8:05 PM
    but I've only heard of a couple of those books
  • Mango 🥭January 1, 2018, 8:05 PM
    Do you know if packt has uptodate and accurate info?
  • MickJanuary 1, 2018, 8:06 PM
    it never occured to me to try it outi simply mispelled something x_x
  • gdudeJanuary 1, 2018, 8:06 PM
    :P
  • MickJanuary 1, 2018, 8:06 PM
    honestly <@!109040264529608704> im more surprised thats a thing even ._.an extra 3 before the variable jand suddenly python gets weirdx3
  • lemonJanuary 1, 2018, 8:15 PM
    <@!95729236731494400> looks ok. py3 and modern, popular frameworks all over the place at first glance. but none of these books are well known, and packt seems to release almost exclusively books by indian authors I've never heard of.
  • mnJanuary 2, 2018, 5:25 AM
    morning
  • lemonJanuary 1, 2018, 8:16 PM
    I'm sure you could learn a lot from working through these books though but I doubt any of them are the best book on the topic.
  • AlpacaJanuary 2, 2018, 12:11 PM
    Anybody got some good project ideas for someone pretty new to python?
  • Deleted UserJanuary 2, 2018, 10:54 AM
    Oh, that Humble Bundle is there already dropped
  • shadyJanuary 2, 2018, 12:17 PM
    make hangman
  • SocialistDudeJanuary 2, 2018, 1:40 PM
    Anyone good with python webscraping?
  • gdudeJanuary 2, 2018, 1:40 PM
    `requests` and `bs4`that's what everyone is using hereor `aiohttp` if you need asyncio
  • SocialistDudeJanuary 2, 2018, 1:40 PM
    I use bs4 yea
  • gdudeJanuary 2, 2018, 1:40 PM
    :P
  • SocialistDudeJanuary 2, 2018, 1:41 PM
    How is it possible to take the review rating on tripadvisor<span alt="3.5 of 5 bubbles" class="ui_bubble_rating bubble_35" content="3.5" property="ratingValue" style="font-size:18px;"></span>any idea?
  • gdudeJanuary 2, 2018, 1:42 PM
    hmm, you can probably find it using the `property` attributeI don't actually use BS4 so I'm not sure of the search syntax though
  • jerbobJanuary 2, 2018, 2:20 PM
    Yeah, you might be able to do a
    soup.find("span",{"property":"ratingValue"})
    
    Or something along those lines
  • gdudeJanuary 2, 2018, 2:23 PM
    I'm pretty sure this breaks the tripadvisor ToS thoughso watch your usagethey provide an API for getting this data themselves, but there are display requirements
  • SocialistDudeJanuary 2, 2018, 2:29 PM
    Thanks guysTheir API doesn't give review text so I have to scrape itJust using 1 page
  • MickJanuary 2, 2018, 7:32 PM
    is using `break` and `continue` considered bad code style?in many cases i find using them much clearer because it reduces the need for multiple nested `if-else` clausesbut some people told me its not a good idea
  • gdudeJanuary 2, 2018, 7:35 PM
    Depends on the context
  • SocialistDudeJanuary 2, 2018, 1:41 PM
    They have bubbles lol
  • Zwack010January 2, 2018, 7:35 PM
    I like to use them to prevent nestingNested ifs and loops just look ugly, and hard to read imo
  • MickJanuary 2, 2018, 7:36 PM
    also i think that the `else` statement on loops works if you dont break during the loopso that could be quite handy sometimes
  • gdudeJanuary 2, 2018, 7:36 PM
    yep, that's what it does
  • lemonJanuary 2, 2018, 7:36 PM
    I would personally discourage any use of `else` for a loop.but I encourage `break` and `continue`
  • gdudeJanuary 2, 2018, 7:37 PM
    It's kinda hard to readwith the else at the end of the loopmost people don't know about itI've honestly never seen someone do it lol
  • lemonJanuary 2, 2018, 7:37 PM
    I tend to agreeEffective Python has a chapter that's about how you should never do it
  • MickJanuary 2, 2018, 7:38 PM
    yeah, ive never seen someone use itwell, at least not outside of the description of the else clause in the documentation
  • lemonJanuary 2, 2018, 7:39 PM
    the problem with the else in loops is that it doesn't do what you might intuitively expect it to.if they had named it `finally` instead, it would have been finethere is a `finally` clause in try except
  • MickJanuary 2, 2018, 7:39 PM
    well, its not quite like `finally` because it doesnt do it in all cases
  • lemonJanuary 2, 2018, 7:39 PM
    and it does what you might expect
  • MickJanuary 2, 2018, 7:40 PM
    there is also an `else` clause in `try/except` which works just like in loopsiirc
  • lemonJanuary 2, 2018, 7:40 PM
    the else in the loops does not.imo
  • Zwack010January 2, 2018, 7:40 PM
    ^ This is true
  • lemonJanuary 2, 2018, 7:40 PM
    yes. but the else in try also makes intuitive sense
  • MickJanuary 2, 2018, 7:41 PM
    well, id expect the else to happen if it were on breaks, which is quite counterintuitive to meid never write something that doesnt make sense first and foremost for me._.
  • lemonJanuary 2, 2018, 7:42 PM
    that's the primary problem I have with it, as well.
  • MickJanuary 2, 2018, 7:43 PM
    though ive never seen even a single place to use it either way so 0.0
  • lemonJanuary 2, 2018, 7:42 PM
    yeah. the fact that it doesn't happen when you hit a break (or a return statement btw) is a problem
  • SomeoneJanuary 2, 2018, 7:44 PM
    I use even bare excepts, am I weird
  • lemonJanuary 2, 2018, 7:45 PM
    it's not weird, it's just lazy.
  • gdudeJanuary 2, 2018, 7:53 PM
    I would find it useful if it only triggered on a break>:|
  • lemonJanuary 2, 2018, 11:01 PM
    yes, through `self`
  • ChristopherJanuary 2, 2018, 10:57 PM
    Methods in Classes can access other methods all within the same class, correct ?How can you verify if a class has self if it's unknown ? And what if the method doesn't have `self` ?
  • gdudeJanuary 2, 2018, 11:09 PM
    Most of the time you're looking at bound methods, which are called against an instance of the classOkay, so there are a few different types of methods on classes`x = ClassName(); x.method()`These methods _always_ have `self` defined as the first parameterIt doesn't actually have to be called that, but you usually do by conventionWhat matters is that there's an argument and python will automatically assign `self` to it when you call itThose ones don't get a `self` automaticallyYou can also have unbound methods, such as classmethods, which you call against the class directly instead of an instance of itHowever, whether a method is bound or unbound depends entirely on how you call itThe example with the bound method above would be the same as doing `ClassName.method(x)`In that case, the method is unbound and you're filling in self yourself
  • superhelixJanuary 2, 2018, 11:25 PM
    HeyI'd like help with some basic codepython
  • jerbobJanuary 2, 2018, 11:25 PM
    That's what we're here for :P
  • superhelixJanuary 2, 2018, 11:26 PM
    line 13, in read
        for x,y in instructions[0]:
    TypeError: 'int' object is not iterable
    it's giving me this and i have no clue what it means
  • jerbobJanuary 2, 2018, 11:25 PM
    What's the issue?Is that the entirety of the code?
  • superhelixJanuary 2, 2018, 11:26 PM
    import turtle
    
    x = 0
    y = 0
    turtle.ht()
    turtle.screensize()
    turtle.speed(0)
    
    pileList = [(1,3),(2,3),(3,3)]
    
    def read(instructions):
        while instructions != []:
            for x,y in instructions[0]:
                turtle.goto(x * 5, y * 5)
                instructions = instructions[1:]
    while 1:
        read(pileList)
    Yes
  • jerbobJanuary 2, 2018, 11:27 PM
    In your function `read`, you take a list as an argument
  • superhelixJanuary 2, 2018, 11:27 PM
    yes
  • jerbobJanuary 2, 2018, 11:27 PM
    Alright so let's break this downThis line is confusing:
    for x,y in instructions[0]:
    
    What you're doing is`(1,3)`You're taking the first coordinate in your list of coordinatesAnd you're assuming that the coordinate is a container of multiple containers that have a length of 2
  • superhelixJanuary 2, 2018, 11:30 PM
    oh
  • jerbobJanuary 2, 2018, 11:30 PM
    What it probably should be is:
    for x,y in instructions:
    
  • superhelixJanuary 2, 2018, 11:30 PM
    howd it know which um *tuple*? to grab
  • jerbobJanuary 2, 2018, 11:31 PM
    The `for` loop iterates through the list
  • superhelixJanuary 2, 2018, 11:31 PM
    oh
  • jerbobJanuary 2, 2018, 11:31 PM
    So the first time, it gets `(1,3)`
  • PyButtJanuary 2, 2018, 11:31 PM
  • jerbobJanuary 2, 2018, 11:32 PM
    And sets x to `1` and y to `3`The next, `(2,3)`, and finally `(3,3)`
  • superhelixJanuary 2, 2018, 11:32 PM
    I think I understandThanks
  • jerbobJanuary 2, 2018, 11:33 PM
    Did you make the code yourself?npI think I kinda understand what you were trying to achieveYou can remove the `instructions = instructions[1:]`Does it work?
  • lemonJanuary 3, 2018, 12:05 AM
    he means that if you decorate a class method with the `@classmethod` decorator, the method can belong to the class instead of the instance of the class, in which case it would have a `cls` instead of a `self` and you'd have to call the method through that.
  • ChristopherJanuary 2, 2018, 11:52 PM
    <@!109040264529608704> What do you mean `You can also have unbound methods, such as classmethods, which you call against the class directly instead of an instance of it` ?
  • joeJanuary 3, 2018, 2:20 AM
    Please don't ping me for no given reason.
  • lemonJanuary 3, 2018, 12:05 AM
    google `python @classmethod` for some more info on how that works.
  • joeJanuary 3, 2018, 2:20 AM
    Also, please ask your question in a relevant help channel
  • DoubleVJanuary 3, 2018, 6:56 AM
    Hey, was just wondering what happens if you have let's say this code and convert it to an exe file:
    import time
    print("Hi")
    time.sleep(5)
    
    Where will it "print" Hi?
  • Trixton78January 3, 2018, 2:20 AM
    all my sorry
  • DoubleVJanuary 3, 2018, 7:04 AM
    ok. How do I make it output something that someone can read then? Thanks
  • gdudeJanuary 3, 2018, 7:01 AM
    It won't unless you run it from a terminal
  • DoubleVJanuary 3, 2018, 7:04 AM
    By just running it