1

I am trying to get the name of main function that is called. I mean the case when I run main function (updating.new_cycle) and in some conditions other function (inserting.inserting_data_ts) is running, via import from inserting.py file.

My code:

updating.new_cycle(new,
                   old,
                   db, '2018-09-13')

In function new_cycle:

for i in list(new):
    if i not in old:
        import inserting            
        newdata = {u'type': u'FeatureCollection', u'features': new[i]}
        inserting.inserting_data_ts(new, TimeBegin, None)

So, I want to catch this condition is proceeded: when inserting_data_ts is called from updating.new_cycle (when main calling function is updating.new_cycle, not inserting.inserting_data_ts).

How can I achieve this?

Jane
  • 269
  • 3
  • 15

1 Answers1

0

Be explicit

So, I want to catch this condition is proceeded: when inserting_data_ts is called from updating.new_cycle

Just add an extra variable to your function, something like:

inserting.inserting_data_ts(new, TimeBegin, None, origin_flag=True)

Then define inserting_data_ts with an additional keyword argument origin_flag defaulting to False.

jpp
  • 159,742
  • 34
  • 281
  • 339