Re: relative speed of incremention syntaxes (or "i=i+1" VS "i+=1")

2011-08-21 Thread Terry Reedy
_ 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

Re: relative speed of incremention syntaxes (or "i=i+1" VS "i+=1")

2011-08-21 Thread Terry Reedy
ower than the syntax;-). -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: relative speed of incremention syntaxes (or "i=i+1" VS "i+=1")

2011-08-21 Thread Terry Reedy
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

Re: Order of addresses returned by socket.gethostbyname_ex()

2011-08-22 Thread Terry Reedy
, 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

Re: is there any principle when writing python function

2011-08-23 Thread Terry Reedy
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

Re: is there any principle when writing python function

2011-08-23 Thread Terry Reedy
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

Re: upgrade python

2011-08-23 Thread Terry Reedy
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

Re: Windows No-Install Distribution?

2011-08-23 Thread Terry Reedy
everything. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: Announcing a new podcast: Radio Free Python

2011-08-24 Thread Terry Reedy
, * 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

Re: [OT-ish] Design principles: no bool arguments

2011-08-25 Thread Terry Reedy
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

Re: Record seperator

2011-08-27 Thread Terry Reedy
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

Re: typing question

2011-08-27 Thread Terry Reedy
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

Re: Understanding .pth in site-packages

2011-08-27 Thread Terry Reedy
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

Re: Record seperator

2011-08-27 Thread Terry Reedy
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

Re: Why do closures do this?

2011-08-27 Thread Terry Reedy
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

Re: Why do closures do this?

2011-08-28 Thread Terry Reedy
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

Re: A question about class as an iterator

2011-08-28 Thread Terry Reedy
to use something else. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: about if __name == '__main__':

2011-08-28 Thread Terry Reedy
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

Re: Why PyImport_ExecCodeModule takes char*?

2011-08-28 Thread Terry Reedy
istory for some things is portability across platforms and the main compilers. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: Handling 2.7 and 3.0 Versions of Dict

2011-08-30 Thread Terry Reedy
you. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: Why do class methods always need 'self' as the first parameter?

2011-08-31 Thread Terry Reedy
= 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

Re: Subclassing str object

2011-08-31 Thread Terry Reedy
ich will make tracebacks much less informative. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: Closures and Partial Function Application

2011-08-31 Thread Terry Reedy
ange(5): g() print(i) f() # 5 -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: Why do class methods always need 'self' as the first parameter?

2011-08-31 Thread Terry Reedy
. 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

Re: fun with nested loops

2011-09-01 Thread Terry Reedy
However, I can also understand the desire to improve. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: Optparse buggy?

2011-09-01 Thread Terry Reedy
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://

Re: Python thread

2011-09-01 Thread Terry Reedy
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

Re: Python thread

2011-09-01 Thread Terry Reedy
read_%28computer_science%29 -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: PythonThreading

2011-09-01 Thread Terry Reedy
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: Handling 2.7 and 3.0 Versions of Dict

2011-09-02 Thread Terry Reedy
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

Re: [Python-ideas] allow line break at operators

2011-09-03 Thread Terry Reedy
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

Re: Functions vs OOP

2011-09-03 Thread Terry Reedy
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

Re: IDLE from python 3.2 constantly crashes

2011-09-03 Thread Terry Reedy
tly what you do and what 'it crashes' means. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: SSL module needs issuer information

2011-09-03 Thread Terry Reedy
one with a specific feature request. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: Functions vs OOP

2011-09-03 Thread Terry Reedy
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

Re: Functions vs OOP

2011-09-04 Thread Terry Reedy
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

Re: Need help with simple OOP Python question

2011-09-05 Thread Terry Reedy
= 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

Re: One line command line filter

2011-09-05 Thread Terry Reedy
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

Re: Functions vs OOP

2011-09-05 Thread Terry Reedy
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

Re: One line command line filter

2011-09-05 Thread Terry Reedy
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

Re: One line command line filter

2011-09-05 Thread Terry Reedy
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

Re: Relative seeks on string IO

2011-09-06 Thread Terry Reedy
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

Re: Floating point multiplication in python

2011-09-07 Thread Terry Reedy
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

Re: Best way to check that you are at the beginning (the end) of an iterable?

2011-09-07 Thread Terry Reedy
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

Re: 2to3 chokes on bad character

2011-02-24 Thread Terry Reedy
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

Re: Why this difference?

2011-02-24 Thread Terry Reedy
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

Re: py3k: converting int to bytes

2011-02-24 Thread Terry Reedy
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

Re: py3k: converting int to bytes

2011-02-24 Thread Terry Reedy
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

Re: backwards-compatibility

2011-02-26 Thread Terry Reedy
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

Re: come back and find python 3

2011-02-26 Thread Terry Reedy
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

Re: urlopen returns forbidden

2011-02-28 Thread Terry Reedy
" 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

Re: Problems with read_eager and Telnet

2011-02-28 Thread Terry Reedy
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

Re: Problems with read_eager and Telnet

2011-02-28 Thread Terry Reedy
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. --

Re: 3.1 -> 3.2: base64 lost deprecation warning

2011-02-28 Thread Terry Reedy
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

Re: Checking against NULL will be eliminated?

2011-03-03 Thread Terry Reedy
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

Re: Pure python standard library and License

2011-03-03 Thread Terry Reedy
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.

Re: how to read the last line of a huge file???

2011-03-05 Thread Terry Reedy
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

Re: 下载 below Download, in python.org site menu

2011-03-06 Thread Terry Reedy
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

Re: Fun with 'str' and 'bytes'

2011-03-06 Thread Terry Reedy
codes include s = C char[] = Py bytes of possibly unspecified length copied unchanged. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: encoding hell - any chance of salvation ?

2011-03-07 Thread Terry Reedy
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

Re: my computer is allergic to pickles

2011-03-07 Thread Terry Reedy
, 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

Re: strange behaviour with while-else statement

2011-03-07 Thread Terry Reedy
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

Re: Problem with Python GUI checklist, Tkinter

2011-03-07 Thread Terry Reedy
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

Re: Absolutely Insane Problem with Gmail

2011-03-07 Thread Terry Reedy
. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: changing to function what works like a function

2011-03-07 Thread Terry Reedy
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

Re: Numerical representation

2011-03-07 Thread Terry Reedy
[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

Re: embedded python 2.7.1 slow startup

2011-03-08 Thread Terry Reedy
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

Re: Finding keywords

2011-03-08 Thread Terry Reedy
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

Re: Python language changes that first shipped in something besides CPython?

2011-03-08 Thread Terry Reedy
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

Re: Python language changes that first shipped in something besides CPython?

2011-03-08 Thread Terry Reedy
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

Re: I found some very odd behaviour in Python's very basic types

2011-03-09 Thread Terry Reedy
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

Re: Compile time evaluation of dictionaries

2011-03-10 Thread Terry Reedy
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

Re: Python Tools for Visual Studio from Microsoft - Free & Open Source

2011-03-10 Thread Terry Reedy
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

Re: Just finished reading of "What’s New In Python 3.0"

2011-03-10 Thread Terry Reedy
. 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

Re: Use-cases for alternative iterator

2011-03-11 Thread Terry Reedy
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

Re: IDLE doesn't start

2011-03-11 Thread Terry Reedy
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

Re: Calling C++ Modules in Python

2011-03-11 Thread Terry Reedy
enough for many purposes. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: Changing class name causes process to 'hang'

2011-03-12 Thread Terry Reedy
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

Re: Changing class name causes process to 'hang'

2011-03-12 Thread Terry Reedy
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

Re: Changing class name causes process to 'hang'

2011-03-13 Thread Terry Reedy
;). 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

Re: organizing many python scripts, in a large corporate environment.

2011-03-13 Thread Terry Reedy
ividuals, not straight-jacketed machines in asylums ;-). -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: Compile time evaluation of dictionaries

2011-03-14 Thread Terry Reedy
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

Re: organizing many python scripts, in a large corporate environment.

2011-03-14 Thread Terry Reedy
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

Re: possible to run a python script without installing python?

2011-03-15 Thread Terry Reedy
. Translate as needed for *nix. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: Memory Usage of Strings

2011-03-16 Thread Terry Reedy
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

Re: Fitting polynomial curve

2011-03-16 Thread Terry Reedy
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

Re: Python 3.2 Debug build

2011-03-17 Thread Terry Reedy
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

Re: Abend with cls.__repr__ = cls.__str__ on Windows.

2011-03-17 Thread Terry Reedy
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

Re: Abend with cls.__repr__ = cls.__str__ on Windows.

2011-03-17 Thread Terry Reedy
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

Re: Abend with cls.__repr__ = cls.__str__ on Windows.

2011-03-18 Thread Terry Reedy
bug report. http://bugs.python.org/issue11603 where I added additional comments. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: class error

2011-03-18 Thread Terry Reedy
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

Re: Bounds checking

2011-03-18 Thread Terry Reedy
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

Re: Syntax Error

2011-03-18 Thread Terry Reedy
ot;) If running with Py3, 'import Tkinter' will fail; change to 'import tkinter'. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: Syntax Error

2011-03-19 Thread Terry Reedy
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

Re: Pyserial

2011-03-20 Thread Terry Reedy
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

Re: Regex in if statement.

2011-03-20 Thread Terry Reedy
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

Re: why memoizing is faster

2011-03-24 Thread Terry Reedy
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

Re: why memoizing is faster

2011-03-24 Thread Terry Reedy
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

Re: why memoizing is faster

2011-03-24 Thread Terry Reedy
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

Re: why memoizing is faster

2011-03-25 Thread Terry Reedy
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

<    5   6   7   8   9   10   11   12   13   14   >