Trey Hunner  

@treyhunner

Python & Django team trainer🎓 Curator of 🐍🍪 Former director at . 💖 Thought follower 🤔 he/him

San Diego, CA
Vrijeme pridruživanja: veljača 2014.

Tweetovi

Blokirali ste korisnika/cu @treyhunner

Jeste li sigurni da želite vidjeti te tweetove? Time nećete deblokirati korisnika/cu @treyhunner

  1. Prikvačeni tweet

    I run a service called to help professional Python developers get practice with interesting Python features. Short on time but want to level-up your skills every week? Try it out! ✨ The first 4 weeks are completely free. 🐍🍪

    Poništi
  2. 31. sij

    The sorted, min, and max functions all follow this convention of accepting a key function

    Poništi
  3. proslijedio/la je Tweet
    31. sij

    If you're at all interested in , thinking about coming to ? Today's the last day to request financial assistance. See art displays & performances, meet people at all programming skill levels, dip your toe into a new project...

    Prikaži ovu nit
    Poništi
  4. 30. sij

    An demo context manager ✨ class Connection: def __init__(self, yay): self.yay = yay def __enter__(self): print("Opened") return self def __exit__(self, *args): print("Closed") with Connection("Python!") as c: print(c.yay)

    Poništi
  5. 29. sij

    Finally watched 's talk, "Writing simpler and more maintainable Python" today. Some great visuals and analogies in this talk! 👍 I love the complexity mountain range, the functionality/users table, and the gravity of complexity. 🏔📈

    Poništi
  6. 28. sij

    "We use the same syntax for constructing objects from classes and for calling functions: this fact is the main reason the word "callable" is such an important part of our Python vocabulary."

    Poništi
  7. 28. sij

    Two surprises for new Pythonistas: 1. Variables in don't have types. Objects have types. 2. Variables don't contain objects; variables point to objects. Assignment changes where a variable points. Mutation changes an object. More from :

    Poništi
  8. proslijedio/la je Tweet
    25. sij

    Day 35<2020-01-23> Learnt more about List comprehensions - here's some advice from . List comprehensions are great, but sometimes less readable. Solution: break up a list comprehension over several lines.

    Poništi
  9. 24. sij

    "You'll also find functions-that-accept-functions in third-party libraries, like in Django, and in numpy."

    Poništi
  10. proslijedio/la je Tweet
    24. sij
    Odgovor korisniku/ci

    It does! No variable points to the file object after this line, so the file object is destroyed: text = open("file.txt").read() When a file object is destroyed in , the file auto-closes. This doesn't close the file: f = open("file.txt") text = ()

    Poništi
  11. proslijedio/la je Tweet
    24. sij
    Odgovor korisnicima

    An example of carriage returns being stripped (and the last newline being stripped) when using splitlines on a string: >>> text = "Python\r\nis\r\nlovely!" >>> text.split('\n') ['Python\r', 'is\r', 'lovely!'] >>> text.splitlines() # better ['Python', 'is', 'lovely!']

    Poništi
  12. proslijedio/la je Tweet
    22. sij

    I am gonna blog about this but DID YOU KNOW that you can use "&" (and), "|" (or) and "~" (not) for permissions? (h/t ) permission_classes = [IsSuperUser | IsAdmin]

    Poništi
  13. 23. sij

    Need to split up text into lines in ? Use the string splitlines method instead of the split method >>> text = open("file.txt").read() >>> text 'Python\nis\nlovely\n' >>> text.split("\n") ['Python', 'is', 'lovely', ''] >>> text.splitlines() ['Python', 'is', 'lovely']

    Poništi
  14. 23. sij

    You can do a case insensitive comparison in by normalizing the case of your strings first: >>> x = "Python" >>> y = "Python" >>> x.lower() == y.lower() True The casefold method normalizes more than lower/upper because it's more unicode-aware:

    Poništi
  15. 21. sij

    When making a dictionary the last value for a key "wins": >>> items = [('a', 1), ('b', 2), ('a', 3)] >>> dict(items) {'a': 3, 'b': 2} You could make the first values "win", by reversing the iterable before passing it to dict: >>> dict(reversed(items)) {'a': 1, 'b': 2}

    Poništi
  16. 20. sij

    By the way if you want to go the other way and confuse everyone, you could put trailing commas to pack and unpack in all your assignments. >>> x, = 1, >>> (x, y), = (1, 2),

    Prikaži ovu nit
    Poništi
  17. 20. sij

    Yes you *can* make a single-item tuple without parentheses. It's valid syntax. I say "don't" because it's a readability misunderstanding waiting to happen. These are too similar for my liking: >>> x = 1, >>> x = 1

    Prikaži ovu nit
    Poništi
  18. 20. sij

    "You can pass functions around because in Python, functions are objects."

    Poništi
  19. 20. sij

    It's the comma that makes the tuple in , not the parentheses. Feel free to leave those off (readability permitting). loc = (3, 4, 5) loc = 3, 4, 5 Except empty tuples are all about parens: stuff = () Also don't make single-item tuples without parens... 😲 nums = 3,

    Prikaži ovu nit
    Poništi
  20. 19. sij

    Did you know that you can include __dict__ in __slots__ on classes? class A: __slots__ = ('x', 'y', '__dict__') This won't make class instances save any memory, but lookups to x and y should be faster >>> a = A() >>> a.x = 2 >>> a.z = 4 >>> a.__dict__ {'z': 4}

    Poništi
  21. 17. sij

    When working with iterators, remember that you can only loop over them one time before they're exhausted. Iterators are single-use iterables. >>> nums = (n**2 for n in range(100)) >>> max(nums) 9801 >>> min(nums) ValueError: min() arg is an empty sequence

    Poništi

Čini se da učitavanje traje već neko vrijeme.

Twitter je možda preopterećen ili ima kratkotrajnih poteškoća u radu. Pokušajte ponovno ili potražite dodatne informacije u odjeljku Status Twittera.

    Možda bi vam se svidjelo i ovo:

    ·