macros

Runtime variable for Oracle DATE type in Airflow

Runtime variable for Oracle DATE type in Airflow Question: I’m trying to define task that requires a run-time parameter (let’s call it ‘batch_dt’) in Apache Airflow. I’m using OracleStoredProcedureOperator and the parameter of the procedure is of database type date. procedure use_dates ( i_date in date, i_date2 in date, i_date3 in date ); However I’m …

Total answers: 2

AIRFLOW: use .replace() or relativedelta() in jinja template for {{ds}}

AIRFLOW: use .replace() or relativedelta() in jinja template for {{ds}} Question: My goal is to return 1st day of previous month based on airflow macro variable {{ds}} and use it e.g. in HiveOperator. E.g. For ds = 2020-05-09 I expect to return: 2020-04-01 The solution I found and tried were: SET hivevar_LAST_MONTH='{{ (ds.replace(day=1) – macros.timedelta(days=1)).replace(day=1) …

Total answers: 2

How to configure PyCharm to develop LibreOffice Python macros?

How to configure PyCharm to develop LibreOffice Python macros? Question: I’ve installed Python 3.5.1 as default in Win7(x64) for all my projects in Python. I use PyCharm 5.0.5 community edition for develop Python scripts and its default settings has “Default Project Interpreter” as “3.5.1 (C:Python35python.exe)” At my work we are migrating from MS Office 2007/2010 …

Total answers: 2

Python-like C++ decorators

Python-like C++ decorators Question: Are there ways to decorate functions or methods in C++ like in python style? @decorator def decorated(self, *args, **kwargs): pass Using macros for example: DECORATE(decorator_method) int decorated(int a, float b = 0) { return 0; } or DECORATOR_MACRO void decorated(mytype& a, mytype2* b) { } Is it possible? Asked By: Artem …

Total answers: 5

How to write an ipython alias which executes in python instead of shell?

How to write an ipython alias which executes in python instead of shell? Question: We can define an alias in ipython with the %alias magic function, like this: >>> d NameError: name ‘d’ is not defined >>> %alias d date >>> d Fri May 15 00:12:20 AEST 2015 This escapes to the shell command date …

Total answers: 2

How to run python macros in LibreOffice?

How to run python macros in LibreOffice? Question: When I go to Tools -> Macros -> Organize Macros -> Python I get this dialog: It is not possible to create new Python macros. Apparently LibreOffice has no Python editor so I have to write the macros elsewhere and then just execute them. But I do …

Total answers: 5

*args, **kwargs in jinja2 macros

*args, **kwargs in jinja2 macros Question: How are extra args & kwargs handled for a Jinja2 macro? The documentation isn’t exactly clear offhand. For example, this is clearly wrong: {% macro example_1(one, two, **kwargs) %} do macro stuff {% endmacro %} which results in jinja2.exceptions.TemplateSyntaxError TemplateSyntaxError: expected token ‘name’, got ‘**’ The documentation says: kwargs …

Total answers: 2

What can you do with Lisp macros that you can't do with first-class functions?

What can you do with Lisp macros that you can't do with first-class functions? Question: I think I understand Lisp macros and their role in the compilation phase. But in Python, you can pass a function into another function def f(filename, g): try: fh = open(filename, “rb”) g(fh) finally: close(fh) So, we get lazy evaluation …

Total answers: 8