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


Groups > comp.lang.python > #106395

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

Newsgroups comp.lang.python
Date 2016-04-03 12:31 -0700
References (3 earlier) <ndpgql$im4$1@dont-email.me> <03c7da56-c752-460f-98b1-84b7166a2cc3@googlegroups.com> <ndpmuo$4sq$1@dont-email.me> <32c7ba6b-b61d-45fb-89a8-dd62aa09fe78@googlegroups.com> <ndrbl5$u2r$1@dont-email.me>
Message-ID <860f0703-08a1-4721-86c9-67ddc129cdc6@googlegroups.com> (permalink)
Subject Re: [Beginner] - Hanging in the code, can't figure out what's wrong
From "Loop.IO" <thisisink01@gmail.com>

Show all headers | View raw


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

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