ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Your first question is a bit ambiguous, provide an example of what you mean, in answer to your second question:
Code:
#!/usr/bin/python
import sys
print >> sys.stderr, 'this goes to stderr'
print >> sys.stdout, 'this goes to stdout'
Code:
core:~/vir$ ./test.py
this goes to stderr
this goes to stdout
core:~/vir$ ./test.py 2>std.err
this goes to stdout
core:~/vir$ ./ test.py 1>std.out
this goes to stderr
core:~/vir$
- do you see "print-without-a-new-line-or-space-in-python" in the URL ?
And you know, indeed there is an example:
Code:
Now, you can fix the issue with the line break by inserting a comma after the print statement:
print "Hello",
print "Python",
print "!"
This will print:
Hello Python !
But the problem is that it will still insert a space after it prints the text, so to fix this you will have to use sys.stdout.write like this:
import sys
sys.stdout.write("Hello ")
sys.stdout.write("Python")
sys.stdout.write("!")
This will print:
Hello Python!
So, do yo perform WEB search and can you use 'Find' function of your favorite WEB browser ?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.