Re: copy on write

2012-02-02 Thread Steven D'Aprano
why shouldn't += work? Ultimately, there is no right answer, because the multitude of requirements are contradictory. No matter what Python did, somebody would complain. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Killing threads, and os.system()

2012-02-03 Thread Steven D'Aprano
p/syncless/ http://opensource.hyves.org/concurrence/ http://www.tornadoweb.org/ http://docs.python.org/library/asyncore.html http://pyro.sourceforge.net/ http://wiki.python.org/moin/ParallelProcessing -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Script randomly exits for seemingly no reason with strange traceback

2012-02-03 Thread Steven D'Aprano
he problem go away? If you perturb your script (add a few blank lines at the end, or a comment), does it go away? -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Script randomly exits for seemingly no reason with strange traceback

2012-02-03 Thread Steven D'Aprano
")" If that were the case, the module wouldn't run at all, it would consistently raise SyntaxError before running. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Script randomly exits for seemingly no reason with strange traceback

2012-02-04 Thread Steven D'Aprano
On Sat, 04 Feb 2012 10:32:25 -0600, Andrew Berg wrote: > On 2/3/2012 5:25 PM, Steven D'Aprano wrote: >> Which version of Python, which version of Windows? > I keep that information in my signature for every post I make to this > list. CPython 3.2.2 | Windows NT 6.1.7601.17640

Re: PyCrypto builds neither with MSVC nor MinGW

2012-02-05 Thread Steven D'Aprano
linker. >>> >>> Unfortunately neither install on my computer, with a PATH with the >>> following: >>> >>> C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC >>> C:\libraries\MinGW\msys\1.0\bin >>> C:\libraries\MinGW >>> C:\Py

Re: difference between random module in python 2.6 and 3.2?

2012-02-05 Thread Steven D'Aprano
eed; seed(42); print(choice(list(range(1000" 639 steve@runes:~$ python3.1 -c "from random import choice, seed; seed(1); print(choice(list(range(1000" 134 -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: difference between random module in python 2.6 and 3.2?

2012-02-05 Thread Steven D'Aprano
On Mon, 06 Feb 2012 00:07:04 -0500, Terry Reedy wrote: > On 2/5/2012 11:01 PM, Steven D'Aprano wrote: > >> Reading the docs, I would expect that when using an int as seed, you >> should get identical results. > > That is similar to expecting hash to be consistent f

Re: difference between random module in python 2.6 and 3.2?

2012-02-06 Thread Steven D'Aprano
the convenience > transformations can be changed if improvements are needed or thought > sufficiently desirable. A more explicit note will help, but the basic problem applies: how do you write deterministic tests given that the random.methods (apart from random.random itself) can be changed

Re: iterating over list with one mising value

2012-02-07 Thread Steven D'Aprano
[1, 'a', 'A', 2, 'b', 'B', 3, 'c', 'C', 4, 'd', 'D', 5, 'e'] >>> collate(seq, 3) [[1, 2, 3, 4, 5], ['a', 'b', 'c', 'd', 'e'], ['A', 'B', 'C', 'D']] >>> collate(seq, 2) [[1, 'A', 'b', 3, 'C', 'd', 5], ['a', 2, 'B', 'c', 4, 'D', 'e']] >>> collate(seq, 9) [[1, 4], ['a', 'd'], ['A', 'D'], [2, 5], ['b', 'e'], ['B'], [3], ['c'], ['C']] -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: turbogears 1

2012-02-07 Thread Steven D'Aprano
I basically given vaporware? Does anyone have any up to date info? > > Have you considered Ruby on Rails? Now that's just cruel. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: frozendict

2012-02-08 Thread Steven D'Aprano
no way to implement one that doesn't suck? Because it's a solution in search of a problem? Actually, that's unfair. A write-once dict would be awesome for providing read-only constants, if only there were some way to set a namespace to using non-builtin dicts. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: when to use import statements in the header, when to use import statements in the blocks where they are used?

2012-02-08 Thread Steven D'Aprano
ing inside a function is that there can sometimes be strange effects with threads, or so I've been told, but I couldn't begin to explain exactly what (allegedly) can go wrong. > I still think readability trumps all the other reasons, for nearly all > programs. Which is a good reason fo

Re: Cycle around a sequence

2012-02-08 Thread Steven D'Aprano
want to make a copy, then I recommend your trick of generating the indexes: def cycle(seq, n): for indexes in (xrange(n, len(seq)), xrange(n)): for i in indexes: yield seq[i] If your data is humongous but only available lazily, buy more memory :) -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Read-only attribute in module

2012-02-09 Thread Steven D'Aprano
all over the place. We have properties, which can easily create read-only and write-once attributes. We have descriptors which can be used for the same. We have immutable types, and constant values, but not constant names. Python can enforce all common software contracts I can think of, except the contract that a name will be set to a specific value. And that is, in my opinion, a weakness in Python. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: frozendict

2012-02-09 Thread Steven D'Aprano
dicts. http://securitytracker.com/id/1026478 http://bugs.python.org/issue13703 If there is anyone still assuming that dicts have a predictable order, they're going to be in for a nasty surprise one of these days. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Read-only attribute in module

2012-02-10 Thread Steven D'Aprano
On Thu, 09 Feb 2012 22:27:50 -0500, Terry Reedy wrote: > On 2/9/2012 8:04 PM, Steven D'Aprano wrote: > >> Python happily violates "consenting adults" all over the place. We have >> properties, which can easily create read-only and write-once >> attributes.

Re: Python usage numbers

2012-02-11 Thread Steven D'Aprano
e fine. In Python 3 I get an error. What should I do that requires no thought?" Obvious answers: - Try decoding with UTF8 or Latin1. Even if you don't get the right characters, you'll get *something*. - Use open(filename, encoding='ascii', errors='surrogateescape') (Or possibly errors='ignore'.) -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Python usage numbers

2012-02-11 Thread Steven D'Aprano
ords and documents and files to deal with. Encodings are not going away. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Python usage numbers

2012-02-11 Thread Steven D'Aprano
ou stick to nothing but Windows, because Windows' default encoding is localised: a file generated in (say) Israel or Japan or Germany will use a different code page (encoding) by default than one generated in (say) the US, Canada or UK. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Numeric root-finding in Python

2012-02-11 Thread Steven D'Aprano
approximately -1.00572223991.) I know that Newton's method is subject to cycles, but I haven't found any discussion about Halley's method and cycles, nor do I know what the best approach for breaking them would be. None of the papers on calculating the Lambert W function that I have found mentions this. Does anyone have any advice for solving this? -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Python usage numbers

2012-02-12 Thread Steven D'Aprano
On Sun, 12 Feb 2012 01:05:35 -0600, Andrew Berg wrote: > On 2/12/2012 12:10 AM, Steven D'Aprano wrote: >> It's not just UTF8 either, but nearly all encodings. You can't even >> expect to avoid problems if you stick to nothing but Windows, because >> Windows&#x

Re: Python usage numbers

2012-02-12 Thread Steven D'Aprano
On Sun, 12 Feb 2012 05:11:30 -0600, Andrew Berg wrote: > On 2/12/2012 3:12 AM, Steven D'Aprano wrote: >> NTFS by default uses the UTF-16 encoding, which means the actual bytes >> written to disk are \x1d\x040\x04\xe5\x042\x04 (possibly with a leading >> byte-order mark

Re: Python usage numbers

2012-02-12 Thread Steven D'Aprano
On Sun, 12 Feb 2012 12:11:46 -0500, Roy Smith wrote: > In article , > Dennis Lee Bieber wrote: > >> On Sun, 12 Feb 2012 10:48:36 -0500, Roy Smith wrote: >> >> >As Steven D'Aprano pointed out, it was missing some commonly used US >> >symbols such

Re: Numeric root-finding in Python

2012-02-12 Thread Steven D'Aprano
ce/generated/ scipy.special.lambertw.html Naturally I thought "I can do better than that". Looks like I can't :) -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Python usage numbers

2012-02-12 Thread Steven D'Aprano
en I ran Mac OS 6, I had memorised many keyboard shortcuts for these things. Option-4 was the pound sign, I believe, and Option-Shift-4 the cent sign. Or perhaps the other way around? -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Numeric root-finding in Python

2012-02-12 Thread Steven D'Aprano
On Sun, 12 Feb 2012 12:18:15 -0800, Mark Dickinson wrote: > On Feb 12, 6:41 am, Steven D'Aprano [email protected]> wrote: > >>             err = -a/b  # Estimate of the error in the current w. >>             if abs(err) <= 1e-16: >>            

Re: Python usage numbers

2012-02-12 Thread Steven D'Aprano
l just as many bytes as it is characters, and everybody will be happy > again. I think you mean 4 times as many bytes as characters. Unless you have 32 bit bytes :) -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: how to tell a method is classmethod or static method or instance method

2012-02-13 Thread Steven D'Aprano
hon/download/Descriptor.htm And I'll take this opportunity to plug my dualmethod descriptor: http://code.activestate.com/recipes/577030-dualmethod-descriptor/ -- Steven -- http://mail.python.org/mailman/listinfo/python-list

OT: Entitlements [was Re: Python usage numbers]

2012-02-13 Thread Steven D'Aprano
gt; You are only born with one > guarantee; you will die, guaranteed! Any questions? Yes. Why haven't you moved to a libertarian paradise like Somalia yet? You'd like it there. There are two sorts of people: those who can afford their own private militia, and victims. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: OT: Entitlements [was Re: Python usage numbers]

2012-02-13 Thread Steven D'Aprano
On Mon, 13 Feb 2012 08:01:59 -0800, Rick Johnson wrote: > Evolution knows how to handle degenerates. And yet here you still are. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: OT: Entitlements [was Re: Python usage numbers]

2012-02-13 Thread Steven D'Aprano
on? Please don't disappoint your millions of fans! -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Kill files [was Re: OT: Entitlements [was Re: Python usage numbers]]

2012-02-15 Thread Steven D'Aprano
ple second chances (and apparently third and fourth and fifth chances). Methinks it's time for Monsieur Johnson to go back in the killfile. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Interactive keyword help

2012-02-15 Thread Steven D'Aprano
ns by site.py. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Complexity question on Python 3 lists

2012-02-15 Thread Steven D'Aprano
/(log n)**2). Regardless of the exact Big Oh behaviour, it is going to be SLOW for large values of n. The behaviour of append is the least of your concerns. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: entering unicode (was Python usage numbers)

2012-02-18 Thread Steven D'Aprano
it, then paste it into the input buffer to be processed. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Python as a default shell, replacement of bash, sh, cmd ?

2012-02-19 Thread Steven D'Aprano
support choosing a shell, you can't use anything but the built-in shell regardless of what Python does. Either way, this is not a Python problem to solve. It is an OS issue. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: netCDF4 variable manipulation

2012-02-20 Thread Steven D'Aprano
nfig file is -- is it an INI file, XML, JSON, YAML, Unix-style rc file, a binary pickle, or something else? -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Python LOC, .exe size, and refactoring

2012-02-21 Thread Steven D'Aprano
ng your code is double-plus good for maintainability. You should do it anyway. But don't do it to shrink an 11MB exe down to 10.8MB. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Python as a default shell, replacement of bash, sh, cmd ?

2012-02-22 Thread Steven D'Aprano
nt an environment where the tools don't mix content and presentation by default." "My OS has a shell which sucks and blows at the same time. I want something better." So basically, there exists a niche for Python as a shell, and thanks to the time machine, there already exists a powerful Python shell ready to fill that niche. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Python math is off by .000000000000045

2012-02-22 Thread Steven D'Aprano
l-as-always-ly y'rs, -- Steven -- http://mail.python.org/mailman/listinfo/python-list

distutils + mercurial good practice question

2012-02-22 Thread Steven D'Aprano
bad practice? -- Steven -- http://mail.python.org/mailman/listinfo/python-list

ANN: pyprimes 0.1 released

2012-02-22 Thread Steven D'Aprano
rator(): ... if p > 1: break ... return time() - t ... py> test(pyprimes.primes) 0.013000965118408203 py> test(pyprimes.naive_primes1) 4.1489889621734619 -- Steven -- http://mail.python.org/mailman/listinfo/python-list

distutils bdist_wininst failure on Linux

2012-02-23 Thread Steven D'Aprano
stutils/command/bdist_wininst.py", line 262, in create_exe cfgdata = cfgdata.encode("mbcs") LookupError: unknown encoding: mbcs How do I fix this, and is it a bug in distutils? -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: sum() requires number, not simply __add__

2012-02-23 Thread Steven D'Aprano
ies on, the right answer is usually: "Don't do that then." Python doesn't try to prevent people from shooting themselves in the foot. Monkey-patching-by-actual-monkeys-for-fun-and-profit-ly y'rs, -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: distutils bdist_wininst failure on Linux

2012-02-23 Thread Steven D'Aprano
On Thu, 23 Feb 2012 07:09:35 -0800, jmfauth wrote: > On 23 fév, 15:06, Steven D'Aprano [email protected]> wrote: >> Following instructions here: >> >> http://docs.python.org/py3k/distutils/builtdist.html#creating- windows... >> >> I am t

Re: distutils bdist_wininst failure on Linux

2012-02-23 Thread Steven D'Aprano
On Fri, 24 Feb 2012 00:11:11 +, Steven D'Aprano wrote: > On Thu, 23 Feb 2012 07:09:35 -0800, jmfauth wrote: > >> On 23 fév, 15:06, Steven D'Aprano > [email protected]> wrote: >>> Following instructions here: >>> >>> http:/

Re: A quirk/gotcha of for i, x in enumerate(seq) when seq is empty

2012-02-23 Thread Steven D'Aprano
you need: the addition of one extra line, to initialise the loop variable i (and, if you need it, x) before hand. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Please verify!!

2012-02-24 Thread Steven D'Aprano
abs instead of spaces, but since that's not going to happen, I can interoperate better with the mass of broken tools out there, and with other people, by using spaces. I wonder whether Windows users tend to be more sympathetic to tabs than Unix/Linux users, and if so, I wonder what if anything that means. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Does turtledemo in Python 3.2 actually work?

2012-02-24 Thread Steven D'Aprano
3k/library/turtle.html#demo-scripts -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: A quirk/gotcha of for i, x in enumerate(seq) when seq is empty

2012-02-24 Thread Steven D'Aprano
k me a long time to stop thinking that the else clause executes when the for loop was empty. In Python 4000, I think for loops should be spelled: for name in iterable: # for block then: # only if not exited with break else: # only if iterable is empty and likewise for whil

Re: PyWart: Language missing maximum constant of numeric types!

2012-02-24 Thread Steven D'Aprano
ther: isinstance(other, type(self)) __ne__ = __gt__ = lambda self, othr: not isinstance(othr, type(self)) __lt__ = lambda self, other: False __ge__ = lambda self, other: True __hash__ = lambda self: 42 -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: namespace question

2012-02-24 Thread Steven D'Aprano
un not intended), and it is quite common to store them in variables: for cls in (int, float, Decimal, Fraction, myint, myfloat): do_something_with(cls) Other languages may choose to use illogical terminology if they choose. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: PyWart: Language missing maximum constant of numeric types!

2012-02-24 Thread Steven D'Aprano
e-200 * -1e-200 -0.0 and well-written functions should honour those separate zeroes because sometimes it makes a difference. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: namespace question

2012-02-24 Thread Steven D'Aprano
On Sat, 25 Feb 2012 00:39:39 +, Mark Lawrence wrote: > On 24/02/2012 22:25, Steven D'Aprano wrote: >> On Fri, 24 Feb 2012 10:08:43 -0800, David wrote: >> >>> Your code updated to show the difference between a variable, a class >>> variable, and an instan

Re: PyWart: Language missing maximum constant of numeric types!

2012-02-24 Thread Steven D'Aprano
argument that this is useful and should be part of the Python built-ins. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Python math is off by .000000000000045

2012-02-25 Thread Steven D'Aprano
999ap+0' >>>> >>>> > jmf What's your point? I'm afraid my crystal ball is out of order and I have no idea whether you have a question or are just demonstrating your mastery of copy and paste from the Python interactive interpreter. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: webbrowser.open always opens up Safari on Lion

2012-02-25 Thread Steven D'Aprano
at part of the behaviour actually experienced contradicts the documented behaviour of webbrowser.open()? http://docs.python.org/library/webbrowser.html -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: webbrowser.open always opens up Safari on Lion

2012-02-25 Thread Steven D'Aprano
On Sun, 26 Feb 2012 14:23:43 +0800, Leo wrote: > On 2012-02-26 11:36 +0800, Steven D'Aprano wrote: >> What part of this do you think is the bug, and why? What part of the >> behaviour actually experienced contradicts the documented behaviour of >> webbrowser.open()? &g

Re: [RELEASED] Release candidates for Python 2.6.8, 2.7.3, 3.1.5, and 3.2.3

2012-02-26 Thread Steven D'Aprano
ly, it > can't be both a release candidate *and* released. What do you believe the words imply? I believe that they imply that the version is a candidate to be a production-ready release of the software, as opposed to a pre-alpha, alpha or beta version, but not yet the production-ready version. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: PyWart: Language missing maximum constant of numeric types!

2012-02-26 Thread Steven D'Aprano
(flag1), bool(flag2) # normalise to booleans >>> test(0, '') (False, True) So the two forms will take opposite branches of the if statement when maxlength is 0 and string is the empty string. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: namespace question

2012-02-26 Thread Steven D'Aprano
tring. Or to make this painfully complete: some_string is a name linked to a value which can vary (hence a variable) intended to be limited to strings (hence a string variable). Python may not enforce this to the same extent as C or Haskell or Pascal, but the concept still holds. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: PyWart: Language missing maximum constant of numeric types!

2012-02-26 Thread Steven D'Aprano
do_something() This can be simplified to: def confine_length(string, maxlength=None): if maxlength is None or len(string) <= maxlength: do_something() Or even simpler: def confine_length(string, maxlength=float('inf')): if len(string) <= maxlength:

Re: Python math is off by .000000000000045

2012-02-26 Thread Steven D'Aprano
.java.programmer/Floating-point-roundoff-error -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: PyWart: Language missing maximum constant of numeric types!

2012-02-26 Thread Steven D'Aprano
al values, say, BIGGEST and SMALLEST, which compare larger and smaller to any other value, regardless of type and including strings, not literally a string with an infinite number of characters. I can see some value for this as a convenience, but not enough to make it a built-in language feature.

Re: Python urllib2 problem: Name or service not known

2012-02-27 Thread Steven D'Aprano
w I can't access the > camera. [...] Check your web proxy and firewall. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: namespace question

2012-02-28 Thread Steven D'Aprano
On Tue, 28 Feb 2012 22:36:56 +1100, Ben Finney wrote: > Steven D'Aprano writes: > >> On Sun, 26 Feb 2012 19:47:49 +1100, Ben Finney wrote: >> >> >> An integer variable is a variable holding an integer. A string >> >> variable is a variable holdin

Re: Listing children processes

2012-02-28 Thread Steven D'Aprano
On Tue, 28 Feb 2012 23:41:16 +, Mark Lawrence wrote: > I've been told of by the BDFL for stating that > people should not top post on any Python mailing list/news group. He's the BDFL of Python, not of mailing list etiquette. -- Steven -- http://mail.python.org/mailman

Re: A quirk/gotcha of for i, x in enumerate(seq) when seq is empty

2012-02-28 Thread Steven D'Aprano
iller language, the identifiers "foo" and "bar" will be reserved words, never used, and not even mentioned in the reference manual. Any program using one will simply dump core without comment. Multitudes will rejoice. -- Tim Peters, 29 Apr 1998 -- Steven --

Re: lang comparison: in-place algorithm for reversing a list in Perl, Python, Lisp

2012-02-29 Thread Steven D'Aprano
ioms. You don't need a temporary variable to swap two values in Python. A better way to reverse a list using more Pythonic idioms is: for i in range(len(list_a)//2): list_a[i], list_a[-i-1] = list_a[-i-1], list_a[i] But the best way (even more idiomatic and much, much faster) is this: list_a.reverse() -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Is it necessary to call Tk() when writing a GUI app with Tkinter?

2012-02-29 Thread Steven D'Aprano
essage twice? It's very annoying. There is no need to C.C. python-list because comp.lang.python is the mirror of the mailing list. Thank you. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: exec

2012-03-01 Thread Steven D'Aprano
hat will work, or delegation, or composition. But given the toy example you have shown, I don't know what that might be. If you explain what you are actually doing, perhaps someone can suggest a better solution. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: this afternoon's duck typing exercise ...

2012-03-01 Thread Steven D'Aprano
On Fri, 02 Mar 2012 16:15:47 +1100, Cameron Simpson wrote: > Sorry, little technical content here, just a newly hatched programmer: > > duck typing, an intro > http://www.flickr.com/photos/cskk/6799351990/in/photostream/ I love it! Excellent! -- Steven -- http://mail.python

Building Python with non-standard tcl/tk support

2012-03-03 Thread Steven D'Aprano
I need to do to have Python 3.2 use tcl/tk 8.5? I have installed tcl/tk 8.5.11 from source, and the binaries are here: /usr/local/lib/libtcl8.5.so /usr/local/lib/libtk8.5.so In the Python 3.2 source, I do the usual: ./configure make sudo make altinstall (altinstall to avoid nuking

Re: Building Python with non-standard tcl/tk support

2012-03-03 Thread Steven D'Aprano
On Sat, 03 Mar 2012 10:17:40 -0800, Westley Martínez wrote: > On Sat, Mar 03, 2012 at 05:36:52PM +0000, Steven D'Aprano wrote: >> I'm trying to re-build Python 3.2 with support for TCL/TK 8.5, but when >> I run "make" I get this message: >> >

Re: Building Python with non-standard tcl/tk support

2012-03-03 Thread Steven D'Aprano
On Sat, 03 Mar 2012 17:06:39 -0800, Westley Martínez wrote: > On Sun, Mar 04, 2012 at 12:50:53AM +0000, Steven D'Aprano wrote: >> Okay, now I'm making progress... if I remove the previously existing >> _tkinter in lib-dynload, and re-run "make", I get somet

Re: Jython callable. How?

2012-03-04 Thread Steven D'Aprano
for more information. >>> >>> class Test: ... def __call__(self): ... return 42 ... >>> >>> x = Test() >>> x() 42 Perhaps if you show us what you actually do, and what happens, we might be able to tell you what is happening. Please COPY AND PASTE the full traceback. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: How to convert simple B/W graphic to the dot matrix for the LED display/sign

2012-03-04 Thread Steven D'Aprano
ut I did not find solution there. > > It will be really helpful If somebody here can show me the direction to > go? What file format is the graphic in? How big is it? What file format do you want it to be? -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Tkinter: Why aren't my widgets expanding when I resize the window?

2012-03-05 Thread Steven D'Aprano
x27;t worth it. Which is a pity, because I gather that Rick actually does know Tkinter well. But dealing with him is like wrestling with a pig: "I learned long ago, never to wrestle with a pig. You get dirty, and besides, the pig likes it." -- George Bernard Shaw -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: pickle/unpickle class which has changed

2012-03-06 Thread Steven D'Aprano
e.dumps(c) py> C.b = 42 # add a new class attribute py> d = pickle.loads(pickled) py> d.a 23 py> d.b 42 Unless you mean something different from this, adding attributes to the class is perfectly fine. But... why are you dynamically adding attributes to the class? Isn't tha

Re: What's the best way to write this regular expression?

2012-03-06 Thread Steven D'Aprano
ckduckgo.com/html/?q=python%20htmllib%20tutorial Also, you're still double-posting. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: help: confused about python flavors....

2012-03-06 Thread Steven D'Aprano
are all free software, so the only cost is your time), and decide for yourself which one meets your needs. We can't answer that, because we don't know what you need. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: "Decoding unicode is not supported" in unusual situation

2012-03-07 Thread Steven D'Aprano
by using: if type(s) is unicode: ... instead of if isinstance(s, unicode): ... Consequently, when the library passes a unicode *subclass* to the tounicode function, the "type() is unicode" test fails. That's a bad bug. It's arguable that the library shouldn't even use isinstance, but that's an argument for another day. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: "Decoding unicode is not supported" in unusual situation

2012-03-07 Thread Steven D'Aprano
e no decoding happens anyway. I don't believe that it is the job of unicode() to Do What I Mean, but only to Do What I Say. If I *explicitly* tell unicode() to decode the argument (by specifying either the codec or the error handler or both) then it should not double-guess me and ignore t

Re: Python site-packages permission denied?

2012-03-08 Thread Steven D'Aprano
ite-packages/urllib2_file.py: Permission denied I note also that Chris' final comment was: "In any case, you generally need to `sudo` when installing stuff system- wide." which is probably the solution the OP is looking for. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: "Decoding unicode is not supported" in unusual situation

2012-03-09 Thread Steven D'Aprano
ters, and the str type was still based on bytes, with explicit support for non-ASCII values: steve@runes:~/Downloads/python-0.9.1$ ./python0.9.1 >>> print 'This is *not* ASCII \xCA see the non-ASCII byte.' This is *not* ASCII � see the non-ASCII byte. Any conversion from bytes (including Python 2 strings) to Unicode is ALWAYS a decoding operation. It can't possibly be anything else. If you think that it can be, you don't understand the relationship between strings, Unicode and bytes. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: How to know that two pyc files contain the same code

2012-03-10 Thread Steven D'Aprano
ile ham.py x = 23 def func(): a = 23 return a + 19 # file = spam.py def func(): return 42 tmp = 19 x = 4 + tmp del tmp do you expect spam.pyc and ham.pyc to count as "the same"? -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: How to know that two pyc files contain the same code

2012-03-10 Thread Steven D'Aprano
On Sun, 11 Mar 2012 12:15:11 +1100, Chris Angelico wrote: > On Sun, Mar 11, 2012 at 9:52 AM, Steven D'Aprano > wrote: >> On Sat, 10 Mar 2012 15:48:48 +0100, Gelonida N wrote: Define >> "identical" and "the same". >> >> If I compile these

Why are some unicode error handlers "encode only"?

2012-03-11 Thread Steven D'Aprano
ecode("cp932", "backslashreplace") => r'aaa--騷--\xe9\x21--bbb' and similarly for xmlcharrefreplace. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Raise X or Raise X()?

2012-03-11 Thread Steven D'Aprano
ver takes your fancy. Personally, I used "raise X" to mean "this doesn't need arguments and should never have any" and "raise X()" to mean "this needs arguments but I'm too lazy to provide them right now". Think of it as a FIXME. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: How to break long method name into more than one line?

2012-03-11 Thread Steven D'Aprano
line. I found that def > abcdeef\ > dddaaa(self): > pass > > does not work, but > def \ > abcsajfoijfiawifoiwejfoi(self): > pass > > works. Is this the only way to do it? Yes. You can't split tokens over multiple lines, or put any whitespace between them. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Raise X or Raise X()?

2012-03-12 Thread Steven D'Aprano
eve@runes:~$ python2.6 Python 2.6.6 (r266:84292, Dec 27 2010, 00:02:40) [GCC 4.4.5] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> raise StopIteration("out of fuel") Traceback (most recent call last): File "", line 1, in StopIteration: out of fuel -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Enchancement suggestion for argparse: intuit type from default

2012-03-14 Thread Steven D'Aprano
at there is a way to over-rule the type-inference, there is no need to declare types in the common case. Explicit declarations should be used only for the uncommon cases where type inference cannot cope. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: How to decide if a object is instancemethod?

2012-03-14 Thread Steven D'Aprano
method in theory, but I can't see any way to actually get one in practice. In Python, and probably most languages, a bare, unadorned "method" is implied to be an instance method; "instance method" is (possibly) a retronym to distinguish them from other, newer(?), types

Re: Python is readable

2012-03-15 Thread Steven D'Aprano
g out punctuation is a real pessimation: an example of being "penny wise and pound foolish". -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Python is readable

2012-03-15 Thread Steven D'Aprano
acket: py> x = [ ... 1, 2, 3, ... 4, 5, 6, ... 7, 8, 9, ... 10, 11, 12, ... 13, 14, 15 ... ] py> x [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15] Indentation is only syntactically significant in blocks and statements. > I like it because it reads like a tree. Funny. I dislike it because it is a tree on its side. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Python is readable

2012-03-15 Thread Steven D'Aprano
eep reading? >From what you have show, and the sample chapters on the link above, I am impressed. The author is aiming to teach basic concepts and impart *understanding* rather than just force-feed the reader idioms which would be incomprehensible to them. Vern Cedar (the author) is an actual professional teacher, and from the samples I have seen, he knows what he is doing. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Python is readable

2012-03-15 Thread Steven D'Aprano
esult = [] for i in range(len(list1)): result.append(list1[i] + list2[i]) is likely to be simpler to understand. The downside is that experienced programmers may roll their eyes at how you are dumbing down the code, or worse, accusing you of deliberately misrepresenting the language. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Python is readable

2012-03-15 Thread Steven D'Aprano
inal Hypercard GUI.) I think Python is pretty close to the top of the readability versus expressiveness curve. That's not to say that Python is the optimal combination, or can't be improved, or even that every language should compromise expressiveness for comprehensibility (or vice versa). -- Steven -- http://mail.python.org/mailman/listinfo/python-list

cannot open shared object file

2012-03-16 Thread Steven Lo
Hi, We are getting the following error during a 'make' process on a CentOS release 5.4 system: Running mkfontdir... Creating SELinux policy... /usr/bin/python: error while loading shared libraries: libpython2.4.so.1.0: cannot open shared object file: No such file or directory However, we

<    9   10   11   12   13   14   15   16   17   18   >