Re: Closures in leu of pointers?

2013-06-29 Thread Steven D'Aprano
were entirely different concepts, like a list and an int, you wouldn't have people confusing them. Nobody ever asks why Python doesn't let you sort an int, or take the square of a list... -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Closures in leu of pointers?

2013-06-29 Thread Steven D'Aprano
problem you want to solve, than the metaproblem of how to program Perl using Python syntax. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Unittest fails to import module

2013-06-29 Thread Steven D'Aprano
os.getenv('PYTHONPATH')) print(sys.path) What do they say? What should they say? The second step is to confirm that you can import the blablabla.py module. From the command line, cd into the code directory and start up a Python interactive session, then run "import blablabla" and

Re: Closures in leu of pointers?

2013-06-29 Thread Steven D'Aprano
On Sat, 29 Jun 2013 14:42:58 -0500, Tim Chase wrote: > On 2013-06-29 19:19, Steven D'Aprano wrote: >> Nobody ever asks why Python doesn't let you sort an int, or take the >> square of a list... > > just to be ornery, you can sort an int: > >>&g

Re: Closures in leu of pointers?

2013-06-30 Thread Steven D'Aprano
human reader, for example, may read the function once, and re-interprete what's already seen on the basis of what they've just seen. For a human reader, such backtracking is probably easier than a two-pass process explicitly memorizing which variables are local and which are global.

Re: Stupid ways to spell simple code

2013-06-30 Thread Steven D'Aprano
O0OO0O OO0O00 = range(5) list(OO0O0O(lambda O: any(O[O0] < O[O0-1] for O0 in range(1, sum(('O' for O in O), type('O', (), {'__add__': lambda O0O, OO0: OO0})()).count('O'))), (OOO00O(OO0O00) or OO0O00 for O in O0OO0O([0] -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Closures in leu of pointers?

2013-07-01 Thread Steven D'Aprano
Even if you believe that generator functions would have been better with different syntax, there is no evidence that re-using def is actively harmful. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: indexerror: list index out of range??

2013-07-01 Thread Steven D'Aprano
nd he can be very helpful (although sometimes abrasive). I think on balance, when he's not flaming, he makes a positive contribution to this community. The kill-filing is only temporary, and I look forward to seeing his posts again soon. Hopefully by that time, he'll stop feeling put-out a

Re: python adds an extra half space when reading from a string or list

2013-07-01 Thread Steven D'Aprano
tralia time). The above website is written for Java programmers, but the advice holds for any language including Python. The above of course assumes that I have not kill-filed you for continuing to be abusive on-list. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: python adds an extra half space when reading from a string or list

2013-07-01 Thread Steven D'Aprano
On Mon, 01 Jul 2013 16:28:52 +0300, Νίκος wrote: > Στις 1/7/2013 3:43 μμ, ο/η Steven D'Aprano έγραψε: [...] >> The above of course assumes that I have not kill-filed you for >> continuing to be abusive on-list. > > So, Steven you want me to sit tight and read all the

Re: python adds an extra half space when reading from a string or list

2013-07-01 Thread Steven D'Aprano
On Mon, 01 Jul 2013 15:08:18 +0200, Antoon Pardon wrote: > Op 01-07-13 14:43, Steven D'Aprano schreef: > >> Νίκος, I am not going to wade through this long, long thread to see >> what problem you are trying to solve today. > > Nikos is not trying to solve a problem

Re: PYTHONPATH and module names

2013-07-01 Thread Steven D'Aprano
necessary or not > allowed I not know :-) ] Not necessary. __future__ statements are guaranteed to "work" in all future versions, in the sense that once a __future__ feature is added, it will never be removed. So Python has had "nested scopes" since version 2.2 (by memory), but: from __future__ import nested_scopes still is allowed in Python 3.3, even though it has been a no-op since 2.2 or 2.3. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Stupid ways to spell simple code

2013-07-01 Thread Steven D'Aprano
rick, because calling f(5) returns 25. It's not: @gen def f(arg): return arg**2 because that raises TypeError. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: python adds an extra half space when reading from a string or list

2013-07-01 Thread Steven D'Aprano
ver you see me wearing a yellow hat, just turn away." > Let me know what you think about this. Sure, no problem. *plonk* -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: python adds an extra half space when reading from a string or list

2013-07-02 Thread Steven D'Aprano
to the behind over the internet, it is the best we can do. Oh, and one last point -- I have never kill-filed anyone merely for being the messenger that another person is causing trouble, as you suggest. I have kill-filed people for being abusive, for flaming, or for trolling. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: HTML Parser

2013-07-02 Thread Steven D'Aprano
oup+tutorial > I am looking for a good tutorial for HTMLParser or any similar parser > which have an .exe file for my environment and a good tutorial. Why do you care about a .exe file? Most Python libraries are .py files. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: how to calculate reputation

2013-07-02 Thread Steven D'Aprano
.html and I bring to your attention that this doesn't necessarily have anything to do with *sorting*. The Ruby function given returns a number between 0 and 1. You don't have to sort on that number, you can use that as your reputation. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: OSError [Errno 26] ?!?!

2013-07-02 Thread Steven D'Aprano
ts when i hit save in the text editor. >> >> CGI? Is this 2000? Nobody uses that wording these days. > > He is indeed using actual, bona fide CGI scripts. It's not just an > antiquated wording for "web app". CGI didn't stop working just because mo

Re: python adds an extra half space when reading from a string or list

2013-07-02 Thread Steven D'Aprano
to be a bit more patient to those who have trouble following the >> advise. > > It's quite clear that you're more interested in having arguments and > slinging insults than you are in discussing python. I'm here to discuss > python. Well said. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Python list code of conduct

2013-07-02 Thread Steven D'Aprano
I refer to state of maturity, not chronological age. Some people are adult at ten, others can live to ninety and never be worthy of the term. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Bug reports [was Re: Python list code of conduct]

2013-07-02 Thread Steven D'Aprano
ced? So anyway, if you're going to make a fool of yourself by loudly proclaiming that your broken code is a bug in the language, at least do it here rather than waste the time of the people actually working on Python :-) -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: python adds an extra half space when reading from a string or list

2013-07-02 Thread Steven D'Aprano
ept that Alex Martelli was right, although I still think that *failing an assignment* for a single unnecessary global declaration is unfairly harsh. [2] Sometimes it builds stronger, better character. Sometimes it builds weaker, broken character. It's all character. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: How to tell Script to use pythonw.exe ?

2013-07-02 Thread Steven D'Aprano
the file extension association and finds python.exe * Windows calls python.exe with the path to the script as argument * finally python.exe opens the script. Instead, you can use .pyw as the file extension, which should do what you want. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

OT Plague [was Re: python adds an extra half space when reading from a string or list]

2013-07-02 Thread Steven D'Aprano
ith the actual responses you are attempting to mock. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Python list code of conduct

2013-07-02 Thread Steven D'Aprano
Underground, which emphatically does not exist, then -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Why is CPython 2.5 a dependency for Jython 2.5?

2013-07-03 Thread Steven D'Aprano
2.5.1+ on Debian squeeze? -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Why is CPython 2.5 a dependency for Jython 2.5?

2013-07-03 Thread Steven D'Aprano
ly not: >>> sys.path ['', '/usr/lib/site-python', '/usr/share/jython/Lib', '__classpath__', '__pyclasspath__/', '/usr/share/jython/Lib/site-packages'] -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: DOS or not? [was Re: How to tell Script to use pythonw.exe ?]

2013-07-03 Thread Steven D'Aprano
l is aimed more for batch use rather than interactive use. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

[SPOILERS] Python easter eggs

2013-07-03 Thread Steven D'Aprano
Most people are familiar with: import this and sometimes even with: from __future__ import braces But I'm aware of at least three more. Anyone care to give them? -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: [SPOILERS] Python easter eggs

2013-07-03 Thread Steven D'Aprano
On Wed, 03 Jul 2013 10:15:22 -0600, Ian Kelly wrote: > And in Jython there's: > > from __future__ import GIL Nice one! I didn't know about that! -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Python list code of conduct

2013-07-03 Thread Steven D'Aprano
n-list This is the canonical archive for the list, and doesn't involve the atrocious Google Groups interface. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: python adds an extra half space when reading from a string or list

2013-07-03 Thread Steven D'Aprano
On Wed, 03 Jul 2013 11:08:11 -0700, rusi wrote: > And when Nikos moves up from petty criminal status to responsible > citizen, "Petty criminal status"? /headdesk -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: python adds an extra half space when reading from a string or list

2013-07-03 Thread Steven D'Aprano
t" is, well, bullshit. The first use of "civilization" in recorded English is from the 18th century, 1704, with the meaning of the legal process of turning a criminal case into a civil case. It didn't get it's modern meaning of the opposite of barbarism until the second half

Default scope of variables

2013-07-03 Thread Steven D'Aprano
riables considered harmful", one of the classic papers of computer science: http://c2.com/cgi/wiki?GlobalVariablesConsideredHarmful [2] Actually, Javascript gives you something a little closer to Python's "nonlocal" by default: each enclosing function is searched for a matching variable, terminating at the global scope. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Default scope of variables

2013-07-03 Thread Steven D'Aprano
On Thu, 04 Jul 2013 14:07:55 +1000, Chris Angelico wrote: > On Thu, Jul 4, 2013 at 1:27 PM, Steven D'Aprano > wrote: >> With respect to the Huffman coding of declarations, Javascript gets it >> backwards. Locals ought to be more common, but they require more >> typ

Re: Default scope of variables

2013-07-03 Thread Steven D'Aprano
es the problem of inner i overwriting outer i nicely. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Important features for editors

2013-07-04 Thread Steven D'Aprano
orum to make such offers. Thank you Robert. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Important features for editors

2013-07-04 Thread Steven D'Aprano
al" as Nikos. Speaking of petty, this whole witch-hunt is getting ridiculous. Don't you have something more productive to do? Accusing people of colluding in crimes because they fail to be sufficiently zealous in "objecting to the crime" is nuts. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Default scope of variables

2013-07-04 Thread Steven D'Aprano
On Thu, 04 Jul 2013 03:06:25 -0400, Dave Angel wrote: > On 07/04/2013 01:32 AM, Steven D'Aprano wrote: >> > >> >> Well, if I ever have more than 63,000,000 variables[1] in a function, >> I'll keep that in mind. >> > >> >&g

Re: Default scope of variables

2013-07-04 Thread Steven D'Aprano
On Thu, 04 Jul 2013 15:47:57 +1000, Chris Angelico wrote: > On Thu, Jul 4, 2013 at 3:32 PM, Steven D'Aprano > wrote: >> Accidental shadowing can be a problem, but I've never heard of anyone >> saying that they were *forced* to shadow a global they needed access >&

Re: Default scope of variables

2013-07-04 Thread Steven D'Aprano
LLIC CAPITAL LETTER ZHE True Lu ᚃ OGHAM LETTER FEARN True Lo ‰ PER MILLE SIGN False Po ⇄ RIGHTWARDS ARROW OVER LEFTWARDS ARROW False So ∞ INFINITY False Sm -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: How is this evaluated

2013-07-04 Thread Steven D'Aprano
g-tested, value-if-true, value-if-false) The condition being tested is, "l in consonants". The value if true is "l + 'o' + l". And the value if false is just l. So putting this all together, we can convert the generator expression version to this longer, but more r

Re: How is this evaluated

2013-07-05 Thread Steven D'Aprano
On Fri, 05 Jul 2013 17:05:49 +1000, Chris Angelico wrote: > On Fri, Jul 5, 2013 at 11:41 AM, Steven D'Aprano > wrote: >> If you know C, that's like: >> >> ?(condition-being-tested, value-if-true, value-if-false) > > Or to be precise: > > con

Re: question please

2013-07-05 Thread Steven D'Aprano
dy else's? -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: How to make this faster

2013-07-05 Thread Steven D'Aprano
the way, I'm not exactly sure how you go from "I don't do numerical calculations on numpy arrays" to "therefore Python should have arrays". -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: How to make this faster

2013-07-05 Thread Steven D'Aprano
... you should consider writing this: for r, row in enumerate(grid): for c, value in enumerate(row): ... -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: How to make this faster

2013-07-05 Thread Steven D'Aprano
e, plus some unknown error, somewhere between the smallest error and the biggest error; whereas the minimum gives you: - some unknown "true" time, plus the smallest error yet seen. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: How to make this faster

2013-07-05 Thread Steven D'Aprano
pre-existing list is just being grabbed, which is fast. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

How to check for threads being finished?

2013-07-05 Thread Steven D'Aprano
? Should I stick a call to time.sleep() inside the while loop? If so, how long should I sleep? That's probably an unanswerable question, but some guidelines on choosing the sleep time will be appreciated. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: How to check for threads being finished?

2013-07-05 Thread Steven D'Aprano
On Fri, 05 Jul 2013 19:12:44 +0200, Irmen de Jong wrote: > On 5-7-2013 18:59, Steven D'Aprano wrote: >> I then block until the threads are all done: >> >> while any(t.isAlive() for t in threads): >> pass >> >> >> Is that the right way to wa

Re: How to make this faster

2013-07-05 Thread Steven D'Aprano
On Fri, 05 Jul 2013 18:39:15 +, Helmut Jarausch wrote: > On Fri, 05 Jul 2013 16:50:41 +0000, Steven D'Aprano wrote: > >> On Fri, 05 Jul 2013 16:07:03 +, Helmut Jarausch wrote: >> >>> The solution above take 0.79 seconds (mean of 100 calls) while the

Re: Editor Ergonomics [was: Important features for editors]

2013-07-06 Thread Steven D'Aprano
down the rate of keystrokes and uses different muscle groups. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Numeric coercions

2013-07-06 Thread Steven D'Aprano
some operation which is guaranteed to promote any numeric type to float, but not strings? For the record, calling promote() as above is about 7 times slower than calling float in Python 3.3. [1] Or should that be demote? -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Numeric coercions

2013-07-06 Thread Steven D'Aprano
On Sun, 07 Jul 2013 05:17:01 +0100, Joshua Landau wrote: > On 7 July 2013 04:56, Steven D'Aprano > wrote: ... >> def promote(x): >> if isinstance(x, str): raise TypeError return float(x) >>>> from operator import methodcaller >>>> safe_fl

Re: Default scope of variables

2013-07-07 Thread Steven D'Aprano
c.__defaults__ = func.__defaults__ return newfunc And in use: py> f = chained_function(lambda x: x+y, {'y': 100}) py> f(1) 101 py> f.__globals__.maps.insert(0, {'y': 200}) py> f(1) 201 py> del f.__globals__.maps[0]['y'] py> f(1) 101 -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Default scope of variables

2013-07-07 Thread Steven D'Aprano
's a much more common need than being able to have an x inside the loop and an x outside the loop. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Default scope of variables

2013-07-07 Thread Steven D'Aprano
feel your pain, but I wonder why we sometimes accept "a line of code can't be moved around" as an issue to be solved by the language. After all, in general most lines of code can't be moved around. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Default scope of variables

2013-07-07 Thread Steven D'Aprano
On Mon, 08 Jul 2013 13:11:37 +1000, Chris Angelico wrote: > On Mon, Jul 8, 2013 at 12:23 PM, Steven D'Aprano > wrote: >> On Mon, 08 Jul 2013 10:48:03 +1000, Chris Angelico wrote: [...] >>> That means that I, as programmer, have to keep track of the nesting >>>

Re: hex dump w/ or w/out utf-8 chars

2013-07-07 Thread Steven D'Aprano
sSynchro+='c'+sLineHexND[k+1]+sLineHexND[k+2]+sLineHexND[k +3]+'2e' > k+=3 > elif sLineHexND[k]=='e': > sSynchro+='e'+sLineHexND[k+1]+sLineHexND[k+2]+sLineHexND[k +3]+\ > sLineHexND[k+4]+sLineHexND[k+5]+'2e2e' > k+=5 Apart from being hideously ugly to read, I do not believe this code works the way you think it works. Adding to the loop variable doesn't advance the loop. Try this and see for yourself: for i in range(10): print(i) i += 5 The loop variable just gets reset once it reaches the top of the loop again. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Important features for editors

2013-07-07 Thread Steven D'Aprano
On Sun, 07 Jul 2013 23:16:39 -0700, jussij wrote: > I couldn't live without the keyboard macro record and playback. I used to work with a programmer who couldn't live without his insulin injections. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Editor Ergonomics [was: Important features for editors]

2013-07-08 Thread Steven D'Aprano
On Sun, 07 Jul 2013 22:34:46 -0700, jussij wrote: > On Sunday, July 7, 2013 12:41:02 PM UTC+10, Steven D'Aprano wrote: > >> I am not an ergonomic expert, but I understand that moving from mouse >> to keyboard actually helps prevent RSI, because it slows down the rate &g

Re: A small question about PEP 8

2013-07-08 Thread Steven D'Aprano
ne up _under_ the last item? ISTM the code > isn't consistent with the description. I agree. I think it is just a mistake, and should say "under the FIRST item of the list". -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: A small question about PEP 8

2013-07-08 Thread Steven D'Aprano
itional line. At least this time I'm in good company, since that's recommended by PEP 8. > Or you can (be sane) and put it at no indentation: > > """ > a_wonderful_set_of_things = { > ..., > not_missing_an_end_brace > } > """ I consider that the least aesthetically pleasing, and also rather awkward: some_result = some_function( arg1, arg2, arg3, arg4, [item1, item2, item3, item4, item5, item6, item7, item8, item9, item10, ], arg6, key=spam, word=eggs, extras=None, foo=bar, ) -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: ipython

2013-07-08 Thread Steven D'Aprano
et any errors? Try going to the Start menu, selecting the Run command, and typing ipython [enter]. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: looking for a new router

2013-07-08 Thread Steven D'Aprano
On Mon, 08 Jul 2013 21:52:19 -0700, saadharana wrote: > Hey i'm looking for a new router. I recommend this one: http://www.bunnings.com.au/products_product_1350w-aeg-12-router-rt1350e_P6230066.aspx Helpfully-as-ever-ly yrs, -- Steven -- http://mail.python.org/mailman/listinf

Re: hex dump w/ or w/out utf-8 chars

2013-07-08 Thread Steven D'Aprano
for Latin characters in two forms: "half-width" and "full-width". The half-width form took up a single fixed-width column; the full-width forms took up two fixed-width columns, so they would line up nicely in columns with Asian characters. See also: http://www.unicode.org/reports/tr11/ and search Wikipedia for "full-width" and "half-width". -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: hex dump w/ or w/out utf-8 chars

2013-07-08 Thread Steven D'Aprano
for Python 2.x, and not using u'' for strings, then you're making a rod for your own back. Do yourself a favour and get into the habit of always using u'' strings in Python 2. I'll-start-taking-my-own-advice-next-week-I-promise-ly yrs, -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: hex dump w/ or w/out utf-8 chars

2013-07-09 Thread Steven D'Aprano
ld-fashioned way of writing AE. But to Danes and Norwegians, Æ is an ordinary letter, as distinct from AE as TH is from Þ. (Which English used to have.) And so on... I don't know what a special character is, unless it is the ASCII NUL character, since that terminates C strings. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: hex dump w/ or w/out utf-8 chars

2013-07-09 Thread Steven D'Aprano
entype.info/blog/2011/01/24/capital-sharp-s/ http://en.wikipedia.org/wiki/Capital_ẞ Font support is still quite poor, but at least half a dozen Windows 7 fonts provide it, and at least one Mac font. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Stack Overflow moderator “animuson”

2013-07-10 Thread Steven D'Aprano
On Wed, 10 Jul 2013 18:26:19 +1000, Chris Angelico wrote: > On Wed, Jul 10, 2013 at 5:55 PM, Mats Peterson wrote: >> A moderator who calls himself “animuson” on Stack Overflow doesn’t want >> to face the truth. He has deleted all my postings regarding Python >> regular expression matching being e

Re: Babel i18n package has new maintainers

2013-07-10 Thread Steven D'Aprano
I thought I'd post > this here to make others aware of it. Thanks Stefan, it's good to see informative posts about Python packages. I personally don't need it, but I'll keep it in mind for the future. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Stack Overflow moderator “animuson”

2013-07-10 Thread Steven D'Aprano
arefully contrived micro- benchmarks using a beta version of Python 3.3, non-ASCII string operations can be marginally slower than in 3.2. > Additionally my account has been suspended for 7 days. Such a dickwad. I cannot imagine why he would have done that. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Stack Overflow moder ator “animuson”

2013-07-10 Thread Steven D'Aprano
On Wed, 10 Jul 2013 08:46:44 +, Mats Peterson wrote: > Chris Angelico wrote: >> On Wed, Jul 10, 2013 at 6:33 PM, Mats Peterson >> wrote: >>> Steven D'Aprano wrote: >>>> On Wed, 10 Jul 2013 18:26:19 +1000, Chris Angelico wrote: [...] >>>>

Re: Prime number generator

2013-07-10 Thread Steven D'Aprano
m have? I can't directly answer that question, but I can make a shameless plug for this: https://pypi.python.org/pypi/pyprimes If your prime generator performs better than, or worse than, all of those in the above module, I may have to steal it from you :-) -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: ANN: psutil 1.0.0 released

2013-07-10 Thread Steven D'Aprano
On Wed, 10 Jul 2013 17:46:13 +0200, Giampaolo Rodola' wrote: > Hi there folks, > I'm pleased to announce the 1.0.0 release of psutil: > http://code.google.com/p/psutil/ Congratulations on the 1.0.0 release! -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: StackOverflowmoderator “animuson”

2013-07-10 Thread Steven D'Aprano
27;s regex implementation was slower than Perl's. So what? Do you have a patch? -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Stack Overflow moderator “animuson”

2013-07-10 Thread Steven D'Aprano
On Wed, 10 Jul 2013 16:54:02 +0100, Joshua Landau wrote: > On 10 July 2013 10:00, Steven D'Aprano wrote: >> On Wed, 10 Jul 2013 07:55:05 +, Mats Peterson wrote: >> >>> A moderator who calls himself “animuson” on Stack Overflow doesn’t >>> want to

Re: Stack Overflow moderator “animuson”

2013-07-10 Thread Steven D'Aprano
On Wed, 10 Jul 2013 18:53:34 +0100, Joshua Landau wrote: > I might be misattributing posts then. Or... YOU'RE IN DENIAL! Ranting Rick? Is that you? :-) > Who wins? You decide! Ah, definitely not RR :-) -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Documenting builtin methods

2013-07-10 Thread Steven D'Aprano
fficient a way > to set documentation, and would hamper introspection)? > > How about dropping the "simply" requirement? I don't believe so. [1] IronPython and Jython both currently do the same thing as CPython, so even if this is not explicitly language-defined behaviour, it looks like it may be de facto standard behaviour. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Documenting builtin methods

2013-07-11 Thread Steven D'Aprano
On Thu, 11 Jul 2013 17:06:39 +1000, Chris Angelico wrote: > On Thu, Jul 11, 2013 at 4:06 PM, Steven D'Aprano > wrote: >> I think the right solution here is the trivial: >> >> def exhaust(it): >> """Doc string here.""" >>

Mypy

2013-07-11 Thread Steven D'Aprano
Things are certainly heating up in the alternate Python compiler field. Mypy is a new, experimental, implementation of Python 3 with optional static typing and aiming for efficient compilation to machine code. http://www.mypy-lang.org/index.html -- Steven -- http://mail.python.org/mailman

Re: Callable or not callable, that is the question!

2013-07-11 Thread Steven D'Aprano
eful slacker and did not. However there was a discussion in this thread: http://mail.python.org/pipermail/python-dev/2011-March/109090.html Here's a simpler demonstration of the issue: assert callable(staticmethod(lambda: None)) -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Editor Ergonomics [was: Important features for editors]

2013-07-11 Thread Steven D'Aprano
k, let alone micro-optimizations like these. The difference between a 60 wpm typist and a 90 wpm typist is normally that the 90 wpm typist can introduce bugs 50% faster :-) I'm joking, of course, but typing *accuracy* is far more important than typing speed. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: hex dump w/ or w/out utf-8 chars

2013-07-11 Thread Steven D'Aprano
that (say) a C compiler can tell the difference between the long 1199876496 and the float 67923.125? They both have exactly the same four bytes: py> import struct py> struct.pack('f', 67923.125) b'\x90\xa9\x84G' py> struct.pack('l', 1199876496) b'\x90\xa9\x84G' *Everything* in a computer is bytes. The only way to tell them apart is by external markers. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Editor Ergonomics [was: Important features for editors]

2013-07-11 Thread Steven D'Aprano
mes even close to a real mouse for feedback and ease of use. Maybe a stylus. But that's it. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: How do I get the OS System Font Directory(Cross-Platform) in python?

2013-07-11 Thread Steven D'Aprano
at last you have a simple function get_font_directory() that works everywhere. Now that you see how complex it is to write this "simple" function, are you surprised that one doesn't yet exist? :-) -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Callable or not callable, that is the question!

2013-07-12 Thread Steven D'Aprano
have two functions for something which is conceptually one? -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: hex dump w/ or w/out utf-8 chars

2013-07-12 Thread Steven D'Aprano
than merely an o or c in superscript. Nevertheless, in mathematics at least, it is normal to leave out the radian sign when talking about angles. By default, "1.2" means "1.2 radians", not "1.2 degrees". -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: RE Module Performance

2013-07-12 Thread Steven D'Aprano
uot; \ > "if 'b' in data: pass" 100 loops, best of 3: 0.219 usec per loop In Python, we often use plain string operations instead of regex-based solutions for basic tasks. Regexes are a 10lb sledge hammer. Don't use them for cracking peanuts. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: How do I get the OS System Font Directory(Cross-Platform) in python?

2013-07-13 Thread Steven D'Aprano
e are a few de- facto standard locations. For more information, see for example: http://www.centos.org/docs/5/html/Deployment_Guide-en-US/s1-x-fonts.html -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: help with explaining how to split a list of tuples into parts

2013-07-13 Thread Steven D'Aprano
ht: spam, ham, eggs = [(1, 2, 3, 4)][0][1:] Can you see why the last one works? The word you are looking for is "slicing", and you can test it like this: print( [100, 200, 300, 400, 500][1:] ) print( [100, 200, 300, 400, 500][2:4] ) print( [100, 200, 300, 400, 500][2:5] ) > .

Re: hex dump w/ or w/out utf-8 chars

2013-07-13 Thread Steven D'Aprano
uffer[5-1] # character to the left of the caret '5' py> buffer[5] # character to the right of the caret '\ud83d' Funny, that looks different. py> unicodedata.name(buffer[5]) Traceback (most recent call last): File "", line 1, in ValueError: no such name No name? Because buffer[5] is only *half* of the surrogate pair. It is broken, and there is really no way of fixing that breakage in Python 3.2 with a narrow build. You can fix it with a wide build, but only at the cost of every string, every name, using double the amount of storage, whether it needs it or not. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: hex dump w/ or w/out utf-8 chars

2013-07-13 Thread Steven D'Aprano
t; for n in (1, 2**20, 2**30, 2**31, 2**65): ... print repr(n), type(n), sys.getsizeof(n) ... 1 12 1048576 12 1073741824 12 2147483648L 18 36893488147419103232L 22 You have been using Flexible Integer Representation for *years*, and it works great, and you've never noticed any pro

Re: Ideal way to separate GUI and logic?

2013-07-13 Thread Steven D'Aprano
from the internal logic. But, my guess is that for anything non-trivial, you probably should have one main module handling the UI, and a second (and possibly more) modules handling the implementation, plus at least one other module for testing. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: [Python-ideas] float('∞')=float('inf')

2013-07-13 Thread Steven D'Aprano
On Sun, 14 Jul 2013 11:53:55 +1000, Chris Angelico wrote: > Doh, I forgot which channel this was on again :( It feels like a > python-list thread. Can't you just hit Reply-List or even Reply-All? -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Beazley 4E P.E.R, Page29: Unicode

2013-07-14 Thread Steven D'Aprano
he original poster did, and then decode those bytes to a string, you will get what you expect. Using Python 2.5, where the b prefix is not needed: py> tasty = 'Jalape\xc3\xb1o' # actually bytes py> tasty.decode('utf-8') u'Jalape\xf1o' py> print tasty.decode('utf-8') # oops I forgot to reset my terminal JalapeУБo py> print tasty.decode('utf-8') # terminal now set to UTF-8 Jalapeño > Could someone take the time to read carefully and clarify what DB is > saying?? Hope this helps. [1] Assume the font file is 100K in size, and it has glyphs for 256 characters. That works out to 195 bytes per glyph. [2] Technically, the UTF-8 scheme can handle 31-bit code points, up to the (hypothetical) code point U+7FFF, using up to six bytes per code point. But Unicode officially will never go past U+10, and so UTF-8 also will never go past four bytes per code point. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: hex dump w/ or w/out utf-8 chars

2013-07-14 Thread Steven D'Aprano
years after Latin-1 was already in use in people's computers. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Ideal way to separate GUI and logic?

2013-07-14 Thread Steven D'Aprano
vate, internal only functions. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: what thread-synch mech to use for clean exit from a thread

2013-07-14 Thread Steven D'Aprano
urrencyExchange(in_case = callback) > agio.start() > > Go_On = True > while Go_On: >do_something_delicate(rate_supplied_by=agio) Change to: while agio.updates_seen: do_something_delicate... -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: what thread-synch mech to use for clean exit from a thread

2013-07-14 Thread Steven D'Aprano
Oh, I forgot another comment... On Mon, 15 Jul 2013 03:04:14 +, Steven D'Aprano wrote: > On Mon, 15 Jul 2013 10:27:45 +0800, Gildor Oronar wrote: >>while time.time() - self.rate_timestamp < 5*3600: >> ... # update exchange rate

<    1   2   3   4   5   6   7   8   9   10   >