473,602 Members | 2,809 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Re: Linux.com: Python 3 makes a big break

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
Oct 18 '08 #1
8 1171
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%.

Oct 19 '08 #2
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],
}
)

Oct 19 '08 #3
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
Oct 19 '08 #4
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
Oct 19 '08 #5
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.
Oct 19 '08 #6
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
Oct 19 '08 #7
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.
Oct 19 '08 #8
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?
Oct 19 '08 #9

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

Similar topics

4
3001
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"
699
33733
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...
34
5067
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
0
1641
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...
10
1716
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:
53
5313
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...
852
28256
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
2
20835
jwwicks
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...
6
1546
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...
0
7993
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
8404
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
8056
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
8270
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
6730
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
5870
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
5440
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();...
1
1511
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1256
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.