On Sat, 18 Oct 2008 15:30:23 -0400, Terry Reedy <tj*****@udel.e duwrote:
>http://www.linux.com/feature/150399 Interesting article with one minor incompleteness. "For instance, the print statement got turned into a print function; you must now put parentheses around what you want to print to the screen. The change allows developers to work with print in a more flexible and uniform way. If someone needs to replace the print function with some other action, it can be done with a universal search and replace, rather than rewriting each print statement by hand."
Even easier, print as a function can be replaced simply by defining a new version with the same name. No search/replace is needed. And reversion to the built-in only requires commenting out the replacement.
Perhaps it also omitted the fact that nothing prevents you from defining a
function to write things to stdout (or elsewhere) in Python 2.5, making the
Python 3.x change largely a non-feature. ;)
Jean-Paul 8 1178
On 18 Okt., 22:01, Jean-Paul Calderone <exar...@divmod .comwrote:
Perhaps it also omitted the fact that nothing prevents you from defining a
function to write things to stdout (or elsewhere) in Python 2.5, making the
Python 3.x change largely a non-feature. ;)
Jean-Paul
Even more. If someone had solved the hard problem of finding a less
cumbersome way of writing sys.stdout.writ e(...) the request for
multiline lambdas ( multi expression lambdas actually ) could have
been decreased about 75-80%.
In message
<de************ *************** *******@g61g200 0hsf.googlegrou ps.com>, Kay
Schluehr wrote:
If someone had solved the hard problem of finding a less
cumbersome way of writing sys.stdout.writ e(...) ...
I don't see what the big deal is. I regularly write things like
sys.stdout.writ e \
(
"<INPUT TYPE=\"RADIO\" NAME=\"%(name)s \""
" ID=\"%(name)s[%(value)s]\" VALUE=\"%(value )s\"%(checked)s >"
"<LABEL FOR=\"%(name)s[%(value)s]\">%(title)s </LABEL>\n"
# using LABEL lets user click on text to select button
%
{
"name" : EscapeHTML(Name ),
"value" : EscapeHTML(Valu e),
"title" : Title,
"checked" : ("", " CHECKED")[Checked],
}
)
On Sat, 18 Oct 2008 21:34:13 -0700, Kay Schluehr wrote:
On 18 Okt., 22:01, Jean-Paul Calderone <exar...@divmod .comwrote:
>Perhaps it also omitted the fact that nothing prevents you from defining a function to write things to stdout (or elsewhere) in Python 2.5, making the Python 3.x change largely a non-feature. ;)
Jean-Paul
Even more. If someone had solved the hard problem of finding a less
cumbersome way of writing sys.stdout.writ e(...) the request for
multiline lambdas ( multi expression lambdas actually ) could have been
decreased about 75-80%.
Er, am I missing something? How about this?
import sys
pr = sys.stdout.writ e
pr('Is this less cumbersome enough for you?')
But of course, that doesn't really help you avoid multi-expression
lambdas, unless you want to write obfuscated code:
def foo(x):
y = x+1
print y
return y
is roughly, but inefficiently, equivalent to:
lambda x: sys.stdout.writ e(x+1) or x+1
But that's cumbersome and obfuscated, and not scalable at all.
--
Steven
In article <gd**********@l ust.ihug.co.nz> ,
Lawrence D'Oliveiro <ld*@geek-central.gen.new _zealandwrote:
>In message <de*********** *************** ********@g61g20 00hsf.googlegro ups.com>, Kay Schluehr wrote:
>> If someone had solved the hard problem of finding a less cumbersome way of writing sys.stdout.writ e(...) ...
I don't see what the big deal is. I regularly write things like
sys.stdout.writ e \
(
"<INPUT TYPE=\"RADIO\" NAME=\"%(name)s \""
" ID=\"%(name)s[%(value)s]\" VALUE=\"%(value )s\"%(checked)s >"
"<LABEL FOR=\"%(name)s[%(value)s]\">%(title)s </LABEL>\n"
# using LABEL lets user click on text to select button
%
{
"name" : EscapeHTML(Name ),
"value" : EscapeHTML(Valu e),
"title" : Title,
"checked" : ("", " CHECKED")[Checked],
}
)
Why are you using a backslash?
--
Aahz (aa**@pythoncra ft.com) <* http://www.pythoncraft.com/
import antigravity
On 19 Oct 2008 07:44:52 -0700 aa**@pythoncraf t.com (Aahz) wrote:
sys.stdout.writ e \
(
Why are you using a backslash?
Because he hasn't opened the paren yet. He could have put the open
paren on the same line as the write obviating the need for the
backslash but then his open/close parens wouldn't line up. It just a
matter of style.
--
D'Arcy J.M. Cain <da***@druid.ne t | Democracy is three wolves http://www.druid.net/darcy/ | and a sheep voting on
+1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner.
In article <ma************ *************** ***********@pyt hon.org>,
D'Arcy J.M. Cain <da***@druid.ne twrote:
>On 19 Oct 2008 07:44:52 -0700 aa**@pythoncra ft.com (Aahz) wrote:
>> sys.stdout.writ e \ (
Why are you using a backslash?
Because he hasn't opened the paren yet. He could have put the open paren on the same line as the write obviating the need for the backslash but then his open/close parens wouldn't line up. It just a matter of style.
Well, no, it's not *just* a matter of style. I'm strongly opposed to
backslashes because they break when you get whitespace after them. (And
note carefully that I said "when" and not "if".)
--
Aahz (aa**@pythoncra ft.com) <* http://www.pythoncraft.com/
import antigravity
In message <vZ************ *************** ***@earthlink.c om>, Dennis Lee
Bieber wrote:
There is also the matter that the original material is using " on
each line to delimit the string, and then \" within the line to escape
the desired output "s, rather than either using ' for the string and
bare " for the output characters ...
I prefer using double-quotes universally. One less decision to make.
... or triple quoting the whole block...
Not a good idea.
In message <gd**********@p anix3.panix.com >, Aahz wrote:
I'm strongly opposed to backslashes because they break when you get
whitespace after them.
1) I've never had that problem.
2) Even if I did, it would report a syntax error, it's not going to fail
silently and introduce any run-time bugs, is it? This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: inquirydog |
last post by:
Hello-
I, the inquirydog, would like to solicit suggestions for a new
web page I am making:
I am creating a simple website that will translate concepts
between windows os's, Linux, and the Java language with all of its
related technologies. The website is at
http://members.dslextreme.com/users/inquirydog, and is a mock-version
of the Rosetta stone, which indicates concepts from each "platform"
|
by: mike420 |
last post by:
I think everyone who used Python will agree that its syntax is
the best thing going for it. It is very readable and easy
for everyone to learn. But, Python does not a have very good
macro capabilities, unfortunately. I'd like to know if it may
be possible to add a powerful macro system to Python, while
keeping its amazing syntax, and if it could be possible to
add Pythonistic syntax to Lisp or Scheme, while keeping all
of the...
|
by: Maboroshi |
last post by:
Hello
My question has to do with python and linux - I was interested in
finding out what it would take to reimplement the Linux Kernel in python
basically just taking the source code from linux and rewriting it in
python Would this idea make sense to do - if so what would be the
benefits of doing this and in what way would this not be a good idea
Cheers
|
by: David H |
last post by:
Background.
I'm running on WinXP w/ MS Services for Unix installed (to give
rsh/rlogin ability), both Python 2.3 and 2.4 version. In linux, I'm
running RHEE with python2.3 version. The code below works fine for me
in linux, but in WinXP the popen*() command "hangs". More
specifically, I get an apparent python prompt (without the '>>> ', but
whatever I type has no effect, and hitting return does a CR but not
the additional LF, so I...
|
by: stylecomputers |
last post by:
Hey guys,
I am absolutely new to Linux programming, with no w######s programming
experience except a small amount of C++ console apps.
Reasonably new to Linux, BSD etc, got good sound networking base of
knowledge and dont have any problem working the command line etc.
I want to learn a language that I can use in my networking duties that
is most likely to be of use to me. I have a few choices I can think of
being:
| |
by: noahmd |
last post by:
Okay, once-upon-a-time I tried to start programming by learning C. At
the time I was younger and didn't really understand all that C had to
offer. I eventually moved over to Microsoft's Visual Basic. It was
nice to be able to design a visual application with no effort (too bad
I didn't really learn the ins and outs of programming)
Long story short, I want to get back into programming, and Python looks
like a good choice for me to...
|
by: Mark Tarver |
last post by:
How do you compare Python to Lisp? What specific advantages do you
think that one has over the other?
Note I'm not a Python person and I have no axes to grind here. This is
just a question for my general education.
Mark
|
by: jwwicks |
last post by:
C/C++ Programs and Debugging in Linux
This tutorial will give you a basic idea how to debug a program in Linux using GDB. As you are aware Visual Studio doesn’t run on Linux so you have to use some of the tools provided on the command-line. If you hate the command line tools, get over it since you’re bound to be using them at some point in your career. All commands in Linux ARE case sensitive so capital letters are different from lowercase...
|
by: Terry Reedy |
last post by:
http://www.linux.com/feature/150399
Interesting article with one minor incompleteness.
"For instance, the print statement got turned into a print function; you
must now put parentheses around what you want to print to the screen.
The change allows developers to work with print in a more flexible and
uniform way. If someone needs to replace the print function with some
other action, it can be done with a universal search and replace, rather...
|
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,...
|
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...
| |
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...
|
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...
|
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...
|
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();...
|
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
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |