python> use c quick swap> #if 1 // no reshape

In C, you can use # if 1 to do a quick swap. http://qiita.com/7of9/items/867287b73d3b2cc1b87f

.c


#if 1 // no reshape
   // do nothing
#else
   use_reshape();
#endif

By changing the above # if 1 to # if 0, else and later are valid.

This quick swap is also used for other purposes. "Clarification that you are working most recently". (Maybe it doesn't mean quick swap).

I wondered if I could do the same with python.

#if 1 // feed_dict
      _, t_loss = sess.run([train_op, loss], feed_dict={input_ph:inputs_batch.eval(), output_ph:output_batch.eval()})
#else    
#      _, t_loss = sess.run([train_op, loss], feed_dict=feed_dict(True, inputs_rs, output_rs))
#endif      

In python, the code starting with # is a comment, so adding the above does not affect the code. It's not a quick swap, but it seems possible to "clarify that you are working most recently". The code you want to disable is the "self-service comment out" method where you add # yourself.

Note that the # if 1 related part will be deleted as soon as the latest work is completed, so it will not be left in VCS.

Recommended Posts

python> use c quick swap> #if 1 // no reshape
Use C ++ functions from python with pybind11
How to use the C library in Python
Wrap C with Cython for use from Python
Wrap C ++ with Cython for use from Python
You should know if you use Python! 10 useful libraries
Python if statement
[C] Use qsort ()
Python quick start
python C ++ notes
python, openFrameworks (c ++)
[Python] if statement
python> Check if code is printable> Use ord () / all (c in string.printable for c in hello)
If you can't use Beautiful Soup 4 after updating to Python 3.5. ImportError: No module named bs4