473,394 Members | 1,481 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

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 1576
In <11**********************@l39g2000cwd.googlegroups .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.softspace` 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.softspace` 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.softspace 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
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...
4
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...
2
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...
66
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,...
9
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...
7
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...
1
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...
0
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....
2
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...
0
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...

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.