473,761 Members | 2,455 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

program with raw_input prompt behaves differently after compile

tim
I want to write a program that looks into a given folder, groups files
that have a certain part of the filename in common and then copy those
groups one at a time to another place, using the raw_input prompt to
continue or break.

here's what I have:

###########
def makegroepen():
global p
import os
from longestcommonpr efix import longestcommonpr efix
p = raw_input('path ')
l = os.listdir(p)
l.sort()
groepen=[]
groep=[]
basenames=[]
for r in l:
if r.find('_poly16 .mp3'):
baselist = r.split('_')
mopobasename = baselist[0]
if mpbasename not in basenames:

basenames.appen d(mpbasename)
for s in l:

if
longestcommonpr efix([s,mpbasename])==mpbasename:
print mpbasename
if s not in groep:
groep.append(s)
if len(groep)==6:
groepen.append( groep)
groep=[]
print groepen
return groepen
def movegr():
global p, groepen
for t in groepen:
contprompt=raw_ input('continue ? (n to stop)')
if contprompt=='n' :
break
for curr in t:
if os.path.isfile( p+'\\'+curr):
tempfile = open(p+'\\'+cur r, 'rb')
tempfile.seek(0 )
tempfilecont = tempfile.read()
dircondition = os.path.exists( 'c:\\content\\w orkfolder')
if dircondition == False:
os.makedirs('c: \\content\\work folder')
destfile = open('c:\\conte nt\\workfolder\ \'+curr, 'wb')
destfile.write( tempfilecont)
destfile.close( )
if __name__=='__ma in__':
global groepen
groepen = makegroepen()
movegr()

########
(I renamed 'commonprefix' to 'longestcommonp refix', it is actually just
the 'binary search version' I found at
http://aspn.activestate.com/ASPN/Coo.../Recipe/252177 )

It works fine when I run this from PythonWin IDE, but after compiling an
executable from it (py2exe) it exits whatever I type in the 'continue?'
prompt.
What am I doing wrong?
Thanks,
Tim

Dec 24 '05 #1
2 1489
tim wrote:
I want to write a program that looks into a given folder, groups files
that have a certain part of the filename in common and then copy those
groups one at a time to another place, using the raw_input prompt to
continue or break.

[...]

It works fine when I run this from PythonWin IDE, but after compiling an
executable from it (py2exe) it exits whatever I type in the 'continue?'
prompt.
What am I doing wrong?


Maybe this helps:

http://forums.devshed.com/python-pro...or-187633.html

The solution described here was to compile the program as a console app,
rather than a Windows app.

--
Hans Nowak
http://zephyrfalcon.org/
Dec 24 '05 #2
tim
It was kindof a stupid mistake on my part: I had to put 'import os' at
the very beginning, and not only in one of my two function definitions.
Thanks anyway, thanks to your link I also found how to change the colour
of the console...neat :p !
Tim

Hans Nowak wrote:
tim wrote:
I want to write a program that looks into a given folder, groups files
that have a certain part of the filename in common and then copy those
groups one at a time to another place, using the raw_input prompt to
continue or break.

[...]


It works fine when I run this from PythonWin IDE, but after compiling an
executable from it (py2exe) it exits whatever I type in the 'continue?'
prompt.
What am I doing wrong?


Maybe this helps:

http://forums.devshed.com/python-pro...or-187633.html

The solution described here was to compile the program as a console app,
rather than a Windows app.

Dec 25 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
3000
by: Helmut Jarausch | last post by:
Hi when using an interactive Python script, I'd like the prompt given by raw_input to go to stderr since stdout is redirected to a file. How can I change this (and suggest making this the default behaviour) Many thanks for a hint, Helmut Jarausch
5
2282
by: Thomas Philips | last post by:
I'd like to stop a program (i.e. terminate its execution) without raising an exception if some condition is met, e.g answer = " " while answer not in "yn": answer = raw_input("y for yes, n for no, enter to exit ") if answer == "" stop/quit/end/whatever it takes to terminate the program elif answer == "y" #Yes
2
7240
by: J. W. McCall | last post by:
I'm working on a MUD server and I have a thread that gets keyboard input so that you can enter commands from the command line while it's in its main server loop. Everything works fine except that if a player enters the 'shutdown' command, everything shuts down, but the input thread is still sitting waiting for enter to be pressed for raw_input. After enter is pressed, it exits back to the command prompt as it should. I'm wondering if...
6
2787
by: tigrfire | last post by:
I've been working on a program to try and play a game of Craps, based on a version I found elsewhere - I didn't code the original, but I added a few things such as a balance and wager system. I'm having trouble doing it all without using global variables though, so I have another post in this group about local variable usage and how to pass it, but just when I thought I'd got it, my program has a segmentation fault. I'm not exactly sure...
21
8776
by: planetthoughtful | last post by:
Hi All, As always, my posts come with a 'Warning: Newbie lies ahead!' disclaimer... I'm wondering if it's possible, using raw_input(), to provide a 'default' value with the prompt? I would like to include the ability to edit an existing value (drawn from an SQLite table) using a DOS console Python app, but my gut
0
1753
by: biganimal | last post by:
I have a program and I want the program to be able to save question/answers so the program actually gets smarter without getting amnesia everytime its started. Can anyone help??? # questor.py # define some constants for futureuse kQuestion = 'question' kGuess = 'guess'
8
5314
by: Dox33 | last post by:
I ran into a very strange behaviour of raw_input(). I hope somebody can tell me how to fix this. (Or is this a problem in the python source?) I will explain the problem by using 3 examples. (Sorry, long email) The first two examples are behaving normal, the thirth is strange....... I wrote the following flabbergasting code: #-------------------------------------------------------------
0
1295
by: Nick Stinemates | last post by:
On Tue, Apr 15, 2008 at 07:24:05AM -0700, shawn s wrote: I love that you call the users of your app retards :) That rocks! ping runs forever. tracert doesnt. try: -- Nick Stinemates (nick@stinemates.org)
5
7117
by: jamitwidme | last post by:
Is there any way to type into a Tkinter frame window? I want to use raw_input() within a Tkinter frame.
0
9336
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10111
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9948
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9902
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9765
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5215
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5364
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3866
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2738
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.