_ methods.
> import numpy as np
> a = np.zeros(3)
Numpy arrays meet the qualification above.
If the value on the left doesn't have an __iadd__ method, then addition is
performed and the name is re-bound to the result:
As is also done with the results of __ixxx__ m
ower than the syntax;-).
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
to read once one
gets used to the idiom.
number_of_chars += 1 # versus
number_of_chars = number_of_chars + 1
Not repeating was a major reason for the addition.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
, that is not in the contract.
Our testing indicated that the interfaces are returned in a specific
order, but we want to know if this is really the case (on all
platforms).
Even if it were so now, a patch could change things.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
10 different 'functions' within a function, or at
least a commented block, is enough.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
hunks and one three-line chunk.
In terms of different functions performed (see my previous post), I see
attribute lookup
assignment
enumerate
sequence unpacking
for-looping
if-conditioning
lower
startswith
return
That is 9, which is enough.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
ecute from an IDLE editor window, so PATH and command prompts
are mostly irrelevant for me.
Should I uninstall the old version.
If and only if you are sure you have no further use for it.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
everything.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
,
* and Tim Peters.
You can find it at http://www.radiofreepython.com/ as of this very minute.
What a treat. Thank you. Please announce the next one too.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
etty obvious that True=='on', and False=='off'.
As I remember, Guido only recommendeds splitting if the boolean arg is
(would be) always (nearly) passed as a constant True or False. Of
course, I am not sure how one forsees that at the design stage, prior to
field use.
--
T
blank lines.
def paragraphs(file):
para = []
for line in file:
if line:
para.append(line)
else:
yield para # or ''.join(para), as desired
para = []
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
On 8/27/2011 9:42 AM, Jason Swails wrote:
P.S. I'll note that my "preferred" behavior is how python3.2 actually
operates
Python core developers agree. This is one of the reasons for breaking a
bit from 2.x to make Python 3.
--
Terry Jan Reedy
--
http://mail.python.org/m
files/directories when asked for a listing.
Doc says first match, and I presume that includes first match within a
directory.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
On 8/27/2011 5:07 PM, Roy Smith wrote:
In article,
Terry Reedy wrote:
On 8/27/2011 1:45 PM, Roy Smith wrote:
In article<4e592852$0$29965$c3e8da3$54964...@news.astraweb.com>,
Steven D'Aprano wrote:
open("file.txt") # opens the file
.read() # read
what you mean by 'this'.
Closures are nested functions that access the locals of enclosing
functions. To ensure that the access remains possible even after the
enclosing function returns, the last value of such accessed names is
preserved even after the enclosing function returns. (Th
s normal and nested
functions as much the same as possible. This is intentional. It would be
extremely disconcerting if moving code that contains a def into or out
of a wrapping function radically changed its behavior more than is
absolutely necessary.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
to use something else.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
t_main
function, so one can write (in IDLE, for instance)
from test.test_xxx import test_main as f; f()
and run that test. Very handy.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
istory for some things is portability across
platforms and the main compilers.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
you.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
= C(3)
C.double = double
c.doub = double
# not c.double as that would mask access to C.double in c.double() below
print(double(c), C.double(c), c.double(), c.doub(c))
# 6 6 6 6
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
ich will make
tracebacks much less informative.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
ange(5): g()
print(i)
f()
# 5
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
.
but adding it to
the object directly will not wrap the function as a method. Can
somebody explain why?
Someone else did. Not wrapping is normal, wrapping is a special case.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
However, I can also
understand the desire to improve.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
On 9/1/2011 5:12 PM, Fulvio wrote:
I'm on python3.2, trying some experiment with OptionParser but no success
Do note "The optparse module is deprecated and will not be developed
further; development will continue with the argparse module."
--
Terry Jan Reedy
--
http://
on threads are not mapped to the core in the system.
They all run on the same core.
On using multiprocessing module, separate processes are created with unique
PID.
That is why multiprocessing was added.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
read_%28computer_science%29
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
Please do not repeatedly post the same thing. Doing so, with different
titles, will only annoy people. It takes awhile for a post to show up
with whatever news or mail reader you are using.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
re in the module.
Does that mean the rules would be different inside a function?
Yes. Inside a function, you would have to add
global getDictValues
before the if statement in order for the assignments to have global effect.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
en if you could, it would be confusing for human readers. There would
then be three ways to escape newline, with one doing double duty. And
for what? Merely to avoid using either of the two methods already available.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
n creating classes just to
have a class to attach functions to. How awful. (Oh, right, I believe I
just described Java.)
Am I missing something, or am I taking things too literally?
No, it is the OO purists who are missing something.
Yes, Python.
--
Terry Jan Reedy
--
http://mail.python.o
tly what you do and what 'it crashes' means.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
one with a specific feature request.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
On 9/3/2011 5:34 PM, William Gill wrote:
On 9/3/2011 3:15 PM, Terry Reedy wrote:
William Gill wrote:
During some recent research, and re-familiarization with Python, I came
across documentation
Ours, or someone else's?
Python.
Since in Python, everything is an object, that would
functional programming'. As the use of Python
has expanded, so has the variety of backgrounds of Python programmers.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
= self.parents
hierarchy.append(self)
obj = cls(hierarchy)
self.sub[obj.id] = obj
Indexing objects by their internal id is usually useless. Considier
whether you should be using sets rather than dicts.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
concrete solution, preferably with some previous
discussion. I take is that your proposal would be to add another builtin
means to access stdin.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
source of problems that it
turns out good to contain the problem somewhat -- hence the wish for
encapsulation.
One can find in the python library itself all 4 combinations:
syntactically and semantically OO : sort
syntactically and semantically FP: sorted
syntactically OO semantically FP: join
of an
expression"
Every Python programmer should peruse that chapter to learn what is
available for possible future use.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
On 9/5/2011 7:18 PM, Steven D'Aprano wrote:
Terry Reedy wrote:
The doc says "-c
Execute the Python code in command. command can be one or more
statements separated by newlines,"
However, I have no idea how to put newlines into a command-line string.
I imagine that it depen
xt.seek(15,0) # no problem with absolute seek
txt.write('xxx')
s = txt.getvalue()
print(ord(s[12]))
# 0
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
small enough that it underflows to zero, so we have the
error term e increasing to 2*a*e as a fairly simple estimate of the new
error.
And the relative error, which is what is often important, increases from
e/a to 2e/a.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
easy. Cheers,
Or grab and process the first item separately from the rest.
it = iter(iterable)
try:
first = next(it)
except StopIteration:
raise ValueError("Empty iterable not allowed")
for i in it:
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
unpleasant bug, a regression from 3.1.x. If they are tested
with the last beta or first release candidate, it would have been found
and fixed. Now its there until 3.2.1.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
and change
its internal rules as it pleases. When creating string objects from
literals that look like identifiers, CPython does this, but apparently
not when splitting an existing string.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
ch is to reverse the
sequence of remainders from dividing by 10 and then add ord('0') to get
the char code.
Note: an as yet undocumented feature of bytes (at least in Py3) is that
bytes(count) == bytes()*count == b'\x00'*count.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
On 2/24/2011 9:25 PM, John Machin wrote:
On Feb 25, 4:39 am, Terry Reedy wrote:
Note: an as yet undocumented feature of bytes (at least in Py3) is that
bytes(count) == bytes()*count == b'\x00'*count.
Python 3.1.3 docs for bytes() say same constructor args as for
bytearray(); this
ut running through
2to3. You did not specify how far forward you want to cater to.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
as solving
many, but many have (hopefully) been ironed out in 3.2. Do start with
3.2.0 rather than 3.1.3.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
" and specifically, how to find Wikipedia's?
I looked as the Wikipedia articles on API and web services and did not
find any mention of thiers (though there is one for Amazon).
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
er()?
Read the source Lib/telnetlib.py (as I just did). It is pretty
straightforwad code.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
this: 20Hz.
I suspect that is by design, so as to not interfere with the simulation
itself.
This is quite poor for a quasi-realtime hardware interface (which is
in my intention).
I suggest you discuss your use case on a FlightGear mailing list
(mirrored on gmane as newsgroups) or forum.
--
ned off by default so as to not annoy
users who can do nothing about them and developers who do not want to do
anything at the moment. I presume the doc for warnings says how to turn
them back on.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
t the change is documented with a note as to when the
change was made. But this is never intentionally done as casually as you
imply. Contributions to improve test coverage so as to prevent
unintended changes are welcome.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
related to various library modules
(each identified) in another. There is no BSD license because bsddb in
no longer included.
You could take the disappearance of the BD licence with the
disappearance of the bsddb module as confirmation of your hypothesis;-).
--
Terry Jan Reedy
--
http://mail.
ve you can. You have to be at a position and f.tell() will
report it.
Note: if a file is utf-8 encoded, and you seek to an arbitrary position
in binary mode, it is easy to synchronize by discarding the remainder
(if any)of a multibyte char and finding the start of the next char.
--
Terry
a translated page is planned?
Chinese readers will know when to use it.
Why a special link just for Chinese and not several other languages?
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
codes include s = C char[] = Py bytes of possibly
unspecified length copied unchanged.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
py", line 43, in hasValidHeader
header = self.readString(64) ## read max 64 chars
File "pygold\GrammarReader.py", line 68, in readString
result.append(char)
TypeError: array item must be unicode character
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
, do whatever, and
write out in entirety) then that is no advantage to you.
Similar to marshal is json, which is more limited but more portable,
because understood by other languages.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
as correct, just hit return twice to run.
But I almost never type something so complex in the shell. I nearly
always use editor, where I can correct mistakes easily.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
icit binding of 'xxx'. I do not know if
really equivalent or if tk or tkinter have bug.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
y a mixed syntax and mixed paradigm language. Some
people find the mixture to be an advantage. If you want a pure language,
try something else.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
[1]/r1**3-mu*X[1]/r2**3
Az= -(1-mu)*X[2]/r1**3-mu*X[2]/r2**3
XDelta=array([X[3], X[4], X[5], Ax, Ay, Az])
return XDelta
\
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
or a compiled shared library version of every module
to be imported. I wonder if it would be faster to make a set with all
shared library names and check that instead before going to the file
system. On an embedded system, especially, something might even be built
into the binary or r
something like this also. I have seen a claim that
Google only looks at the first x words, hence the advice 'Make sure your
target keywords are in the first x words.'. You, of course, can and
should process entire docs
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
and they have contributed new tests. Modules? I have never seen 'We
first did this with xpython on the tracker, but it is possible.
The best place to ask is the developer lists for each project.
gmane.comp.lang.jython.devel
gmane.comp.python.pypy
gmane.comp.pyhton.ironpython.user (no d
On 3/8/2011 4:39 PM, Larry Hastings wrote:
Adding to my previous response, extended slices and ellipses were added
for numerical python, but that is cpython extension, not alternative.
The 3.x memoryview came from there too, I believe.
--
Terry Jan Reedy
--
http://mail.python.org/mailman
says that str == type("hello"),
overwriting the str name changes nothing in the literal.
Right. By design. String and number literals are always string and
number literals.
Is this a bug?
No.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
only to this particular 'in' context. It follows a
similar optimization for turning lists into tuples (although in this
latter case, the programmer could have remembered to use () instead of []).
The optimization *did* happen because various people started an issue,
wrote a patch, reviewed the patch, and committed it to the cpython
source. You might read the issue if you have not:
http://bugs.python.org/issue6690
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
but a few
questions: 1) I have regular Python installed not Cpython
CPython *is* regular Python!
Which is to say, 'python*' binaries are compiled from the CPython codebase.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
.
I agree ;-). Now read What's New for 3.1 and 3.2 and load and use 3.2
with numberous fixes and improvements to doc and code. 3.3 will be
better yet.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
xplicit "if l == '': break" in first loop.
I suspect the two param form, still rather new and unusual, is used less
that is could, and perhaps should be. I am glad you raised the question
to get me thinking about it.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
I would first
write down the current setting before deleting it, so you could restore
it if necessary.
I once had a similar py2.2 installation on my HP, but I deleted it
several years ago as I never used any program that used it.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
enough for many purposes.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
seeing cgitools/cgirev, it is hard to say. Something like
while True:
try:
x = cgitools()
break
except NameError
pass
would produce the symptom ;-)
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
On 3/12/2011 7:18 PM, Tim Johnson wrote:
* Terry Reedy [110312 13:28]:
On 3/12/2011 2:53 PM, Tim Johnson wrote:
Is 'cgilib' *your* wrapper of the cgi module, or from a third party.
cgilib is my module. I use the cgi module as follows:
## code below
import cgi
;). So
they will not change or disappear without notice. I expect them to be
pretty stable.
On the other hand, they are mostly intended for internal use by type(ob)
(for every ob), str/repr(ob) (for many obs), tracebacks, and other
messages. Indeed, one 'should' use type(ob) rather than ob.__class__.
However, custom messages may require direct use of .__name__. As you
discovered, using it for program logic has problems.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
ividuals, not straight-jacketed
machines in asylums ;-).
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
le optimizer, Raymond H.,
would like to replace some or all of it with an ast optimizer, rather
than expand it.
Perhaps if and when that is done, someone will devise some broader but
guaranteed safe detect and replace rules.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
On 3/14/2011 4:31 PM, bruce bushby wrote:
but has anybody seen any
efforts to allow python to "import modules via a socket"
I do not remember any such thing.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
.
Translate as needed for *nix.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
d) + extra space (for list to grow without
reallocation and copy)
>>> L = []
>>> for i in xrange(2):
... L.append(str(i) * (5000 / len(str(i
...
>>> sys.getsizeof(L)
178024
== 8*2 + extra
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
cx**2 + dx + e
(I'm not sure what thats called but one degree up from a cubic curve)
quartic
Also, I'm sure it'll take alot of time to brute force it like this but
I'm sure I'm missing something for this.
Look at scipy.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
docs, you
might as well get the latest even you want to build from a frozen x.y.z
code branch.
Unfortunately, I have no idea about your specific problem. I presume
someone has done a 3.2 debug build on windows, but do not know for sure.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/lis
Python 2.6.5 on Windows 7.
class Foo(object):
pass
Foo.__repr__ = Foo.__str__ # this will cause an abend.
2.7.1 and 3.2.0 on winxp, no problem, interactive intepreter or IDLE
shell. Upgrade?
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
On 3/17/2011 10:00 PM, Terry Reedy wrote:
On 3/17/2011 8:24 PM, J Peyret wrote:
This gives a particularly nasty abend in Windows - "Python.exe has
stopped working", rather than a regular exception stack error. I've
fixed it, after I figured out the cause, which took a while, bu
bug report.
http://bugs.python.org/issue11603
where I added additional comments.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
Dict,), d)
But Module is not a metaclass and does not expect the tuple of base
classes, and Module.__new__ passed too much to Module.__init__.
Since others have made the same mistake, I opened an issue to improve
the message.
http://bugs.python.org/issue11604
--
Terry Jan Reedy
--
http://ma
values< 0: %s" % (attr)
dir() has to do a bit a computation. I would be tempted to give 'state'
a set of attributes to check. Call it 'nonnegatives'.
for attr in nonnegatives:
if ...
This allows for attributes not subject to that check.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
ot;)
If running with Py3, 'import Tkinter' will fail; change to 'import tkinter'.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
o try moving the
line to a different place (and adjusting indent as necessary) to see
what happens. Debugging is often a matter of trying different things to
collect more bits of information. Python, especially with IDLE or other
editor with a Run key, make that especially easy.
--
Terry J
immediately
Assuming your 2.7.1 was installed normally, with the CPython .msi
installer from python.org, you should perhaps ask the pyserial folks.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
ble return values from the
function you want to use and which indicates failure. Then test that the
result is not the failure value.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
i-1])
return _cache[n]
This should be slightly faster than the crazy-key cache for the memoized
recursive version.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
on name (in this 'fib') with a direct reference to the
function itself, as a constant (and this could be done), then the
wrapper would not get called from within the function.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
On 3/24/2011 8:26 PM, Fons Adriaensen wrote:
On Thu, Mar 24, 2011 at 08:12:22PM -0400, Terry Reedy wrote:
The irony of this is that memoizing 'recursive' functions with a
decorator depends on the fact the Python does not have truly recursive
functions. A function cannot call itsel
On 3/25/2011 4:49 AM, Andrea Crotti wrote:
Terry Reedy writes:
def fib_iter(n, _cache = [1,1]):
k = len(_cache)
if n>= k:
for i in range(k, n+1):
_cache.append(_cache[i-2] + _cache[i-1])
return _cache[n]
I just realized that the signature really ought to be
901 - 1000 of 8116 matches
Mail list logo