Raymond Hettinger

@raymondh

Python core developer. Freelance programmer/consultant/trainer. Husband to Rachel. Father to Matthew.

Santa Clara, CA
Vrijeme pridruživanja: ožujak 2008.

Tweetovi

Blokirali ste korisnika/cu @raymondh

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

  1. 27. sij

    The .8 docs for statistics.NormalDist includes an examples/recipes section. 10-15 minutes to update your skills for cumulative distributions, quartiles and deciles, Monte Carlo simulations, Binomial distributions, and Naïve Bayesian Classifiers.

    Poništi
  2. 27. sij

    While it can be done, it is messy and full of interesting surprises. Better to incorporate the concrete class using composition, leaving inheritance for the abstract base class. Alternatively, inherit from the concrete class, skip the ABC, and override/extend methods as needed.

    Prikaži ovu nit
    Poništi
  3. 27. sij

    question worth pondering: Can you inherit from a concrete collection and an abstract base class collection at the same time?

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

    The issue arose accidentally today in class when "False" was passed to a "filename" parameter. The program didn't give an error and appeared to hang. It took a while to find the root cause. open() accepts a filename string, a path-like object, or an integer file descriptor.

    Prikaži ovu nit
    Poništi
  5. 14. sij

    pop quiz. Do you know what this does: with open(False) as f: s = ()

    Prikaži ovu nit
    Poništi
  6. 29. pro 2019.

    If there could have been a 5th choice, I would have added: * textwrap.dedent()

    Prikaži ovu nit
    Poništi
  7. 29. pro 2019.

    Which little known tool do you consider indispensable?

    Prikaži ovu nit
    Poništi
  8. 21. pro 2019.

    Compilers can never add malicious code. NOT The python.exe executable guaranteed to be safe. NOT The BIOS is always safe. NOT Intel IME can be complete trusted. HOPEFULLY

    Prikaži ovu nit
    Poništi
  9. 21. pro 2019.

    Assume that users have altered cookies. Assume that HTML requests may have been constructed maliciously. Assume that all data inputs may have been constructed maliciously.

    Prikaži ovu nit
    Poništi
  10. 21. pro 2019.

    SQL is powerful, always sanitize the inputs YAML is powerful, don't load untrusted data. XML macros are powerful, don't parse untrusted data. ANSI.SYS is powerful, don't print untrusted text files.

    Prikaži ovu nit
    Poništi
  11. 21. pro 2019.

    security: eval() is powerful, don't feed it untrusted inputs. "import" is powerful, don't import untrusted modules. "pickle" is powerful, don't unpickle untrusted data. Programmable computers are powerful, don't run untrusted programs.

    Prikaži ovu nit
    Poništi
  12. 14. pro 2019.

    Run with Python 3.8 on macOS 10.15.1 using: from string import Template s = 'abc' t = 'def'

    Prikaži ovu nit
    Poništi
  13. 14. pro 2019.

    's f-strings are amazingly fast! f'{s} {t}' # 78.2 ns s + ' ' + t # 104 ns ' '.join((s, t)) # 135 ns '%s %s' % (s, t) # 188 ns '{} {}'.format(s, t) # 283 ns Template('$s ').substitute(s=s, t=t) # 898 ns

    Prikaži ovu nit
    Poništi
  14. 13. pro 2019.

    oddity. The data type returned by star packing and unpacking is context dependent: >>> def f(x, *args): return args >>> type(f(2, 4, 6)) <class 'tuple'> >>> x, *args = (2, 4, 6) >>> type(args) <class 'list'> I wish the latter case returned a tuple.

    Poništi
  15. 12. pro 2019.

    from fraction import Fraction

    Prikaži ovu nit
    Poništi
  16. 12. pro 2019.

    Output: 2 Octave 3/2 Perfect 5th 4/3 Perfect 4th 5/4 Major 3rd 6/5 Minor 3rd 1 Unison

    Prikaži ovu nit
    Poništi
  17. 12. pro 2019.

    music theory: semitone = 2 ** (1/12) steps = {'Octave': 12, 'Perfect 5th': 7, 'Perfect 4th': 5, 'Major 3rd': 4, 'Minor 3rd': 3, 'Unison': 0} for interval, n in steps.items(): ratio = Fraction(semitone**n).limit_denominator(10) print(ratio, interval)

    Prikaži ovu nit
    Poništi
  18. 11. pro 2019.

    Over time, many statements have evolved a variant form as an expression: print ⟶ print() function def ⟶ lambda if ⟶ ternary operator for-loop with list.append() ⟶ list comprehension def and yield ⟶ generator expression = assignment ⟶ walrus operator

    Poništi
  19. 7. pro 2019.

    implementation note: The JSON and ElementTree parsers both intern recurring keys and tags. This gives a nice memory savings when loading from large JSON and XML files.

    Poništi
  20. 5. pro 2019.

    Here are the imports: from random import sample from statistics import fmean, stdev, quantiles

    Prikaži ovu nit
    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:

    ·