News for hackers. Stuff that matters.
Re:Show HN: ConvTools – generates Python code of conversions... by carapace on Sunday March 29, 2020 @05:03PM (#22722707)
In re: the "magic", it seems to me that you could use a mock object and get the required info from it.
Re:Show HN: ConvTools – generates Python code of conversions... by westandskif on Monday March 30, 2020 @09:40AM (#22727910)
In terms of the implementation, it's kind of trivial to implement the "magic", but it would be both confusing and inconsistent, see below.

e.g. imagine a case where you'd want to call datetime.strptime, partially initializing it at the moment of conversion definition. at the moment it is:

  c.call_func(
      datetime.strptime,
      c.item("updated"),
      "%Y-%m-%d"
  )
but it's unclear to me how would the "magic" approach deal with the case above.
Re:Show HN: ConvTools – generates Python code of conversions... by carapace on Monday March 30, 2020 @02:04PM (#22730485)
Replace your current namespace with a mock object? You can eval or exec code with any dictionary-flavored object, and mocks can imitate dicts.

edit: no, you can't in Python 3..

I'll try to have a closer look later today.