Re: One line command line filter

2011-09-05 Thread Steven D'Aprano
y fixascii.py fix.py frange.py frequencies.py Other shells may be different. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: One line command line filter

2011-09-05 Thread Steven D'Aprano
wants to replace bash one-liners at the command line with Python one-liners, sure, why not? If you build up a useful collection of sys admin tools or recipes, you might like to consider sharing them. Perhaps if Python was used more by sys admins, there might be less resistance to making it easi

Re: Best way to print a module?

2011-09-05 Thread Steven D'Aprano
copy of the module __dict__, less dunder names, and pass it to the prettyprint module for printing. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

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

2011-09-05 Thread Steven D'Aprano
s part of the bound method, it isn't implied by context or history or guessed from the environment. Contrast what Python actually does with a hypothetical language where bound methods' instances are implicitly assigned according to the most recent instance created: black_knight = Knight() funclist.append(spam) # refers to black_knight.spam white_knight = Knight() funclist.append(spam) # refers to white_knight.spam baldrick = Knave() funclist.append(eggs) # oops, Knaves don't have an eggs attribute -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Floating point multiplication in python

2011-09-06 Thread Steven D'Aprano
umber. Normally you don't see it, because Python truncates the result when printing: >>> str(1.1) '1.1' but the difference is there. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Floating point multiplication in python

2011-09-06 Thread Steven D'Aprano
t;> b = F(11, 10)**2 >>> y = F.from_float(1.1**2) >>> f = y - b >>> print f 21/112589990684262400 which is slightly more than double e above, and slightly less than our estimate of 2*a*e = 11/56294995342131200 So we can conclude that, at least for 1.1**2, Python floats are more accurate than we would expect from a simple application of the binomial theorem. (For implementations using IEEE doubles.) -- Steven -- 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 Steven D'Aprano
False if self.end: raise StopIteration if random.random() < 0.01: self.end = True return time.asctime() def __iter__(self): return self -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: How to structure packages

2011-09-07 Thread Steven D'Aprano
sing an editor with no search functionality. Other than that, is there any justification for this rule? Any Java fans want to defend this? If "one class per file", why not "one method per class" too? Why is the second rule any more silly than the first? -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Python fails on math

2011-02-24 Thread Steven D'Aprano
ecision than if you store after each operation. That's a big if though. Which languages support such a thing? C doubles are 64 bit, same as Python. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Why this difference?

2011-02-24 Thread Steven D'Aprano
t. Absolutely correct. It can be quite surprising when Python re-uses objects. E.g this surprised me: >>> x, y = "hello world", "hello world" >>> x == y, x is y (True, True) compared to this: >>> x = "hello world" >>> y = &q

Re: Python fails on math

2011-02-24 Thread Steven D'Aprano
On Thu, 24 Feb 2011 10:40:45 -0600, Robert Kern wrote: > On 2/24/11 5:55 AM, Steven D'Aprano wrote: >> On Wed, 23 Feb 2011 13:26:05 -0800, John Nagle wrote: >> >>> The IEEE 754 compliant FPU on most machines today, though, has an >>> 80-bit internal re

Re: Newbie...

2011-02-24 Thread Steven D'Aprano
) Just do this: sine = 'blah blah blah' See how much simpler and clearer it is? > sine=chr(15)+chr(45)+chr(63)+chr(45)+chr(15)+chr(3)+chr(0)+chr(3) This is much more easily and efficiently written as: sine = ''.join([chr(n) for n in (15, 45, 63, 45, 15, 3, 0, 3)]) or even shorter, as a string constant: sine = '\x0f-?-\x0f\x03\x00\x03' -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Newbie...

2011-02-25 Thread Steven D'Aprano
ctal escapes and character escapes like \n for newline. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: I'm happy with Python 2.5

2011-02-27 Thread Steven D'Aprano
On Sun, 27 Feb 2011 05:34:44 -0800, n00m wrote: > Python 2.5 (r25:51908, Sep 19 2006, 09:52:17) [MSC v.1310 32 bit > (Intel)] on win32 > > and Idon't move neither up nor down from it (the best & the fastest > version) Congratulations. -- Steven -- http://mail.pyt

Re: Problem with python 3.2 and circular imports

2011-02-27 Thread Steven D'Aprano
ort mod1 If you change the "import mod*" lines to "import pkg.mod*" it works for me in Python 3.1 and 3.2. According to my understand of PEP 328, "from . import mod*" should work, but I agree with you that it doesn't. If you get rid of the circular import,

Re: Various behaviors of doctest

2011-02-27 Thread Steven D'Aprano
you have to pass buffer.as_string() to your CGI program, in whatever way you would normally do so. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: urlopen returns forbidden

2011-02-28 Thread Steven D'Aprano
t's blocking your program. What he said. Please don't abuse Wikipedia by screen-scraping it. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: how to properly pass literal strings python code to be executed using python -c

2011-02-28 Thread Steven D'Aprano
u don't. You don't call a function "tree", so you can't be getting that error. The actual function you call is shutil.rmtree. Please don't retype, summarize, simplify or paraphrase error messages. Copy and paste them *exactly* as they are shown, complete with any traceback which is printed. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Checking against NULL will be eliminated?

2011-03-02 Thread Steven Howe
runtime errors. And over course, I still use lots of parentheses to group my logic. Hell, I still do a lot of that when using bash. So PEP 4000, go ahead, break some over indulgent code and coders; I'm not bothered. Steven On 03/02/2011 07:15 AM, Tom Zych wrote: On Wed, 02 Mar 20

Re: Checking against NULL will be eliminated?

2011-03-02 Thread Steven D'Aprano
On Wed, 02 Mar 2011 08:20:56 -0800, Steven Howe wrote: > Back at NCR, they stressed the axiom '90% of the time is spent fixing > 10% of the code'. It's not an axiom, it's a platitude. Nor is it based on any objective evidence I've ever seen. > How true that

Re: Checking against NULL will be eliminated?

2011-03-02 Thread Steven D'Aprano
On Wed, 02 Mar 2011 23:46:31 +, Steven D'Aprano wrote: > For starters, how about giving an example of a built-in string, list or > dictionary where `if len(x) == 0` and `if x` give different results? Er, how embarrassment... of course I mean either len(x) != 0, or not x, tak

Re: having both dynamic and static variables

2011-03-02 Thread Steven D'Aprano
runtime data can enable the compiler to generate code which is significantly faster than would be generated at compile time. Finally, Python 3 introduced type annotations, which are currently a feature looking for a reason. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Playing WAV file with Python

2011-03-03 Thread Steven Howe
intriguing. Perhaps you can spool a wav file to a port, attach the analog out to an external amplifier. http://groups.google.com/group/python-on-a-chip?pli=1 Also, perhaps you should be looking atArduino and audio projects. http://www.ladyada.net/make/waveshield/ Good luck, Steven Howe -- http://mail.python.org/mailman/listinfo/python-list

Re: having both dynamic and static variables

2011-03-05 Thread Steven D'Aprano
07/)? Or is this some other feature > that I'm unaware of? Sorry, yes, I meant function annotations. Of course you can use function annotations for more than just types. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: having both dynamic and static variables

2011-03-05 Thread Steven D'Aprano
ages other than Python and C. Personally, I find that hard to believe. Why would the world need _three_ programming languages? *wink* -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: having both dynamic and static variables

2011-03-06 Thread Steven D'Aprano
principle. > but if Python were to have constants I think it would be better to use > something more descriptive than 'let'. Also, because the defined > constant is static, I think it would be better to use 'is' instead of > '='. Example: No, we'r

Re: I'm happy with Python 2.5

2011-03-06 Thread Steven D'Aprano
orget about > fretting over whether 2.5 or 3.1 is faster. You're using the wrong > language to begin with. Surely that depends on whether you care about execution speed or development speed. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: having both dynamic and static variables

2011-03-06 Thread Steven D'Aprano
e best, since I'm sure some people will be surprised that you can do this: # hypothetical example const L = [1, 2, 3] L.append(4) # works del L[:] # works L = [] # fails but I call that a feature, not a bug. If you want an immutable constant, use a tuple, not a list. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: I'm happy with Python 2.5

2011-03-06 Thread Steven D'Aprano
ness, the Python Dev team is very aware of the risk of performance degradation. Performance is important, but it is not *so important* that it outweighs everything else. The question that needs to be asked is not "Is Python 3 fast?", but instead "Is Python 3 fast enough?".

Re: having both dynamic and static variables

2011-03-07 Thread Steven D'Aprano
On Mon, 07 Mar 2011 13:20:39 -0800, Paul Rubin wrote: > Steven D'Aprano writes: >> but I call that a feature, not a bug. If you want an immutable >> constant, use a tuple, not a list. > > Nope: > > L = ([1,2],[3,4]) # tuple > L[0].append(5) # mu

Re: Finding keywords

2011-03-09 Thread Steven D'Aprano
gt; robust. Please suggest. Please start with a definition of what you mean by "keywords" in context. How would *you* recognise them, if you were reading the URL? -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Compile time evaluation of dictionaries

2011-03-10 Thread Steven D'Aprano
bove at compile- time, and I can only think of two reasons why it won't: - lack of interest from anyone willing and able to write a patch; - the added complexity may be more than the benefit gained. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Compile time evaluation of dictionaries

2011-03-10 Thread Steven D'Aprano
ole optimizer to recognise this as a constant, which pushes up the complexity for no additional gain, but the principle still applies. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Use-cases for alternative iterator

2011-03-10 Thread Steven D'Aprano
; next(it) 0 >>> next(it) 1 >>> next(it) 2 >>> next(it) Traceback (most recent call last): File "", line 1, in StopIteration I've never seen this second form in actual code. Does anyone use it, and if so, what use-cases do you have? -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Grabbing user's agent and OS type

2011-03-11 Thread Steven D'Aprano
you give the user-agent string too much credit. Despite what some people think, including some browser developers, it's a free-form string and can contain anything the browser wants. There's no guarantee that fields will appear in a particular order, or even appear at all. If you're doing feature detection by parsing the UA string, you're in a state of sin. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: enhanced map function

2011-03-11 Thread Steven D'Aprano
exactly? E.g. a = [1, 2, [3, 4]]; b = [1, [2, 3], 4] What do you expect to happen if the shorter list is empty? E.g. a = [1, 2, [3, 4], 5]; b = [1, 2, [], 3] This will get really messy fast. My advice is to forget about this as a bad idea, and instead concentrate on making sure your data isn

Re: Compile time evaluation of dictionaries

2011-03-11 Thread Steven D'Aprano
language, what you are looking at is an implementation of that language. Although I have never used it myself, apparently Cesare Di Mauro's WPython does more constant folding optimizations than CPython. See pages 21-24 of http://wpython2.googlecode.com/files/Beyond%20Bytecode%20-%20A%20Wordcode-based%20Python.pdf -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Problems of Symbol Congestion in Computer Languages

2011-03-13 Thread Steven D'Aprano
something which is universal and unchanging. Anybody anywhere in the world can (in principle) determine their own standard one metre rule, or one second timepiece, without arguments about which Roman soldier's paces defines a yard, or which king's forearm is a cubit. Fo

Guido rethinking removal of cmp from sort method

2011-03-13 Thread Steven D'Aprano
itten using a key function, or that perform really badly when done so, this would be a good time to speak up. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Get Path of current Script

2011-03-14 Thread Steven D'Aprano
On Mon, 14 Mar 2011 02:25:46 -0700, Alexander Schatten wrote: > is there an easy way (API) to get the directory of the currently running > script? import __main__ import os print os.path.dirname(__main__.__file__) -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Get Path of current Script

2011-03-14 Thread Steven D'Aprano
On Mon, 14 Mar 2011 10:29:42 +, Duncan Booth wrote: > Steven D'Aprano wrote: > >> On Mon, 14 Mar 2011 02:25:46 -0700, Alexander Schatten wrote: >> >>> is there an easy way (API) to get the directory of the currently >>> running script? >

Re: Guido rethinking removal of cmp from sort method

2011-03-14 Thread Steven D'Aprano
On Mon, 14 Mar 2011 12:10:27 +0100, Jean-Michel Pichavant wrote: > Steven D'Aprano wrote: >> The removal of cmp from the sort method of lists is probably the most >> disliked change in Python 3. On the python-dev mailing list at the >> moment, Guido is considering wheth

Re: writing command-line options into file

2011-03-14 Thread Steven D'Aprano
#x27;) opt_writer(ofile, parser, "-opt1", metavar="MY_OPTION1", default=123) opt_writer(ofile, parser, "-opt2", metavar="YOUR_OPTION2" ,default= "abc") opt_writer(ofile, parser, "-opt3", metavar="FLAG", default=True) ofile.close() -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Guido rethinking removal of cmp from sort method

2011-03-14 Thread Steven D'Aprano
key= return instances of that class. You mean like this? http://docs.python.org/dev/library/functools.html#functools.cmp_to_key -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Problem with command-line registeration with PyPI in Windows 7

2011-03-16 Thread Steven D'Aprano
y the same) problem. I eventually worked around it by creating a config file with my username and password: [distutils] index-servers = pypi [pypi] username: password: How you would do the same thing under Windows, I don't know. -- Steven -- http://mail.python.

Re: Coding and Decoding in Python

2011-03-17 Thread Steven D'Aprano
lue: return k raise KeyError('no such value found') If you have many keys/values, then simply create a reverse dictionary: Rev_QCam_Info = {} for key, value in QCam_Info.items(): Rev_QCam_Info[value] = key and then search that. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: enhanced map function

2011-03-17 Thread Steven D'Aprano
On Thu, 17 Mar 2011 08:31:28 -0700, Patrick wrote: > Steven, > > Thanks for the info of itertools. It is a great start for me. Overall, I > agree with you that it is really the user data needs to be sorted out. > However, novice users may need help on certain patterns such as >

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

2011-03-17 Thread Steven D'Aprano
eone will benefit from this. > > Python 2.6.5 on Windows 7. I get the same behaviour on Python 2.6, 2.7 and 3.1 under Linux: the Python process hangs until killed manually. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

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

2011-03-19 Thread Steven D'Aprano
On Fri, 18 Mar 2011 14:15:46 -0700, Carl Banks wrote: > I observed the same behavior (2.6 and 3.2 on Linux, hangs) and went > ahead and submitted a bug report. Thank you. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Syntax Error

2011-03-19 Thread Steven D'Aprano
line, but I can't see the problem. Well, what does the syntax error say? Please post the complete traceback showing the full error. Copy and paste it, in full, do not summarize, paraphrase, re-word, simplify or otherwise change it. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: value of pi and 22/7

2011-03-19 Thread Steven D'Aprano
r tips > equals one cubit. When you don't have a proper measuring tape, it can be > pretty accurate for comparing two measurements. "Measure with micrometer, mark with chalk, cut with axe." Just wait until you tell your apprentice to go fetch a piece of wood three cubits long...

Re: Bounds checking

2011-03-19 Thread Steven D'Aprano
o to stderr, not stdout; the return result should be non-zero) as well as normal conventions for Python code (the caller should be able to easily catch the exception -- catching sys.exit can be done, but it is a pretty unusual thing to do). -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Bounds checking

2011-03-19 Thread Steven D'Aprano
gt; d = Demo(-42) Traceback (most recent call last): File "", line 1, in File "", line 3, in __init__ File "", line 8, in _setx ValueError: attempt to set x to negative value >>> d = Demo(42) >>> d.x 42 >>> d.x = -23 Traceback (most rec

Re: Bounds checking

2011-03-19 Thread Steven D'Aprano
vs. > potential 10 separate checks? I don't see the advantage? You should always aim to fail as close as possible to the source of the error as is practical. That decreases the amount of debugging required when something fails: instead of searching your entire program, you only have to sea

Re: Some Minor questions on Class and Functions

2011-03-19 Thread Steven D'Aprano
ELLO SIR"): return message Now you can call the function, and print the result: print hello() If you want to capture the return value, you can: result = hello() print result.lower() If you want to change the message used, you can pass it to the function as an argument: hello("Greetings and salutations!") Hope this helps, -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: class error

2011-03-19 Thread Steven D'Aprano
that UserDict ignores PEP-8, as that it pre-dates PEP-8. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: dynamic assigments

2011-03-24 Thread Steven D'Aprano
of_rows". You, the programmer, don't care what that string actually is, because you never need to refer to it directly. You always refer to it indirectly via the variable name s. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: dynamic assigments

2011-03-24 Thread Steven D'Aprano
viruses and malware, far more common (and much easier to perform!) today than buffer overflows. If an unprivileged process can inject code into something that a privileged process is running, your computer is compromised. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Guido rethinking removal of cmp from sort method

2011-03-24 Thread Steven D'Aprano
function must always be complicated. Or even that a comparison function is never less complicated than a key function. That's not the point. The point is to find an example where a comparison function will work where no key function is either possible or practical. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: dynamic assigments

2011-03-24 Thread Steven D'Aprano
On Thu, 24 Mar 2011 19:51:08 -0700, scattered wrote: > On Mar 24, 7:18 pm, Steven D'Aprano [email protected]> wrote: >> On Thu, 24 Mar 2011 14:39:34 -0700, scattered wrote: >> > Could try: >> >> >>>> my_list = [("x&q

Re: dynamic assigments

2011-03-24 Thread Steven D'Aprano
ode smell? A code smell is something that makes you go "Hmmm..." (or at least, it *should* do so), not necessarily the wrong thing. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Guido rethinking removal of cmp from sort method

2011-03-24 Thread Steven D'Aprano
usec per loop That's two orders of magnitude faster. (You need the n=2 to defeat Python's compile-time constant folding, otherwise timing measurements will be misleading.) -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: functools.partial doesn't work without using named parameter

2011-03-25 Thread Steven D'Aprano
fs() got multiple values for keyword argument 'f' fs expects to be called like fs(f, s). It gets called with one positional argument, [0,1,2,3], which gets bound to the left-most parameter f, and one keyword argument, f1, which *also* gets bound to the parameter f (only by name this time,

Re: Guido rethinking removal of cmp from sort method

2011-03-25 Thread Steven D'Aprano
On Fri, 25 Mar 2011 10:21:35 +0100, Antoon Pardon wrote: > On Thu, Mar 24, 2011 at 11:49:53PM +0000, Steven D'Aprano wrote: >> On Thu, 24 Mar 2011 17:47:05 +0100, Antoon Pardon wrote: >> >> > However since that seems to be a problem for you I will be more >&

Re: dynamic assigments

2011-03-25 Thread Steven D'Aprano
On Fri, 25 Mar 2011 02:47:04 -0700, scattered wrote: > I specified that the cipher text consists of characters in the range A > to Z (note the case). So you did. My apologies. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Converting an array of string to array of float

2011-03-25 Thread Steven D'Aprano
st-of-floats at the same time, hundreds of millions of items or more, then you can change the list items in place: for i, s in enumerate(alist): alist[i] = float(s) But for small lists and merely large lists (millions or tens of millions) of items, this will probably be much slower than the solutions shown above. But your MMV -- time your code and find out for yourself. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Guido rethinking removal of cmp from sort method

2011-03-25 Thread Steven D'Aprano
ere key-based sorting sucks. We already know that some people just prefer the look and feel of writing and using cmp functions. Is there anything else? -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: dynamic assigments

2011-03-25 Thread Steven D'Aprano
On Fri, 25 Mar 2011 13:29:20 +0100, Seldon wrote: > On 03/25/2011 12:05 AM, Steven D'Aprano wrote: >> On Thu, 24 Mar 2011 19:39:21 +0100, Seldon wrote: >> >>> Hi, I have a question about generating variable assignments >>> dynamically. >> [...] >>

Re: Guido rethinking removal of cmp from sort method

2011-03-26 Thread Steven D'Aprano
On Fri, 25 Mar 2011 16:04:02 -0700, Carl Banks wrote: > On Mar 25, 3:06 pm, Steven D'Aprano [email protected]> wrote: > > The reason Guido is considering re-introducing cmp is that somebody at > > Google approached him with a use-case where a key-based sort di

Re: why memoizing is faster

2011-03-26 Thread Steven D'Aprano
cated caching system, you can build one. But this will trade off memory for time: the cache will be slower, there will be more misses, but you won't use as much memory. > I mean, when is the object _cache freed from the memory? When the function is freed, which will happen at

Re: Writing to a file

2011-03-26 Thread Steven D'Aprano
ting a ladder out of the shed > and climbing through your bedroom window to get into bed at night, > instead of just using the stairs. > > Use open/write/close. It's much more direct and efficient. I would say the analogy is more like calling the local handyman to come to your

Re: why memoizing is faster

2011-03-26 Thread Steven D'Aprano
On Sat, 26 Mar 2011 07:14:17 -0700, eryksun () wrote: > On Saturday, March 26, 2011 7:50:36 AM UTC-4, Steven D'Aprano wrote: >> >> That's of the order of 200 MB of memory -- not that much for today's >> systems. I've had people email me .doc files that

Re: why memoizing is faster

2011-03-26 Thread Steven D'Aprano
to manage it. But having said that, don't be scared of throwing memory at a problem to make it fast, especially in a language like Python. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Data files for tests

2011-03-27 Thread Steven D'Aprano
as test_spam? -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: best python games?

2011-03-27 Thread Steven D'Aprano
ts coding :) > > It uses way too much floating point incorrectly, the in-game calculator > gives the result of 878.53 - 874.20 as 4.32999. Well no wonder you're complaining! That's *completely* wrong, the correct value is 4.32999272. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Guido rethinking removal of cmp from sort method

2011-03-28 Thread Steven D'Aprano
On Mon, 28 Mar 2011 11:06:20 +0200, Antoon Pardon wrote: > On Fri, Mar 25, 2011 at 10:40:03PM +0000, Steven D'Aprano wrote: >> On Fri, 25 Mar 2011 13:56:23 +0100, Antoon Pardon wrote: >> >> > Look we are provided with the cmp_to_key function. If something >> &

Re: Guido rethinking removal of cmp from sort method

2011-03-28 Thread Steven D'Aprano
mer("sorted(data, key=cmp_to_key(cmp_func))", setup) print "Comparison function:", print min(t1.repeat(number=100, repeat=7)) print "Key function:", print min(t2.repeat(number=100, repeat=7)) print "Double sort:", print min(t3.repeat(number=100, repeat=7)) print

Re: ValueError: insecure pickle string

2011-03-28 Thread Steven D'Aprano
h > the script file and pickled file from Windows. What version of Python are you using on Ubuntu? Is it the same version of Python on Windows? Please show the full error traceback and the string that causes the error. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Why aren't copy and deepcopy in __builtins__?

2011-03-28 Thread Steven D'Aprano
roduction code. Normally techniques like list slicing, list comprehensions, {}.copy() and similar are more than enough. It's nice to have the copy module there as a fall-back if I should ever need it, but I haven't needed it yet. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Guido rethinking removal of cmp from sort method

2011-03-30 Thread Steven D'Aprano
a download. For anyone who knows how to do C extensions, this shouldn't be hard: just grab the code in Python 2.7 and make it a stand- alone function that can be imported. If you get lots of community interest in this, that is a good sign that the solution is useful and practical, and then you can push to have it included in the standard library or even as a built-in. And if not, well, at least you will be able to continue using cmp in your own code. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Guido rethinking removal of cmp from sort method

2011-03-31 Thread Steven D'Aprano
nge.org/durusmail/qp/441/ http://nedbatchelder.com/blog/200910/running_the_same_code_on_python_2x_and_3x.html Note that last link is from 2009. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Learn Python the Hardway exercise 11 question 4

2011-03-31 Thread Steven D'Aprano
last line has > ’6\’2"’ with that \’ sequence. See how the single-quote needs to be > escaped because otherwise it would end the string? I'm sorry, are you asking a question and expecting an answer, replying to somebody else's question, or just sharing something you thought was interesting? -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: In List Query -> None Case Sensitive?

2011-03-31 Thread Steven D'Aprano
is important to programmers, and a tool that generates as crufty HTML as Word does will unfortunately reflect badly on the person using the tool.) -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Alias for an attribute defined in a superclass

2011-03-31 Thread Steven D'Aprano
ng > ‘Bar.beans’? I don't believe so. So long as you don't rebind the "alias" or the original, you should be fine. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: In List Query -> None Case Sensitive?

2011-04-01 Thread Steven D'Aprano
y improvements and breakages in the user-interface between versions and platforms, so YMMV. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: a basic bytecode to machine code compiler

2011-04-01 Thread Steven D'Aprano
lementation that does the same; Compyler claims to be a native x86 assembly compiler; UnPython claims to be an experimental Python to C compiler. Of the six, as far as I know only Shedskin and Psyco are widely used. Good luck, and remember: Release early, release often, and let the community

Re: Guido rethinking removal of cmp from sort method

2011-04-01 Thread Steven D'Aprano
On Fri, 01 Apr 2011 14:31:09 -0700, geremy condra wrote: > On Wed, Mar 30, 2011 at 7:13 PM, Steven D'Aprano > wrote: > > > >> Or, an alternative approach would be for one of the cmp-supporters to >> take the code for Python's sort routine, and implement

Re: Guido rethinking removal of cmp from sort method

2011-04-01 Thread Steven D'Aprano
n, and have that drive the language change decisions. > Instead we're going to have to give up a lot of possible improvements we > could have gotten from the new implementation. There's always Python 4000 :) -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Guido rethinking removal of cmp from sort method

2011-04-01 Thread Steven D'Aprano
it as a complete new language instead of > similar to Perl 4 -> 5 and comparable to Python 2 -> 3. What you have described is not a reason for rejecting the claim that Perl 6 was a fiasco, but the reason for *why* it was a fiasco. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Guido rethinking removal of cmp from sort method

2011-04-02 Thread Steven D'Aprano
iented. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: a basic bytecode to machine code compiler

2011-04-02 Thread Steven D'Aprano
On Fri, 01 Apr 2011 17:45:39 +0200, Stefan Behnel wrote: > Steven D'Aprano, 01.04.2011 14:57: >> I suggest you check out the competitors: >> >> Shedskin is a Python to C++ compiler; Psyco is a JIT specialising >> compiler; Nuitka claims to be a C++ implementation

Re: Guido rethinking removal of cmp from sort method

2011-04-02 Thread Steven D'Aprano
then there could be circumstances where the benefit outweighed the cost, and the rule would be "*Almost* never change a published interface".) To be sure, interface stability is a good thing. But it is not the only good thing, and it is not so good that it always outweighs every other consideration. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Guido rethinking removal of cmp from sort method

2011-04-02 Thread Steven D'Aprano
opers: if you want somebody to scratch your itch instead of their own, you need to convince them to do so. My point was that good community support is a fairly good method of persuasion. The broader community does not get a vote, but that does not mean their voices are unheard. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Guido rethinking removal of cmp from sort method

2011-04-02 Thread Steven D'Aprano
On Fri, 01 Apr 2011 19:29:59 -0700, Paul Rubin wrote: > Steven D'Aprano writes: >> What I'm saying is this: cmp is already removed from sorting, and we >> can't change the past. Regardless of whether this was a mistake or not, > > No it's not alread

Re: Why is return type in getfullspec().annotations named as "return"?

2011-04-02 Thread Steven D'Aprano
On Sat, 02 Apr 2011 17:15:52 -0700, andrew cooke wrote: > This conflicts with any parameter named "return". Wouldn't it have been > better to use "->" as the key? Is there any way this can be changed? Can you give an example of a function with a parameter n

Re: Python CPU

2011-04-02 Thread Steven D'Aprano
course these days a $400 entry level PC is far more powerful than a Mac II.) There were also Forth chips, which let you run Forth in hardware. I believe they were much faster than Forth in software, but were killed by the falling popularity of Forth. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Python CPU

2011-04-02 Thread Steven D'Aprano
ig Three" Python implementations: * CPython (the one you're probably using) * Jython (Python on Java) * IronPython (Python on .Net) with PyPy (Python on Python) catching up. http://www.jython.org/ -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Guido rethinking removal of cmp from sort method

2011-04-03 Thread Steven D'Aprano
ly true for pure Python code, but for a C extension, the barrier to Do It Yourself will be much higher for most Python coders. On the other hand, for a pure Python function or class, you could stick it on ActiveState's Python cookbook and get some imperfect measure of popularity and/or usefulness from the comments and votes there. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Guido rethinking removal of cmp from sort method

2011-04-04 Thread Steven D'Aprano
l of incompatibilities, most of which can be automatically resolved by the 2to3 fixers. To describe them as different "languages" leaves no term to describe the differences between (say) Python and Cobra: http://cobra-language.com/docs/python/ let alone something like Python

Re: Guido rethinking removal of cmp from sort method

2011-04-04 Thread Steven D'Aprano
isn't interested in good-faith debate. He's trying to rally followers to lead on his crusade to save Python from itself (which *entirely* consists of him declaring that there is a problem, and everyone else dropping what they're doing to do the actual work of fixing it). -- Steven -- http://mail.python.org/mailman/listinfo/python-list

<    15   16   17   18   19   20   21   22   23   24   >