Quantcast
Channel: Python script for making a table - Code Review Stack Exchange
Viewing all articles
Browse latest Browse all 3

Answer by jcollado for Python script for making a table

$
0
0

I think you already have an idea about what to do. In particular, the idea touse a dictionary to store information using a key will make your code free ofexecs. For example:

linesigs = {}for sig in stringsig:    filename = 'SummerStc_{}_{}.txt'.format(stringcpu[1], sig)    with open(filename, 'r') as filesig:        linesigs[sig] = filesig.readlines()

Note that:

  • You can iterate over the array directly to avoid using a counter
  • It's useful to use the with statement to avoid forgetting about the closing files

Aside from this, a few more pieces of advices:

  • If you absolutely need a counter, use enumerate in for loops to avoid keeping track of counters in the code
  • Use a template engine to generate the latex code like jinja2

I think your code needs a little bit of work, so feel free to apply some fixesand write a new question to get a new review on the improved code.


Viewing all articles
Browse latest Browse all 3

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>