simply stupid
Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: simply stupid

  1. #1
    Senior Member IcSilk's Avatar
    Join Date
    Aug 2001
    Posts
    296

    simply stupid

    alright so please no flaming me here. This is such a simple question

    Im completely new to compilers/interpreters and have just started to take up learning python as a bit of a hobby

    I have python27 installed and just started using the shell to learn.
    I have noticed that I can't seem to write more than one line of code because every time I press enter it executes the line I just finished. then for shits and giggles I tried running the basic hello world from the cmd prompt and it asked what program to use to run it with.
    I chose crimson editor as that is what I use for my site scripts. and it just showed the exact same things as the interpreter showed -> one line of code and the executed code.

    How do I write multi-line code in the python shell without it running it everytime I press enter?
    Why isn't it running from the cmd prompt?
    I have completely overlooked something, I know. but this has never been my thing and its only recently I've tried to expand my thing, lol (not by whipping it against the bedpost or anything )

    thanks
    "In most gardens they make the beds too soft - so that the flowers are always asleep" - Tiger Lily

  2. #2
    Senior Member
    Join Date
    Jul 2002
    Posts
    744
    make a file, write to file, set permissions...what you wrote to file will run....
    Every now and then, one of you won't annoy me.

  3. #3
    Senior Member IcSilk's Avatar
    Join Date
    Aug 2001
    Posts
    296
    How do I write multi-line code in the python shell without it running it everytime I press enter?
    lol, I feel very stupid. The interpreter knows when continuation lines are needed and when they are not.

    I guess a simple print statement is an end of code command
    "In most gardens they make the beds too soft - so that the flowers are always asleep" - Tiger Lily

  4. #4
    Senior Member IcSilk's Avatar
    Join Date
    Aug 2001
    Posts
    296
    make a file, write to file, set permissions...what you wrote to file will run....
    When I try to run it from the command line and press enter another command line window pops up for only a split second and disappears again.
    Any idea why? any idea how to get it to stop?
    "In most gardens they make the beds too soft - so that the flowers are always asleep" - Tiger Lily

  5. #5
    Senior Member mungyun's Avatar
    Join Date
    Apr 2004
    Location
    Illinois
    Posts
    172
    While i'm not a pro at python, i do have plenty of experience with other languages and in my experience it's because the command window (your program) closes after execution finishes. Which, for most learner programs, takes lest than .5 second.

    Maybe try adding the following line at the end of your code. that way it waits for you to press something before ending

    Code:
    raw_input("Press Enter to continue...")
    EDIT: Actually, I noticed that you are using 2.7 python. if you use Python 3 it is just input()

    And its not stupid, you are just learning
    Last edited by mungyun; August 18th, 2011 at 02:55 PM.
    I believe in making the world safe for our children, but not our childrenís children, because I donít think children should be having sex. -- Jack Handey

  6. #6
    Senior Member
    Join Date
    Jul 2002
    Posts
    744
    When I try to run it from the command line and press enter another command line window pops up for only a split second and disappears again.
    Any idea why? any idea how to get it to stop?

    Quote Originally Posted by bludgeon View Post
    ...what you wrote to file will run....
    it's doing what you asked it to?
    Every now and then, one of you won't annoy me.

  7. #7
    Senior Member mungyun's Avatar
    Join Date
    Apr 2004
    Location
    Illinois
    Posts
    172
    Quote Originally Posted by bludgeon View Post
    it's doing what you asked it to?
    I think his problem is that what he runs, opens and closes so fast that he cant see whats on that screen. I think if he adds that raw_input() line to the end of his code, he will be able to see his results.
    I believe in making the world safe for our children, but not our childrenís children, because I donít think children should be having sex. -- Jack Handey

  8. #8
    Senior Member
    Join Date
    Jul 2002
    Posts
    744
    ^

    isn't there some "pause" command?
    Every now and then, one of you won't annoy me.

  9. #9
    Senior Member mungyun's Avatar
    Join Date
    Apr 2004
    Location
    Illinois
    Posts
    172
    There is (time.sleep(seconds)) but generally i see examples that wait for keyboard input to continue. I prefer to wait for keyboard input but pause works just as well.

    Edit:

    IcSilk, I don't know what OS you use mainly but if you use Windows and have Visual Studio 2010 (Possibly just the express versions) there is a python addon for it that is pretty neat. Just downloaded it and it gives you an option for a python project and even gives you a graphical viewer for when you make graphical programs.

    Even has error hilighting and auto indent. Pretty common but still neat.
    Last edited by mungyun; August 18th, 2011 at 03:51 PM.
    I believe in making the world safe for our children, but not our childrenís children, because I donít think children should be having sex. -- Jack Handey

  10. #10
    AO BOFH: Luser Abuser BModeratorFH gore's Avatar
    Join Date
    Oct 2002
    Location
    Michigan
    Posts
    7,177
    I'm not a Python Wizard either (Wow do we all say this now? heh) But I do use Perl which is very similar from the point of view of the Computer; It's something that you typed instructions into, and then an Interpreter tells the Computer "He said to do this now with this and these options" much like a normal Interpreter would if you were having a Conversation with someone who didn't speak the Languages or Language you spoke.

    I did grab some Python stuff for Windows, because like a year ago, I was bored one day, and I realized I could probably mess around with it for something to do. I don't normally do this stuff on Windows though because it kinda sucks.

    I only have ONE machine with Windows even on it, and even then, it's ONE Partition, which has Windows 7 Installed on it, so I can play games and stuff. Everything else I have here, is running Linux, or BSD. And, in Linux and BSD, it's way easier.

    For example; Say I'm working on a Perl Script that I want to do something with; Just as an example of course -

    I open Vi, type out my Instructions that I want the Interpreter to tell my OS to do, and then save the file. I have options now, as to what I want to happen; I can save it a certain way, or, just name it "My_script.pl" and then make it executable.

    From there, I type this command:

    ./My_script.pl

    And it does so.

    When I got Python stuff downloaded, I noticed that it was a whole lot like Perl, which is why I'm even telling you all this stuff, but, mainly, my point is that you may very well have an easier time just using Vi or Emacs, and then typing out the script, and then, having the Python Interpreter run it.
    Kill the lights, let the candles burn behind the pumpkinsí mischievous grins, and let the skeletons dance. For one thing is certain, The Misfits have returned and once again everyday is Halloween.The Misfits FreeBSD
    Cannibal Holocaust
    SuSE Linux
    Slackware Linux

Similar Threads

  1. about mozilla
    By moonstar550 in forum AntiOnline's General Chit Chat
    Replies: 10
    Last Post: April 10th, 2004, 03:03 AM
  2. Spy Sweeper- OpenSite spyware???
    By al1aprize in forum Spyware / Adware
    Replies: 23
    Last Post: March 15th, 2004, 01:24 AM
  3. Playing with Windows
    By gizmofreak in forum AntiOnline's General Chit Chat
    Replies: 2
    Last Post: December 7th, 2003, 06:43 PM
  4. how stupid u r?
    By neohunk in forum Tech Humor
    Replies: 5
    Last Post: November 19th, 2003, 01:40 PM
  5. Yo mamma so fat, ugly and stupid
    By nate_k9 in forum Tech Humor
    Replies: 5
    Last Post: October 26th, 2003, 08:56 AM

Posting Permissions

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