473,769 Members | 2,337 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Misleading wikipedia article on Python 3?

I'm surprised to read this:

http://en.wikipedia.org/wiki/Python_3

"""Note that while there is no explicit requirement that code be able
to run unmodified in both versions, in practice it is quite likely for
most code. As of January 2007, it looks like most reasonable code
should run quite well under either branch."""
I haven't been following Python 3 development recently. Have things
really changed that much? Last time I looked, e.g. dict.items() no
longer returned a list. Seems unlikely that most code will run on 2
and 3, in that case, and IIUC Guido has said all along that not much
code will run on both.

Maybe somebody who's following current Py3k goings-on can fix the
article if needed...
John
Aug 5 '07
27 1515
On 2007-08-08, Istvan Albert <is***********@ gmail.comwrote:
On Aug 8, 2:00 pm, Neil Cerutti <horp...@yahoo. comwrote:
>I thought, in fact, that open was on more shaky ground. ;)

yeah, that too ...
OK, I had misremembered. The current docs say that open is
preferred, and that file should rather be used as a type name.
>
>I can't find any evidence of that in the PEPs. Do you have a reference?

here is something:

http://svn.python.org/view/python/br...6685&view=auto

look for :

- Removed these Python builtins:
apply(), callable(), coerce(), file(), reduce(), reload()
Thanks very much.

--
Neil Cerutti
Outside of the killings, Washington has one of the lowest crime rates in the
country. --Marion Barry
Aug 8 '07 #21
Istvan Albert <is***********@ gmail.comwrites :
apply(), callable(), coerce(), file(), reduce(), reload()
reduce() is really gone????? Maybe itertools can get an ireduce
function or something like that?
Aug 8 '07 #22
On 2007-08-08, Paul Rubin <httpwrote:
Istvan Albert <is***********@ gmail.comwrites :
> apply(), callable(), coerce(), file(), reduce(), reload()

reduce() is really gone????? Maybe itertools can get an
ireduce function or something like that?
I don't see how file() can be "removed", actually, unless the
file type itself is getting axed.

--
Neil Cerutti
Aug 8 '07 #23
I don't see how file() can be "removed", actually, unless the
file type itself is getting axed.
Indeed, that's the case. Py3k won't use stdio for file input and
output, but the io module.

Regards,
Martin
Aug 8 '07 #24
Istvan Albert wrote:
A solution would be writing the code with a logging function to begin
with, alas many times that is out of one's hand.
If the code has been written with calls to a builtin
print function, the situation isn't much better. You
could monkeypatch the print function, but that's
probably worse than swapping sys.stdout.

(I agree that print should be a function, simply because
there's no strong reason for it *not* to be. But I
don't think it makes a difference to this particular
problem.)

--
Greg
Aug 9 '07 #25
On 8/8/07, greg <gr**@cosc.cant erbury.ac.nzwro te:
Istvan Albert wrote:
A solution would be writing the code with a logging function to begin
with, alas many times that is out of one's hand.

If the code has been written with calls to a builtin
print function, the situation isn't much better. You
could monkeypatch the print function, but that's
probably worse than swapping sys.stdout.
You can easily modify print in a safe way. Here's an example, that
will work in any recent version of Python:

import sys

def print_(s):
print s

def logger(method):
def wrapper(s):
sys.stderr.writ e('Logging: %s\n' % s)
method(s)
return wrapper

print_ = logger(print_)

print_('hello')
Running this code will do a regular print of 'hello', as well as
"logging" it to stderr. As a function, you can convert print wholesale
to another logging function, or wrap it transparently like this to
provide additional logging functionality. What do you find wrong with
this sort of "monkeypatching "?

--
Evan Klitzke <ev**@yelp.co m>
Aug 9 '07 #26
Evan Klitzke wrote:
On 8/8/07, greg <gr**@cosc.cant erbury.ac.nzwro te:
>Istvan Albert wrote:
>>A solution would be writing the code with a logging function to begin
with, alas many times that is out of one's hand.
If the code has been written with calls to a builtin
print function, the situation isn't much better. You
could monkeypatch the print function, but that's
probably worse than swapping sys.stdout.

You can easily modify print in a safe way. Here's an example, that
will work in any recent version of Python:

import sys

def print_(s):
print s

def logger(method):
def wrapper(s):
sys.stderr.writ e('Logging: %s\n' % s)
method(s)
return wrapper

print_ = logger(print_)

print_('hello')
Running this code will do a regular print of 'hello', as well as
"logging" it to stderr. As a function, you can convert print wholesale
to another logging function, or wrap it transparently like this to
provide additional logging functionality. What do you find wrong with
this sort of "monkeypatching "?
foolish question maybe.
Why wouldn't you do it this way ?

def print_(s):
print s

def logger(m):
sys.stderr.writ e('Logging: %s\n' % m)
method(m)

print_ = logger(print_)

print_('hello')


Aug 10 '07 #27
Evan Klitzke wrote:
You can easily modify print in a safe way.
Yes, but you'd still have to replace the builtin print
function with your own to get it used by non-cooperative
code. That doesn't seem to gain you much over replacing
sys.stdout with something that intercepts and logs
stuff written to it.
What do you find wrong with this sort of "monkeypatching "?
At least sys.stdout was designed somewhat with the
possibility of replacing it in mind. It's not an
entirely unexpected thing to do. Replacing something
in the builtin namespace seems like a more drastic
step, somehow.

--
Greg
Aug 10 '07 #28

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

Similar topics

0
1161
by: Laurence Parry | last post by:
Some people over on Wikipedia seem to have the idea that VB.NET is not a major programming language: http://en.wikipedia.org/wiki/Template_talk:Major_programming_languages_small#Visual_Basic_.NET I think they're wrong. But I had to agree with what one guy said - the general view in the geeky programming community is that VB.NET is a poor brother to C#; some still think it's just a slightly improved version of VB! I don't think this will...
24
2380
by: Luis M. González | last post by:
For those interested in the simplest, easiest and most pythonic web framework out there, there's a new page in Wikipedia: http://en.wikipedia.org/wiki/Karrigell
9
4963
by: AES | last post by:
I fairly often make PDF copies of web pages or sites by copying the web page link from the web page itself and pasting it into the Acrobat 7.0 Standard "Create PDF From Web Page" command. (Not trying to steal material; usually just want to make a temporary copy to read offline, e.g. on a plane flight.) This almost always works remarkably well, but when I tried it recently with a Wikipedia article
8
2131
by: Claudio Grondi | last post by:
Here an example of what I mean (Python 2.4.2, IDLE 1.1.2, Windows XP SP2, NTFS file system, 80 GByte large file): Traceback (most recent call last): File "<pyshell#1>", line 1, in -toplevel- f = file('veryBigFile.dat','r+') IOError: No such file or directory: 'veryBigFile.dat'
7
1419
by: Pitaridis Aristotelis | last post by:
There is a free encyclopedia called wikipedia (http://wikimediafoundation.org/). Does anyone knows how to use it in order to get various articles for diplaying them in my application?
5
7669
by: jkn | last post by:
Hi all Python 2.4.2 (#1, Apr 26 2006, 23:35:31) on linux2 Type "help", "copyright", "credits" or "license" for more information. Traceback (most recent call last): File "<stdin>", line 1, in ? IOError: invalid mode: a
11
2318
by: Paddy | last post by:
I just had a link to Tim peters first post on doctest: http://groups.google.com/group/comp.lang.python/msg/1c57cfb7b3772763 removed from http://en.wikipedia.org/wiki/Doctest as it doesn't fit their guidelines for external links. I wonder, could maybe the official website be persuaded to host a copy so that it could be linked to? Tim, would you object? - Paddy.
2
2626
by: John Nagle | last post by:
For some reason, Python's parser for "robots.txt" files doesn't like Wikipedia's "robots.txt" file: False The Wikipedia robots.txt file passes robots.txt validation, and it doesn't disallow unknown browsers. But the Python parser doesn't see it that way. No matter what user agent or URL is specified; for that robots.txt file, the only answer is "False". It's failing in Python 2.4 on Windows and 2.5 on Fedora Core.
13
2464
by: Paddy | last post by:
I would value the opinion of fellow Pythoneers who have also contributed to Wikipedia, on the issue of "Is Python Standardized". Specifically in the context of this table: http://en.wikipedia.org/wiki/Comparison_of_programming_languages#General_comparison (Comparison of programming languages) And this entry in the talk page http://en.wikipedia.org/wiki/Talk:Comparison_of_programming_languages#Standardized_Python.3F (Talk:Comparison of...
0
9423
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,...
0
10211
Oralloy
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...
0
8870
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
7408
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
6673
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
5298
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
5447
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3958
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
3
2815
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.