::
str(pizza_night)
'fri'
shirt_colour.index
2
--
\ It ain't so much the things we don't know that get us in |
`\ trouble. It's the things we know that ain't so. -- Artemus |
_o__) Ward (1834-67), U.S. journalist |
Ben Finney
--
http
be |
`\ made in a very narrow field.” —Niels Bohr |
_o__) |
Ben Finney
--
http://mail.python.org/mailman/listinfo/python-announce-list
Support the Python Software Foundation:
http://www.python.org/psf/donations/
for me |
`\ at kick boxing.” —Emo Philips |
_o__) |
Ben Finney
--
http://mail.python.org/mailman/listinfo/python-announce-list
Support the Python Software Foundation:
http
).
* A document answering Frequently Asked Questions is now added.
--
\ “Any intelligent fool can make things bigger and more complex… |
`\It takes a touch of genius – and a lot of courage – to move in |
_o__)the opposite direction.” —Albert Einstein |
Ben Finney
) |
Ben Finney
--
http://mail.python.org/mailman/listinfo/python-list
Ben Finney [EMAIL PROTECTED] wrote:
If I want to implement a __repr__ that's reasonably nice to the
programmer, what's the Right Way? Are there recipes I should look
at?
As a (carefully selected) example from the code I'm writing:
import lib.attribute
m = lib.attribute.Human_Sex
Marc 'BlackJack' Rintsch [EMAIL PROTECTED] wrote:
In [EMAIL PROTECTED], Ben Finney wrote:
class Human_Sex(str):
def __repr__(self):
repr_str = %s(name=%s) % (
self.__class__.__name__,
str.__repr__(self
Erik Max Francis [EMAIL PROTECTED] wrote:
Ben Finney wrote:
If I want to implement a __repr__ that's reasonably nice to the
programmer, what's the Right Way? Are there recipes I should look
at?
I tend to use:
def __repr__(self):
if hasattr(self, '__str__
exhilarating as to be shot at without |
`\result. -- Winston Churchill |
_o__) |
Ben Finney
--
http://mail.python.org/mailman/listinfo/python-list
record to learn Spanish. I turned it |
`\on and went to sleep; the record got stuck. The next day I |
_o__)could only stutter in Spanish. -- Steven Wright |
Ben Finney
--
http://mail.python.org/mailman/listinfo/python-list
)Gordon Noel Byron |
Ben Finney
--
http://mail.python.org/mailman/listinfo/python-list
) |
Ben Finney
--
http://mail.python.org/mailman/listinfo/python-list
) |
Ben Finney
--
http://mail.python.org/mailman/listinfo/python-list
those bumper stickers. He hates |
`\ New York. -- Steven Wright |
_o__) |
Ben Finney
--
http://mail.python.org/mailman/listinfo/python-list
Philips |
Ben Finney
--
http://mail.python.org/mailman/listinfo/python-list
Roy Smith [EMAIL PROTECTED] wrote:
Ben Finney [EMAIL PROTECTED] wrote:
Test cases should each run individually, from a known state, and
not depend on any other tests. You can define a fixture for
several tests in the unittest.TestCase methods setUp() and
tearDown(), to establish and clear
.
The definition is agreeably solid.
The intention is disagreeably sickening.
--
\ Room service? Send up a larger room. -- Groucho Marx |
`\ |
_o__) |
Ben Finney
in the way.
--
\ I put instant coffee in a microwave oven and almost went back |
`\ in time. -- Steven Wright |
_o__) |
Ben Finney
--
http://mail.python.org/mailman/listinfo/python-list
) |
Ben Finney
--
http://mail.python.org/mailman/listinfo/python-list
Steven D'Aprano [EMAIL PROTECTED] wrote:
On Mon, 14 Nov 2005 00:48:46 +1100, Ben Finney wrote:
I believe Pierre is looking for a syntax that will save him from
assigning values to names; that Python will simply assign
arbitrary unique values for these special names.
What I still don't
Michael [EMAIL PROTECTED] wrote:
Ben Finney wrote:
I've yet to see a convincing argument against simply assigning
values to names, then using those names.
If you have a name, you can redefine a name, therefore the value a
name refers to is mutable.
Since there are mutable and immutable
Ben Finney [EMAIL PROTECTED] wrote:
I want my modules to (sometimes) define an abstract base exception
class, that all other exceptions in that module inherit from.
Not a whole lot of feedback on this, so here's the implementation I
decided upon.
class FooException(Exception
Ben Finney [EMAIL PROTECTED] wrote:
I want my modules to (sometimes) define an abstract base exception
class, that all other exceptions in that module inherit from.
[re-posting with the implementation properly foo-ified]
Not a whole lot of feedback on this, so here's the implementation I
two boys and a girl.' -- Steven Wright |
_o__) |
Ben Finney
--
http://mail.python.org/mailman/listinfo/python-list
at |
`\the rate of 40,000 or even 4,000 per hour ... -- F. H. Wales |
_o__) (1936) |
Ben Finney
--
http://mail.python.org/mailman/listinfo/python-list
) |
Ben Finney
--
http://mail.python.org/mailman/listinfo/python-list
of the
built-in iterable types?
--
\ A good politician is quite as unthinkable as an honest |
`\burglar. -- Henry L. Mencken |
_o__) |
Ben Finney
--
http://mail.python.org/mailman
sys; help(sys.exit)' will be of assistance.
--
\I always had a repulsive need to be something more than |
`\ human. -- David Bowie |
_o__) |
Ben Finney
--
http
Earl, _Red Meat_ |
Ben Finney
--
http://mail.python.org/mailman/listinfo/python-list
mine to theirs, hence the
question.
--
\ I planted some bird seed. A bird came up. Now I don't know |
`\ what to feed it. -- Steven Wright |
_o__) |
Ben Finney
--
http://mail.python.org
of |
`\ sex. -- Gore Vidal |
_o__) |
Ben Finney
--
http://mail.python.org/mailman/listinfo/python-list
Fuzzyman [EMAIL PROTECTED] wrote:
Ben Finney wrote:
On dirtSimple.org[0], PJE wrote:
[...] Python code is easy to write, but hard to depend on. You
pretty much have to:
1. limit yourself to platforms with a suitable packaging
system,
2. bundle all
) |
Ben Finney
--
http://mail.python.org/mailman/listinfo/python-list
Diller |
Ben Finney
--
http://mail.python.org/mailman/listinfo/python-list
you looked at it in the right way, did not become still |
_o__) more complicated. -- Paul Anderson |
Ben Finney
--
http://mail.python.org/mailman/listinfo/python-list
|
_o__) |
Ben Finney
--
http://mail.python.org/mailman/listinfo/python-list
The Eternal Squire [EMAIL PROTECTED] wrote:
Ben Finney wrote:
Ethics such as sharing, and helping one's neighbour?
Giving away an illegal copy of software it not helping one's
neighbor, it is making that neighbor an accessory to copyright
infringement, a federal offense punishable
Wright |
_o__) |
Ben Finney
--
http://mail.python.org/mailman/listinfo/python-list
is useful for debugging.
--
\ If you go flying back through time and you see somebody else |
`\ flying forward into the future, it's probably best to avoid eye |
_o__)contact. -- Jack Handey |
Ben Finney
--
http://mail.python.org/mailman
to a costume party at your boss's house, wouldn't |
`\ you think a good costume would be to dress up like the boss's |
_o__) wife? Trust me, it's not. -- Jack Handey |
Ben Finney
--
http://mail.python.org/mailman/listinfo/python-list
Bengt Richter [EMAIL PROTECTED] wrote:
Ben Finney [EMAIL PROTECTED] wrote:
Getting a numeric index might be useful in a language such as
Pascal, with no built-in dict or sequence types. In Python, where
any immutable object can be a dict key, and any sequence can be
iterated, it seems
[EMAIL PROTECTED] wrote:
Ben Finney wrote:
How do we deal with the rampant proliferation of a zillion
implementations of some standard idiom in PyPI?
How about some kind of mega util package? One big package with all
those recurring reinventions. If it gets popular enough, I'm sure
of the |
`\ precipitate. -- Steven Wright |
_o__) |
Ben Finney
--
http://mail.python.org/mailman/listinfo/python-list
Bengt Richter [EMAIL PROTECTED] wrote:
On Sat, 19 Nov 2005 11:10:42 +1100 (EST), Ben Finney [EMAIL PROTECTED]
wrote:
Bengt Richter [EMAIL PROTECTED] wrote:
If [an enumeration has a fixed sequence], what is more natural
than using their index values as keys to other ordered info?
I don't
Steven D'Aprano [EMAIL PROTECTED] wrote:
On Fri, 18 Nov 2005 14:32:46 +1100, Ben Finney wrote:
Is there any difference between a Python immutable value, and a
constant? I suppose constant also implies that the *name* binds
unchangeably to a particular value. Is that meaningful?
That's
|
`\Wright |
_o__) |
Ben Finney
--
http://mail.python.org/mailman/listinfo/python-list
) |
Ben Finney
--
http://mail.python.org/mailman/listinfo/python-list
just an awful lot of |
_o__) 'us'. -- Douglas Adams |
Ben Finney
--
http://mail.python.org/mailman/listinfo/python-list
[restored my attribution line so we know who said what]
Christoph Zwerschke [EMAIL PROTECTED] wrote:
Ben Finney wrote:
In what cases do you find yourself needing a dict that preserves
its key order? Can you present a use case that would be improved
by an ordered dict?
There are too many
just as little |
`\ taste. -- Henry L. Mencken |
_o__) |
Ben Finney
--
http://mail.python.org/mailman/listinfo/python-list
to |
`\ recognize a mistake when you make it again. -- Franklin P. |
_o__)Jones |
Ben Finney
--
http://mail.python.org/mailman/listinfo/python-list
on my dog. Now he's gone. -- Steven |
`\Wright |
_o__) |
Ben Finney
--
http://mail.python.org/mailman/listinfo/python-list
Alex Martelli [EMAIL PROTECTED] wrote:
Ben Finney [EMAIL PROTECTED] wrote:
How can a (user-defined) class ensure that its instances are
immutable, like an int or a tuple, without inheriting from those
types?
You can make a good start by defining __setattr__, __delattr__ (and
__setitem__
Alex Martelli [EMAIL PROTECTED] wrote:
Ben Finney [EMAIL PROTECTED] wrote:
How can a (user-defined) class ensure that its instances are
immutable, like an int or a tuple, without inheriting from those
types?
[...]
Of course, these restrictions can be easily worked around
Alex Martelli [EMAIL PROTECTED] wrote:
Ben Finney [EMAIL PROTECTED] wrote:
Why is I want to make objects immutable seen as I don't trust
my users? Are Python's existing immutable types also seen the
same way? If not, why the distinction?
A type implemented in C offers different
bought some batteries, but they weren't included; so I had |
`\ to buy them again. -- Steven Wright |
_o__) |
Ben Finney
--
http://mail.python.org/mailman/listinfo/python-list
of the
freedom for anyone they choose to hack on it.
--
\ I have a map of the United States; it's actual size. It says |
`\ '1 mile equals 1 mile'... Last summer, I folded it. -- Steven |
_o__) Wright |
Ben Finney
--
http
, in |
_o__) a letter to Madison |
Ben Finney
--
http://mail.python.org/mailman/listinfo/python-list
you see the stop sign?' I said, 'Yeah, but I |
_o__) don't believe everything I read.' -- Steven Wright |
Ben Finney
--
http://mail.python.org/mailman/listinfo/python-list
) |
Ben Finney
--
http://mail.python.org/mailman/listinfo/python-list
scrutiny, over an extended time,
before deciding they'll be a net benefit.
--
\ Unix is an operating system, OS/2 is half an operating system, |
`\ Windows is a shell, and DOS is a boot partition virus. -- |
_o__) Peter H. Coffin |
Ben
:-)
--
\ Timid men prefer the calm of despotism to the boisterous sea |
`\ of liberty. -- Thomas Jefferson |
_o__) |
Ben Finney
--
http://mail.python.org/mailman/listinfo/python-list
Francisco. I found someone's heart. -- Steven |
`\Wright |
_o__) |
Ben Finney
--
http://mail.python.org/mailman/listinfo/python-list
not deter the next. |
`\ Well, what of it? The first one is at least disposed of. -- |
_o__) Henry L. Mencken |
Ben Finney
--
http://mail.python.org/mailman/listinfo/python-list
Mike Meyer [EMAIL PROTECTED] wrote:
Ben Finney [EMAIL PROTECTED] writes:
Mike Meyer [EMAIL PROTECTED] wrote:
Lots of people seem to want immutable instances. Nobody seems to
have a use case for them.
Perhaps you missed my release announcement of the 'enum' package
that explains why Enum
Mike Meyer [EMAIL PROTECTED] wrote:
Ben Finney [EMAIL PROTECTED] writes:
Since the values of an enumeration are directly reflected in
the values and attributes, Enum instances are immutable to
preserve this relationship
This justifies making the attributes immutable
to get around it, all of which seem hackish to some degree.
--
\It's not what you pay a man, but what he costs you that |
`\ counts. -- Will Rogers |
_o__) |
Ben Finney
--
http
Duncan Booth [EMAIL PROTECTED] wrote:
Ben Finney wrote:
What is the common idiom here? I can conceive of several possible
ways to get around it, all of which seem hackish to some degree.
I don't know if it is the common idiom, but I tend to write:
TESTDIR = os.path.dirname
']
acc.flush()
Flushing items: ['strawberry']
--
\ [W]e are still the first generation of users, and for all that |
`\ we may have invented the net, we still don't really get it. |
_o__) -- Douglas Adams |
Ben Finney
--
http
data needs to be tested.
How should this be resolved?
--
\ I never forget a face, but in your case I'll be glad to make |
`\ an exception. -- Groucho Marx |
_o__) |
Ben Finney
--
http
to meet them halfway by helping them help you.
--
\ I put instant coffee in a microwave oven and almost went back |
`\ in time. -- Steven Wright |
_o__) |
Ben Finney
--
http
Scott David Daniels [EMAIL PROTECTED] wrote:
Ben Finney wrote:
Summary: I'm looking for idioms in unit tests for factoring out
repetitive iteration over test data
How about something like:
class Test_Game(unittest.TestCase):
[...]
def runs(self, throws
the other day. They said my |
`\personality was weird. ... That's okay, I have four more. -- |
_o__)Bug-Eyed Earl, _Red Meat_ |
Ben Finney
--
http://mail.python.org/mailman/listinfo/python-list
Ben Finney [EMAIL PROTECTED] wrote:
Summary: I'm looking for idioms in unit tests for factoring out
repetitive iteration over test data.
Thanks to those who've offered suggestions, especially those who
suggested I look at generator functions. This leads to::
import unittest
import
|
`\ to. -- Elvis Aaron Presley (1935-1977) |
_o__) |
Ben Finney
--
http://mail.python.org/mailman/listinfo/python-list
make you believe absurdities can make you commit |
`\ atrocities. -- Voltaire |
_o__) |
Ben Finney
--
http://mail.python.org/mailman/listinfo/python-list
values from different enumerations should not
compare?
--
\ I was the kid next door's imaginary friend. -- Emo Philips |
`\ |
_o__) |
Ben Finney
--
http
) |
Ben Finney
--
http://mail.python.org/mailman/listinfo/python-list
. -- |
`\ Donald Robert Perry Marquis |
_o__) |
Ben Finney
--
http://mail.python.org/mailman/listinfo/python-list
Antoon Pardon [EMAIL PROTECTED] writes:
Ben Finney wrote:
The 'enum' package in Cheeseshop [defines enumerations as]
sequences (of unique arbitrary values), that can be iterated and
tested for membership.
Sure but we do have this:
from enum import Enum
day = Enum('mon', 'tue', 'wed', 'thu
. -- Groucho Marx |
_o__) |
Ben Finney http://www.benfinney.id.au/
--
http://mail.python.org/mailman/listinfo/python-list
|
`\ was glad to get rid of it. -- Groucho Marx |
_o__) |
Ben Finney
--
http://mail.python.org/mailman/listinfo/python-list
[EMAIL PROTECTED] writes:
Ben Finney wrote:
Is there some behaviour other than evaluate to False or raise an
exception, that could indicate not comparable?
Yes: return NotImplemented. Note that the == operator automagically
returns False in this case.
spam.__eq__(spam)
True
::
str(pizza_night)
'fri'
shirt_colour.index
2
--
\ It ain't so much the things we don't know that get us in |
`\ trouble. It's the things we know that ain't so. -- Artemus |
_o__) Ward (1834-67), U.S. journalist |
Ben Finney
--
http
--
\There was a point to this story, but it has temporarily |
`\ escaped the chronicler's mind. -- Douglas Adams |
_o__) |
Ben Finney http://www.benfinney.id.au/
--
http://mail.python.org/mailman/listinfo/python-list
things you learn from the internet |
`\ is that there is no 'them' out there. It's just an awful lot of |
_o__) 'us'. -- Douglas Adams |
Ben Finney
--
http://mail.python.org/mailman/listinfo/python-list
) |
Ben Finney
--
http://mail.python.org/mailman/listinfo/python-list
reply to the message
author.
--
\ What I resent is that the range of your vision should be the |
`\ limit of my action. -- Henry James |
_o__) |
Ben Finney
--
http://mail.python.org/mailman
. -- Mahatma Gandhi (when |
`\asked what he thought of Western civilization) |
_o__) |
Ben Finney
--
http://mail.python.org/mailman/listinfo/python-list
) |
Ben Finney
--
http://mail.python.org/mailman/listinfo/python-list
Peter Hansen [EMAIL PROTECTED] wrote:
Ben Finney wrote:
Roy Smith [EMAIL PROTECTED] wrote:
[current-directory module shadowing a system module]
All hail the coming of PEP 328:
URL:http://www.python.org/peps/pep-0328.html
Which, unless I misunderstand, would do nothing to change
Aahz [EMAIL PROTECTED] wrote:
Ben Finney [EMAIL PROTECTED] wrote:
So, under PEP 328 rules, the original poster's current-directory
module could only be imported (a) if the current directory was in
sys.path, or (b) if the code specified a relative import. The
accidental shadowing
the move. Day 2: Everybody |
_o__) talks to me like I'm an idiot.' -- Steven Wright |
Ben Finney http://www.benfinney.id.au/
--
http://mail.python.org/mailman/listinfo/python-list
U.S. 624 (1943) |
_o__) |
Ben Finney http://www.benfinney.id.au/
--
http://mail.python.org/mailman/listinfo/python-list
|
`\ |
_o__) |
Ben Finney http://www.benfinney.id.au/
--
http://mail.python.org/mailman/listinfo/python-list
advanced bug is indistinguishable from a |
`\ feature. -- Rich Kulawiec |
_o__) |
Ben Finney
--
http://mail.python.org/mailman/listinfo/python-list
read, so I got |
`\ flip-ups. -- Steven Wright |
_o__) |
Ben Finney
--
http://mail.python.org/mailman/listinfo/python-list
about cutting |
`\ them down? We might, if they screamed all the time, for no good |
_o__) reason. -- Jack Handey |
Ben Finney
--
http://mail.python.org/mailman/listinfo/python-list
)Hitch-Hiker's Guide To The Galaxy_, Douglas Adams |
Ben Finney http://www.benfinney.id.au/
--
http://mail.python.org/mailman/listinfo/python-list
:
URL:http://dsbl.org/programs
--
\ Buy not what you want, but what you need; what you do not need |
`\ is expensive at a penny. -- Cato, 234-149 BC, Relique |
_o__) |
Ben Finney http://www.benfinney.id.au
1 - 100 of 4158 matches
Mail list logo