s you have a very specialized purpose, it would be more educational
about Python programming.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
int too large to convert to float
I think the multiplication should have the same behavior than the
division:
* `inf` or `-inf` when the operands are inside the limits,
but the result is not
* `OverflowError` when the result, and at least one operand,
are out of range.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
ion cannot associate additional data with a string
to make processing of the string easier.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
ple is creating a list of a million tuples, which otherwise triggers
a lot of useless background bookkeeping. The cyclic gc is tuned for
'normal' use patterns.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
whatever = type("WhatEver", (obj,), {"method1": super(WhatEver,
self).request("method1")})
'method1' has to be mapped to a function object.
but when i try this I get 'NameError: name 'self' is not defined'
defining these c
e: text/plain
Content-Length: 59
You should have made subject line something like
"Webapp2: AssertionError"
as only someone familiar with webapp2 could give you any help.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
(6004799503160661, 18014398509481984)
> So from that standpoint it makes sense to me to cast to
> Fraction when comparing.
Otherwise, == becomes non-transitive
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
te it yourself, ask someone else to update it, or use something else.
Or regress to an older Python that it will work with.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
On 7/29/2013 1:29 PM, Steven D'Aprano wrote:
On Mon, 29 Jul 2013 13:08:20 -0400, Terry Reedy wrote:
In other words, there can be multiple unequal Franctions that have the
same float value: for instance, Fraction(1,3) and
Fraction(6004799503160661, 18014398509481984)
> So f
ve, the
recommended limit will be raised to 100, or at least say that some are
using that as the guideline. 200 char lines are harder to read.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
On 7/29/2013 5:01 PM, Terry Reedy wrote:
On 7/29/2013 3:43 PM, Devyn Collier Johnson wrote:
In Python programming, the PEP8 recommends limiting lines to a maximum
of 79 characters because "There are still many devices around that are
limited to 80 character lines"
"plus, limi
you are set to go. Have fun.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
On 7/30/2013 1:40 PM, Joshua Landau wrote:
Additionally, who says a language couldn't use, say, B-Trees for all of
its list-like types, including strings?
Tk apparently uses a B-tree in its text widget.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
nit__(self, two=None):
self.two = Value(two if two is not None else C.two)
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
to be a standalone objects when there is an
obvious alternative (in this case, bytes).
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
make them compatible with 3.0 and 3.1 if they aren't
already.
Forget about 3.0. Really. As for 3.1 versus 3.2, there were no core
syntax changes in 3.2. There were a few, but only a few, enhancements in
builtin classes. If you have a decent test suite, just run it under 3.1.
--
Terry Jan
something
that will help you.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
uch a function. If not, someone on the
pygame list must know how. (I am assuming that sdl library and hence
pygame use directx.)
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
, 'minus'))
print "%r" % (get_numbers(1+3, 2+9, 'add'))
print "%r" % (get_numbers(10, 2, 'divide'))
Output:
C:\code\python>ex19.py
-1
None
15
None
5
None
7.5
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
ony in
what he intended to be a refutation of Wolfgang Keller's comment ;-).
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
ll is moved and has a different context.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
On 6/25/2012 8:34 AM, Michael Gundlach wrote:
Hello again Terry (and mailing list),
On Sun, Jun 24, 2012 at 9:34 AM, Michael Gundlach mailto:gundl...@gmail.com>> wrote:
I've now changed to 2.7.3, and if I don't write back in the next few
days, it means that that f
x27;s no call for such
vitriol. Please keep it off this forum.
From http://www.thefreedictionary.com/vitriol - "Bitterly abusive
feeling or expression." I do not believe that my comment above deserves
the term vitriol.
I saw it more as sarcasm and an expression of frustration.
was relaxed.
Complete agreed. I have used all of sep=, end=, and file= at various times.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
he raising code knows and that is hard to get otherwise.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
, or how feasible that would be.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
1. They will confuse themselves by thinking that 'u' actually means
somethings. They may then confuse others by writing about its supposed
meaning. This might get amusing.
2. They will use 'u' in Python 3 only code, thereby making it
incompatible with 3.2-, even if it
that you could resize
the main window after inserting tab widgets but before displaying. If
not, you should be to create the widgets first, find the largest height
and width, create the master, and then put the widgets into the master,
changing their 'master' attribute.
--
Terry
B()
b.do()
# print (with print adjusted for PY3)
A.do: self.name = b
If you want a B instance to act like an A instance, you can change its
class (subject to some limitations). The following works.
b = B()
b.__class__ = A
b.do()
If make the change temporary and the reversion automatic, writ
may
really not know what came from where
from x import y,x # fine, common, used in stdlib
import x as y # ditto
from x import y as z # ditto
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
the name-space ref does make it easy
to identify the origins of a function (at the expense of more typing)
import tkinter as tk
for example, to minimize extra typing while identifying source.
___
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
x27;t be necessary), or
make an educated guess, which would almost certainly be correct, but
we're supposed to refuse the temptation to guess, right?
Python pretty consistently evaluates expressions and equal precedence
operators left to right. One really should learn that. No
'implement
thon3
Python 3.1.3 (r313:86834, Nov 28 2010, 11:28:10)
[GCC 4.4.5] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import tkinter
and who compiled that (correctly)?
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
erators as comparison operators, and gives them behaviour
appropriate to comparisons.
I considered this a great feature of Python when I first learned it.
Reading about how rare it is among programming languages to treat
comparisons in the standard way in mathematics reinforces that.
--
Terry
main points of the language take
just a few hours to review.
Perhaps my advantage learning Python was that I had written code in over
10 other languages and dialects and so had few expectations and made few
assumptions.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
On 7/2/2012 10:14 AM, contro opinion wrote:
i solve it myself
1.download tile-0.8.4.0.tar.gz
Or install the latest tcl/tk 8.5(.11), which includes tile/tkk and bug
fixes, instead of the rather old 8.4.?.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
On 7/2/2012 11:02 AM, Thomas Heller wrote:
Am 27.06.2012 20:06, schrieb Terry Reedy:
On 6/27/2012 10:36 AM, Thomas Heller wrote:
Is there a tool, similar to 2to3, which converts python2 code
to code using six.py, so that it runs unchanged with python2
*and* python 3?
Others have expressed a
').encode('utf-8') == x
but on cmd, it print broken characters
Printing utf-8 encoded bytes as if cp949 encoded bytes is pretty hilariour
the question may look silly:(
but I want to know what is the problem
or how to print the not broken strings.
thanks for reading.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
').encode('utf-8') == x
but on cmd, it print broken characters
Printing utf-8 encoded bytes as if cp949 encoded bytes is pretty hilariour
the question may look silly:(
but I want to know what is the problem
or how to print the not broken strings.
thanks for reading.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
.M object at 0x0220A1C0> None False
Is C a dictless class? Your choice ;-).
Actually, Python thinks not. If we add
class Mclassob(object): pass
and have __call__ return an instance thereof and try
c.__class__ = C
we get
TypeError: __class__ must be set to a class, not &
tively, I still get 3. Maybe the constant folder
is always on now.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
he
non-existent com.sun.star.ui module. Still, a lot more is needed to
understand even the example.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
. Writing non-api code is relatively easy; accessing the
OO/LO api is harder. I made a start. When I get further, I will look at
the examples that are close to some things I want to do. I will also
study your Python examples. Thanks for the help.
Terry
--
http://mail.python.org/mailman/listinfo
gs are on the Labels, not a
containing Frame.
# Dell E6500, Ubuntu 10.04, Python 2.6
You might try a current Python release, and the latest tcl/tk 8.5.11
released last March (comes with 3.3.0 Windows release, don't know how on
Ubuntu). There might be (have been?) a bug with events on Frames, or on
Frames within Frames treated as widgets.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
On 7/8/2012 10:02 PM, self.python wrote:
it's a finder using threading to accelerate
Threading with Python does not accelerate unless all but one of the
treads are i/o bound. You need multiple processes to use multiple cores
in parallel.
--
Terry Jan Reedy
--
http://mail.pytho
On 7/9/2012 1:49 PM, Rick Johnson wrote:
On Jul 9, 12:58 am, Terry Reedy wrote:
When posting problem code, you should post a minimal, self-contained
example that people can try on other systems and versions. Can you
create the problem with one record, which you could give, and one
binding? Do
ogling gives me no clue.
4th hit: Arithmetic Logic Unit (hardware) -- Wikipedia
ALU class -- software version or simulation thereof.
The hardware version of Dennis's distributed design would be
interesting. Spreadsheets are based in part on the same idea of
distributed logic and arithm
rators in the usual sense
because of short-circuiting.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
prerequisites for other modules).
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
On 7/14/2012 5:26 AM, Ian Kelly wrote:
On Fri, Jul 13, 2012 at 5:09 PM, Terry Reedy wrote:
I believe the following rule is true: if a op b is True or False raises,
Sorry, left out 'or' in 'or raises'
I don't follow. Raises what?
an Exception.
then op
expressions are resolved at call time.
and
d) people more often forget c) when thinking about lambda expressions
that for def statements.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
her to change the current behavior was discussed on python-ideas a
couple of months ago. I believe inertia and back-compatibity and the
rare use case won.
> reinforces the point that if you only want to test whether you have
> None, you should use "is not None" rather than relying
ense, but any other value would not). Should I?
If you only want to execute the if branch when x is literally the bool
object True and x could be some other non-bool true value such as 1 or
'a' or [1], etc, then you should.
If x is guaranteed to be True or False, which is the case you
def __new__(meta, *args): ...
def method(cls, *args): ...
class Example(metaclass=ExampleMeta):
def another_method(self): ...
What do others do?
Not too many people write real metaclasses. Python lets you chose. Have
you looked at the C code of type? (Not that you are bound by it.)
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
n runtime errors however they occur and if I can
leave it to the compiler to check as much as possible then I'll take that.
import ast
a = ast.literal_eval(input('enter a value: '))
b = ast.literal_eval(input('enter a comparable value: ')
try:
print('th
With some inefficient redundancy, I believe it could be done in one
line in Python. Better code would take a few more.
In bash this is laughably trivial
sort -nr $1 | head -${2:-10}
Won't sort work alphabetically and leave the following as is?
1\talpha
11\tbeta
2\tgamma
--
Terry Jan R
o any of them have a premade 3.3.0b0
available? (In some ways, it is already better than 3.2.3.)
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
of undefined_names
other that assignments do. The actually execution order is expression
first, then if. You can explicitly test "'some_name' in namespace" or
"hasattr(obj, 'somename') by turning the possibly undefined name into a
string object.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
dependent unless you take steps to make them
independent by not having them raise exceptions or by catching exception
as you go until you are done. If you make a error_list of problems as
you go, you could end the method with assertFalse(error_list).
--
Terry Jan Reedy
--
http://mail.python.
an __index__ method, so that it can be used as a sequence index) and
that its value is >= 0.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
On 7/20/2012 11:52 PM, Alec Taylor wrote:
ask on PyPy's list
But yes, it is designed as a 1:1 replacement of CPython
It is a replacement for some late 2.x versions but not, at present, for
Python 3.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
raw (string literal) and NOT as (raw string) literal. I know that the
docs sometimes leave off 'literal', but that sometimes confuses people
that there is such a thing as a raw string instance.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
reely donated time.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
he side where I missed it.
http://www.win.tue.nl/~aserebre/MSR2012.pdf
for anyone interested. So I withdraw the corresponding parts of my
comment. Of course, A.S. could have just posted it instead of or in
addition to the indirect link. Now that I look at it, I agree with the
intent.
--
=[1,2,3,5,4,4,1,3,2,1,3,4]
no_data_a=1
no_data_b=2
a_clean=(4,4,5,4,4,2,4)
b_clean=(3,5,4,4,3,3,4)
cleaned = list(zip(*(pair for pair in zip(a,b)
if pair[0] != no_data_a and pair[1] != no_data_b)))
print(cleaned, cleaned == [a_clean, b_clean])
#
[(4, 4, 5, 4, 4, 2, 4), (3, 5, 4, 4, 3, 3, 4)] True
--
Terry Jan
can only use code that works with x.y ;=). However, any Python
process can use any other program via the subprocess module. You just
have to work out the data transfer.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
LAY=1: 0.0027711391449 seconds
This is a huge difference. Setting TCP_NODELAY=1 will bring the runtime
from 3:30 minutes down to 14 seconds! Not Perl speed, but close.
Do you think this warrants a change in our docs, if not the code?
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
proceedures, and that is not going to change, especially for a null
proceedure.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
. It would
increase SQL parsing time and don't look good. Let's just say that the
limit should be 32 characters.
If I controlled all the component names, I would try to limit their
lengths so that the sum of lengths was limited to the limit.
--
Terry Jan Reedy
--
http://mail.
me as return None in this context
A function needs a lot more meat than that to be added as a builtin.
---
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
processor. Such things
often make changes of various sorts.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
es coded in C.
The first 'killer app' for Python, in the 1990s, was its use as a glue
language for interactive and batch scientific/numerical computation
mostly done in compiled Fortran.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
g.
2) If the platform byte-order is reversed, do I need to take any special
action? I don't think I do, because even though the float is reversed, so
will be the bit mask. Is this correct?
The math modules functions to disassemble floats will not care.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
but not possibly both. In the rare cases when one wants to
catch both errors, one can easily enough. To continue the example above,
popping an empty list and empty set produce IndexError and KeyError
respectively:
try:
while True:
process(pop())
except (KeyError, IndexError)
as
(about) 2*N - log2(N) parent child relationships. In other words, nearly
quadruple the number of entities to learn, discuss, and remember. Well,
there had better be a good necessity to do so ;-).
And, of course, once new entities *are* conjured up, it is hard to get
rid of them.
--
Terr
node
could have an indefinite number of ancestors.
from https://en.wikipedia.org/wiki/Binary_tree
"A full binary tree (sometimes proper binary tree or 2-tree or strictly
binary tree) is a tree in which every node other than the leaves has two
children."
--
Terry Jan R
On 7/31/2012 4:49 PM, Chris Kaynor wrote:
On Tue, Jul 31, 2012 at 1:21 PM, Terry Reedy mailto:tjre...@udel.edu>> wrote:
Another example: KeyError and IndexError are both subscript errors,
but there is no SubscriptError superclass, even though both work
thru the same mec
t line. It is not
relevant to your question.
dict.fromkeys(['China','America'])
output:{'America': None, 'China': None}
The interactive interpreter echoes the result of evaluating expressions.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
On 8/1/2012 11:53 AM, Ethan Furman wrote:
Terry Reedy wrote:
On 7/31/2012 4:49 PM, Chris Kaynor wrote:
On Tue, Jul 31, 2012 at 1:21 PM, Terry Reedy wrote:
one wants to catch both errors, one can easily enough. To continue
the example above, popping an empty list and empty set produce
ndows installer is a .msi file created by a
script that uses msilib. I don't know whether that script is in the
repository.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
nt) for dynamic class creation.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
) to produce a filter object that produced
filteriterators, the latter would often only work for the first. Also,
If you want the filtered collection more than once, you should just save
it. On the other hand, reproducing counts with a rangeiterator is nearly
as fast as looking them up in a saved list, and much more memory efficient.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
ent
files lists. I use it for short shippets that are two long to directly
type into the shell.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
ce as such
postings rather that go look to find out the context. However, this one
is wrong on its own ;-).
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
documentation bug http://bugs.python.org/>
describing this?
Sure, once I understand how it's really supposed to work :-)
You don't need a final solution to file. Anyway, I think the change
above might be enough.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
s list (which Guido reads even if he does not
write much).
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
and deconstruct. Python iterator embody the the same
principle. next(iterator) = iterator: return one item and mutate
yourself to represent the rest -- or raise StopIteration.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
improved a bit and opened an issue to "Improve
socketserver doc"
http://bugs.python.org/issue15608
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
a
lot of
parameters).
He can't change the function definition.
One can always wrap a function with an adaptor if the signature is too
awful.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
On 8/9/2012 4:06 PM, giuseppe.amatu...@gmail.com wrote:
Terry and MRAB,
thanks for yours suggestions,
in the end i found this solution
mask=( a != 0 ) & ( b != 0 )
a_mask=a[mask]
b_mask=b[mask]
array2D = np.array(zip(a_mask,b_mask))
unique=dict()
for row in array2D :
row = tuple
n.
In 3.x, .keys, .values, and .items are set-like read-only views
specifically designed for iteration. So in 3.x they are THE way to do so
for whichever alternative is appropriate. Iterating by keys and then
looking up values instead of yielding the values at the same time is
ext
ment, *before* the class is created.
Rather unusual ;-).
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
) % 2))
== 1 + (not len(L) % 2)
Works just fine with parentheses to enforce the correct interpretation.
This also works in Python 3.2, fwiw (except that you need
list(range(5)) to create the sample list).
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
s
damaged. Easiest fix is to uninstall and re-install Python. But download
a more recent version first. Uninstall might not be needed, but makes
process more like to work.
In the regular interactive command prompt interpreter
import idlelib.idle
should start idle.
--
Terry Jan Reed
t true. Whether the function is coded in Python or C
cls.__ipow__(base, exp, mod) # or
base.__ipow__(exp, mod)
while he would be able to
call the normal version with the third argument.
That can also be done directly
>>> int.__pow__(5, 3, 4)
1
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
ther the original
author or not, wraps the function (say to log calls), then the function
continues to work with the wrapped version.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
nw.exe)
{Just booted the Win7 laptop with Python 2.7.x: The only real difference
is that it uses Python.File where the above has py_auto_file}
Re-installing, as I suggested in the first response, is much easier,
especially for someone not familiar with the above.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
original, as k removals from
len n list is O(k*n) versus O(n) for new list and copy.
P/S: str is a builtin, you'd better avoid assigning to it.
Agreed. People have actually posted code doing something like
...
list = [1,2,3]
...
z = list(x)
...
and wondered and asked why it does not work.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
ng something OT does not excuse it. It should still be related. We
cannot allow 1000s of OT posts a day, marked OT or not.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
101 - 200 of 8120 matches
Mail list logo