t
containers, and thinking of them that way will frequently lead you to
the wrong conclusion.
https://nedbatchelder.com/text/names1.html>
--
\ “Theology is the effort to explain the unknowable in terms of |
`\ the not worth knowing.” —Henry L. Mencken |
_o__)
e you tried using that library and timing the result?
--
\ “You don't need a book of any description to help you have some |
`\kind of moral awareness.” —Dr. Francesca Stavrakoloulou, bible |
_o__) scholar, 2011-05-08 |
Ben Finney
--
http
purpose::
with foo.open() as logfile:
frobnicate_the_whelk(logfile=logfile)
--
\ “I don't want to live peacefully with difficult realities, and |
`\ I see no virtue in savoring excuses for avoiding a search for |
_o__) real answers.” —Pau
is to the |
_o__) culinary arts.” —Michael Bacarella |
Ben Finney
--
https://mail.python.org/mailman/listinfo/python-list
ovenance of the key that made the signature.
--
\“Human reason is snatching everything to itself, leaving |
`\ nothing for faith.” —Bernard of Clairvaux, 1090–1153 CE |
_o__) |
Ben Finney
--
https://mail.python.org/mailman/listinfo/python-list
ne by children. |
`\ They had all the paintings up on refrigerators.” —Steven Wright |
_o__) |
Ben Finney
--
https://mail.python.org/mailman/listinfo/python-list
sier when the RefrigeratedShippingContainer encapsulates
the conversions of temperature units.
--
\ “When we pray to God we must be seeking nothing — nothing.” |
`\—Francis of Assisi |
_o__)
Arup Rakshit writes:
Michael Torrie writes:
> On 03/18/2019 05:55 PM, Ben Finney wrote:
> >> If I call `_c_to_f`, `_f_to_c` methods on `self` instead of
> >> `RefrigeratedShippingContainer` class object, still it works.
> >
> > That's right, and is inde
ex tasks we expect of a programmer's editor like
Vim or GNU Emacs.
--
\“The reason we come up with new versions is not to fix bugs. |
`\ It's absolutely not.” —Bill Gates, 1995-10-23 |
_o__)
is not ignorance but the illusion of |
_o__)knowledge.” —Daniel J. Boorstin, historian, 1914–2004 |
Ben Finney
--
https://mail.python.org/mailman/listinfo/python-list
`\ approaches zero. All non-Free software is a dead end.” —Mark |
_o__) Pilgrim, 2006 |
Ben Finney
--
https://mail.python.org/mailman/listinfo/python-list
ssed before?
Too many times to count :-)
--
\ “Theology is the effort to explain the unknowable in terms of |
`\ the not worth knowing.” —Henry L. Mencken |
_o__) |
Ben Finney
--
https://mail.p
x27;s going to change depending on
the environment).
--
\ “Courage is not the absence of fear, but the decision that |
`\ something else is more important than fear.” —Ambrose Redmoon |
_o__) |
Ben Finney
--
https://mail.python.org/mailman/listinfo/python-list
imity |
`\of the graveyard.” —Justice Roberts in 319 U.S. 624 (1943) |
_o__) |
Ben Finney
--
https://mail.python.org/mailman/listinfo/python-list
;s no music, no |
`\ choreography, and the dancers hit each other.” —Jack Handey |
_o__) |
Ben Finney
--
https://mail.python.org/mailman/listinfo/python-list
do you need to also have them bound to separate names; what problem
are you trying to solve that you think this will help?
--
\ “If [a technology company] has confidence in their future |
`\ ability to innovate, the importance they place on protecting |
_o__) their pas
'Banana Split']
The above code produces this output, without any need for binding new
names. So what is it you are actually trying to achieve, and why do you
think the new bindings are necessary?
--
\“The number of UNIX installations has grown to 10, with more |
`\ expected.” —Unix Programmer's Manual, 2nd Ed., 1972-06-12 |
_o__) |
Ben Finney
--
https://mail.python.org/mailman/listinfo/python-list
se:
to give the return address for an individual 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__)
t would be a good idea." -- Mahatma Gandhi (when |
`\asked what he thought of Western civilization) |
_o__) |
Ben Finney
--
http://mail.python.org/mailman/listinfo/python-list
x." -- Gore Vidal |
_o__) |
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:
Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote:
> In <[EMAIL PROTECTED]>, Ben Finney wrote:
>
> > class Human_Sex(str):
> > def __repr__(self):
> > repr_str = "%s(name=%s)" % (
> >
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:
>
>
ing in life is so exhilarating as to be shot at without |
`\result." -- Winston Churchill |
_o__) |
Ben Finney
--
http://mail.python.org/mailman/listinfo/python-list
e way to do what I'm describing? Am I missing a
common programming pattern?
--
\ "I bought a self learning 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
se who dare not, are slaves." -- "Lord" George |
_o__) Gordon Noel Byron |
Ben Finney
--
http://mail.python.org/mailman/listinfo/python-list
gs/viewpost.jsp?thread=92662>
--
\ "The shortest distance between two points is under |
`\ construction." -- Noelie Alito |
_o__) |
Ben Finney
--
http://mail.python.org/mailman/listinfo/python-list
value of nothing." -- Oscar Wilde |
_o__) |
Ben Finney
--
http://mail.python.org/mailman/listinfo/python-list
t;I know the guy who writes all those bumper stickers. He hates |
`\ New York." -- Steven Wright |
_o__) |
Ben Finney
--
http://mail.python.org/mailman/listinfo/python-list
other enemas..." -- Emo 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 metho
|
_o__) |
Ben Finney
--
http://mail.python.org/mailman/listinfo/python-list
states could be represented
in the enumeration, and individual states compared to see if they are
"later" that each other. If sequence was not considered important, of
course, this feature would not get in the way.
--
\ "I put instant coffee in a microwave oven and almost went
Steven Wright |
`\ |
_o__) |
Ben Finney
--
http://mail.python.org/mailman/listinfo/python-list
e yet to see a convincing argument against simply assigning values
to names, then using those names.
--
\ "Yesterday I parked my car in a tow-away zone. When I came back |
`\ the entire area was missing." -- Steven Wright |
_o__)
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 th
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 mu
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 FooEx
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
ctually useful to some
amount of users for solving actual problems, that's the time to talk
about promoting it.
--
\ "I went to the cinema, it said 'Adults: $5.00, Children $2.50'. |
`\ So I said 'Give me two boys and a girl.'" -- Steven Wright |
_o__) |
Ben Finney
--
http://mail.python.org/mailman/listinfo/python-list
onceive that anybody will require multiplications 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
Homer, _The Simpsons_ |
_o__) |
Ben Finney
--
http://mail.python.org/mailman/listinfo/python-list
er-created iterable types that don't inherit from any of the
built-in iterable types?
--
\ "A good politician is quite as unthinkable as an honest |
`\burglar." -- Henry L. Mencken |
_o__)
t;
In this case, 'import sys; help(sys.exit)' will be of assistance.
--
\"I always had a repulsive need to be something more than |
`\ human." -- David Bowie |
_o__)
ough." -- Bug-Eyed Earl, _Red Meat_ |
Ben Finney
--
http://mail.python.org/mailman/listinfo/python-list
oblems in
future?
[0] http://dirtsimple.org/2005/07/reinvent-no-more-forever.html>
[1] Of course, someone already has. I prefer mine to theirs, hence the
question.
--
\ "I planted some bird seed. A bird came up. Now I don't know |
`\
tigation takes the place 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
-- Steven Wright |
_o__) |
Ben Finney
--
http://mail.python.org/mailman/listinfo/python-list
next twelve years |
_o__) telling them to sit down and shut up." -- Phyllis Diller |
Ben Finney
--
http://mail.python.org/mailman/listinfo/python-list
roblem, however complicated, which, |
`\ when 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
evil" away from
children.
--
\ "Those are my principles. If you don't like them I have |
`\ others." -- Groucho Marx |
_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
> infri
es longer." -- Steven Wright |
_o__) |
Ben Finney
--
http://mail.python.org/mailman/listinfo/python-list
Phillip J. Eby <[EMAIL PROTECTED]> wrote:
> Ben Finney wrote:
> > - It's just a pretty simple type, with unit tests. Does this
> > really justify a PyPI package?
>
> Yes.
Thanks for the brief, but supportive discussion from everyone. I've
now packag
|
_o__) |
Ben Finney
--
http://mail.python.org/mailman/listinfo/python-list
multiply to
create much longer strings.
--
\ "Everything is futile." -- Marvin of Borg |
`\ |
_o__) |
Ben Finney
--
http://mail.python.org/mailman/listinfo/python-list
a filthy lie. Besides, it was only in rats and has not been |
_o__) reproduced in humans." -- Linus Torvalds |
Ben Finney
--
http://mail.python.org/mailman/listinfo/python-list
Bengt Richter <[EMAIL PROTECTED]> wrote:
> Ben Finney <[EMAIL PROTECTED]> wrote:
> >I've recently packaged 'enum' in PyPI.
> [...]
> My notion of enum comes from (what I remember of) Pascal
You might want to investigate the 'enum' package for
they show whatever
information you think 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 Hand
comes much easier to read.
--
\"If you go 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 an
[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 reinventio
#l2h-244>
--
\ "If you're not part of the solution, you're part 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 u
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
>>> print today.index
2
>>> print today.key
tue
--
\ "I spilled spot remover on my dog. Now he's gone." -- Steven |
`\Wright |
_o__) |
Ben Finney
--
http://mail.python.org/mailman/listinfo/python-list
f in the |
`\ occurrence of the improbable." -- Henry L. Mencken |
_o__) |
Ben Finney
--
http://mail.python.org/mailman/listinfo/python-list
quot;One of the most important 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
[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
eory that some other fellow has just as little |
`\ taste." -- Henry L. Mencken |
_o__) |
Ben Finney
--
http://mail.python.org/mailman/listinfo/python-list
quot;Experience is that marvelous thing that enables you to |
`\ recognize a mistake when you make it again." -- Franklin P. |
_o__) Jones |
Ben Finney
--
http://mail.python.org/mailman/listinfo/python-list
gence." -- |
`\ Henry L. Mencken |
_o__) |
Ben Finney
--
http://mail.python.org/mailman/listinfo/python-list
:
File "", line 1, in ?
AttributeError: 'int' object has no attribute 'base'
Is this a wart? Why?
If it's not a wart, why would it be a wart for user-defined types to
have the same behaviour?
--
\ "I spilled spot remover 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
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, thes
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? I
t can be compared only with other values
from the same enumeration, but can be coerced to simple strings
matching the original arguments to Enum().
The design is based in part on Zoran Isailovski's recipe, "First
Class Enums in Python" in the ASPN Python Cookbook
http://aspn.activestate.co
achines to become
hackers of those machines; they still all get the benefit 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." -- S
r |
`\will lose both, and deserve neither." -- Thomas Jefferson, in |
_o__) a letter to Madison |
Ben Finney
--
http://mail.python.org/mailman/listinfo/python-list
gument when
called as a method.
To do this on an already-defined function, use new.instancemethod.
>>> import new
>>> help(new.instancemethod)
--
\ "One time a cop pulled me over for running a stop sign. He |
`\said, 'Didn't 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
Maurits Cornelis Escher |
_o__) |
Ben Finney
--
http://mail.python.org/mailman/listinfo/python-list
rutiny, 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 Finney
--
http://mail.python.org/mailman/listinfo/python-list
er. You've probably stopped me from
writing a bunch of misguided code and realising 5 years too late :-)
--
\ "Timid men prefer the calm of despotism to the boisterous sea |
`\ of liberty." -- Thomas Jefferson |
_o__)
and that is enough for meu. The above should be considered as
> an explanation of how understood, not as a correction of how yuo
> should have wrote it.
An object lesson in taking programmers at their word :-)
--
\ "I went to San Francisco. I found someone's heart." --
g one scoundrel, it appears, does 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 m
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"
ve of several possible ways
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__)
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
>> 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://mail.python.org/mailman/listinfo/python-list
sEqual(score, instance.get_score())
self.iterate_test(test_func)
That's somewhat clearer; the test function actually focuses on what
it's testing. Those layers of indirection are annoying, but they allow
the data sets to grow without writing more code to handle them.
Testing a rules-based system involves lots of data sets, and each data
set represents a separate test case; but the code for each of those
test cases is mindlessly repetitive. Factoring them out seems like it
needs a lot of indirection, and seems to make each test harder to
read. Different *types* of tests would need multiple iterators, more
complex test parameter dicts, or some more indirection. Those all
sound ugly, but so does repetitively coding every test function
whenever some new 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://mail.python.org/mailman/listinfo/python-list
"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
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):
my job 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::
impor
tters.
--
\ "I don't know anything about music. In my line you don't have |
`\ to." -- Elvis Aaron Presley (1935-1977) |
_o__) |
Ben Finney
--
http://mail.python.org/mailman/listinfo/python-list
, just deliver the message.
--
\ "Those who can make you believe absurdities can make you commit |
`\ atrocities." -- Voltaire |
_o__) |
Ben Finney
--
http://mail.python.org/mailman/listinfo/python-list
|
_o__) |
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:
> > http://www.python.org/peps/pep-0328.ht
801 - 900 of 4138 matches
Mail list logo