Re: trying to strip out non ascii.. or rather convert non ascii

2013-10-28 Thread Steven D'Aprano
s to treat it no differently from other fuzzy searches. A good search engine should be tolerant of spelling errors and alternative spellings for any letter, not just those with diacritics. Ideally, a good search engine would successfully match all three of "naïve", "naive" a

Re: Function for the path of the script?

2013-10-28 Thread Steven D'Aprano
ding unwanted GG posts outweighs the risk of throwing out a useful post or two. Isn't freedom of choice wonderful? No matter what you choose, you'll annoy somebody, possibly yourself :-) -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Cookie fucking problem

2013-10-28 Thread Steven D'Aprano
r made out to the solicitors Hummerdinger, Hummerdinger, Hummerdinger, Hummerdinger, and McCormack? As I recall, not only did the secretary leave out one of the Hummerdingers, but he left out the most important one. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Slicing with negative strides

2013-10-29 Thread Steven D'Aprano
On Tue, 29 Oct 2013 08:53:08 +, Duncan Booth wrote: > Steven D'Aprano wrote: > >> Does anyone here use slices (or range/xrange) with negative strides >> other than -1? >> >> E.g. sequence[2:15:-3] > > With any negative stride your example is just t

Re: Possibly better loop construct, also labels+goto important and on the fly compiler idea.

2013-10-29 Thread Steven D'Aprano
a bit until the button exists click the button > Putting this exit condition on the top makes no sense. Wait until you actually start programming before deciding what makes sense or doesn't. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Possibly better loop construct, also labels+goto important and on the fly compiler idea.

2013-10-30 Thread Steven D'Aprano
On Tue, 29 Oct 2013 13:00:07 -0700, rurpy wrote: > On Tuesday, October 29, 2013 8:08:16 AM UTC-6, Steven D'Aprano wrote: >> On Tue, 29 Oct 2013 12:37:36 +0100, Skybuck Flying wrote: >>[...] >> Skybuck, please excuse my question, but have you ever done any >> progr

Re: trying to strip out non ascii.. or rather convert non ascii

2013-10-31 Thread Steven D'Aprano
Showing results for misspelled Search instead for mispealled But I see now that this is nonsense and there is *absolutely no reason* to match something other than the ecaxt wrods I typed. Perhaps you should submit a bug report to Google: "When I mistype a word, Google co

Re: Possibly better loop construct, also labels+goto important and on the fly compiler idea.

2013-10-31 Thread Steven D'Aprano
On Wed, 30 Oct 2013 19:48:55 -0700, rurpy wrote: > On 10/30/2013 04:22 AM, Steven D'Aprano wrote: >> Skybuck's experience at programming *is relevant* to the question of >> whether or not he understands what he is talking about. > > No. You claimed his propositio

Re: Possibly better loop construct, also labels+goto important and on the fly compiler idea.

2013-10-31 Thread Steven D'Aprano
On Thu, 31 Oct 2013 21:41:32 -0700, rurpy wrote: > On 10/31/2013 02:41 AM, Steven D'Aprano wrote: >> On Wed, 30 Oct 2013 19:48:55 -0700, rurpy wrote: >>> On 10/30/2013 04:22 AM, Steven D'Aprano wrote: >>>> Skybuck's experience at programming *is releva

OT: Hierarchies [was Re: Possibly better loop construct, also labels+goto important and on the fly compiler idea.]

2013-11-01 Thread Steven D'Aprano
27;s service at any time, or at least at any time within pre- defined boundaries (even servants get days off), and that he would have no right to refuse service. But that's not the case. He is a volunteer who is free to say No at any time, and the quickest way to get him to say No would be to treat him as a servant. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: trying to strip out non ascii.. or rather convert non ascii

2013-11-01 Thread Steven D'Aprano
On Thu, 31 Oct 2013 03:33:15 -0700, wxjmfauth wrote: > Le jeudi 31 octobre 2013 08:10:18 UTC+1, Steven D'Aprano a écrit : >> I'm glad that you know so much better than Google, Bing, Yahoo, and >> other >> search engines. When I search for "mispealled" Goo

Re: Possibly better loop construct, also labels+goto important and on the fly compiler idea.

2013-11-01 Thread Steven D'Aprano
are simply wrong. This is four posts in a row now that you have wrongly represented me. I can only conclude that you think that by repeating a lie often enough, you'll convince others that it must be true and "win". I will no longer play this game with you. Goodbye. *plonk* -- S

Re: Algorithm that makes maximum compression of completly diffused data.

2013-11-02 Thread Steven D'Aprano
application itself. Then, if you just look at the compressed file (the "data.zip" equivalent, although I stress that zip compression is *not* like this), you might think it has shrunk quite a lot. But when you include the hidden data, the compression is not quite so impressive... -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Possibly better loop construct, also labels+goto important and on the fly compiler idea.

2013-11-02 Thread Steven D'Aprano
email and ever more pedantic arguments about the precise wording. Even when all participants are arguing in good faith, they risk becoming quagmires which go nowhere in dozens of posts. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: How to use variables across modules

2013-11-02 Thread Steven D'Aprano
ike this, the question of how to use variables across modules is irrelevant. The right answer to the question "What's the best way to manage global variables across modules?" is "Don't". -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: zero argument member functions versus properties

2013-11-02 Thread Steven D'Aprano
t; to O(1) somehow (usually with lazy eval). So the implementation should > drive the property or not decision. I think that is reasonable. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Basic Python Questions - Oct. 31, 2013

2013-11-03 Thread Steven D'Aprano
y.blogspot.com.au/2011/06/speeding-up-python-numpy-cython-and.html -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Slicing with negative strides

2013-11-04 Thread Steven D'Aprano
On Mon, 04 Nov 2013 00:15:40 +0100, Martin Manns wrote: > On 29 Oct 2013 05:22:00 GMT > Steven D'Aprano wrote: > >> Does anyone here use slices (or range/xrange) with negative strides >> other than -1? > > I have used negative strides for comparing discrete

Re: Algorithm that makes maximum compression of completly diffused data.

2013-11-04 Thread Steven D'Aprano
othing to do with "n". But in case you actually meant "i", again you are mistaken. i is a symbolic name for an exact number. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Algorithm that makes maximum compression of completly diffused data.

2013-11-04 Thread Steven D'Aprano
On Tue, 05 Nov 2013 04:33:46 +, Steven D'Aprano wrote: > On Mon, 04 Nov 2013 14:34:23 -0800, jonas.thornvall wrote: > >> Den måndagen den 4:e november 2013 kl. 15:27:19 UTC+1 skrev Dave Angel: >>> On Mon, 4 Nov 2013 05:53:28 -0800 (PST), jonas.tho

Re: How to add a current string into an already existing list

2013-11-05 Thread Steven D'Aprano
ive interpreter: type() # replace the stars with the object and see what is printed. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: how to find out utf or not

2013-11-05 Thread Steven D'Aprano
"myfile" is (although sometimes you can make a good prediction: "my holiday picture" is probably a JPEG. And so it is with byte-strings. Unless you know where they came from and how they were prepared, you can't easily tell what encoding they used, at leas

Re: Help me with this code PLEASE

2013-11-05 Thread Steven D'Aprano
he way you want it to. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Help me with this code

2013-11-05 Thread Steven D'Aprano
nd use actual fractions, which will give you exact values instead of approximate. At the beginning of your code, put from fractions import Fraction and then change the code to look something like this: result += Fraction((-1) ** (k+1))/Fraction(2*k-1) -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Algorithm that makes maximum compression of completly diffused data.

2013-11-07 Thread Steven D'Aprano
. The ability to losslessly compress *everything* is sheer pseudo- mathematics, up there with finding an exact rational value for pi, or squaring the circle using only a compass and straight-edge. But the ability to losslessly compress *useful data* is real, and such algorithms operate by fi

Re: Show off your Python chops and compete with others

2013-11-07 Thread Steven D'Aprano
to allow those sorts of debating shenanigans, the obvious counter is "yes, but when I said that the function doesn't return None, I actually meant that it doesn't solve the Halting Problem, and it still doesn't do that, so I win nyah nyah nyah". -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Algorithm that makes maximum compression of completly diffused data.

2013-11-07 Thread Steven D'Aprano
ssion algorithm that can losslessly compress arbitrary random data of any length. I am as sure as this as I am sure you don't have a perpetual motion machine, a method for squaring the circle using only a compass and straight-edge, or a fool-proof system for winning the lottery every

Re: chunking a long string?

2013-11-08 Thread Steven D'Aprano
ave four bytes each for the two characters and a 40 byte header. Observe: py> c = '\U0001d11e' py> len(c) 1 py> sys.getsizeof(2*c) - sys.getsizeof(c) 4 py> sys.getsizeof(1000*c) - sys.getsizeof(999*c) 4 How big is the object overhead on a (say) thousand character string? Just one percent: py> (sys.getsizeof(1000*c) - 4000)/4000 0.01 -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: chunking a long string?

2013-11-08 Thread Steven D'Aprano
7;x') --> ABC DEF Gxx args = [iter(iterable)] * n return izip_longest(fillvalue=fillvalue, *args) grouper(your_string, 10, '') ought to give you the results you want. I expect (but haven't tested) that for strings, the slice version will be faster. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

The narcissism of small code differences

2013-11-09 Thread Steven D'Aprano
Uses an example written in Ruby, but don't let that put you off: http://raganwald.com/2008/05/narcissism-of-small-code-differences.html -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: To whoever hacked into my Database

2013-11-09 Thread Steven D'Aprano
ly on that -- if the attacker manages to discover that they use port 45081 instead of 22, they still have to defeat the normal ssh security before gaining access. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Sandboxing Python [was Re: New user's initial thoughts / criticisms of Python]

2013-11-09 Thread Steven D'Aprano
think it is recommended to use a chroot jail to lock access down to some subset of the file system. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: chunking a long string?

2013-11-09 Thread Steven D'Aprano
"123abc" py> v = "123abc" py> u is v True Hmmm, obviously the rules are a tad more complicated than I thought... in any case, you shouldn't rely on automatic interning since it is an implementation dependent optimization and will probably change without notice. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: chunking a long string?

2013-11-09 Thread Steven D'Aprano
ber=10)) 0.00881262868642807 String equality does a short-cut of checking for identity; if the strings are interned, they will be identical. [1] Assuming that you actually do have duplicate strings. If every string is unique, interning them potentially wastes memory. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: PyWart: Python modules are not so "modular" after all!

2013-11-10 Thread Steven D'Aprano
uot;] = any_object_you_like() Want a module with __setattr__ and __getattr__? Make a class, instantiate it, and shove it in sys.modules. This has worked since Python 2.1: http://code.activestate.com/recipes/65207-constants-in-python/ -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: New user's initial thoughts / criticisms of Python

2013-11-11 Thread Steven D'Aprano
although you're storing intervals as the keys, you're matching regular ints. I wonder if this would be a good use-case for Antoine Pitrou's TransformDict? http://www.python.org/dev/peps/pep-0455/ -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Getting globals of the caller, not the defining module

2013-11-11 Thread Steven D'Aprano
don't really want to do that. What (if anything) are my other options? -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Is anyone else unable to log into the bug tracker?

2015-02-26 Thread Steven D'Aprano
Malik Rumi wrote: > On Friday, January 9, 2015 at 7:49:09 PM UTC-6, Steven D'Aprano wrote: >> I'm having trouble logging into the bug tracker. Is anyone else having >> the same problem, that is, your user name and password worked earlier but >> doesn't wor

Re: Newbie question about text encoding

2015-02-26 Thread Steven D'Aprano
le corrupted byte can only corrupt a single code point. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Newbie question about text encoding

2015-02-26 Thread Steven D'Aprano
fo/2000-April/021070.html I quote: I do not see any need for a "double udaatta". Perhaps "double ANudaatta" is meant here? I don't know Sanskrit, but if somebody suggested that Unicode doesn't support English because the important letter "double-oh&quo

Re: Newbie question about text encoding

2015-02-26 Thread Steven D'Aprano
ch slower than real memory. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Newbie question about text encoding

2015-02-27 Thread Steven D'Aprano
Dave Angel wrote: > On 02/27/2015 12:58 AM, Steven D'Aprano wrote: >> Dave Angel wrote: >> >>> (Although I believe Seymour Cray was quoted as saying that virtual >>> memory is a crock, because "you can't fake what you ain't got.") >

Re: Python Worst Practices

2015-02-27 Thread Steven D'Aprano
a function are distinct from those outside. > * Design your syntax so that you can’t disambiguate them contextually > between bind and reference Do you have an example of where Python cannot distinguish between a binding operation and a reference? > * Be sure to use it in a late bound language where no warnings will be > provided about the mistake you’re making at authorship time, deferring the > educational experience to sundry run times Python raises a SyntaxError at compile time, not run time, if you try to bind to a keyword: py> global = 23 File "", line 1 global = 23 ^ SyntaxError: invalid syntax -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Python Worst Practices

2015-02-27 Thread Steven D'Aprano
Dan Sommers wrote: > On Sat, 28 Feb 2015 12:09:31 +1100, Steven D'Aprano wrote: > >> There's no harm in calling a local variable "id", if you don't use the >> built-in id() inside that function. That's one of the reasons why >> functions

Re: Python Worst Practices

2015-02-28 Thread Steven D'Aprano
thon%20Performance but overall, I think it's fair to say that IronPython is about 1.8 times the speed of CPython. > With any other implementation language, it would have ground to a halt. That's laughably inaccurate. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Python Worst Practices

2015-03-01 Thread Steven D'Aprano
tps://www.cs.utah.edu/~elb/folklore/mel.html even if he didn't use a magnetised needle and a steady hand. http://xkcd.com/378/ -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: suggestions for functional style (singleton pattern?)

2015-03-01 Thread Steven D'Aprano
Mario Figueiredo wrote: > (warning: Didn't bother prove-reading and spell chocking. Sorry...) Warning: didn't bother reading. Not sorry at all. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: suggestions for functional style (singleton pattern?)

2015-03-01 Thread Steven D'Aprano
alling them singletons just because they quack like singletons is a little weird. Next we'll be calling the Borg pattern "singletons". -- Steven -- https://mail.python.org/mailman/listinfo/python-list

OT Accents [was Re: Python Worst Practices]

2015-03-01 Thread Steven D'Aprano
ermit the Frog on helium. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

(Still OT) It's not the size of the vocabulary that matters, but what you do with it [was Re: Python Worst Practices]

2015-03-01 Thread Steven D'Aprano
Dennis Lee Bieber wrote: > Well... when we've got states bigger than some countries... A Texan farmer goes to Australia on vacation. There he meets an Aussie farmer and gets to talking. They walk around the farm a little, and the Aussie shows off his herd of cattle. The Texan immediately replie

Re: rst and pypandoc

2015-03-02 Thread Steven D'Aprano
the \r that is interpreted by python as special character. > > If I try to escape with '\' I don't seem to find a way out... Can you show what you are doing? Escaping the backslash with another backslash does work: py> for c in '\\ref': ... print(c, or

Re: date

2015-03-02 Thread Steven D'Aprano
014-12-27" py> another_day = datetime.strptime(astring, "%Y-%m-%d") py> difference = today - another_day py> difference.days 65 py> difference.days/7 # weeks 9.285714285714286 -- Steven -- https://mail.python.org/mailman/listinfo/python-list

(Still OT) Nationalism, language and monoculture [was Re: Python Worst Practices]

2015-03-02 Thread Steven D'Aprano
ws as the next guy. I'm allowed to take the parts of their culture I approve of and reject the parts I don't. [2] As opposed to the sense of secret codes and ciphers. [3] In the sense of air that we breathe. One can still have "airs and graces", although we rarely quantify just how many airs somebody is putting on. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: rst and pypandoc

2015-03-02 Thread Steven D'Aprano
Dave Angel wrote: > On 03/02/2015 08:51 AM, alb wrote: >> Hi Steven, >> >> Steven D'Aprano wrote: >> [] >>> Since \r is an escape character, that will give you carriage return >>> followed by "ef{fig:abc". >>> >>> The

Re: date

2015-03-02 Thread Steven D'Aprano
Mark Lawrence wrote: > Give me the Steven D'Aprano solution any day of > the week. Sounds ominous. Is that better or worse than the final solution? -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: rst and pypandoc

2015-03-02 Thread Steven D'Aprano
alb wrote: > Hi Steven, > > Steven D'Aprano wrote: > [] >> Since \r is an escape character, that will give you carriage return >> followed by "ef{fig:abc". >> >> The solution to that is to either escape the backslash: >> >> i

Re: rst and pypandoc

2015-03-02 Thread Steven D'Aprano
hadows. Take a step back, a deep breath, and remember your basic debugging skills: a = r'\\ref{fig:abc}' b = r'\ref{fig:abc}' print a == b print a, b print repr(a), repr(b) print len(a), len(b) I'm sure that you know how to do such simple things to investigate whether t

Re: rst and pypandoc

2015-03-02 Thread Steven D'Aprano
cape any actual percent signs in your text as '%%'. To be clear, what I'm doing here is using Python's % string interpolation to post-process the Latex output: - replace every '%' in your input string with '%%'; - replace every backslash in your input string with '%(b)s'; - convert; - post-process using %. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: (Still OT) Nationalism, language and monoculture [was Re: Python Worst Practices]

2015-03-02 Thread Steven D'Aprano
Sturla Molden wrote: > Steven D'Aprano wrote: > >> Variations in idiom and spelling are a good thing. They open our minds to >> new possibilities, remind us that we aren't all the same, and keep life >> fresh. I remember the first time I realised that when I

Re: Python Worst Practices

2015-03-02 Thread Steven D'Aprano
think that's bad, try pronouncing "ghoti" according to standard English rules: "gh" sounds like "f", like in "enough" (enuf). "o" sounds like "i", like in "women" (wimmin). "ti" sounds like "sh", like in "station" (stashun). So "ghoti" sounds like "fish". -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: (Still OT) Nationalism, language and monoculture [was Re: Python Worst Practices]

2015-03-02 Thread Steven D'Aprano
MRAB wrote: > There might be a difference, like that between "this program contains a > bug" and "this program contains one bug". Those two sentences mean exactly the same thing in standard American, British and Australian English. Pedants can argue whether "one bug" means *exactly* one bug, n

Re: (Still OT) Nationalism, language and monoculture [was Re: Python Worst Practices]

2015-03-02 Thread Steven D'Aprano
Chris Angelico wrote: > And I've seen a number of proposals to build Python with its > keywords localized. ChinesePython: http://www.chinesepython.org/english/english.html Teuton: http://www.fiber-space.de/EasyExtend/doc/teuton/teuton.htm -- Steve -- https://mail.python.org/mailman/listin

Re: Sort list of dictionaries

2015-03-03 Thread Steven D'Aprano
Charles Heizer wrote: > Hello, > I'm new to python and I'm trying to find the right way to solve this issue > I have. > > I'm trying to sort this list by name and then by version numbers. The > problem I'm having is that I can not get the version numbers sorted with > the highest at the top or so

Re: Newbie question about text encoding

2015-03-03 Thread Steven D'Aprano
snowman, I'm going to stick to ASCII"? The "whimsical" characters you are complaining about were important enough to somebody to spend significant amounts of time and money to write up a proposal, have it go through the Unicode Consortium bureaucracy, and eventually have it accep

Re: (Still OT) Nationalism, language and monoculture [was Re: Python Worst Practices]

2015-03-04 Thread Steven D'Aprano
eology professor was suspected of heresy. It went like this: [...] -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: io.open vs. codecs.open

2015-03-04 Thread Steven D'Aprano
.open (2.6 and later); * If you want the enhanced capabilities of Python 3 open, use io.open; * In Python 3, io.open is the same thing as built-in open; * And codecs.open is (I think) mostly there for backwards compatibility. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: (Still OT) Nationalism, language and monoculture [was Re: Python Worst Practices]

2015-03-04 Thread Steven D'Aprano
Marko Rauhamaa wrote: > Steven D'Aprano : > >> Care to enlighten us then? Because your anecdote doesn't appear to >> have even the most tenuous relationship to this discussion. > > English-speaker, when you name things in your Python programs, you had &g

Re: Newbie question about text encoding

2015-03-05 Thread Steven D'Aprano
ing due diligence?" Since Unicode has stability guarantees, and the encodings have not changed in twenty years and will not change in the future, this argument is bogus. Updating to a new version of the standard means, to a first approximation, merely allocating some new code points which had previously been undefined but are now defined. (Code points can be flagged deprecated, but they will never be removed.) -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: HELP!! How to ask a girl out with a simple witty Python code??

2015-03-05 Thread Steven D'Aprano
ual activity or the potential for sexual activity". Nor is any mild joke made at the (self-)expense of some random subgroup of people "sexism", whether than joke is based on a stereotype or not. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Newbie question about text encoding

2015-03-05 Thread Steven D'Aprano
[email protected] wrote: > On Thu, Mar 5, 2015, at 09:06, Steven D'Aprano wrote: >> I mostly agree with Chris. Supporting *just* the BMP is non-trivial in >> UTF-8 >> and UTF-32, since that goes against the grain of the system. You would >> have >> to p

Re: Is nan in (nan,) correct?

2015-03-05 Thread Steven D'Aprano
mizations, the core developers agreed that built-in contain types may assume that `x is y` implies `x == y`. Users of NANs and other non-reflexive types can subclass or define their own membership function. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: HELP!! How to ask a girl out with a simple witty Python code??

2015-03-05 Thread Steven D'Aprano
Ben Finney wrote: > Steven D'Aprano writes: > >> Ben Finney wrote: >> >> > [email protected] writes: >> > >> >> I should have known better than to make a joke on this mailing >> >> list. Someone is bound to get their pantie

Re: Newbie question about text encoding

2015-03-06 Thread Steven D'Aprano
wish to try. - If you are writing your own file system layer, it's 2015 fer fecks sake, file names should be Unicode strings, not bytes! (That's one part of the Unix model that needs to die.) You can use UTF-8 or UTF-16 in the file system, whichever you please, but again remember that both are variable-width formats. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Newbie question about text encoding

2015-03-06 Thread Steven D'Aprano
precede a high surrogate; I'm not convinced you should be allowed to create Unicode strings containing mismatched surrogates like this deliberately, but you certainly shouldn't be able to do so by accident. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Is nan in (nan,) correct?

2015-03-06 Thread Steven D'Aprano
l allow you to decide which operations should trap immediately and which don't, it's not a global all-or-nothing prospect. Alas, although many (most? all?) FPUs these days support these features, hardly any high-level language does. You typically cannot even control these features from C, but have to drop down to assembly. The fine control that IEEE-754 offers is under-utilized because the language designers don't support it. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Is nan in (nan,) correct?

2015-03-06 Thread Steven D'Aprano
ber. Ideally, it should carry diagnostic information so I can see what the failure was, for debugging, although I may not bother to do so that information should at least be available for use. I have just re-invented NANs. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: HELP!! How to ask a girl out with a simple witty Python code??

2015-03-06 Thread Steven D'Aprano
on the root cause of that, and whether or not mild put-downs such as the one in question are part of the cause or not. (Well, I call it a "mild put-down". Ben may or may not agree that it is mild.) -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Is nan in (nan,) correct?

2015-03-06 Thread Steven D'Aprano
ANs: def sorted(it): L = list(it) with disabled_nan_comparisons(): L.sort() # raise if L contains a NAN return L sort of thing. But either solution is a pretty big change for a pretty rare issue. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Is nan in (nan,) correct?

2015-03-06 Thread Steven D'Aprano
Rustom Mody wrote: > On Friday, March 6, 2015 at 10:13:55 PM UTC+5:30, Steven D'Aprano wrote: >> Rustom Mody wrote: >> >> > On Friday, March 6, 2015 at 3:57:12 AM UTC+5:30, [email protected] >> > wrote: >> >> It's been brought up on Stac

Re: A strange statement in the bisect documentation?

2015-03-06 Thread Steven D'Aprano
re the key function version becomes slower. Or possibly faster. - Is there are difference between fast key functions like str, and slow ones that have to do a lot of processing? -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Newbie question about text encoding

2015-03-07 Thread Steven D'Aprano
Rustom Mody wrote: > On Thursday, March 5, 2015 at 7:36:32 PM UTC+5:30, Steven D'Aprano wrote: [...] >> Chris is suggesting that going from BMP to all of Unicode is not the hard >> part. Going from ASCII to the BMP part of Unicode is the hard part. If >> you can do th

Re: Newbie question about text encoding

2015-03-07 Thread Steven D'Aprano
to three bytes using UTF-8: py> u'\udbff'.encode('utf-8') '\xed\xaf\xbf' py> u'\udf01'.encode('utf-8') '\xed\xbc\x81' giving six bytes in total: '\xed\xaf\xbf\xed\xbc\x81' This is not UTF-8! But some software mislabels it as UTF-8. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Newbie question about text encoding

2015-03-07 Thread Steven D'Aprano
Marko Rauhamaa wrote: > Steven D'Aprano : > >> Marko Rauhamaa wrote: >> >>> That said, UTF-8 does suffer badly from its not being >>> a bijective mapping. >> >> Can you explain? > > In Python terms, there are bytes objects b that do

Re: Newbie question about text encoding

2015-03-08 Thread Steven D'Aprano
Steven D'Aprano wrote: > Marko Rauhamaa wrote: > >> Steven D'Aprano : >> >>> Marko Rauhamaa wrote: >>> >>>> That said, UTF-8 does suffer badly from its not being >>>> a bijective mapping. >>> >>&g

Re: surprising exception text

2015-03-08 Thread Steven D'Aprano
) >> >> Cheers, >> Cameron Simpson >> > > What is the bug report number? > Who said it was a bug? Cameron called it "surprising", not "wrong". -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Newbie question about text encoding

2015-03-08 Thread Steven D'Aprano
specify the endianness (say, utf-16-be or -le) then you don't get the BOMs. > I was simply stating that UTF-8 is not a bijection between unicode > strings and octet strings (even forgetting Python). Enriching Unicode > with 128 surrogates (U+DC80..U+DCFF) establishes a bijection, but not > without side effects. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Newbie question about text encoding

2015-03-08 Thread Steven D'Aprano
Rustom Mody wrote: > On Saturday, March 7, 2015 at 4:39:48 PM UTC+5:30, Steven D'Aprano wrote: >> Rustom Mody wrote: >> > This includes not just bug-prone-system code such as Java and Windows >> > but seemingly working code such as python 3. >> >> W

Re: Newbie question about text encoding

2015-03-08 Thread Steven D'Aprano
Marko Rauhamaa wrote: > Steven D'Aprano : > >> Marko Rauhamaa wrote: >>> '\udd00' is a valid str object: >> >> Is it though? Perhaps the bug is not UTF-8's inability to encode lone >> surrogates, but that Python allows you to create lon

Re: Newbie question about text encoding

2015-03-08 Thread Steven D'Aprano
F-16 byte-strings. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Letter class in re

2015-03-09 Thread Steven D'Aprano
t; > I am using python 3.4 The re module in Python is pretty old and basic. Can you use Matthew Barnett's regex module, available on PyPI? I understand it has a richer set of flags for things such as Unicode letters and the like. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Use à Python 2 module with Python 3

2015-03-09 Thread Steven D'Aprano
g the documentation. So it may be worth just trying it and seeing for yourself. For PyQt specifically, googling suggests that PyQt does work with Python 3, but the documentation is out of date and you may have difficulty installing it: https://www.google.com.au/search?q=pyqt+python3 -- Steve

Re: Python3: Reading a text/binary mixed file

2015-03-09 Thread Steven D'Aprano
Paulo da Silva wrote: > Hi! > > What is the best way to read a file that begins with some few text lines > and whose rest is a binary stream? > > As an exmaple ... files .pnm. > > Thanks for any comments/help on this. A mixed text/binary file is really a binary file that contains some binary

Re: Did https://pypi.python.org/pypi/ became huge and slow?

2015-03-10 Thread Steven D'Aprano
loading via https, which has more overhead than http. There's a certificate that needs to be checked, the content can't be cached, and there's the cost of encryption. Do you have some reason for thinking that the content-length should not be 9870689 bytes? Should it be less or

Re: Did https://pypi.python.org/pypi/ became huge and slow?

2015-03-10 Thread Steven D'Aprano
OP: You're downloading the entire list of packages, which is > why it's taking so long. That seems to be the likely explanation. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Use à Python 2 module with Python 3

2015-03-11 Thread Steven D'Aprano
; Dose pyqt4 support Python 3 ? I can only repeat what I already wrote a few days ago: For PyQt specifically, googling suggests that PyQt does work with Python 3, but the documentation is out of date and you may have difficulty installing it: https://www.google.com.au/search?q=pyqt+python3

Re: __new__() does not return anything, on singletong pattern

2015-03-11 Thread Steven D'Aprano
Mario Figueiredo wrote: > I'm fairly new to Python, so I don't know if the following is me > abusing the programming language idioms, or simply a mistake of my IDE > code inspection routine. > > I have a singleton Map class which is defined like so: > > class Map: > _instance = None > de

Re: __new__() does not return anything, on singletong pattern

2015-03-12 Thread Steven D'Aprano
t tiresomely difficult). -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: __new__() does not return anything, on singletong pattern

2015-03-12 Thread Steven D'Aprano
Mario Figueiredo wrote: > On Thu, 12 Mar 2015 16:31:12 +1100, Steven D'Aprano > wrote: > >>Mario Figueiredo wrote: >> >> >>If this is supposed to be a singleton, you can't create more instances. >>The point of a singleton that there is only

Re: generator/coroutine terminology

2015-03-12 Thread Steven D'Aprano
ator object, which is a kind of iterator. > Same applies when foo is a 'coroutine' ie > something having yield used in an rhs and used with '.send' from outside: > What to call foo and what to call foo(x)? foo is a generator function, and foo(x) is a generator

Re: My emails are getting bounced?

2015-03-12 Thread Steven D'Aprano
has become a sad joke more often than not. [1] Hard to believe, but yes people do still use AOL. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

<    69   70   71   72   73   74   75   76   77   78   >