Re: [on topic] Re: readline trick needed

2012-10-16 Thread Steven D'Aprano
On Tue, 16 Oct 2012 13:20:24 +0100, Robert Kern wrote: > On 10/16/12 12:27 PM, Steven D'Aprano wrote: >> Well, I was hoping for a pure Python solution, rather than having to >> troll through who knows how many thousands of lines of code in a >> language I can barely re

Re: Aggressive language on python-list

2012-10-16 Thread Steven D'Aprano
behaviour? How will others know that I do not agree with your advice? -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: OT Questions

2012-10-16 Thread Steven D'Aprano
h your preferred name (David rather than Dwight). You might not realise that your "From address" still says Dwight -- I had to manually change it above. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Aggressive language on python-list

2012-10-16 Thread Steven D'Aprano
On Tue, 16 Oct 2012 14:10:17 -0700, rurpy wrote: > On 10/16/2012 10:49 AM, Steven D'Aprano wrote: >> > On Tue, 16 Oct 2012 09:27:48 -0700, rurpy wrote about trolls and >> > dicks: > > No, I wrote about trolls. "dicks" is a highly emotive and almost

Re: Aggressive language on python-list

2012-10-16 Thread Steven D'Aprano
On Wed, 17 Oct 2012 02:45:04 +, Steven D'Aprano wrote: > Dwight "call me David, but I can't be bothered changing my signature" > Hutto's behaviour. I withdraw this dig at David Hutto. It was unnecessary, and it turns out, wrong as he has now changed his s

Re: Aggressive language on python-list

2012-10-16 Thread Steven D'Aprano
are that even if I'm not interested in it, it is a part of Python culture and *somebody* needs to deal with it. I'm just glad its not me. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: OT Questions

2012-10-17 Thread Steven D'Aprano
r had me tested!". >> >> > Someone insulted my intelligence, and stated how they worked with much > smarter people... Much smarter people than *himself*, not smarter than you. Demian made no comment about *your* intelligence. > this was just a confidence statement that I'm > intelligent as well, so don't get uppity with me. Please tone down the aggression. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Script for finding words of any size that do NOT contain vowels with acute diacritic marks?

2012-10-17 Thread Steven D'Aprano
atic and a poor design, you weren't directly the target of the comment. I'm glad you already knew what Ian said, but you're not the only person reading this thread. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Aggressive language on python-list

2012-10-17 Thread Steven D'Aprano
On Wed, 17 Oct 2012 14:10:34 -0700, rurpy wrote: > On 10/17/2012 02:28 PM, Oscar Benjamin wrote:> On 17 October 2012 19:16, > Chris Angelico wrote: >>> On Thu, Oct 18, 2012 at 3:48 AM, wrote: >>>>On 10/16/2012 08:45 PM, Steven D'Aprano wrote: >>>&g

Re: Aggressive language on python-list

2012-10-17 Thread Steven D'Aprano
for a couple of days and then come back focused on Python, rather than on defending yourself against real or imagined slights. I'm not your dad and I'm not sending you to your room, but sometimes a man has to know when it's best to just walk away and let things cool off, regardless of

Re: A desperate lunge for on-topic-ness

2012-10-17 Thread Steven D'Aprano
s in the line was the impetus that finally made you act. > 6. Realise that if it's that long, it probably shouldn't have been a > list comprehension in the first place. What if it wasn't a list comp in the first place? :) Refactoring code makes most long lines go away on their own. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: unittest for system testing

2012-10-18 Thread Steven D'Aprano
x27;fileC'] def testFilesExist(self): for name in self.list_of_files: assertTrue(os.path.exists(name) total_tests, failed_tests = unittest.testmod() # I think... if failed_tests != 0: sys.exit(1) run_application() I think the first sample is much to be prefe

Re: A desperate lunge for on-topic-ness

2012-10-18 Thread Steven D'Aprano
Error: invalid token Honestly, it's not that hard to diagnose line continuation errors. It's probably easier to diagnose them than to diagnose missing parentheses. The more I hear people dissing line continuation backslashes, the more I want to use them everywhere. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: A desperate lunge for on-topic-ness

2012-10-18 Thread Steven D'Aprano
Or possibly they're just unlucky to require a library with excessively long names and can't do much about it. I'm not saying that every line that exceeds 79 characters is crap, but I am saying that if you have trouble keeping *at least* 90% of your code under 79 characters, you may ve

Re: A desperate lunge for on-topic-ness

2012-10-18 Thread Steven D'Aprano
r the hard parts, not the easy parts, and so you should treat vertical space is cheaper than horizontal space, and try to keep your line length down. And note that, even when writing, most of your time is problem spent in writing what is already there. Coding is rarely like typing out di

Re: Add if...else... switch to doctest?

2012-10-18 Thread Steven D'Aprano
ction to take an argument and re-write the doctest: >>> function(True) [1, 2] >>> function(False) [1, 2, 3] And now you have good code and a good doctest. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: A desperate lunge for on-topic-ness

2012-10-18 Thread Steven D'Aprano
y that Keynes, and Adam Smith for that matter, would have agreed with him. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: section with in a section config file and reading that config file

2012-10-19 Thread Steven D'Aprano
wise the OP could write his own code, possibly by subclassing from ConfigParser. A simple google for "python ini file nested sections" finds this: http://wiki.python.org/moin/ConfigParserShootout -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Python does not take up available physical memory

2012-10-19 Thread Steven D'Aprano
when you try to run it. A 64-bit build requires a 64-bit operating system and 64-bit hardware. A 32-bit build can be used in either system. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Python does not take up available physical memory

2012-10-19 Thread Steven D'Aprano
try to work with it one line at a time: for line in open("some file"): process(line) rather than reading the whole file into memory at once: lines = open("some file").readlines() for line in lines: process(line) -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: A desperate lunge for on-topic-ness

2012-10-19 Thread Steven D'Aprano
long, because it can always be shortened. Some code might be more conveniently written as a single long line. But I would argue that nearly never is code more easily *read* as a single long line, and since code is read much more than it is written, it is more important to optimise for reading, not w

Re: section with in a section config file and reading that config file

2012-10-19 Thread Steven D'Aprano
On Fri, 19 Oct 2012 23:59:03 +0200, Tarek Ziadé wrote: > On 10/19/12 11:29 PM, Steven D'Aprano wrote: >> On Fri, 19 Oct 2012 12:09:53 +0200, Tarek Ziadé wrote: >> >>> On 10/19/12 11:51 AM, kampy wrote: >>>> hi all, >>>> my requirement is to hav

Re: A desperate lunge for on-topic-ness

2012-10-21 Thread Steven D'Aprano
at does what in preparation to refactoring it. > Seriously -- I can't remember the last time I printed souce code... I've never printed souce code either *wink* -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: A desperate lunge for on-topic-ness

2012-10-21 Thread Steven D'Aprano
On Sun, 21 Oct 2012 20:20:41 +1100, Chris Angelico wrote: > On Sun, Oct 21, 2012 at 7:07 PM, Steven D'Aprano > wrote: >> On Sat, 20 Oct 2012 14:18:47 +, Grant Edwards wrote: >>> True, but nobody prints source code out on paper do they? >> >> I do. >&

Re: A desperate lunge for on-topic-ness

2012-10-21 Thread Steven D'Aprano
On Sun, 21 Oct 2012 22:43:07 +1100, Chris Angelico wrote: > On Sun, Oct 21, 2012 at 9:00 PM, Steven D'Aprano > wrote: >> Er, no. Note spelling of "source code" vs "souce code". Hence the grin. > > Ahh. I totally didn't see that, I'm way too

Re: Recursive Generator Error?

2012-10-21 Thread Steven D'Aprano
ion directly will raise error, is > it right? You can call the function directly, and it will return an generator object. You don't have to iterate over that generator object, although you normally will. Example: py> def test(): ... yield 42 ... py> test py> type(test)

Re: A desperate lunge for on-topic-ness

2012-10-21 Thread Steven D'Aprano
On Mon, 22 Oct 2012 07:22:18 +1100, Chris Angelico wrote: > On Mon, Oct 22, 2012 at 6:11 AM, Steven D'Aprano > wrote: >>> Ahh. I totally didn't see that, I'm way too used to reading past >>> typos. >> >> As a programmer, doesn't that

Re: A desperate lunge for on-topic-ness

2012-10-23 Thread Steven D'Aprano
in File "", line 3, in test NameError: global name 'cos' is not defined So, legal or not, they're definitely something you want to avoid. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Fast forward-backward (write-read)

2012-10-23 Thread Steven D'Aprano
s of the 1960s and 70s will never be obsolete. No matter how much memory you have, there will always be times when you want to process more data than you can fit into memory. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: A desperate lunge for on-topic-ness

2012-10-23 Thread Steven D'Aprano
On Tue, 23 Oct 2012 17:24:34 -0600, Ian Kelly wrote: > On Tue, Oct 23, 2012 at 4:34 PM, Steven D'Aprano > wrote: >> On Tue, 23 Oct 2012 10:50:11 -0600, Ian Kelly wrote: >> >>>> if someone is foolish enough to use the >>>> >>>> f

Re: Split single file into multiple files based on patterns

2012-10-24 Thread Steven D'Aprano
. Are you just excited and want to tell everyone, or do you actually have a question? Have you tried to write some code, or do you just expect others to do your work for you? If so, I see that your expectation was correct. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Fast forward-backward (write-read)

2012-10-24 Thread Steven D'Aprano
requires that forward is a non- lazy (eager) sequence. So again you're stuck trying to read the entire file into RAM. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Listen for changes in variable (alsaaudio.Mixer(x,x).getvolume(x)

2012-10-24 Thread Steven D'Aprano
olume in the first place. If it is written to a file, you can listen for changes to the file without polling on Linux systems. > If this is not possible with Python, any suggestions on what else are > also welcome of course. That's not a Python question, it's an Alsa question. Who

Re: resume execution after catching with an excepthook?

2012-10-24 Thread Steven D'Aprano
platform-specific code to get a key press: http://code.activestate.com/recipes/577977 Note however that it blocks if there is no key press waiting. I suspect that you may need a proper event loop, as provided by GUI frameworks, or curses. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: [OT] Re: turn list of letters into an array of integers

2012-10-25 Thread Steven D'Aprano
e -- that beast bit me! I don't think so. Are you thinking of the famous Monty Python "Dead Parrot Sketch"? Here's one of many versions: http://www.youtube.com/watch?v=4vuW6tQ0218 -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: while expression feature proposal

2012-10-25 Thread Steven D'Aprano
so handle the full range of generator behaviour, and allow generator code to be refactored in a simple and straightforward way. [end quote] http://www.python.org/dev/peps/pep-0380/ "yield from" is a *huge* win in terms of correctness and power, not just a trivial saving in lines

Re: resume execution after catching with an excepthook?

2012-10-25 Thread Steven D'Aprano
On Fri, 26 Oct 2012 01:51:43 +1100, Chris Angelico wrote: > On Thu, Oct 25, 2012 at 12:15 PM, Steven D'Aprano > wrote: >> I don't believe that there is any >> way to jump back to the line of code that just failed (and why would >> you, it will just fail again)

Re: bit count or bit set && Python3

2012-10-25 Thread Steven D'Aprano
mber=100, repeat=7)) 4.141788959503174 That makes the "inelegant" solution using bin() and count() about 600 times faster than the mathematically clever solution using bitwise operations. On the other hand, I'm guessing that PyPy would speed up MRAB's version significantly. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: bit count or bit set && Python3

2012-10-25 Thread Steven D'Aprano
On Thu, 25 Oct 2012 09:17:40 -0700, rusi wrote: > On Oct 25, 8:57 pm, Steven D'Aprano [email protected]> wrote: >> On Fri, 26 Oct 2012 02:31:53 +1100, Chris Angelico wrote: >> > On Fri, Oct 26, 2012 at 2:25 AM, Christian Heimes >> > wrote: >&

Re: bit count or bit set && Python3

2012-10-25 Thread Steven D'Aprano
nders when you divide the number by successively larger powers of some base.: 123 = 1*10**2 + 2*10**1 + 3*10**0 Hence, mathematical. Of course, none of this challenges the fact that, at least in Python, reasoning about digits is often best done on the string representation rather than t

Re: a.index(float('nan')) fails

2012-10-25 Thread Steven D'Aprano
ot;"Return the index of the first NAN in seq, otherwise None.""" for i, x in enumerate(seq): if isnan(x): return i For old versions of Python that don't provide an isnan function, you can do this: def isnan(x): return x != x -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: a.index(float('nan')) fails

2012-10-25 Thread Steven D'Aprano
prior to the IEEE 754 standard. Seriously, there are some real horror stories about numerical computing back in the Bad Old Days. Like computers where 1.0/x could give a divide- by-zero error even though x == 0 returned False. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: better way for ' '.join(args) + '\n'?

2012-10-26 Thread Steven D'Aprano
gt; >def helper(s): >for i in s[:-1]: > yield i > yield ' ' >yield s[-1] >yield '\n' >line = ''.join(tmp(args)) > > Efficiency-wise, this is satisfactory. Have you actually tested this? I would not be the least surprised if that's actually less efficient than the (' '.join(seq) + '\n') version. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: while expression feature proposal

2012-10-26 Thread Steven D'Aprano
On Fri, 26 Oct 2012 17:23:12 +1100, Chris Angelico wrote: > Why is everyone skirting around C-style assignment expressions as though > they're simultaneously anathema and the goal? :) Only if your goal is to introduce an anathema :P -- Steven -- http://mail.python.org/mailman/list

Re: a.index(float('nan')) fails

2012-10-26 Thread Steven D'Aprano
On Fri, 26 Oct 2012 03:54:02 -0400, Terry Reedy wrote: > On 10/25/2012 10:44 PM, Steven D'Aprano wrote: >> On Thu, 25 Oct 2012 22:04:52 -0400, Terry Reedy wrote: >> >>> It is a consequence of the following, which some people (but not all) >>> be

Re: a.index(float('nan')) fails

2012-10-26 Thread Steven D'Aprano
ading to loss of precision or even completely wrong answers. Once NANs were introduced, keeping reflexivity would lead to even worse situations than x != x. It would lead to nonsense identities like log(-1) ==log(-2), hence 1 == 2. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: a.index(float('nan')) fails

2012-10-26 Thread Steven D'Aprano
On Sat, 27 Oct 2012 03:45:46 +1100, Chris Angelico wrote: > On Sat, Oct 27, 2012 at 3:23 AM, Steven D'Aprano > wrote: >> In real life, you are *much* more likely to run into these examples of >> "insanity" of floats than to be troubled by NANs: >>

Re: while expression feature proposal

2012-10-26 Thread Steven D'Aprano
. if x is None or x is False: return yield x for x in iterate_until_none_or_false( some_function, 1, 2, "c", spam="yummy"): process(x) -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: attaching names to subexpressions

2012-10-28 Thread Steven D'Aprano
is probably better put into fixing bugs. There is a great shortage of time and manpower for the Python developers, there is a list of open bugs half a mile long. Every minute spent adding new syntax for some minor benefit is time that could be fixing bugs that cause actual problems with r

Re: Negative array indicies and slice()

2012-10-29 Thread Steven D'Aprano
the reply is going to python-list. Then hit Send. (P.S. when you signed up for [email protected], if you selected the option to receive a single daily digest instead of individual emails, you're going to have a bad time. Do yourself a favour -- and the rest of us -- and change b

Re: Negative array indicies and slice()

2012-10-29 Thread Steven D'Aprano
flexible, less efficient. [snip] > In 'C', where Python is written, That's a popular misapprehension. Python is written in Java, or Lisp, or Haskell, or CLR (dot Net), or RPython, or Ocaml, or Parrot. Each of those languages have, or had, at least one Python implementation. Oh, there's also a version written in C, or so I have heard. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Negative array indicies and slice()

2012-10-29 Thread Steven D'Aprano
40]" 100 loops, best of 3: 0.342 usec per loop [steve@ando ~]$ python2.7 -m timeit -s "x = range(100, 1000, 2)" "[x[i] for i in xrange(20, 40)]" 10 loops, best of 3: 3.43 usec per loop -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Negative array indicies and slice()

2012-10-29 Thread Steven D'Aprano
On Mon, 29 Oct 2012 11:19:38 +, Steven D'Aprano wrote: > Because xrange represents a concrete sequence of numbers, all three of > start, end and stride must be concrete, known, integers: > > py> xrange(4, None, 2) > Traceback (most recent call last): > File "

Re: Immutability and Python

2012-10-29 Thread Steven D'Aprano
e-instances-in-python.html -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Immutability and Python

2012-10-29 Thread Steven D'Aprano
d the examples provided by namedtuple's creator, Raymond Hettinger, that is precisely one of the styles he uses. No need to explicitly declare the base class before using it. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Nice solution wanted: Hide internal interfaces

2012-10-29 Thread Steven D'Aprano
access the functions in the callback dictionary. So you gain nothing but extra work. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Immutability and Python

2012-10-29 Thread Steven D'Aprano
et more clumsy in the immutable form, for > example in the mutable form I would do simply this: > > number = NumWrapper(1) > number.increment() > > while with immutability I have to do this instead: > new_number = number.increment() Why is this clumsy? Do you have problems with this? x = 1 y = x+1 -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Immutability and Python

2012-10-29 Thread Steven D'Aprano
On Mon, 29 Oct 2012 15:45:59 -0700, Chris Kaynor wrote: > On Mon, Oct 29, 2012 at 3:30 PM, Steven D'Aprano > wrote: >> On Mon, 29 Oct 2012 17:05:07 +, andrea crotti wrote: >> >>> I meant how do I create new immutables classes myself, I guess that's &g

Re: Negative array indicies and slice()

2012-10-29 Thread Steven D'Aprano
f code written in pure Python, because it sometimes can be useful. It flat out prohibits monkey-patching of builtins, because it is just too dangerous. Ruby allows monkey-patching of everything. And the result was predictable: http://devblog.avdi.org/2008/02/23/why-monkeypatching-is-destroying-ruby/ -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Negative array indicies and slice()

2012-10-30 Thread Steven D'Aprano
By the way Andrew, the timestamps on your emails appear to be off, or possibly the time zone. Your posts are allegedly arriving before the posts you reply to, at least according to my news client. On Mon, 29 Oct 2012 12:34:24 -0700, Andrew Robinson wrote: > On 10/29/2012 05:02 PM, Ste

Re: Negative array indicies and slice()

2012-10-31 Thread Steven D'Aprano
gurus of Python history. He invented Python's astonishingly excellent sort routine, Timsort, and popularised the famous adverbial phrase signoffs you will see in a lot of older posts. Basically, he is in the pantheon of early Python demigods. stop-me-before-i-start-gushing-over-the-timbot-ly y'rs, -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Obnoxious postings from Google Groups

2012-10-31 Thread Steven D'Aprano
s, but regarding your second point, it has seemed to me for some years now that Gmail is the new Hotmail, which was the new AOL. Whenever there is an inane, lazy, mind-numbingly stupid question or post, chances are extremely high that the sender has a Gmail address. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: sort order for strings of digits

2012-10-31 Thread Steven D'Aprano
; sorted(L, key=split) ['1', '1a', '9', '55', '55a', '1000', 'abc', 'abc2'] The above solution is not quite general: * it doesn't handle negative numbers or numbers with a decimal point; * it doesn't handle the empty string in any meaningful way; * in practice, you may or may not want to ignore leading whitespace, or trailing whitespace after the number part; * there's a subtle bug if a string contains a very large numeric prefix, finding and fixing that is left as an exercise. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: sort order for strings of digits

2012-10-31 Thread Steven D'Aprano
mbda a, b: cmp(abs(a), abs(b))) ... time taken: 63.579679 seconds The Timer() context manager used can be found here: http://code.activestate.com/recipes/577896 -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: sort order for strings of digits

2012-11-01 Thread Steven D'Aprano
On Thu, 01 Nov 2012 11:53:06 +1100, Chris Angelico wrote: > On Thu, Nov 1, 2012 at 10:44 AM, Steven D'Aprano > wrote: >> On the contrary. If you are using cmp with sort, your sorts are slow, >> and you should upgrade to using a key function as soon as possible. >>

Re: Obnoxious postings from Google Groups

2012-11-01 Thread Steven D'Aprano
nd especially C, you're not a real programmer. Real programmers use modern, advanced languages like D, Erlang, Go or Haskell. [1] "Ancient" is a frame of mind, not a chronological state. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Negative array indicies and slice()

2012-11-01 Thread Steven D'Aprano
and constantly allocating and de-allocating memory? Or a tuple? Same again. Some sort of object has to be created. And I have no idea what you are talking about "twice over". What "repetitive method which computers dynamic values"? In any case, I return to my comment earlier in thi

Re: Organisation of python classes and their methods

2012-11-02 Thread Steven D'Aprano
ocumentation per method? As far as I'm concerned that's > not a smell, that's a stink. Depends on the method. For some, 20 lines is 18 lines too many. For others, that's 80 lines too few. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Proper place for everything

2012-11-02 Thread Steven D'Aprano
lity issues, policies, and design decisions. Frequently there are (mis-)features that we simply have to live with, for good or ill. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Proper place for everything

2012-11-02 Thread Steven D'Aprano
for email and news, and Google requires you to sign in just to read the archives, which in my opinion is morally indefensible. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Proper place for everything

2012-11-02 Thread Steven D'Aprano
ng attention. You probably would have got some answers, even if they were only "take it to a specialist PyGTK mailing list". -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: How to generate account number?

2012-11-02 Thread Steven D'Aprano
rested? Read more here: If you ask a question here, please keep the discussion here, don't split it to your personal blog. Tell us your requirements in more detail, and we will try to help you. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: enabling universal newline

2012-11-02 Thread Steven D'Aprano
ines remains None: py> f = open('test.txt') py> f.newlines py> f.readlines() ['a\n', 'b\n', 'c\n', 'd\n'] py> f.newlines ('\r', '\n', '\r\n') py> sys.stdin.newlines is None True -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Organisation of python classes and their methods

2012-11-02 Thread Steven D'Aprano
laced into a single module when the code is related. But in my opinion, you should not split a logical single unit of code, a module of related code, into separate files just because it is "too big" until it is at least as large as decimal.py. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Organisation of python classes and their methods

2012-11-02 Thread Steven D'Aprano
On Sat, 03 Nov 2012 01:06:45 +, Steven D'Aprano wrote: > 100 lines is approximately and a half pages using a 10pt font size > (depending on the font and the platform, of course). Crap. I meant approx *one* and a half pages. -- Steven -- http://mail.python.org/mailman/list

Re: Organisation of python classes and their methods

2012-11-02 Thread Steven D'Aprano
hese methods in their own file, grouped nicely in sub-directories. Ewww. Ewww ewww ewww ewww. Just reading about it makes me feel dirty. Seriously. That means any time you want to jump back and forth from one method to another method OF THE SAME CLASS, you have to change files. Yuck. -- Ste

Re: Obnoxious postings from Google Groups

2012-11-03 Thread Steven D'Aprano
On Sat, 03 Nov 2012 10:24:15 -0400, Dave Angel wrote: > For the DOS world, real programmers have written a "complete" *.com > program using only echo. Echo? Wimps. Real programmers write their code directly on the surface of the hard drive using only a magnetised needle. --

Re: is implemented with id ?

2012-11-03 Thread Steven D'Aprano
s.set_default(s, s) to ensure you are always working with a single string object for each unique value. In some applications that will save time at the expense of space. And there is no need to write "is" instead of "==", because string equality already optimizes the "strings are identical" case. By using ==, you don't get into bad habits, you defend against the odd un-interned string sneaking in, and you still have high speed equality tests. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: is implemented with id ?

2012-11-03 Thread Steven D'Aprano
This has been discussed before: you don't need to compare very many > characters to conclude that strings are unequal (if I remember correctly > you were part of that discussion). On average. Worst case, you have to look at every character. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Proper place for everything

2012-11-04 Thread Steven D'Aprano
On Sat, 03 Nov 2012 22:19:19 -0700, Aahz wrote: > In article <[email protected]>, Steven > D'Aprano wrote: >>On Fri, 02 Nov 2012 04:20:20 -0700, Jason Benjamin wrote: >>> >>> Anybody know of the appropriate place to

Re: Coordination between developers in the Python project

2012-11-05 Thread Steven D'Aprano
e any of that. > For all you know, bit.ly records the ip address of each click. You use gmane to post here. How do you know that they aren't recording your IP address? If they are, what are they going to do with it? What nefarious use do you think people are going to do with your IP address? -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Obnoxious postings from Google Groups

2012-11-05 Thread Steven D'Aprano
then typed Ctrl-J to get a newline. [steve@ando temp]$ ls foo?bar [steve@ando temp]$ python -c "import os > for nm in os.listdir('.'): print repr(nm)" 'foo\nbar' -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Obnoxious postings from Google Groups

2012-11-05 Thread Steven D'Aprano
s, then you need something else to be an argument separator. Or you need argument delimiters. Or strings need to be quoted. Programming languages do these things because they are designed to be correct. Shell do not because they are designed for lazy users and merely aim to be "good enough". -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Multi-dimensional list initialization

2012-11-06 Thread Steven D'Aprano
cts. People will make a 2D array like so: [[0]*5]*10 and it will work. Then they'll write this: [{}]*5 and wonder why it doesn't work the way they expect. Consistency is *much* more valuable than ad hoc DWIM semantics. Languages that try to Do What I Mean somehow end up Doing What Somebody Else Meant, But Not Me. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Obnoxious postings from Google Groups

2012-11-06 Thread Steven D'Aprano
; for the same effect. Well, I learned something new about bash. On the other hand, the Ctrl-Q next-char-is-literal trick works for entering control characters that otherwise don't have a key on the keyboard. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Obnoxious postings from Google Groups

2012-11-06 Thread Steven D'Aprano
ated, and as always, the fact that everything is text in bash means it is way harder than it needs to be to use rich, modern data structures. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: clicking on turtle

2012-11-06 Thread Steven D'Aprano
I can confirm that the same behaviour occurs in Python 2.7 on Linux. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Obnoxious postings from Google Groups

2012-11-06 Thread Steven D'Aprano
On Tue, 06 Nov 2012 23:08:11 +, Prasad, Ramit wrote: > Steven D'Aprano wrote: >> >> On Tue, 06 Nov 2012 17:16:44 +, Prasad, Ramit wrote: >> >> >> To enter the newline, I typed Ctrl-Q to tell bash to treat the next >> >> character as

Re: Multi-dimensional list initialization

2012-11-06 Thread Steven D'Aprano
hey copied? What about mutable objects which are uncopyable, like file objects? > Every time someone passes a list to a function, they *know* that the > list is passed by value -- and the elements are passed by reference. And there goes the last of your credibility. *You* might "know" this, but that doesn't make it so. Python does not use either call-by-value or call-by-reference, and it certainly doesn't use different calling conventions for different arguments or parts of arguments. Everything is passed using the same calling convention. Start here: http://mail.python.org/pipermail/tutor/2010-December/080505.html > People in Python are USED to lists being "the" way to weird behavior > that other languages don't do. Python's calling behaviour is identical to that used by languages including Java (excluding unboxed primitives) and Ruby, to mention only two. You're starting to shout and yell, so perhaps it's best if I finish this here. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Multi-dimensional list initialization

2012-11-06 Thread Steven D'Aprano
by object reference - call by object - call by value, where "values" are references (according to the Java community) - call by reference, where "references" refer to objects, not variables (according to the Ruby community) - reference semantics Anything else? http://en.wik

Re: Obnoxious postings from Google Groups

2012-11-07 Thread Steven D'Aprano
On Wed, 07 Nov 2012 18:52:16 +1300, Gregory Ewing wrote: > Steven D'Aprano wrote: >> The downside is that if spaces are not argument separators, then you >> need something else to be an argument separator. Or you need argument >> delimiters. Or strings need to be quoted

Re: Multi-dimensional list initialization

2012-11-07 Thread Steven D'Aprano
y are old, venerable terms dating back to Algol and possibly even older. All the way back to Fortran perhaps? > What about binding in general, eg "x = y"? Does it make sense to still > call it "call by ..."? Sure, why not? The person who prepares beef tartare or sushimi

Re: Right solution to unicode error?

2012-11-07 Thread Steven D'Aprano
act copy and paste of the error, or have you edited it or reconstructed it? Because it seems to me that if task.subject is a unicode string, as it appears to be, calling print on it should succeed: py> s = u'ABC\u2013DEF' py> print s ABC–DEF What does type(task.subject) return? -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: [Python-ideas] sys.py3k

2012-11-07 Thread Steven D'Aprano
On Thu, 08 Nov 2012 10:14:35 +1100, Chris Angelico wrote: > On Thu, Nov 8, 2012 at 5:35 AM, anatoly techtonik > wrote: >> I thought of sys.py3k check ... Chris, you regularly reply to the wrong mailing list, and you've just done it again. This is not python-ideas. --

Re: Multi-dimensional list initialization

2012-11-07 Thread Steven D'Aprano
ot;pass by foo", but nobody has been able to explain the difference (if any) to me. When you CALL a function, you PASS values to it. Hence the two terms are effectively synonyms, and both refer to the evaluation strategy when binding arguments to parameters. If you believe that is incorrect,

Re: Multi-dimensional list initialization

2012-11-07 Thread Steven D'Aprano
ss by ..." when talking about binding arguments to formal parameters. His objection to "call by ..." is that it doesn't make it clear that the evaluation rules apply to simple binding/assignment as well as calling functions. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Multi-dimensional list initialization

2012-11-07 Thread Steven D'Aprano
m yes? The programmer has to remember Python's execution model in order to correctly predict what Python will do. What's your point? > A single exception exists; There is no such exception in Python. Python always uses the same argument passing (parameter binding) semantics. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: isinstance(.., file) for Python 3

2012-11-08 Thread Steven D'Aprano
gh to treat as a file pass That means that you can also use io.StringIO objects as pseudo-files too. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: duck typing assert‏

2012-11-08 Thread Steven D'Aprano
ot;, but doesn't say what the purpose of the package is: core features of *what*? And the examples.rst file doesn't show any examples. https://bitbucket.org/akorn/wheezy.core/src/ca5b902e9605/doc/examples.rst -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: duck typing assert‏

2012-11-08 Thread Steven D'Aprano
the same interface: IFoo.bar # returns a computed property Foo.bar() # calls a method Since the interfaces are different, duck-typing will fail. It will actually fail in a potentially nasty way: x = Foo.bar # doesn't raise an exception, gives the method object # ... much later do_someth

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