Page 2 of 4 FirstFirst 1234 LastLast
Results 11 to 20 of 36

Thread: Bash to Python

  1. #11
    Join Date
    Jun 2006
    Location
    CT, USA
    Beans
    5,267
    Distro
    Ubuntu 6.10 Edgy

    Re: Bash to Python

    Quote Originally Posted by Pro-reason View Post
    Well, duh. Of course the best thing to do is to port the result. The point is that I don't know how. I am well-versed in bash scripting, but I want to get a programming job. So, I plan to teach myself Python,
    You are asking wrong question, no wonder that the answers do not make any sense.

    From your question any reasonable reader (and I completely agree with Greyed) would assume you are after generic way to translate any bash script to Python. Which would be waste of time, because python is higher-level language with many cool concepts making programming in it more productive: your bash-code would very bad (and tricky-hard to debug as CptPicard mentioned) Python code.

    Why? because you are working "against the grain". You are doing something you are not supposed to do. Python has rule "there should be one obvious way to do it right". Your's way is not obvious, and so wrong.

    Asking right question is half the answer. And your question should be: how a person competent in bash can learn Python quickly? See?

    If you understand basic programming concepts, you can learn basic procedural Python over a weekend, OOP will take you more but you don't need it to be productive - you can safely program for a year by just using existing objects (from library) and arrays of dictionaries for your own "objects".

    See wiki in my sig for links, books and training tasks.

    And you also should really adjust your attitude: if people's answers do not make sense to you, your question does not make sense to them, and it is **your** fault. Nobody owes you anything, volunteers spend own free time to help you. If I spend minutes to write answer for you, it is done in gratitude for people who helped me to learn what I know now, it is not related to you personally in any way. It is easier to ignore a jerk than trying to teach him how to behave.

    Read "How to ask questions" in my sig, and apologize to Greyed.

    Edit: I am **not** saying that Pro-reason is a jerk. He cannot be, with such nick and I am **not** ignoring him, but trying to answer his question. But I **do** think Pro-reason should readjust his attitude. Even if he is expert translator, learning different programming language is more about learning different paradigms than just mechanically translating syntax of one language into another.
    Last edited by pmasiar; November 11th, 2008 at 08:17 PM.

  2. #12
    Join Date
    Aug 2006
    Location
    60°27'48"N 24°48'18"E
    Beans
    3,458

    Re: Bash to Python

    Now, now... I don't think he is being a jerk, just misguided
    LambdaGrok. | #ubuntu-programming on FreeNode

  3. #13
    Join Date
    Sep 2008
    Beans
    65

    Re: Bash to Python

    Quote Originally Posted by pmasiar View Post
    Read "How to ask questions" in my sig, and apologize to Greyed.
    Hahahaaaaa.......!!!!

  4. #14
    Join Date
    Jul 2008
    Location
    $HOME
    Beans
    1,030
    Distro
    Ubuntu 9.10 Karmic Koala

    Re: Bash to Python

    OK, since you're determined to be unhelpful, I give up.
    If people were nicer, I'd answer more queries here!

  5. #15
    Join Date
    Aug 2006
    Location
    60°27'48"N 24°48'18"E
    Beans
    3,458

    Re: Bash to Python

    No, we're not unhelpful, we're just telling you you really are going about it the wrong way. We're professional programmers, no less..

    And the really quick answer truly is that no, there is no such thing as an automatic bash to Python converter. It's probably even theoretically impossible, given the variety of tools you may be calling from your bash script. And trying to use such a hypothetical tool would be much more of an effort than actually learning Python.
    LambdaGrok. | #ubuntu-programming on FreeNode

  6. #16
    Join Date
    Jul 2008
    Location
    $HOME
    Beans
    1,030
    Distro
    Ubuntu 9.10 Karmic Koala

    Re: Bash to Python

    No, you are unhelpful. Being l33t programmers is a handicap here. It makes you pontificate about the purest purist way of doing things, instead of just answering the question.
    If people were nicer, I'd answer more queries here!

  7. #17
    Join Date
    Oct 2006
    Location
    255.255.255.255
    Beans
    Hidden!
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: Bash to Python

    Nothing ever got accomplished by giving up.

    This book is free and WILL help you in your endeavor:

    A Byte of Python (Online version)

    Downloadable PDF


    I wish you luck, even though you won't need it.
    “Give a man a fish and you have fed him for today; teach a man to fish and you have fed him for a lifetime” —unknown

  8. #18
    Join Date
    Aug 2006
    Location
    60°27'48"N 24°48'18"E
    Beans
    3,458

    Re: Bash to Python

    Quote Originally Posted by Pro-reason View Post
    No, you are unhelpful.
    No, we actually help you help yourself and stop wasting your time on a dead end solution.

    Being l33t programmers is a handicap here.
    What you are suggesting qualifies much better as a l33t solution -- "look!! I'm actually hacking Python to act as bash in between of subprocesses!!". We're being very pragmatic here.

    It makes you pontificate about the purest purist way of doing things,
    No, it is the realist way of doing things.

    instead of just answering the question.
    Your question has been answered.
    LambdaGrok. | #ubuntu-programming on FreeNode

  9. #19
    Join Date
    Apr 2007
    Beans
    14,781

    Re: Bash to Python

    Quote Originally Posted by Pro-reason View Post
    No, you are unhelpful. Being l33t programmers is a handicap here. It makes you pontificate about the purest purist way of doing things, instead of just answering the question.
    The question is hard to answer.

    If it is just bash, not calling other programs, it would be very simple to automate a translation.

    However, bash scripts call other programs all the time. Bash scripts are more like glue between other programs.

    One could, I suppose, have something that can automatically translate bash into Python, but the shear number of programs that Bash scripts routinely call, it would be quite hard.

  10. #20
    Join Date
    May 2008
    Beans
    Hidden!

    Re: Bash to Python

    However much I agree that conversion is the wrong way to go about learning Python, I do think it could be done. It would mean using subprocess a lot, and writing Python equivalents to Bash builtins, but besides that I think the biggest challenge would be the parser.

    I am by no means a theorist, but practically, I think it could be done.

Page 2 of 4 FirstFirst 1234 LastLast

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •