473,672 Members | 2,725 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Invoking Python from Cygwin problem.

Ant
Hi all,

Using cygwin and Python 2.5, I have the following scripts, one bash
script and the other a python script:
-------------------------------------------------------------------------------
#!/bin/bash

TEST_VAR=`./test.py`
TEST_VAR2=Test2

echo "Test var: $TEST_VAR OK"
echo "Test var2: $TEST_VAR2 OK"

----------------------------------------------------------------------------------
#!/usr/bin/python
print "Testing",

Running the bash script, I get the following output:

OKt var: Testing
Test var2: Test2 OK

Does anyone have any idea why the script would mess up the first echo?
Are there some kind of control characters being appended to the python
output in Windows? Looks like a CR character, but why?

Cheers,

Nov 24 '06 #1
4 1591
In <11************ **********@l39g 2000cwd.googleg roups.com>, Ant wrote:
----------------------------------------------------------------------------------
#!/usr/bin/python
print "Testing",

Running the bash script, I get the following output:

OKt var: Testing
Test var2: Test2 OK

Does anyone have any idea why the script would mess up the first echo?
Are there some kind of control characters being appended to the python
output in Windows? Looks like a CR character, but why?
It's a feature. The `sys.stdout` object remembers if the last ``print``
ended in a comma (see the `sys.stdout.sof tspace` attribute) and when the
interpreter executes its shutdown code and that `softspace` attribute is
set, an extra '\n' is printed.

Ciao,
Marc 'BlackJack' Rintsch
Nov 25 '06 #2
Ant

Marc 'BlackJack' Rintsch wrote:
....
It's a feature. The `sys.stdout` object remembers if the last ``print``
ended in a comma (see the `sys.stdout.sof tspace` attribute) and when the
interpreter executes its shutdown code and that `softspace` attribute is
set, an extra '\n' is printed.
So the workaround is to directly write to sys.stdout I guess. Or set
sys.stdout.soft space to 0?

Cheers.

Nov 25 '06 #3

Hi all,

Using cygwin and Python 2.5, I have the following scripts,
one bash script and the other a python script:
--------------------------------------------------------------
Ant ....

Using Cygwin and Python 2.4 under Win2K the following version
of your code seems to work OK here with no extraneous CR ....

I only changed the variable names & messages just a bit
for clarity ....

I don't see any real differences in this version
and what you originally posted, so I can't explain
the reason for the semingly extraneous carriage return
that you are seeing ....

# ------------------------------------------------------------

#!/bin/bash

TEST_1=`./test.py`
TEST_2="Testing Bash Value"

echo " "
echo "TEST_1 : $TEST_1 .... OK"
echo "TEST_2 : $TEST_2 .... OK"
# ------------------------------------------------------------

#!/usr/bin/python
print "Testing Python Code",
# ------------------------------------------------------------

$ ./test_vars

TEST_1 : Testing Python Code .... OK
TEST_2 : Testing Bash Value .... OK
--
Stanley C. Kitching
Human Being
Phoenix, Arizona
----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
Nov 25 '06 #4
Ant

Cousin Stanley wrote:
....
Using Cygwin and Python 2.4 under Win2K the following version
of your code seems to work OK here with no extraneous CR ....
Hmm. Just tried it here at home (Python 2.5) and it works fine as
well... Cygwin was pre-installed on my machine when I started work at
the new job a couple of weeks ago. I wonder if it's an old version they
had installed. I'll try updating Cygwin at work and see what happens...

Nov 25 '06 #5

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

Similar topics

2
5788
by: Jörg Maier | last post by:
Hey guys, i have a big problem using Tkinter and pexpect in cygwin. i try to program an winscp-like rsync Program for all posix Platforms (linux, macosx, cygwin). i got a class SslConnection with a method listDirectory that gives back a list of an remote directory using pexpect. this method works in linux, it works in cygwin-python from command-line, but invoked in an Tkinter-Program i got the strange Exception:...
4
2415
by: Andreou Giannis | last post by:
Allthough it is possible to build modules in Python2.3.3 and distutils with cygwin, by running: setup.py build --compiler=cygwin (after i created the libpython23.a) running: setup.py install afterwards, complains about not building with msvs v.6, since my Python distribution is built with it.
2
1935
by: Alain Paschoud | last post by:
Hi all, I made a small dialog in WxPython. I can run the python script with a double-click or through command line, and everything goes fine (dialog appears, which means that wx module has been found). Then, I decided to write a C program (under Windows, with Cygwin) that will read my script (through PyRun_SimpleFile() function) and run it. But the system doesn't find the wx module to import... Traceback (most recent call last):
66
5467
by: Srijit Kumar Bhadra | last post by:
Is there any specific reason for not using MinGW to build the official distribution of Python for Win32? A quick Google search did not reveal the answer to my question. If a link is available, please post it. Best Regards, Srijit
9
2488
by: Endless Story | last post by:
My last version of Python was 2.4, running smoothly on XP with path c: \Python24 - no need even to include this path in PATH; everything worked as it's supposed to at the command line. Just installed Python 2.5, after uninstalling 2.4 (and also 2.3 which had lingered). Now if I open a shell in Windows Python is not available! Here are the symptoms: - If I open a shell using "Command line here" with XP Powertools, then enter "python"...
7
409
by: Anton Mellit | last post by:
Hi, I am working on a Pari-Python module (see about GP/PARI at http://pari.math.u-bordeaux.fr/). Similar project was started by Stefane Fermigier 12 years ago (you can find a post about it on this newsgroup). You can see some screenshots on my blog (http:// mellit.wordpress.com/2007/10/28/pari-python/). I reproduce the text on my blog here. I finished some working version of the pari-python module. I tried to
1
4958
by: Calvin Cheng | last post by:
Hi guys, This may be a cygwin issue but I was hoping to get some answers here as well if someone has fixed this problem before. Basically, I am able to run "python <scriptname>.py" python files in command prompt. Unfortunately, I can't seem to get it to work in cygwin. I always get an error that says: python: can't open file '<scriptname>.py': No such file or directory
0
1365
by: =?iso-8859-1?q?C=E9dric_Lucantis?= | last post by:
Le Thursday 19 June 2008 18:14:03 Calvin Cheng, vous avez écrit : I don't think this is a python problem. Unlike dos, unix (and cygwin) dont look for executables in the current dir by default. Do you correctly type './yourscript.py' rather than 'yourcript.py' ? If it doesn't help it might be an end-line problem : python doesn't care about them, but the shebang line is parsed by cygwin and should match the end-line style you've chosen...
2
2112
by: Ant | last post by:
Hi all, There's a sweet combination of tools that you can assemble using Vim, a Python shell (or any shell for that matter) and GNU screen, where you essentially send selected text from Vim to the Python shell. (See http://technotales.wordpress.com/2007/10/03/like-slime-for-vim/ for more details - though I had to tweak the script a bit to get it to work on Windows - line ending interpretation problem) This works great in Linux, and...
0
8506
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8423
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,...
1
8649
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
7482
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6261
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5725
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4251
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
4447
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
1843
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.