Package: python2.4
Version: 2.4.1-2
Severity: wishlist

Many types in Python are idempotent, so that int(1) works
as expected, float(2.34)==2.34, ''.join('hello')=='hello'
et cetera.

Why not file()?     Currently, file(open(something, 'r')) fails
with "TypeError: coercing to Unicode: need string or buffer, file found."

Semantically, file(fd) should be equivalent to os.fdopen(fd.fileno())
or the proposed file.fromfd() (Jp Calderone, Python-dev, 2003).
You should get another independent
file object that accesses the same file.

What would be gained?

Primarily, it would allow you to derive classes from file more easily.
At present, if you want to derive like so, you're class can only work
when passed a file name or buffer.

class file_with_caching(file):
        def __init__(self, something):
                file.__init__(self, something)
        
        def etcetera...

For instance, you have no way of creating a file_with_caching()
object from the file descriptors returned from os.fork().

Also, you have no way of taking a file that is already open,
and creating a file_with_caching() object from it.    So,
you can't use classes derived from file() on the standard input
or standard output.

This breaks the nice Linux OS-level definition of a file descriptor.
At the Linux level, you have a nice uniform interface where all
file descriptors are equally good.    At the python level, some
are better than others.   It's a case where Python unnecessarily
restricts what you can do.

-- System Information:
Debian Release: testing/unstable
  APT prefers testing
  APT policy: (500, 'testing')
Architecture: i386 (i686)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.11-1-686
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968)

Versions of packages python2.4 depends on:
ii  libbz2-1.0                    1.0.2-8    high-quality block-sorting file co
ii  libc6                         2.3.5-6    GNU C Library: Shared libraries an
ii  libdb4.2                      4.2.52-18  Berkeley v4.2 Database Libraries [
ii  libncurses5                   5.4-9      Shared libraries for terminal hand
ii  libreadline4                  4.3-15     GNU readline and history libraries
ii  libssl0.9.7                   0.9.7e-3   SSL shared libraries
ii  zlib1g                        1:1.2.2-4  compression library - runtime

python2.4 recommends no packages.

-- no debconf information


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to