About insert shell commands into python
Question: I've inserted some shell commands into python script like below:

    
    
    #!/usr/bin/python
    
    import os,sys,re
    import gzip
    import commands
    
    path = "/home/x/nearline"
    
    for file in os.listdir(path):
      if re.match('.*\.recal.fastq.gz', file):
        fullpath = os.path.join(path, file)
        result = commands.getoutput('zcat fullpath |wc -l')
        numseqs = int(result)/4.0
      print numseqs
    

`zcat fullpath |wc -l` is the shell command inserted.

Problem is, I define `fullpath` here for all `fastq` files, but after being
put under `' '`, seems this `fullpath` doesn't work. How can I solve this
problem?


Answer: You have to concatenate the string with the value of the variable:

    
    
    result = commands.getoutput('zcat ' + fullpath + ' |wc -l')
    

