How to turn a python script into a command-line program

preview_player
Показать описание
Using the argparse package, you can turn any Python script into a program you can run from the command-line in bash (terminal, shell, etc. on Mac or Linux). This video shows how to use argparse with an example of turning a fasta file into a fastq file.

Рекомендации по теме
Комментарии
Автор

please my dear can you make one clip write code with python for auto installer application
or hide apk in image

when open image that apk is runing automatic

miryamadvanced
Автор

Nicely Explained: Keep doing the good work.
Got the

shubhamaggarwal
Автор

I just want terminal to automatically run a command when i run the .py script

System-brtx
Автор

You ain have to install argparse, its comes with python3 's standard library

tandavme
Автор

hello,

one small improvement would be getting rid off file.close() statements, using "with" statement:

with open(args.input) as f, open(args.output, 'w') as fout:
f.read()
fout.write(...)

in Python "with" will take care of closing files automatically

voytechj
Автор

How you submit this kind of script to cluster?

NadiasTravelTales
Автор

Yeah i need this to make an hashing algorithm program...




Thx VERY much!

bossman
Автор

exactly what I was searching for thank you so much

arto_
Автор

Awesome Video. Love seeing Python used in wide variety of sciences.

Davidemmanuelkatz
Автор

for a more native flavor you need to move your script to any of the bin folders like /usr/bin or local/bin so it is available system wide and then to use $command arg arg ...n instead of ./script.py arg ...n syntax

stringsc
Автор

Thanks for the clear and concise demonstration.

mohammedahmed
Автор

can i do this without the command prompt?

bsyo
Автор

Hi Maria,

I'm wondering if there is a similar package for R scripts?

Cheers

gatherswag
Автор

can you suggest vice versa if i want to try

medhabhat
Автор

I think I installed argparse. But how do I open it so it is in a cool window on the right side like the one in the video and I can type things into it . (I am using a pc)

starwords
Автор

Hi, how do you make the dollar sign appear on a new line in terminal (or iTerm2)?

napier
Автор

Wow! That's what I was searching for.
Kudos to you!!!

sudhanshukumar
Автор

Didn't know about argparse, thanks.

haroldovivallo
Автор

Hi Maria,

Nice video, thank you so much!
I'm starting learn python for bioinformatics, as I would like to write my own scripts.
I'm woundering if you could explain what seq = "" and fout.write("@" + line[1:]) means in your script.
Also, I found that if you move:

fout.write("@" + line[1:])
seq = ""

to one space before, the script crash. Why that?
Thank you again!
Dani.

DanielFPaulo
Автор

Whenever I want to do something with Python or Bash and I find an OMGenomics video about it I'm like "This is going to be great. It's going to be clear and tell me everything I need"; that just happened again.

brendannolan