[EMAIL PROTECTED] wrote:
If I then wanted to see what scheme's value
compared to, the string's comparison method would have to recognize that it
wasn't truly NUL-terminated, copy it, call strncmp() or whatever underlying
routine is used for string comparisons.
Python string comparisons can't
Stephen J. Turnbull wrote:
But you could have string objects (or a derivative) grow a
compiled_regexp attribute internally.
That would make the core dependent on the re module,
which I think would be a bad idea.
Personally I like the way the compilation step is
made at least somewhat explicit.
LD Gus Landis wrote:
.piece() can be both a verb and a noun
Er, pardon? I don't think I've ever heard 'piece' used
as a verb in English. Can you supply an example sentence?
(And no, Piece, man! doesn't count. :-)
Greg
___
Python-Dev mailing list
Reinhold Birkenfeld wrote:
Greg Ewing wrote:
There's no way importing a module could add something that
works like the old print statement, unless some serious
magic is going on...
You'd have to enclose print arguments in parentheses. Of course, the trailing
comma form would be lost
before, and
rejected on the grounds that it's too visually
confusing having $ signs both inside and outside
the quotes.
--
Greg Ewing, Computer Science Dept, +--+
University of Canterbury, | A citizen of NewZealandCorp, a |
Christchurch, New Zealand
would
need to be willing to convert either or both operands to
strings.
--
Greg Ewing, Computer Science Dept, +--+
University of Canterbury, | A citizen of NewZealandCorp, a |
Christchurch, New Zealand | wholly-owned subsidiary of USA Inc
easily were the only goal, it could
be achieved by making stdout a builtin and using
stdout.write(...).
--
Greg Ewing, Computer Science Dept, +--+
University of Canterbury, | A citizen of NewZealandCorp, a |
Christchurch, New Zealand
to it.
Just because a Python string can contain embedded NULs
doesn't mean it makes sense to use such strings in all
circumstances.
--
Greg Ewing, Computer Science Dept, +--+
University of Canterbury, | A citizen of NewZealandCorp
(sys.stdout)
if __name__ == __main__:
n = 666
x = 3.1415
Print[The answer is, 42]
Print[Tons of spam:, n:6]
Print[x:5:2, squared is, x*x:10:4]
Print[One, Two, ...]
Print[Buckle my shoe]
#
--
Greg Ewing, Computer Science Dept
Raymond Hettinger wrote:
Print[One, Two, ...]
Print[Buckle my shoe]
The ellipsis was a nice touch.
I've been wondering whether it would be worth allowing
ellipses to appear in other places besides slice indices,
so it could be used in a print-function and other such
purposes without
Fredrik Lundh wrote:
(you completely missed the point -- today's print mechanism works on *any*
object
that implements a write method, no just file objects. saying that oh, all
you need is
to add a method or here's a nice mixin doesn't give you a print
replacement)
While we're on the
Phillip J. Eby wrote:
I'm not sure where you got the Python is not a one pass compiler idea; I
don't recall having seen this meme anywhere before, and I don't see how
it's meaningful anyway.
Indeed, Python's bytecode compiler essentially *is*
a one-pass compiler (or at least it used to be --
[EMAIL PROTECTED] wrote:
Greg If a Python function is clearly wrapping a C function, one doesn't
Greg expect to be able to pass strings with embedded NULs to it.
Isn't that just floating an implementation detail up to the programmer (who
may
well not be POSIX- or Unix-aware)?
Yes,
Fredrik Lundh wrote:
maybe some variation of
http://www.python.org/peps/pep-0246.html
combined with default adapters could come in handy here ?
I really hope we can get by with something much less
heavyweight than that. I'm far from convinced that
something like PEP 246 proposes is
Guido van Rossum wrote:
So let's call it the Swiss Army Knife
(...Not) API design pattern.
Aha! Maybe this is the long-lost 20th principle from
the Zen of Python?
Greg
___
Python-Dev mailing list
Python-Dev@python.org
attributes and
methods can be inherited from multiple base classes,
however, if you're willing to write the necessary C code
to create the type object dynamically, as would happen
if it were being defined with Python code.
--
Greg Ewing, Computer Science Dept
will
replace it.
And-then-we-can-call-it-PyBol-3000-ly,
--
Greg Ewing, Computer Science Dept, +--+
University of Canterbury, | A citizen of NewZealandCorp, a |
Christchurch, New Zealand | wholly-owned subsidiary of USA Inc. |
[EMAIL PROTECTED
of automatically.
--
Greg Ewing, Computer Science Dept, +--+
University of Canterbury, | A citizen of NewZealandCorp, a |
Christchurch, New Zealand | wholly-owned subsidiary of USA Inc. |
[EMAIL PROTECTED
details
might yet change. I'd want another couple of releases before
calling it finished.
When I do reach that point, I'd be perfectly willing to
contribute it to the PSF.
--
Greg Ewing, Computer Science Dept, +--+
University of Canterbury, | A citizen
lookups, which was horribly slow. I
think the latest version now creates string objects at module
initialization to avoid this issue, though.
Yes, it now precreates and interns all identifier strings,
which should help considerably.
--
Greg Ewing, Computer Science Dept
and others not.
EIBTI here, I feel.
--
Greg Ewing, Computer Science Dept, +--+
University of Canterbury, | A citizen of NewZealandCorp, a |
Christchurch, New Zealand | wholly-owned subsidiary of USA Inc. |
[EMAIL PROTECTED
Oren Tirosh wrote:
perhaps the Python 3 executable should have a different name as part
of the standard distribution? I suggest py / py.exe
Or python3? EIBTI :-)
--
Greg Ewing, Computer Science Dept, +--+
University of Canterbury, | A citizen
.
--
Greg Ewing, Computer Science Dept, +--+
University of Canterbury, | A citizen of NewZealandCorp, a |
Christchurch, New Zealand | wholly-owned subsidiary of USA Inc. |
[EMAIL PROTECTED
?
--
Greg Ewing, Computer Science Dept, +--+
University of Canterbury, | A citizen of NewZealandCorp, a |
Christchurch, New Zealand | wholly-owned subsidiary of USA Inc. |
[EMAIL PROTECTED
Nick Coghlan wrote:
Not to mention the annoyingly large number of fonts that make '`' and '''
look
virtually identical :(
Well, you need to be careful about choice of font for
programming anyway, for 0/O, 1/l, etc.
--
Greg Ewing, Computer Science Dept
Oren Tirosh wrote:
I suggest an explicitly and permanently different name for the
interpreter executable of this new and incompatible branch of the
language. I want Python 3 scripts starting with #! to have an average
shelf life longer than 18 months.
That makes sense, but I'd prefer
Nathan Bullock wrote:
I find that I quite often want a
function that will give me a relative path from path A
to path B. I have created such a function, but it
would be nice if it was in the standard library.
+1 from me. It's a fairly common thing to want to do.
Greg
Trent Mick wrote:
If this *does* get added (I'm +0) then let's call it relpath or
relpathto as in the various implementations out there:
+1 on that, too. Preferably just relpath.
--
Greg Ewing, Computer Science Dept, +--+
University of Canterbury
...
import dis
dis.dis(f)
2 0 LOAD_CONST 1 (2)
3 LOAD_CONST 2 (3)
6 BINARY_ADD
7 RETURN_VALUE
8 LOAD_CONST 0 (None)
11 RETURN_VALUE
--
Greg Ewing, Computer
Brett Cannon wrote:
Would anyone really throw a huge fit if they went away? I am willing
to write a PEP for their removal in 2.6 with a deprecation in 2.5 if
people are up for it.
-1. I don't think this could realistically be done before 3.0,
because it would break a lot of existing code for
Karl Chen wrote:
Hi, has anybody considered adding something like this:
a = [1, 2]
[ 'x', *a, 'y']
as syntactic sugar for
a = [1, 2]
[ 'x' ] + a + [ 'y' ].
You can write that as
a = [1, 2]
a[1:1] = a
Greg
___
Python-Dev
François Pinard wrote:
The only practical reason to like this feature is sparing the need of
finding an otherwise useless name for the formal argument.
If the argument represents a coherent enough concept
to be passed in as a tuple in the first place, it
should be possible to find a meaningful
with tuples.
That might be a reasonable idea to consider for Py3k
in any case.
--
Greg Ewing, Computer Science Dept, +--+
University of Canterbury, | A citizen of NewZealandCorp, a |
Christchurch, New Zealand | wholly-owned subsidiary
complex.
But it's a rather selective kind of consistency. To be
truly consistent in this sense, arbitrary lvalues would
have to be allowed in the parameter list.
--
Greg Ewing, Computer Science Dept, +--+
University of Canterbury, | A citizen
where the call was.
--
Greg Ewing, Computer Science Dept, +--+
University of Canterbury, | A citizen of NewZealandCorp, a |
Christchurch, New Zealand | wholly-owned subsidiary of USA Inc. |
[EMAIL PROTECTED
the language
because of this.
--
Greg Ewing, Computer Science Dept, +--+
University of Canterbury, | A citizen of NewZealandCorp, a |
Christchurch, New Zealand | wholly-owned subsidiary of USA Inc. |
[EMAIL PROTECTED
/mailman/options/python-dev/greg.ewing%40canterbury.ac.nz
--
Greg Ewing, Computer Science Dept, +--+
University of Canterbury, | A citizen of NewZealandCorp, a |
Christchurch, New Zealand | wholly-owned subsidiary of USA Inc. |
[EMAIL
Alexander Myodov wrote:
for i in largelist while !found:
This doesn't cover enough use cases to be worth it, IMO.
The exit condition is often buried in the middle of
other statements in the loop, not right at the
beginning.
--
Greg Ewing, Computer Science Dept
that would not be so. E.g. I might
be generating pathames to go into a tar file that will
be unpacked in a different place or on another system.
--
Greg Ewing, Computer Science Dept, +--+
University of Canterbury, | A citizen of NewZealandCorp
, it's easy to miss the conditional while
skimming.
Guido wrote that while he was in listen-to-the-masses
mode. If he's switched back to follow-my-instincts
mode, it may need to be re-evaluated.
--
Greg Ewing, Computer Science Dept, +--+
University
needing any more keywords:
x if b else y if c else z
But if you require parens, it's not so nice:
(x if b else (y if c else z))
--
Greg Ewing, Computer Science Dept, +--+
University of Canterbury, | A citizen of NewZealandCorp, a |
Christchurch
, an exhausted
list iterator is false; probably by virtue of having a __len__()
method that returns the number of remaining items.
This seems like a misfeature to me. In fact I think an
iterator having a len() method at all is a misfeature --
the concept doesn't make sense.
--
Greg Ewing, Computer Science
-short-circuiting, only that they coerce their evaluated
operands to bool. Short-circuiting vs. non-short-circuiting
is an orthogonal issue.
--
Greg Ewing, Computer Science Dept, +--+
University of Canterbury, | A citizen of NewZealandCorp
Fredrik Lundh wrote:
for Python 3000, I'd recommend switching to and then and or else instead
of the current ambiguous single-keyword versions.
And then we could call the language Pyffel. :-)
--
Greg Ewing, Computer Science Dept, +--+
University
, as is the default
for user-defined classes.
--
Greg Ewing, Computer Science Dept, +--+
University of Canterbury, | A citizen of NewZealandCorp, a |
Christchurch, New Zealand | wholly-owned subsidiary of USA Inc. |
[EMAIL PROTECTED
Ron Adam wrote:
(a if e then b)
((a1 if e1 then b1) if e then b)
(a if e then (a2 if e2 then b2))
((a1 if e1 then b1) if e then (a2 if e2 then b2))
I think you mean 'else' rather than 'then' in all
those, don't you?
--
Greg Ewing, Computer Science Dept
has a bone, happy
sounds unnatural.
So I still prefer a if b else c to any of the alternatives,
and I still think parens should not be required.
--
Greg Ewing, Computer Science Dept, +--+
University of Canterbury, | A citizen of NewZealandCorp
of iterators associated
with particular types is too much to fit in my brain. I'd
rather they all had the same interface.
--
Greg Ewing, Computer Science Dept, +--+
University of Canterbury, | A citizen of NewZealandCorp, a |
Christchurch, New Zealand
the
documentation slightly simpler, since LCs can be described
fully and accurately in terms of translation to for-loops.
Whether those are *good* reasons or not is debatable.
In Py3k it's possible that this will be resolved by making
for-loop variables local to the loop as well. Or maybe not.
--
Greg Ewing
Nick Coghlan wrote:
Python, however, uses a dynamic name binding system and scopes are expensive
because they require setting up all of the machinery to support nested
visibility.
Scopes within a function needn't be anywhere near as expensive
as scopes for nested functions are. The compiler
Terry Reedy wrote:
Now, can you honestly say that you would (naively) read
return foo if bar else baz
and be certain you knew what it meant?
I can honestly say that, given I knew I was reading Python
code, it would never have entered by head to read foo if
as meaning that foo was the
)
# Do something with the next message
I don't see how that helps, since makeSomeBlockingCall()
is evaluated (and therefore blocks) *before* the yield
happens.
--
Greg Ewing, Computer Science Dept, +--+
University of Canterbury, | A citizen
Nick Coghlan wrote:
i.e., it's
like an or, only we're asking that the decision be made based on something
other than the truth value of the left hand operand.
Hmmm, then maybe it should be
a or c if b
or perhaps
a or, if b, c
:-)
--
Greg Ewing, Computer Science Dept
the calling frame straight
into the called one.
Or is this already done these days?
--
Greg Ewing, Computer Science Dept, +--+
University of Canterbury, | A citizen of NewZealandCorp, a |
Christchurch, New Zealand | wholly-owned subsidiary
returning
a value from a function by storing it in a global rather than
using a return statement.
--
Greg Ewing, Computer Science Dept, +--+
University of Canterbury, | A citizen of NewZealandCorp, a |
Christchurch, New Zealand | wholly-owned
for returning
things. This would make the for-loop situation even safer,
since then you could distinguish between falling off the
end of a generator and executing 'return None' inside it.
--
Greg Ewing, Computer Science Dept, +--+
University of Canterbury
is concerned.
The pattern of thinking is the same: I want to deal
with the first n of these things individually, and the
rest collectively.
--
Greg Ewing, Computer Science Dept, +--+
University of Canterbury, | A citizen of NewZealandCorp
.
If you want a thread that can preempt others, you give
it a higher priority.
--
Greg Ewing, Computer Science Dept, +--+
University of Canterbury, | A citizen of NewZealandCorp, a |
Christchurch, New Zealand | wholly-owned subsidiary
to answer newbie variable
variable questions, to which the *correct* answer is
invariably start thinking in Python, not bash/perl/tcl/PHP/
whatever.
--
Greg Ewing, Computer Science Dept, +--+
University of Canterbury, | A citizen of NewZealandCorp
Ron Adam wrote:
My concern is if it's used outside of functions, then on the left hand
side of assignments, it will be used to pack, but if used on the right
hand side it will be to unpack.
I don't see why that should be any more confusing than the
fact that commas denote tuple packing on
Guido van Rossum wrote:
BTW, what should
[a, b, *rest] = (1, 2, 3, 4, 5)
do? Should it set rest to (3, 4, 5) or to [3, 4, 5]?
Whatever type is chosen, it should be the same type, always.
The rhs could be any iterable, not just a tuple or a list.
Making a special case of preserving one
mechanism for lookups in module namespaces.
--
Greg Ewing, Computer Science Dept, +--+
University of Canterbury, | A citizen of NewZealandCorp, a |
Christchurch, New Zealand | wholly-owned subsidiary of USA Inc. |
[EMAIL PROTECTED
-level tools should go in their own suitably-named
modules.
--
Greg Ewing, Computer Science Dept, +--+
University of Canterbury, | A citizen of NewZealandCorp, a |
Christchurch, New Zealand | wholly-owned subsidiary of USA Inc. |
[EMAIL
as to suggest doing this,
rather pointing out that, if we had an autoloading mechanism,
this would be an obvious use case for it.
I'm not familiar with the clever trick Greg is proposing,
I'll see if I can cook up an example of it to show. Be
warned, it is very hackish...
--
Greg Ewing, Computer
for heap types
Have the rules concerning assignent to __class__ been
made more restrictive recently?
--
Greg Ewing, Computer Science Dept, +--+
University of Canterbury, | A citizen of NewZealandCorp, a |
Christchurch, New Zealand
#--
--
Greg Ewing, Computer Science Dept, +--+
University of Canterbury, | A citizen of NewZealandCorp, a |
Christchurch, New Zealand | wholly-owned subsidiary of USA Inc. |
[EMAIL PROTECTED
the
lnotab table? How about getting rid of all the delicate
code and replacing it with something much simpler?
--
Greg Ewing, Computer Science Dept, +--+
University of Canterbury, | A citizen of NewZealandCorp, a |
Christchurch, New Zealand
case it's a class.)
--
Greg Ewing, Computer Science Dept, +--+
University of Canterbury, | A citizen of NewZealandCorp, a |
Christchurch, New Zealand | wholly-owned subsidiary of USA Inc. |
[EMAIL PROTECTED
no. indexes a tuple of file
names attached to the code object. All entries are 32-bit
integers.
Easy to generate, easy to look up with a binary search,
should be big enough for everyone except those generating
obscenely huge code objects on 64-bit platforms.
--
Greg Ewing, Computer Science Dept
for this to fail.
--
Greg Ewing, Computer Science Dept, +--+
University of Canterbury, | A citizen of NewZealandCorp, a |
Christchurch, New Zealand | wholly-owned subsidiary of USA Inc. |
[EMAIL PROTECTED
Phillip J. Eby wrote:
I meant that just changing its class is a mutation, and since immutables
can be shared or cached, that could lead to problems. So I do think
it's a reasonable implementation limit to disallow changing the
__class__ of an immutable.
That's a fair point.
Although I
Sokolov Yura wrote:
May be allow modules to define __getattr__ ?
I think I like the descriptor idea better. Besides
being more in keeping with modern practice, it would
allow for things like
from autoloading import autoload
Foo = autoload('foomodule', 'Foo')
Blarg =
Phillip J. Eby wrote:
A more
compact scheme is possible, by using two tables - a bytecode-line
number table, and a line number- file table.
If you have to encode multiple files, you just offset their line numbers
by the size of the other files,
More straightforwardly, the second
Phillip J. Eby wrote:
At 08:07 PM 10/14/2005 +1300, Greg Ewing wrote:
More straightforwardly, the second table could just be a
bytecode - file number mapping.
That would use more space in any case involving multiple files.
Are you sure? Most of the time you're going to have
chunks
of a good solution to that, yet.
--
Greg Ewing, Computer Science Dept, +--+
University of Canterbury, | A citizen of NewZealandCorp, a |
Christchurch, New Zealand | wholly-owned subsidiary of USA Inc. |
[EMAIL PROTECTED
Neal Norwitz wrote:
We all know Guido likes Python. But the real question is do pythons like
Guido?
http://python.org/neal/
??? I get a 404 for this.
--
Greg Ewing, Computer Science Dept, +--+
University of Canterbury, | A citizen
but just use the name of doesn't
seem right.
And in my version, it's not *really* redundant, since the
name is only used to derive the names of the accessor methods.
It doesn't *have* to be the same as the property name, although
using anything else could justifiably be regarded as insane...
--
Greg
Guido van Rossum wrote:
Let's change the property built-in so that its arguments can be either
functions or strings (or None).
If an argument is a string, it should be a method name, and the method
is looked up by that name each time the property is used.
That sounds reasonable.
--
Greg
Antoine Pitrou wrote:
I suppose something like:
class C(object):
x = prop:
Yay for property x!
def __get__(self):
return self._x
def __set__(self, value):
self._x = x
I've just looked at Steven Bethard's recipe, and it seems
to give
indexing is
O(log n). Not as good as O(1) but a lot better
than O(n).
--
Greg Ewing, Computer Science Dept, +--+
University of Canterbury, | A citizen of NewZealandCorp, a |
Christchurch, New Zealand | wholly-owned subsidiary of USA Inc
, especially if there is an easy
way to explicitly materialise the view as an independent
string when wanted.
--
Greg Ewing, Computer Science Dept, +--+
University of Canterbury, | A citizen of NewZealandCorp, a |
Christchurch, New Zealand
Martin v. Löwis wrote:
For window.draw, people will readily understand that
they are supposed to use Latin letters. More generally, they will know
what script to use just from looking at the identifier.
Would it help if an identifier were required to be
made up of letters from the same
M.-A. Lemburg wrote:
If you are told to debug a program
written by say a Japanese programmer using Japanese identifiers
you are going to have a really hard time.
Or you could look upon it as an opportunity to
broaden your mental horizons by learning some
Japanese. :-)
--
Greg Ewing
the characters you want, for your own in-house use.
--
Greg Ewing, Computer Science Dept, +--+
University of Canterbury, | A citizen of NewZealandCorp, a |
Christchurch, New Zealand | wholly-owned subsidiary of USA Inc. |
[EMAIL PROTECTED
things like
up3levels = dirname ** 3
--
Greg Ewing, Computer Science Dept, +--+
University of Canterbury, | A citizen of NewZealandCorp, a |
Christchurch, New Zealand | wholly-owned subsidiary of USA Inc. |
[EMAIL PROTECTED
references the new object.
--
Greg Ewing, Computer Science Dept, +--+
University of Canterbury, | A citizen of NewZealandCorp, a |
Christchurch, New Zealand | wholly-owned subsidiary of USA Inc. |
[EMAIL PROTECTED
to it
will be broken. Or does your resurrection code
intervene before that happens?
--
Greg Ewing, Computer Science Dept, +--+
University of Canterbury, | A citizen of NewZealandCorp, a |
Christchurch, New Zealand | wholly-owned subsidiary of USA Inc
some way
of hooking other things into it (as does Tkinter),
but whichever one you're using, it likes to be in
charge. Code which blocks reading from standard
input doesn't fit very well into any of them.
--
Greg Ewing, Computer Science Dept, +--+
University
Gustavo J. A. M. Carneiro wrote:
The object isn't really destroyed. Simply ob_refcnt drops to zero,
then tp_dealloc is called, which is supposed to destroy it. But since I
wrote tp_dealloc, I choose not to destroy it,
Be aware that a C subclass of your wrapper that overrides
tp_dealloc is
Michiel Jan Laurens de Hoon wrote:
I have an extension module for scientific visualization. This extension
module opens one or more windows, in which plots can be made.
What sort of windows are these? Are you using an existing
GUI toolkit, or rolling your own?
For the graphics windows to
[EMAIL PROTECTED] wrote:
Python could dictate that the
way to play ball is for other packages (Tkinter, PyGtk, wxPython, etc) to
feed Python the (socket, callback) pair. Then you have a uniform way to
control event-driven applications.
Certainly, if all other event-driven packages are
Noam Raphael wrote:
All that is needed to make Tkinter and Michiels'
code run together is a way to say add this callback to the input
hook instead of the current replace the current input hook with this
callback. Then, when the interpreter is idle, it will call all the
registered callbacks,
Noam Raphael wrote:
On 11/13/05, Greg Ewing [EMAIL PROTECTED] wrote:
Noam Raphael wrote:
callback. Then, when the interpreter is idle, it will call all the
registered callbacks, one at a time, and everyone would be happy.
Except for those who don't like busy waiting.
I'm
-savvy language seems a wart.
--
Greg Ewing, Computer Science Dept, +--+
University of Canterbury, | A citizen of NewZealandCorp, a |
Christchurch, New Zealand | wholly-owned subsidiary of USA Inc. |
[EMAIL PROTECTED
Here's a somewhat radical idea:
Why not write the parser and bytecode compiler in Python?
A .pyc could be bootstrapped from it and frozen into
the executable.
--
Greg Ewing, Computer Science Dept, +--+
University of Canterbury, | A citizen
:
return True
else:
look in the instance dict for the attribute
There wouldn't be a need to rely on catching exceptions
at all, then.
--
Greg Ewing, Computer Science Dept, +--+
University of Canterbury, | A citizen of NewZealandCorp
and
notifying the submitter? I don't see why a full-blown
registration and login should be required.
If the submitter chooses not to supply an email address,
then they have no grounds for being upset at not receiving
any notifications!
--
Greg Ewing, Computer Science Dept
Guido van Rossum wrote:
Um, that does't work for types which customize __getattribute__ or
__getattr__ in various ways.
There could be a __hasattr__ slot in the class itself for
that purpose.
IMO a property that has a side effect (other than updating a cache or
statistics or perhaps
be beefed up to include the
module name somehow, so that it works reliably
(or at least more reliably than now).
--
Greg Ewing, Computer Science Dept, +--+
University of Canterbury, | A citizen of NewZealandCorp, a |
Christchurch, New Zealand
Guido van Rossum wrote:
You *might* want
to separate classes with two blank lines if the methods within them
are separated by single blank lines, but even there it's probably
overkill.
Lately I've taken to putting a separator like this
between consecutive class definitions of any substantial
101 - 200 of 2277 matches
Mail list logo