Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #106400

Re: [Beginner] - Hanging in the code, can't figure out what's wrong

From Michael Selik <michael.selik@gmail.com>
Newsgroups comp.lang.python
Subject Re: [Beginner] - Hanging in the code, can't figure out what's wrong
Date 2016-04-03 19:46 +0000
Message-ID <mailman.410.1459713208.28225.python-list@python.org> (permalink)
References (5 earlier) <ndpmuo$4sq$1@dont-email.me> <32c7ba6b-b61d-45fb-89a8-dd62aa09fe78@googlegroups.com> <ndrbl5$u2r$1@dont-email.me> <860f0703-08a1-4721-86c9-67ddc129cdc6@googlegroups.com> <99671ed7-7a89-4116-917d-3c9151847237@googlegroups.com>

Show all headers | View raw


How do you know when you're done typing the name of the file?

It's hard to get tone right on the internet, so I'll clarify: this is not a
rhetorical question and I mean you, LoopIO, not a generic person.

On Sun, Apr 3, 2016, 8:40 PM Loop.IO <thisisink01@gmail.com> wrote:

> On Sunday, April 3, 2016 at 8:32:06 PM UTC+1, Loop.IO wrote:
> > On Sunday, April 3, 2016 at 4:11:49 PM UTC+1, BartC wrote:
> > > On 03/04/2016 15:41, Loop.IO wrote:
> > > > On Sunday, April 3, 2016 at 1:12:23 AM UTC+1, BartC wrote:
> > > >> On 02/04/2016 23:31, Loop.IO wrote:
> > > >>
> > > >>> Oh i see, so the code prompts for a name.. so i'm more lost than i
> thought, what do I need to change to make it just create the file with the
> chosen name Launch2.bat without the prompt?
> > > >>
> > > >> If you don't want the user to enter anything, then I explained how
> > > >> before, just use:
> > > >>
> > > >>        name='C:\\Documents\\PythonCoding\\launch2.bat'
> > > >>
> > > >> if that's the file name you need.
> > > >>
> > > >> --
> > > >> Bartc
> > > >
> > > > Hi Bartc, i tried that, didn't work
> > >
> > > You mean it gave an error when you tried to create that file?
> > >
> > > Does that path already exist on your machine? If not then trying to
> > > create a file in a non-existent path won't work.
> > >
> > > You can create the path manually outside of Python. Or look up the docs
> > > to find out how to do that. A quick google suggested using os.makedirs
> > > (to create multiple nested paths at the same time).
> > >
> > > The following code worked on my machine:
> > >
> > > import sys
> > > import os
> > >
> > > def create():
> > >     print("creating new file")
> > >
> > >     path="c:/Documents/PythonCoding/"
> > >     name=path+"launch2.bat"
> > >
> > >     try:
> > >             os.stat(path)
> > >     except:
> > >             os.makedirs(path)
> > >
> > >     print (name)
> > >
> > >     try:
> > >             file=open(name,'w')
> > >             file.close()
> > >     except:
> > >             print("error occured")
> > >             sys.exit(0)
> > >
> > > create()
> > >
> > > --
> > > Bartc
> >
> > The issue is that it hangs, there is no error. its like it pauses until
> i press enter, ill try what you've posted one moment
>
> Ok the Bartc code gives me an error.
>
> What is it that makes the code hang with what I have, you said it was that
> it's prompting for a name for the file, so how do I bypass that and force
> it to create the file with the name I've provided?
> --
> https://mail.python.org/mailman/listinfo/python-list
>

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[Beginner] - Hanging in the code, can't figure out what's wrong "Loop.IO" <thisisink01@gmail.com> - 2016-04-02 14:59 -0700
  Re: [Beginner] - Hanging in the code, can't figure out what's wrong BartC <bc@freeuk.com> - 2016-04-02 23:08 +0100
    Re: [Beginner] - Hanging in the code, can't figure out what's wrong Ned Batchelder <ned@nedbatchelder.com> - 2016-04-02 15:16 -0700
      Re: [Beginner] - Hanging in the code, can't figure out what's wrong BartC <bc@freeuk.com> - 2016-04-02 23:27 +0100
        Re: [Beginner] - Hanging in the code, can't figure out what's wrong "Loop.IO" <thisisink01@gmail.com> - 2016-04-02 15:31 -0700
          Re: [Beginner] - Hanging in the code, can't figure out what's wrong BartC <bc@freeuk.com> - 2016-04-03 01:12 +0100
            Re: [Beginner] - Hanging in the code, can't figure out what's wrong Mark Lawrence <breamoreboy@yahoo.co.uk> - 2016-04-03 01:38 +0100
              Re: [Beginner] - Hanging in the code, can't figure out what's wrong "Loop.IO" <thisisink01@gmail.com> - 2016-04-03 12:52 -0700
            Re: [Beginner] - Hanging in the code, can't figure out what's wrong "Loop.IO" <thisisink01@gmail.com> - 2016-04-03 07:41 -0700
              Re: [Beginner] - Hanging in the code, can't figure out what's wrong BartC <bc@freeuk.com> - 2016-04-03 16:11 +0100
                Re: [Beginner] - Hanging in the code, can't figure out what's wrong Rustom Mody <rustompmody@gmail.com> - 2016-04-03 08:25 -0700
                Re: [Beginner] - Hanging in the code, can't figure out what's wrong BartC <bc@freeuk.com> - 2016-04-03 17:04 +0100
                Re: [Beginner] - Hanging in the code, can't figure out what's wrong "Loop.IO" <thisisink01@gmail.com> - 2016-04-03 12:31 -0700
                Re: [Beginner] - Hanging in the code, can't figure out what's wrong "Loop.IO" <thisisink01@gmail.com> - 2016-04-03 12:36 -0700
                Re: [Beginner] - Hanging in the code, can't figure out what's wrong Michael Selik <michael.selik@gmail.com> - 2016-04-03 19:46 +0000
                Re: [Beginner] - Hanging in the code, can't figure out what's wrong BartC <bc@freeuk.com> - 2016-04-03 21:21 +0100
                Re: [Beginner] - Hanging in the code, can't figure out what's wrong "Loop.IO" <thisisink01@gmail.com> - 2016-04-03 14:07 -0700
              Re: [Beginner] - Hanging in the code, can't figure out what's wrong Erik <python@lucidity.plus.com> - 2016-04-03 20:46 +0100
                Re: [Beginner] - Hanging in the code, can't figure out what's wrong "Loop.IO" <thisisink01@gmail.com> - 2016-04-03 12:54 -0700
                Re: [Beginner] - Hanging in the code, can't figure out what's wrong Erik <python@lucidity.plus.com> - 2016-04-03 21:15 +0100
                Re: [Beginner] - Hanging in the code, can't figure out what's wrong "Loop.IO" <thisisink01@gmail.com> - 2016-04-03 13:25 -0700
                Re: [Beginner] - Hanging in the code, can't figure out what's wrong Erik <python@lucidity.plus.com> - 2016-04-03 22:26 +0100
                Re: [Beginner] - Hanging in the code, can't figure out what's wrong "Loop.IO" <thisisink01@gmail.com> - 2016-04-03 14:49 -0700
                Re: [Beginner] - Hanging in the code, can't figure out what's wrong Erik <python@lucidity.plus.com> - 2016-04-03 23:07 +0100
                Re: [Beginner] - Hanging in the code, can't figure out what's wrong Ben Finney <ben+python@benfinney.id.au> - 2016-04-05 06:49 +1000
        Re: [Beginner] - Hanging in the code, can't figure out what's wrong Michael Selik <michael.selik@gmail.com> - 2016-04-02 22:37 +0000
        Re: [Beginner] - Hanging in the code, can't figure out what's wrong Mark Lawrence <breamoreboy@yahoo.co.uk> - 2016-04-03 01:11 +0100
    Re: [Beginner] - Hanging in the code, can't figure out what's wrong "Loop.IO" <thisisink01@gmail.com> - 2016-04-02 15:23 -0700
      Re: [Beginner] - Hanging in the code, can't figure out what's wrong Mark Lawrence <breamoreboy@yahoo.co.uk> - 2016-04-03 01:08 +0100
        Re: [Beginner] - Hanging in the code, can't figure out what's wrong "Loop.IO" <thisisink01@gmail.com> - 2016-04-03 07:45 -0700

csiph-web