one to it (adding, subtracting, etc), and the found status
is lost.
The other option is returning a (number, bool) tuple -- safer, yet more
boring... ;)
Thoughts?
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
Tim Chase wrote:
On 08/15/12 18:26, Ethan Furman wrote:
.index_search(
match,
start=None,
stop=None,
nearest=False,
partial=False )
The defaults are to search the entire index for exact matches and raise
NotFoundError if it can't find anything.
The questi
Steven D'Aprano wrote:
On Wed, 15 Aug 2012 16:26:09 -0700, Ethan Furman wrote:
Indexes have a new method (rebirth of an old one, really):
.index_search(
match,
start=None,
stop=None,
nearest=False,
partial=False )
[...]
Why "index_search" r
Ramchandra Apte wrote:
Are they the same object
Yes.
--
http://mail.python.org/mailman/listinfo/python-list
ror: cannot create 'NoneType' instances
Why is that?
An oversight, and until a few months ago nobody had complained loud
enough. ;)
Why doesn't it just return an existing instance of the type,
like bool, int, str and other built-in non-mutable types do?
In 3.3 it now does.
MRAB wrote:
On 16/08/2012 02:22, Ethan Furman wrote:
Steven D'Aprano wrote:
On Wed, 15 Aug 2012 16:26:09 -0700, Ethan Furman wrote:
Indexes have a new method (rebirth of an old one, really):
.index_search(
match,
start=None,
stop=None,
nearest=False,
pa
MRAB wrote:
On 16/08/2012 17:13, Ethan Furman wrote:
Currently there are:
.index(data) --> returns index of data in Index, or raises error
.query(string) --> brute force search, returns all matching records
.search(match) --> binary search through table, returns all
you feel irritated by it.
I would've complained too if I was going to post a reply to this thread.
Rest assured that in this (bottom-posting vs top-posting) Mark Lawrence
speaks for many of us.
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
Chris Angelico wrote:
PLEASE add attribution back in. It's not about he-said/she-said, it's
about honesty and clarity in reporting. It's far easier to understand
the conversation when we know who said each part [. . .]
+1
--
http://mail.python.org/mailman/listinfo/python-list
way
as signature lines when I hit Reply.
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
Tim Chase wrote:
On 08/31/12 09:15, Skip Montanaro wrote:
We just upgraded the Mailman installation on mail.python.org. Part of that
installation includes spam filtering on messages gated from Usenet to the python-
l...@python.org mailing list. This message is a quick test of that function.
comes "servico movil". Is there anything stock
that I've missed? I can do mystring.encode('us-ascii', 'replace')
but that doesn't keep as much information as I'd hope.
I haven't yet used it myself, but I've heard good things about
http://
*plonk*
--
http://mail.python.org/mailman/listinfo/python-list
Neil Hodgson wrote:
Ethan Furman:
*plonk*
I can't work out who you are plonking. While more than one of the
posters on this thread seem worthy of a good plonk, by not including
sufficient context, you've left me feeling puzzled. Is there a guideline
for this in basic
Greetings!
What is the consensus... okay, okay -- what are some wide ranging
opinions on technologies that I should know if my dream job is one that
consists mostly of Python, and might allow telecommuting?
(Please don't say Java, please don't say Java, please don't sa
Walter Hurry wrote:
On Sat, 22 Sep 2012 10:58:38 -0700, Emile van Sebille wrote:
On 9/21/2012 2:59 PM Ethan Furman said...
...if my dream job is one that consists mostly of Python, and might
allow telecommuting?
Hi Ethan,
I have an open position in my two man office I've tried to f
Mark Lawrence wrote:
On 24/09/2012 07:18, Georg Brandl wrote:
[snip impressive list of improvements]
Yes, but apart from all that, what have the python devs ever done for
us? Nothing :)
I'll take that kind of nothing any day of the week! ;)
~Ethan~
--
http://mail.python.org/ma
he dicts, which isn't even close to what
was requested. With your comment of "Might be better ones, though", I
actually thought that you were aware of this and were being
intentionally satirical.
Unlikely.
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
e a better way, but for now, enumerate works pretty
well.
ROFLOL!!
I look forward to the day when you look back on that statement and
think, "Wow, I've come a long way!"
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
lf-editing.
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
ese things, and instead blaming everyone else, is not
insignificant.
Being wrong is not fun, but learn from it instead of saying, "I'm not
wrong, you just don't understand!"
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
wxjmfa...@gmail.com wrote:
Py 3.3 succeeded to somehow kill unicode and it has
been transformed into an "American" product for
"American" users.
*plonk*
--
http://mail.python.org/mailman/listinfo/python-list
extremely useful contributor. I certainly prefer
him to Xah Lee, who's attempts at improving Python documentation were
beautifully torn to pieces here, IIRC by Ethan Furman, apologies to him
and the actual author if I'm incorrect.
I don't think it was me -- my troll tolerance is
Chris Angelico wrote:
On Wed, Sep 26, 2012 at 10:19 PM, wrote:
After all, if replacing a Nabla operator in a string take
10 times more times in Py33 than in Python32 [. . .]
But I'll give you the benefit
of the doubt; maybe your number is in binary.
+1 QOTW
--
http://mail.python.org/mailma
May I
ask why? Or have I missed something?
The second article didn't reference the first directly, but was aimed at
that general type of article. At any rate, Steven wrote as if it were a
direct response.
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
thinking step 1 is flat-out wrong and doesn't exist. Does anybody
know otherwise?
~Ethan~
[1]
http://stackoverflow.com/q/10536539/208880
[2]
http://www.cafepy.com/article/python_attributes_and_methods/ch01s05.html
--
http://mail.python.org/mailman/listinfo/python-list
Steven D'Aprano wrote:
On Fri, 05 Oct 2012 10:39:53 -0700, Ethan Furman wrote:
There is a StackOverflow question [1] that points to this on-line book
[2] which has a five-step sequence for looking up attributes:
> When retrieving an attribute from an object (print
> objectna
lable on PyPI, too.
[1] http://pypi.python.org/pypi/pysha3
[2] http://keccak.noekeon.org/
Nice! Thanks!
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
was bound to before, it no longer is, because now it is bound
to .
What you are trying to do is mutate C, not rebind it. As Dave
suggested, you can use slice notation ([:]) or some method of C (that
you create) to do so.
Basically i'm asking how to override, if i can,
lices just fine.
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
Steven D'Aprano wrote:
The list.index method tests for the item with equality. Since NANs are
mandated to compare unequal to anything, including themselves, index
cannot match them.
This is incorrect. .index() uses identity first, then equality, and
will match the same NaN in a list. The OP
ap, valveSet=signatures))
8<---
Don't forget to add error checking where appropriate.
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
;would you, could you', end='')
Spam.green()
It can be a pain if you change the class name, but it is certainly one way to
do it.
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
slice arguments, instead of
having to remember the offsets. record['full_name':'zip4'] returns a tuple (or a list, I don't
remember) of about 13 fields -- this is especially useful as that block of fields might not be in
the same place in each table.
~Ethan~
--
http:/
lices -- one example
has already been given in this thread.
Hmmm.
Now, I'm thinking -- The purpose of index(), specifically, is to notify
when something which is not an integer may be used as an index; You've
helpfully noted that index() also *converts* those objects into numb
Chris Angelico wrote:
On Fri, Nov 2, 2012 at 1:12 AM, Ethan Furman wrote:
In other words, the slice contains the strings, and my code calculates
the offsets -- Python doesn't do it for me.
That's correct, but you're still translating those strings into
numeric indices.
True
#x27;t tracked by gc; I'm not
seeing an issue with not fixing the bug.
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
After this post the only credibility you have left (with me, anyway) is that you seem to be willing
to learn. So learn the way Python works before you try to reimplement it.
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
are using numpy as it's common to use a list comprehension to
initialise a numpy array.
A more modest addition for the limited case described in this thread
could be to use exponentiation:
>>> [0] ** (2, 3)
[[0, 0, 0], [0, 0, 0]]
What would happen with
--> [{}] ** (2, 3)
o
Prasad, Ramit wrote:
Dennis Lee Bieber wrote:
Of course, if one has a language that, for some reason, evaluates
right-to-left (APL, anyone), then
x := x - x - x
becomes
x := x - 0
Is that not the same as x:=-x?
No, its the same as 'x = x'.
~Etha
wxjmfa...@gmail.com wrote:
Le mardi 13 novembre 2012 06:42:19 UTC+1, Steven D'Aprano a écrit :
On Tue, 13 Nov 2012 03:08:54 +, Mark Lawrence wrote:
* strings are now proper text strings (Unicode), not byte strings;
Let me laugh.
*plonk*
--
http://mail.python.org/mailman/listinfo/python-l
wargs[k] = v.replace('_', '')
return fn(*args)
and this line ^ becomes
return fn(*args, **kwargs)
return wrapper
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
bruceg113...@gmail.com wrote:
On Thursday, November 15, 2012 11:16:08 PM UTC-5, Ethan Furman wrote:
Emile van Sebille wrote:
Using a decorator works when named arguments are not used. When named
arguments are used, unexpected keyword error is reported. Is there a
simple fix?
Extend def
r use __iter__ and next to conform to the iterator
protocol, or you can define __getitem__.
If using __getitem__ it needs to work with integers from 0 to len(f)-1,
and raise IndexError for len(f), len(f+1), etc.
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
n
you just need one __iter__() method, which returns self.
The `next()` method is also needed, as `__iter__()` and `next()` are the two methods that make up
the iterator protocol (`__next__` in python 3k).
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
/want/ to use a while-else or for-else I
only want the true/false check /once/, at the beginning of the loop.
/Occasionally/ I'll actually have use for the search pattern, and then I
can use the while- or for-else construct, but that's pretty rare for me.
~Ethan~
--
http://mail.pyt
know if there is a cleaner solution, and I quite like yours.
Can you tell us, though, why you have to have y if x == y? Is there
some subtle difference between the two equal objects?
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
reference or will not work
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
()
IDLE is saying that my error is on line 4, at the second set of
quotation marks.
The code is for Python 2 -- are you using Python 3?
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
ner for its component pieces --
some are just more general than others.
Compare:
location = (13, 4, 9)# line, word, char
time = (10, 15, 41) # hour, minute, second
result = ('this', 'that', 'huh') # result a, result b, result c
with:
record1 =
nctions you are actually going to use. ;)
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
tion and assigning to locals() will not actually
change the functions variables.
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
Ethan Furman wrote:
Ian Kelly wrote:
I am not a dev, but I believe it works because assigning to locals()
and assigning via exec are not the same thing. The problem with
assigning to locals() is that you're fundamentally just setting a
value in a dictionary, and even though it happens
Ian Kelly wrote:
On Wed, Feb 1, 2012 at 3:24 PM, Ethan Furman wrote:
Definitely should rely on it, because in CPython 3 exec does not un-optimize
the function and assigning to locals() will not actually change the
functions variables.
Well, the former is not surprising, since exec was
Ian Kelly wrote:
On Wed, Feb 1, 2012 at 4:41 PM, Ethan Furman wrote:
I'm not sure what you mean by temporary:
--> def f(x, y):
... frob = None
... loc = locals()
... loc[x] = y
... print(loc)
... print(locals())
... print(loc)
... print(locals())
...
-
;frob', 'frob': None, 'loc': {...}}
Seems to be stuck that way.
Here is a better example I was thinking of:
--> def f(x, y):
... locals()[x] = y
... locals()['x'] = 17
... print(locals())
... print(x)
... print(y)
...
--> f('a', 42)
{'y': 42, 'x': 'a', 'a': 42}
a
42
So locals() was updated with 'a', but not with the assignment to 'x'.
And of course, if we tried to 'print(a)' we'd get a NameError.
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
Ethan Furman wrote:
Ethan Furman wrote:
Ian Kelly wrote:
I am not a dev, but I believe it works because assigning to locals()
and assigning via exec are not the same thing. The problem with
assigning to locals() is that you're fundamentally just setting a
value in a dictionary, and
print('inside b!')
a.function()
b.function()
print(vars())
The NameSpace objects do *not* get their own copy of globals(), but for
functions, etc., it should work fine. As a bonus the above code works
for both 2.x and 3.x.
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
)
It would have to be `a.x = ...` and `b.x = ...` with corresponding
`print(a.x)` and `print(b.x)`.
Hrm -- and functions/classes/etc would have to refer to each other that
way as well inside the namespace... not sure I'm in love with that...
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
Ethan Furman wrote:
Hrm -- and functions/classes/etc would have to refer to each other that
way as well inside the namespace... not sure I'm in love with that...
Not sure I hate it, either. ;)
Slightly more sophisticated code:
class NameSpace(object):
def __init__
sad commentary on those
who don't ascribe to a religion, as it would appear that they care less
for their society.
2) altruism: unselfish regard for or devotion to the welfare of
others... no mention of religion of any kind, or Jesus in particular.
Altruistic-yet-paradoxically-religio
(although you can create temporary
memory indices)
- auto incrementing fields
Latest version can be found on PyPI at http://pypi.python.org/pypi/dbf.
Comments, bug reports, etc, appreciated!
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
to give people second
chances (and apparently third and fourth and fifth chances). Methinks
it's time for Monsieur Johnson to go back in the killfile.
Luckily for me there are enough folks that still reply to the trolls in
my killfile that I can see if it's time to take them off or not.
e list. There are lots of friendly folks here who will try
to help.
Unfortunately there are also a couple well-known trolls, one of whom is
Rick Johnson (aka Ranting Rick). Please do not take his posts as
representative of the community.
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
nd, if you need it, x) before hand.
Actually,
i = -1
or his reporting will be wrong.
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
erested readers.
I'm a casual interested reader and I have no idea what your post is
trying to say.
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
OKB (not okblacke) wrote:
Anyway, testing this just reinforced my distaste for circular
imports. Just trying to think about how it ought to work with a
importing c but then c and d importing each other makes my brain hurt.
Refactoring the files so that common code is in a separate librar
xplanation.
This should help you understand why you get errors
doing simple things like x/y*y doesn't quite get you back to x.
I already understood that. I just didn't understand what point he was
trying to make since he gave no explanation.
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
ith reload() is probably not going
to happen.
What you should be doing is:
import decimal
from decimal import Decimal
reload(decimal)
Decimal = decimal.Decimal # (rebind 'Decimal' to the reloaded code)
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
A. Lloyd Flanagan wrote:
On Friday, March 2, 2012 6:49:39 PM UTC-5, Ethan Furman wrote:
Jeff Beardsley wrote:
HISTORY:
...
What you should be doing is:
import decimal
from decimal import Decimal
reload(decimal)
Decimal = decimal.Decimal # (rebind 'Decimal' to th
maybe.
Appropriate -- no.
It is unfortunate that those frameworks have that bug, but it is not up
to Decimal to fix it for them.
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
ty:
def __init__(self):
A.__init__(self)
or
def __init__(self):
super(B, self).__init__()
or with Python 3
def __init__(self):
super().__init__()
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
it is:
Mouse
-
Right-click on title bar
Left-click on Edit
Left-click on Mark
Right-click and drag to select desired text
to copy text to clipboard
Keyboard
-
e
k or
arrows to move cursor, to select text
to copy text to clipboard
~Ethan~
--
http://mail.python.org/mailman/listinfo/p
time that attribute is accessed *on that instance*
it will be in the instance dictionary, and that is what will be used.
---
Thanks,
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
Terry Reedy wrote:
Thanks for the review, Terry!
On 3/9/2012 5:10 PM, Ethan Furman wrote:
http://stackoverflow.com/q/9638921/208880
If anyone here is willing to take a look at it and let me know if I did
not write it well, I would appreciate the feedback
Here's the question
Owen Jacobson wrote:
On 2012-03-09 22:10:18 +, Ethan Furman said:
Hey all!
I posted a question/answer on SO earlier, but there seems to be some
confusion around either the question or the answer (judging from the
comments).
http://stackoverflow.com/q/9638921/208880
If anyone here is
hat should not be too
hard..
I believe sys.modules is a dictionary; you might try replacing it with
your own custom dictionary that does whatever when the keys are accessed.
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
h
Steven.
Of course, it doesn't hurt that everything he has said matches with my
experience on the topic.
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
Nathan Rice wrote:
Logo. It's turtles all the way down.
+1 QOTW
--
http://mail.python.org/mailman/listinfo/python-list
d, I completely overlooked that part of the post in my
earnestness to answer…
Completely understandable -- after all, who would not be earnest (and
quick!) when replying to your surrogate god?
;)
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
like "stream
programming", for example. ;)
After the discussion I've seen so far, I still have no idea how I would
use your code or what it's good for.
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
ut I actually also don't need to know - for my purposes, it would be
perfectly good enough to deal with the ascii portions and keep anything
else unchanged.
Where is the data coming from? Files? In that case, it sounds like you
will want to decode/encode using 'latin-1', as th
characters, not sure if that is because the source
has none or something else.
The 'ignore' argument to .decode() caused all non-ascii characters to be
removed.
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
sting
two distinct things, so you should write it as two separate tests:
I have to disagree -- I do not see the advantage of writing a second
test that *will* fail if the first test fails as opposed to bundling
both tests together, and having one failure.
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
ecause they are redundant. Only remove them
when they are obsolete due to changes in the code being tested.
Very persuasive argument -- I now find myself disposed to writing two
tests (not three, nor five ;).
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
the best people I've ever known have had experience
with quite a lot of languages.
I know 10 languages. But I'm not telling you what base that number is :)
There are 10 types of people in the world: those who know binary and
those who don't.
;)
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
definition answer as to why this should not
be so?
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
Ethan Furman wrote:
Okay, so I haven't asked a stupid question in a long time and I'm
suffering withdrawal symptoms... ;)
5 % 0 = ?
Thanks for your replies, much appreciated.
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
s and generator functions under the hood, so in principle
there is nothing preventing with blocks from being injected into their
byte code.
Which would still not be at the module level.
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
_func)
Suggestions?
I don't find either the current syntax nor the new syntax pythonic.
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
ode
you want people to critique, or posted a link to that code.
He did post a link to a blog post describing his module and also a link
to the actual code, on bitbucket IIRC.
Actually, it was Ian Kelly that posted the blog reference.
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
the disk portion had changed, thus clobbering
new data with old.
Yeah, I know, that's not really any better.
*sigh*
Okay, no more __del__ for me!
~Ethan~
Knowledge is knowing that tomatoes are a fruit.
Wisdom is not putting them in a fruit salad.
--
http://mail.python.org/mailman/listinfo/python-list
Available at http://pypi.python.org/pypi/dbf
Fixed issue with Memo fields not returning correct unicode data.
Updated many docstrings.
Nulls now fully supported.
Getting closer to a 1.0 (non-beta!) release; working on PEP 8
compliance, index files, and actual documentation.
Biggest change
=
with Dr Sultan Spells of various natures.
Can anybody put a stop to that?
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
Style question:
Since __all__ (if defined) is the public API, if I am using that should
I also still use a leading underscore on my private data/functions/etc?
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
Emile van Sebille wrote:
On 5/11/2012 9:41 AM Ethan Furman said...
Style question:
Since __all__ (if defined) is the public API, if I am using that should
I also still use a leading underscore on my private data/functions/etc?
I would, even if only to alert any future maintainer of the
or `map`
in the list documentation. Kinda hard to get there without already
knowing the answer.
Unit tests. :)
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
t set
Traceback (most recent call last):
File "", line 1, in
AttributeError: item
>>> class Test2(Test1):
... def __init__(self, price):
... self.price = price
...
>>> t2 = Test2(7.99) # __slots__ not defined in
# subclas
zation;
does anyone know what strings to look for for the other implementations?
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
Ian Kelly wrote:
On Wed, May 16, 2012 at 3:33 PM, Ethan Furman wrote:
Just hit a snag:
In cPython the deterministic garbage collection allows me a particular
optimization when retrieving records from a dbf file -- namely, by using
weakrefs I can tell if the record is still in memory and
101 - 200 of 1941 matches
Mail list logo