938 Matching Annotations
  1. Feb 2020
  2. Jan 2020
  3. Dec 2019
    1. Werkzeug provides a development server: a simple web server that you can run with a single command and almost no configuration. When you do flask run (or werkzeug.serving.run_simple()), this development server is what you are getting
    1. Superseded by (replacement project): https://github.com/QTodoTxt/QTodoTxt2/


      Before I realized there was a replacement project:

      Blah. Looks good but unmaintained. Too many competing forks.

      Other interesting fork: https://github.com/kmicc/QTodoTxt/tree/dev

      This branch is 17 commits ahead, 201 commits behind QTodoTxt:dev. https://github.com/QTodoTxt/QTodoTxt/compare/master...kmicc:dev https://github.com/kmicc/QTodoTxt/network

    1. HTTPretty

      Use this to mock the request object so that it will be easier to mock the request context manager.

  4. Nov 2019
    1. import operator s = sorted(s, key = operator.itemgetter(1, 2))

      Sort by multiple indexes.

    2. to reverse to only one attribute, you can sort twice: first by the secondary s = sorted(s, key = operator.itemgetter(2)) then by the primary s = sorted(s, key = operator.itemgetter(1), reverse=True)

      This makes sense, particularly from specification of sort order in Pandas, if I recall correctly you usually specify the primary last which makes me think on the backend implementation it does something similar to this where it sorts from the lowest priority to the highest priority.

  5. Oct 2019
    1. One of my favorite languages that I have had the pleasure to use is Python. Python supports named parameters without any trickery.... Since I started using Python (some time ago) everything became easier. I believe that every language should support named parameters, but that just isn't the case.
    1. Indicate number of NA values placed in non-numeric columns.

      This is only true when using the Python parsing engine.

      Filled 3 NA values in column name
      

      If using the C parsing engine you get something like the following output:

      Tokenization took: 0.01 ms
      Type conversion took: 0.70 ms
      Parser memory cleanup took: 0.01 ms
      
    1. I can't make an annotation on Google's documentation ( I think it's a Hypothesis bug ) but I've updated the linked code sample below to work as of 10/04/2019 with Python 3

      https://gist.github.com/technoplato/4d28f4f308ea7c5fe20bd23e751e9e60

  6. Sep 2019
    1. Which works fine, but make you use lambda. You could rather use the operator module:import operator mylist = list(zip(range(40, 240), range(-100, 100))) sorted(mylist, key=operator.itemgetter(1))
    1. py27-django{18,19,110,111,111tip},

      An example of how to test multiple python versions against multiple library versions

  7. Aug 2019
    1. intern

      sys.intern in Python3

    2. ascii letters, digits or underscores

      String composed of these characters are interned. Aka the following will not be interned:

      f = 'f o'

      but the following will be interned:

      f = 'f_o'

    3. sequences generated through peephole optimization are discarded if their length is superior to 20

      So values generated via peephole optimization above 20 are not 'pre-computed' but left as is:

      'a' * 21 # remains in the byte code where as
      'a' * 20 # gets converted to 'aaaaaaaaaaaaaaaaaaaa'
      
    4. string subclasses cannot be interned

      Meaning

      class NewString(str):
         pass
      assert NewString('f') is 'f'
      

      Will fail. Where as:

      f = 'f'
      assert f is 'f'
      

      Will pass.

      This is presents a case for not building custom string types in Python as it breaks the string cache and can result in a performance hit.

    5. strings can be compared by a O(1) pointer comparison instead of a O(n) byte-per-byte comparison

      This is a huge advantage. Not only does it save memory by not duplicating simple and common string values, but the comparison method has an early exit that compares the pointers instead of the values. aka in sudo-code form:

      // compare pointers
      if self._value is value:
         return True
      
      // compare values
      for i, v in enumerate(self._value):
         if v != value[i]:
            return False
      return True
      
  8. Jul 2019
    1. On 10 April, astrophysicists announced that they had captured the first ever image of a black hole. This was exhilarating news, but none of the giddy headlines mentioned that the image would have been impossible without open-source software. The image was created using Matplotlib, a Python library for graphing data, as well as other components of the open-source Python ecosystem. Just five days later, the US National Science Foundation (NSF) rejected a grant proposal to support that ecosystem, saying that the software lacked sufficient impact.

      This story raises the question "From the funding point of view, what is reproducible research?".

  9. Jun 2019
    1. get_current_request()

      This can be used to get the current request object if the request object is not already available in the current context. It really shouldn't be used in production code but in a debug/test scenario it can be quite handy.

    1. Corporate training Introduction to Python Advanced Python Python for non-programmers Data science and machine learning in Python Python for system administrators Python Practice Workshop Regular expressions Introduction to Git Online training Weekly Python Exercise NumPy Intro Python: Fundamentals Object-oriented Python Comprehending Comprehensions Understanding and mastering Git Python Workout Practice Makes Regexp Free e-mail courses Regular expressions crash course Boolean indexing in NumPy and Pandas Variable scoping in Python Working with files in Python Teach programming better Blog About Reuven Home → Blog →Python →Why do Python lists let you += a tuple, when you can’t + a tuple? 1 Why do Python lists let you += a tuple, when you can’t + a tuple? Let’s say you have a list in Python: >>> mylist = [10, 20, 30] You want to add something to that list. The most standard way to do this is with the “append” method, which adds its argument to the end of the list: >>> mylist.append(40) >>> print(mylist) [10, 20, 30, 40] But what if you want to add multiple items to a list? If you’re new to Python, then you might think that you can and should use a “for” loop. For example: >>> mylist = [10, 20, 30] >>> new_items = [40, 50, 60] >>> for one_item in new_items: mylist.append(one_item) >>> print(mylist) [10, 20, 30, 40, 50, 60] Great, right? But it turns out that there is a smarter and faster way to do this. You can use the += operator. This operator, which invokes the “iadd” (“inplace add”) method on the object to its left, effectively does what we did above, but in much less code: >>> mylist = [10, 20, 30] >>> new_items = [40, 50, 60] >>> mylist += new_items >>> print(mylist) [10, 20, 30, 40, 50, 60] It’s not a huge surprise that += can do this. After all, we normally expect += to add and assign to the variable on its left; it works with numbers and strings, as well as other types. And we know that we can use the + operator on lists, too: >>> [1, 2, 3] + [4, 5, 6] [1, 2, 3, 4, 5, 6] Can we join a list and a tuple? Let’s check: >>> mylist = [10, 20, 30] >>> t = (40, 50, 60) >>> mylist + t Traceback (most recent call last): File "", line 1, in TypeError: can only concatenate list (not "tuple") to list In other words: No. Trying to add a list and a tuple, even if we’re not affecting either, results in the above error. Which is why it’s so surprising to many of my students that the following does work: >>> mylist = [10, 20, 30] >>> t = (40, 50, 60) >>> mylist += t >>> mylist [10, 20, 30, 40, 50, 60] That’s right: Adding a list to a tuple with + doesn’t work. But if we use +=, it does. What gives? It’s common, when teaching Python, to say that x += 5 is basically a rewrite of x = x + 5 And in the majority of cases, that’s actually true. But it’s not always true. Consider: When you say “x + y” in Python, the “+” operator is translated into a method call. Behind the scenes, no matter what “x” and “y” are, the expression is translated into: x.__add__(y) The “__add__” magic method is what’s invoked on an object when it is added to another object. The object on the right-hand side of the “+” is passed as an argument to the method, while the object on the left-hand side is the recipient of the method call. That’s why, if you want your own objects to handle the “+” operator, you need to define the “__add__” method in your class definition. Do that, and things work just fine. And thus, when we say “x = x + 5”, this is turned into x = x.__add__(5) Meaning: First invoke the method, and then assign it back to the variable “x”. In this case, “x” isn’t changing; rather, the variable is now referencing a new object. Now consider the “+=” operator: It’s translated by Python into “__iadd__”, short for “inplace add.” Notice the slightly different syntax that we use here: x += y is translated into x.__iadd__(y) Did you see the difference between __add__ and __iadd__? The latter executes the assignment all by itself, internally. You don’t have to capture its output and assign it back to x. It turns out that the implementation of list.__iadd__ takes the second (right-hand side) argument and adds it, one element at a time, to the list. It does this internally, so that you don’t need to execute any assignment after. The second argument to “+=” must be iterable; if you say mylist += 5 you will get an error, saying that integers are not iterable. But if you put a string, list, tuple, or any other iterable type on the right-hand side, “+=” will execute a “for” loop on that object, adding each of its elements, one at a time, to the list. In other words: When you use + on a list, then the right-hand object must be a list. But when you use +=, then any iterable type is acceptable: >>> mylist = [10, 20, 30] >>> mylist += [40, 50] # list >>> mylist [10, 20, 30, 40, 50] >>> mylist += (60, 70) # tuple >>> mylist [10, 20, 30, 40, 50, 60, 70] >>> mylist += 'abc' # string >>> mylist [10, 20, 30, 40, 50, 60, 70, 'a', 'b', 'c'] >>> mylist += {'x':1, 'y':2, 'z':3} # dict! >>> mylist [10, 20, 30, 40, 50, 60, 70, 'a', 'b', 'c', 'x', 'y', 'z'] Does this work with other types? Not really. For example: >>> t = (10, 20, 30) >>> t += [40, 50] Traceback (most recent call last): File "", line 1, in TypeError: can only concatenate tuple (not "list") to tuple What happened here? Let’s check the definition of tuple.__iadd__ to find out: >>> help(tuple.__iadd__) Traceback (most recent call last): File "", line 1, in AttributeError: type object 'tuple' has no attribute '__iadd__' Wait a second: There is no “__iadd__” method for tuples? If so, then how can “+=” work at all? Because Python tries to be smart in such cases: If the object implements “__iadd__”, then the “+=” operator invokes it. But if the object lacks an “__iadd__” implementation, then Python does what we all guess it normally does — namely, invoke “__add__”, and then assign the results back to the variable. For example: >>> class Foo(object): def __init__(self, x): self.x = x def __add__(self, other): print("In __add__") return Foo(self.x + other.x) >>> f1 = Foo(10) >>> f2 = Foo(20) >>> f1 += f2 In __add__ >>> vars(f1) {'x': 30} In other words, Python notices that our Foo class lacks an implementation of “__iadd__”, and substitutes “__add__” for it, assigning its result (a new instance of Foo) to the original variable.
  10. Apr 2019
    1. #!/usr/bin/env python3 import configparser import os import sys from selenium import webdriver from selenium.webdriver.chrome.options import Options from selenium.webdriver.common.keys import Keys from selenium.common.exceptions import TimeoutException from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.common.by import By config = configparser.ConfigParser() config.read("config.ini") chrome_options = Options() chrome_options.add_argument("--headless") driver = webdriver.Chrome(executable_path=os.path.abspath("/usr/local/bin/chromedriver"), chrome_options=chrome_options) driver.get("https://fastmail.fm") timeout = 120 try: element_present = EC.presence_of_element_located((By.NAME, 'username')) WebDriverWait(driver, timeout).until(element_present) # Send login information user = driver.find_element_by_name("username") passwd = driver.find_element_by_name("password") user.send_keys(config["default"]["user"]) passwd.send_keys(config["default"]["pass"]) driver.find_element_by_class_name("v-Button").click() print("Logged in") # wait for login to complete element_present = EC.presence_of_element_located((By.CLASS_NAME, 'v-MainNavToolbar')) WebDriverWait(driver, timeout).until(element_present) # click settings menu to make elements visible driver.find_element_by_class_name("v-MainNavToolbar").click() # And follow to settings page driver.find_element_by_link_text("Settings").click() # Wait for settings page to render, oh Javascript element_present = EC.presence_of_element_located((By.LINK_TEXT, 'Rules')) WebDriverWait(driver, timeout).until(element_present) # Click on Rules link driver.find_element_by_link_text("Rules").click() # Click on edit custom sieve code element_present = EC.presence_of_element_located((By.LINK_TEXT, 'Edit custom sieve code')) WebDriverWait(driver, timeout).until(element_present) driver.find_element_by_link_text("Edit custom sieve code").click() print("Editing") # This is super unstable, I hate that we have to go by webid element_present = EC.presence_of_element_located((By.CLASS_NAME, 'v-EditSieve-rules')) WebDriverWait(driver, timeout).until(element_present) print("Find form") elements = driver.find_elements_by_css_selector("textarea.v-Text-input") element = elements[-1] # Find the submit button elements = driver.find_elements_by_css_selector("button") for e in elements: if "Save" in e.text: submit = e print("Found form") # And replace the contents element.clear() with open("rules.txt") as f: element.send_keys(f.read()) # This is the Save button print("Submitted!") submit.click() except TimeoutException as e: print(e) print("Timed out waiting for page to load") sys.exit(0) print("Done!")
  11. Mar 2019
  12. Feb 2019
  13. Jan 2019
    1. MIT “MATLAB is the language used by virtually every team in the world that designs gravitational wave detectors… I look forward to exploring the data from each new detection in MATLAB.” Matthew Evans, Assistant Professor of Physics
    1. KNIME includes Python in various processing nodes for data processing, model learning and prediction, and the generation of visualizations.
  14. Dec 2018
  15. Nov 2018
  16. Oct 2018
    1. All you can do is send a message (AYCDISAM) = Actors model - there is no direct manipulation of objects, only communication with (or invocation of) them. The presence of fields in Java violates this.

      from what I understand in Java... there are some variables on classes (class instances) that are only acessible through methods and for those the "only send message" paradigm holds but there are also fields which are like attributes in python which you can change directly

  17. Aug 2018
  18. Jul 2018
  19. Jun 2018
    1. With over 6 million users, the open source Anaconda Distribution is the fastest and easiest way to do Python and R data science and machine learning on Linux, Windows and Mac OS X. It's the industry standard for developing, testing and training on a single machine

      With over 6 million users, the open source Anaconda Distribution is the fastest and easiest way to do Python and R data science and machine learning on Linux, Windows and Mac OS X. It's the industry standard for developing, testing and training on a single machine

    1. Project Jupyter exists to develop open-source software, open-standards, and services for interactive computing across dozens of programming languages

  20. May 2018
    1. 如果不在同一个package中,例如我们希望在module_21.py中调用module_11.py中的FuncA
      from module_11包名.module_11 import funcA
      
    1.   这两个函数都接收一个分割字符串作为参数,将目标字符串分割为两个部分,返回一个三元元组(head,sep,tail),包含分割符。细微区别在于前者从目标字符串的末尾也就是右边开始搜索分割符。
      >>> "django.core.app".partition('.')
      ('django', '.', 'core.app')
      >>> "django.core.app".rpartition('.')
      ('django.core', '.', 'app')
      
    1. argarse.ArgumentParser.parse_known_args()解析

      有时脚本可能只解析一些命令行参数,将剩下的参数传递给另一个脚本或程序。 在这种情况下,parse_known_args() 方法可能很有用。 它的工作方式与parse_args() 非常相似,只是在出现额外参数时不会产生错误。 相反,它会重新生成包含已填充名称空间和剩余参数字符串列表的两个项目元组。

      import argparse  
      parser = argparse.ArgumentParser()  
      parser.add_argument(  
          '--flag_int',  
          type=float,  
          default=0.01,  
          help='flag_int.'  
      )  
      FLAGS, unparsed = parser.parse_known_args()  
      print(FLAGS)  
      print(unparsed)
      
      # python test.py --flag_int 1 --flag_bool True --flag_string 'haha, I get it' --flag_float 0.2
      
      Namespace(flag_int=1.0)
      ['--flag_bool', 'True', '--flag_string', 'haha, I get it', '--flag_float', '0.2']
      
    1. one level is chosen as the “reference”, and its mean behaviour is represented by the intercept. Each column of the resulting matrix represents the difference between the mean of one level and this reference level
  21. Apr 2018
    1. Iterator Protocol

      The protocol specifies methods to be implemented to make our objects iterable.

      该协议指定了要实现我们的对象迭代的方法。

      "Iterable" simply means able to be looped over or otherwise treated as a sequence or collection.

      “可迭代”仅仅意味着能够循环或像对待序列或集合一样的方式处理。

    2. Classes allow us to create a custom type of object -- that is, an object with its own behaviors and its own ways of storing data.

      Introduction of Classes 类允许我们创建一个自定义类型的对象 - 也就是说,一个对象具有自己的行为和自己的存储数据的方式。

    3. Packages provide for accessing variables within multiple files.

      从package多文件访问变量的注意事项

    4. A package is a directory of files that work together as a Python application or library module.

      Introduction python packages

      packages是一个文件目录,可以作为Python应用程序或库模块一起工作

    5. Recursion features three elements

      递归调用三要素:

      1. recursive call: 递归调用,这是函数对自己的调用;
      2. function process: 函数过程本身;
      3. base condition: 一个基本条件,这是递归链最终返回的点。
    6. *args and **kwargs to capture all arguments

      *args 和 **kwargs 可以代表所有参数

      为了允许装饰函数接受参数,我们必须接受它们并将它们传递给装饰函数。

    7. object: a data value of a particular type variable: a name bound to an object

      什么是object -- 是一个具有类型的数据 什么是变量 -- 是一个绑定对象的名字

    8. All programs named test_something.py that have functions named test_something()

      pytest Basics

    9. unit test: testing individual units (function/method) integration test: testing multiple units together regression test: testing to see if changes have introduced errors end-to-end test: testing the entire program
      • 单元测试 -- 测试单个单元,方法
      • 集成测试 -- 集中测试多个单元
      • 回归测试 -- 测试修改有没有引入新的错误
      • 端到端测试 -- 测试整个程序
    10. pandas is a Python module used for manipulation and analysis of tabular data.

      Introduction to Pandas

      Pandas is used to manipulation and analysis of tabular data

    11. pandas official documentation

      pandas reference and tutorials include:full docs, 10minutes to pandas, blog tutorials

    1. JupyterHub, a multi-user Hub, spawns, manages, and proxies multiple instances of the single-user Jupyter notebook server.
    1. What is music21?

      ¿Qué es Music21?

      Music21 es un conjunto de herramientas para ayudar a los estudiantes de música y personas que escuchan la música de manera activa a resolver preguntas cómo: ¿Cuántas veces hace Bach eso? ¿cuándo fue la primera vez que determinada banda uso cierto orden de acordes?.

    2. How simple is music21 to use?

      ¿Cómo usar Music21?

      Después de instalar python y music21 usando pip u otro método, escribir en un archivo de texto: "from music21 import*" y luego puedes trabajar con todas las funciones que ofrece la biblioteca music21

      Para mostrar una melodía en notación musical se escribe: converter.parse("tinynotation: 3/4 c4 d8 f g16 a g f#").show()

    1. At every turn, IPython chose the way that was more inclusive, to the point where it’s no longer called “IPython”: The project rebranded itself as “Jupyter” in 2014 to recognize the fact that it was no longer just for Python.

      Such an interesting progression!

  22. Nov 2017
    1. Compilers translate an entire program's source code before the program can run. Interpreters translate one line at a time but it doesn't mean that the compilation stage doesn't happen.

    1. At some point in the following decade json-head.appspot.com stopped working. Today I’m bringing it back, mainly as an excuse to try out the combination of Python 3.5 async, the Sanic microframework and Zeit’s brilliant Now deployment platform.

      Oh neat, I had no idea now supported Python. Another option available!

  23. Oct 2017
    1. c = np.full((2,2), 7) # Create a constant array print(c)

      To avoid the warning, use

      np.full((2,2), 7.) or use explicitly for float np.full((2,2),7, dtype=float) or for int np.full((2,2),7, dtype=int)

  24. Sep 2017
    1. However, unlike an ordinary loop, yield from allows subgenerators to receive sent and thrown values directly from the calling scope, and return a final value to the outer generator

      This is the main usage of yield from.

    1. Spectral Python (SPy) is a pure Python module for processing hyperspectral image data. It has functions for reading, displaying, manipulating, and classifying hyperspectral imagery. It can be used interactively from the Python command prompt or via Python scripts
    1. PostgreSQL連接Python

      python连接postgresql,非常简单,基本跟mylsql一样,通过cursor来执行

  25. Jul 2017
  26. Jun 2017
    1. Shannon held up a BBC micro:bit board, which runs MicroPython and has been given to students in the UK, and noted that it only has 16KB of memory.

      check out MicroPython

  27. May 2017
    1. Calling from Python As of 10.10, AppleScript can use Cocoa frameworks in any Script Editor-based script. This makes it easy for Python and other languages that have Objective-C bridges to call AppleScript directly, without having to package everything as an Xcode app. Stick one or more compiled .scpt files containing AppleScript-ObjC "classes" into a folder, e.g.: use framework "Foundation" use scripting additions script MyASClass property parent : class "NSObject" -- on test() activate display dialog "Hello from AppleScript!" end test end script then just use it from Python like this: from Foundation import NSBundle, NSClassFromString import AppleScriptObjC NSBundle.alloc().initWithPath_(FOLDERPATH).loadAppleScriptObjectiveCScripts() MyASClass = NSClassFromString(u"MyASClass") # get the ASOC class... MyASClass.alloc().init().test() # ...then instantiate and call it

      Given that appscript is deprecated, I'm looking at how to call AppleScript directly from Python. This section is a "hello world" demonstration of how.

  28. Apr 2017
  29. Mar 2017
    1. Prophet : Facebook에서 오픈 소스로 공개한 시계열 데이터의 예측 도구로 R과 Python으로 작성되었다.

      python statics opensource, also can use R

  30. Feb 2017
  31. Jan 2017
    1. However, remember that Click is Unicode-based, so the string will always be a Unicode value
    1. In Python, as well as in any other object-oriented programming language, we define a class to be a description of what the data look like (the state) and what the data can do (the behavior). Classes are analogous to abstract data types because a user of a class only sees the state and behavior of a data item. Data items are called objects in the object-oriented paradigm. An object is an instance of a class.

      Class = General description of form and functions of data. Object = A member or instance of a class.

  32. Dec 2016
    1. In that case, you need an empty placeholder list that you can append items to individually.

      这涉及到之后的关于automatioin的程序功能。programming最厉害的地方就在于automation。

  33. Nov 2016
    1. Mastodon.py Documentation

      Python/API documentation for the Mastodon social networking platform.

  34. Sep 2016
  35. Aug 2016
  36. Jul 2016
    1. True.

      a = np.array(1) # 0-d, but different from np.int64(1)

      b = np.array([1]) # 1-d, same as a.reshape((1))

      c = np.array([[1]]) # 2-d, same as a.reshape((1,1))

  37. Jun 2016
    1. Remember that a slicing tuple can always be constructed as obj and used in the x[obj] notation. Slice objects can be used in the construction in place of the [start:stop:step] notation. For example, x[1:10:5,::-1] can also be implemented as obj = (slice(1,10,5), slice(None,None,-1)); x[obj] . This can be useful for constructing generic code that works on arrays of arbitrary dimension.
  38. Apr 2016
    1. That’s probably the Dropbox server. Two million lines of code and counting, and it serves hundreds of millions of users.

      I wonder what the biggest pain points are in maintaining a code base of this size in Python besides typing and performance, which Dropbox are already addressing via mypy and Pyston respectively.

    2. I want Python to be more effective for large projects, without losing sight of its use for small projects and teaching. It’s quite a challenge; my current hope lies in PEP 484 and mypy, an approach to optional static typing (a.k.a. gradual typing). It’s super exciting. There are also other things happening in the community that make Python faster.
  39. Feb 2016
    1. The rule of thumb is to avoid using more than two expressions in a list comprehension. This could be two conditions, two loops, or one condition and one loop. As soon as it gets more complicated than that, you should use normal if and for statements and write a helper function
    2. Dictionaries and sets have their own equivalents of list comprehen-sions.

      It gets better an better!

      d = { "foo": "bar", "baz": "qux" }
      r = {val: key for key, val in d.items()}
      #=> { "bar": "foo", "qux": "baz" }
      
    3. Unlike map, list comprehensions let you easily filter items from the input list, removing corresponding outputs from the result.

      This might be the greatest advantage of list comprehensions. Even in Ruby requires one to return a nil value from a map and then a call to compact, like: array.map(&:transform).compact.

    4. Beware that indexing a list by a negative variable is one of the few situations in which you can get surprising results from slicing. For example, the expression so melist[-n:] will work fine when n is greater than one (e.g., somelist[-3:]). However, when n is zero, the expression so melist[-0:] will result in a copy of the original list.

      Which is the same for somelist[:]. Not sure what the author is getting at. Maybe he meant to say that using variables as indexes when slicing can become confusing?

    5. Slicing can be extended to any Python class that implements the__getitem__ and __setitem__ special methods
    6. In a file, functions and classes should be separated by two blank lines.

      I wonder what the reasoning for having two blank lines for separating functions and one blank line for methods is. Seems like an arbitrary distinction.

  40. Dec 2015
    1. The basic principle is that you patch where an object is looked up, which is not necessarily the same place as where it is defined. A couple of examples will help to clarify this.

      This caught me out, as it did for a lot of other people apparently, see also this useful post about Python Mock gotchas: http://alexmarandon.com/articles/python_mock_gotchas/

  41. Nov 2015
    1. Given we put the system in a known state before the user (or external system) starts interacting with the system (in the When steps). Avoid talking about user interaction in givens. When we take key actions the user (or external system) performs. This is the interaction with your system which should (or perhaps should not) cause some state to change. Then we observe outcomes.
  42. Oct 2015
  43. Jul 2015
  44. May 2015
  45. Mar 2015
    1. Python is in fact compiled to bytecode
    2. A now-famous early usage of Python was in 1996: Google’s first successful web crawler.

      It is interesting to know that this fact on Python!

  46. Nov 2014
    1. Python was created by Guido Van Rossum in the early 90s. It is now one of the most popular languages in existence. I fell in love with Python for its syntactic clarity. It’s basically executable pseudocode.

      Helpful concise, Python syntax doc

    1. The goal of this site is to provide a set of materials in support of my Python for Informatics: Exploring Information book to allow you to learn Python on your own. This page serves as an outline of the materials to support the textbook.

      http://www.pythonlearn.com/ | A great resource for starting programmers looking to build knowledge and gain skills. Open Source Course

  47. Feb 2014
    1. The hard part is teaching the consequences of each choice.

      Once you get the syntax and basic language idioms out of the way this is the real problem that faces us no matter what language we pick.

  48. Dec 2013
    1. Read about how to use all of the things you installed.

      pip = A tool for installing and managing Python packages nose = A testing package for Python virtualenv = A Virtual Python Environment builder; helps you avoid updating libraries when you shouldn't distribute= Easily download, build, install, upgrade, and uninstall Python packages

  49. Nov 2013
    1. A class instance has a namespace implemented as a dictionary which is the first place in which attribute references are searched. When an attribute is not found there, and the instance’s class has an attribute by that name, the search continues with the class attributes.

      This search in namespaces -- first in the class instance and then in the class -- is documented here. Perhaps easier to understand by reading http://stackoverflow.com/a/15992667/7782

    1. Compared with the 1.0 release, there were relatively few backwards incompatible changes, but there are still a few issues to be aware of with this major release.

      I got all panicky when installing internetarchive via pip caused a move from requests 1.1.0 to 2.0.x -- I had thought that jump was the BIG ONE that broke a lot of other modules. Maybe not.

  50. Oct 2013
    1. The ability to seamlessly insert IPython notebooks into posts was one of the biggest drivers of my switch to Pelican.

      I want to study how Jake integrates IPython notebooks into his blogging. I'll be writing a lot in IPython notebook for my teaching.

    1. Three things are required to fully guarantee a repeatable installation using requirements files.

      "Ensuring Repeatability"