Re: Discussion on some Code Issues

2012-07-08 Thread Steven D'Aprano
bility, but uses > language that actually is quite incorrect. It's a better explanation, > though. Hang on, you say that an explanation which is "quite incorrect" is *better* than one which is correct? I can see why they call the card "Madness". :-P -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Discussion on some Code Issues

2012-07-09 Thread Steven D'Aprano
rom DNA to computers to corporations, and even people. But it does depend on context. Sometimes you need more detail than just "Python looks". You need to know precisely *how* Python looks, and how it decides whether it has found or not. And note that I'm still using the intent

Re: Python Interview Questions

2012-07-10 Thread Steven D'Aprano
rience with Python 1.5, 2.3 and 2.4 on Centos systems. Of course, if they try to sell themselves as having five years experience with Python 3.2 and they don't know anything about the with statement, that tells you everything you need to know. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Python Interview Questions

2012-07-10 Thread Steven D'Aprano
s close enough. Of course, an acceptable answer would be "buggered if I know, but if you give me a minute, I'll google it for you". -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Python Interview Questions

2012-07-10 Thread Steven D'Aprano
On Tue, 10 Jul 2012 10:11:22 +0200, Christian Heimes wrote: > Am 10.07.2012 09:33, schrieb Steven D'Aprano: >> This is why I hate job interviews. You have like 30 minutes, or even as >> little as 30 seconds, to make a good impression on somebody who may or >> may not

Re: Python Interview Questions

2012-07-10 Thread Steven D'Aprano
On Wed, 11 Jul 2012 02:59:15 +1000, Chris Angelico wrote: > On Wed, Jul 11, 2012 at 2:51 AM, Steven D'Aprano > wrote: >> If only that were true. I know quite a few people who looked the >> interviewer straight in the eye and told the most bare-faced lies >> without

Re: Opening multiple Files in Different Encoding

2012-07-10 Thread Steven D'Aprano
y auto-detecting the encodings. The chardet module should help you there. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Opening multiple Files in Different Encoding

2012-07-11 Thread Steven D'Aprano
;.bmp". Then what do you expect to do? You can open the file as a binary blob, but what do you expect then? f = open("my_file_name.bmp", "rb") Now what do you want to do with it? > 2) I can not assign > encoding="..." whatever be the encoding I have to re

Re: lambda in list comprehension acting funny

2012-07-11 Thread Steven D'Aprano
s about lambda that fools people into thinking that it is different (I've even been fooled myself!) but it is not. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: lambda in list comprehension acting funny

2012-07-11 Thread Steven D'Aprano
er, decimal, functools, gettext, inspect, pydoc, symtable, uuid, and others. pydoc and idlelib in particular make heavy use of lambda, and the test suite is overflowing with them -- over 600 uses in total. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: lambda in list comprehension acting funny

2012-07-11 Thread Steven D'Aprano
ur-banger. I managed to persuade the team I was on that an RPN > calculator would be simpler to (potentially) implement... And THEN > persuaded them to NOT use the equivalent of an ALU class, but to put the > math work into each operation button... "ALU class"? Googling gives me

Re: lambda in list comprehension acting funny

2012-07-11 Thread Steven D'Aprano
en a functor, either in the Haskell sense or the C++ sense. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: lambda in list comprehension acting funny

2012-07-11 Thread Steven D'Aprano
te order. That's because partial only applies positional arguments from the left. If there was a "right partial" that applies from the right, we could use the built-in instead: funcs = [rpartial(pow, i) for i in range(5)] -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: lambda in list comprehension acting funny

2012-07-11 Thread Steven D'Aprano
or. Yo dawg, I heard you liked functors, so I put a functor in your functor so you can train your markov chains with extra functor parameters to functor objects that are functor factory decorator functors. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: lambda in list comprehension acting funny

2012-07-12 Thread Steven D'Aprano
may not store values by name, but the principle is sound: the function, when called later, looks up the current value of variable i, which is not necessarily the same as it was when the closure was originally defined. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: How to safely maintain a status file

2012-07-12 Thread Steven D'Aprano
at the device's choosing, do they actually write data to the physical media. The result of this is that even when the device tells you that the data is synched, it may not be. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: adding a simulation mode

2012-07-12 Thread Steven D'Aprano
ase leave enough quoted to establish context. Neither email nor usenet are guaranteed delivery services, and they certainly don't guarantee to deliver messages in order. Assume that your readers may not have seen the message you are replying to, and you will probably get more and better re

Re: adding a simulation mode

2012-07-12 Thread Steven D'Aprano
Mwahahaha my pretty, you cannot cancel this!!!") print("...er, now what do I do?") except Exception: print("why am I catching exceptions I can't recover from?") -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: adding a simulation mode

2012-07-12 Thread Steven D'Aprano
s anyway. Well of course it does. If copytree fails, the try block ends and execution skips straight to the except block, which runs, and then the program halts because there's nothing else to be done. That at least is my guess, based on the described symptoms. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: How to safely maintain a status file

2012-07-12 Thread Steven D'Aprano
ite to it myfile.append('some data') # delete it from the "file system" del ns['a'] # but I can still read and write to it myfile.append('more data') print(myfile[0]) # but anyone else will get an error if they try another_file = ns['a'] -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: How to safely maintain a status file

2012-07-12 Thread Steven D'Aprano
tive programs, one which keeps a lock on only the last block of the file, and a tail-like reader which honours that lock. But why bother? Just have the assembler append to the file, and let people use any reader they like, such as tail. Or have I misunderstood you? -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: lambda in list comprehension acting funny

2012-07-12 Thread Steven D'Aprano
1: http://www.haskell.org/ghc/ :? for help > > Prelude> let funcs = [ (\ x -> x ^ i)| i <- [0..4]] > Prelude> (funcs !! 0)(2) > 1 > Prelude> (funcs !! 1)(2) > 2 > Prelude> (funcs !! 2)(2) > 4 > Prelude> -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: How to safely maintain a status file

2012-07-13 Thread Steven D'Aprano
On Thu, 12 Jul 2012 21:26:20 -0700, rantingrickjohnson wrote: > On Thursday, July 12, 2012 10:13:47 PM UTC-5, Steven D'Aprano wrote: >> Rick has obviously never tried to open a file for reading when somebody >> else has it opened, also for reading, and discovered that desp

Re: code review

2012-07-13 Thread Steven D'Aprano
hon does not allow assignment as an expression, so you can't make the typical C error of: if x = y: do_something() # oops meant x == y -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: How to safely maintain a status file

2012-07-13 Thread Steven D'Aprano
or, this may appear mysterious. The solution is to us lsof to identify the unlinked file, which gives you the process id of the application, which you can then kill. As soon as you do that, the space is freed up again. Like all powerful tools, unlinked files can be abused. Underpowered tools c

Re: howto do a robust simple cross platform beep

2012-07-13 Thread Steven D'Aprano
a standard way to play a simple alert sound. Why ask for volunteers to write and maintain the code, and suddenly they go silent. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: lambda in list comprehension acting funny

2012-07-13 Thread Steven D'Aprano
As far as I can tell, Python always uses late binding for scopes; the only time it does early binding is for default values of function parameters. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: lambda in list comprehension acting funny

2012-07-14 Thread Steven D'Aprano
On Fri, 13 Jul 2012 21:53:10 -0700, rusi wrote: > On Jul 14, 8:43 am, Steven D'Aprano +comp.lang.pyt...@pearwood.info> wrote: >> On Fri, 13 Jul 2012 19:31:24 -0700, rusi wrote: >> > Consider the following >> >> > def foo(x): >> >     i = 100 &g

Re: lambda in list comprehension acting funny

2012-07-14 Thread Steven D'Aprano
d, or when the closure is called. > late binding being the > feature that makes duck typing possible. That is conflating two entirely distinct subjects. Python 1.5 had duck- typing but no closures, so the one certainly does not depend on the other. Duck-typing is more a philosophy than a language feature: the language must be typed, and the programmer must prefer to program to a protocol or a specification rather than to membership of a type. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: lambda in list comprehension acting funny

2012-07-15 Thread Steven D'Aprano
On Sun, 15 Jul 2012 10:49:48 +1000, Chris Angelico wrote: > On Sun, Jul 15, 2012 at 9:29 AM, Steven D'Aprano > wrote: >> Not necessarily *compile* time, but the distinction is between when the >> function is defined (which may at compile time, or it may be at run &

Re: Implicit conversion to boolean in if and while statements

2012-07-15 Thread Steven D'Aprano
ang.python/msg/2de5e1c8384c0360?hl=en Sadly, or happily, Python did grow True and False values, but the fundamental distinction between something and nothing still exists. (For the record, I can only think of one trap for the unwary: time objects are false at *exactly* midnight.) -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Implicit conversion to boolean in if and while statements

2012-07-15 Thread Steven D'Aprano
On Sun, 15 Jul 2012 10:19:16 -0600, Ian Kelly wrote: > On Sun, Jul 15, 2012 at 4:56 AM, Steven D'Aprano > wrote: >> (For the record, I can only think of one trap for the unwary: time >> objects are false at *exactly* midnight.) > > Ugh, that's irritating. I c

Re: Implicit conversion to boolean in if and while statements

2012-07-15 Thread Steven D'Aprano
On Sun, 15 Jul 2012 12:02:37 -0500, Andrew Berg wrote: > On 7/15/2012 5:56 AM, Steven D'Aprano wrote: >> 3) Rather than distinguishing "true" from "false", a more useful >> dichotomy is between "something" and "nothing". Python include

Re: Implicit conversion to boolean in if and while statements

2012-07-15 Thread Steven D'Aprano
ing the content of the test or program code or both. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Implicit conversion to boolean in if and while statements

2012-07-15 Thread Steven D'Aprano
es are not interchangeable just because > they can be converted to booleans, so you wouldn't lose much by being > forced to explicitly convert to boolean with something > interface-specific. Until somebody writes an awesomely fast stack class in C and gives it an is_empty() met

Re: Implicit conversion to boolean in if and while statements

2012-07-16 Thread Steven D'Aprano
True, and True == 1, you should be able to convert x into 1. But that's crazy, since x = [None, 42, '']. *shrug* I don't call this a gotcha, but it is one of the more ugly consequences of Python's bool implementation. > Can you > reduce this to the absurd? Or will you just choose to ignore this valid > point? Mu. (Neither true nor false.) -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Implicit conversion to boolean in if and while statements

2012-07-16 Thread Steven D'Aprano
such value", and that's exactly how I am using it, even at the cost of my convenience when writing the code. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Style question: metaclass self vs cls?

2012-07-16 Thread Steven D'Aprano
decorated with classdecorator. I'm very slightly leaning towards writing metaclasses like this: class ExampleMeta(type): def __new__(meta, *args): ... def method(cls, *args): ... class Example(metaclass=ExampleMeta): def another_method(self): ... What do others do? -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Implicit conversion to boolean in if and while statements

2012-07-16 Thread Steven D'Aprano
On Mon, 16 Jul 2012 13:54:32 -0700, Ethan Furman wrote: > Andrew Berg wrote: >> On 7/15/2012 9:38 PM, Steven D'Aprano wrote: >>>> I would expect None to mean "doesn't exist" or "unknown" or something >>>> like that - e.g., a valu

Re: Implicit conversion to boolean in if and while statements

2012-07-16 Thread Steven D'Aprano
On Tue, 17 Jul 2012 01:12:47 +, Steven D'Aprano wrote: > It > looks like Firebird implements the variety of ternary logical called > "Keene logic". Oops, I meant "Kleene". -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Implicit conversion to boolean in if and while statements

2012-07-16 Thread Steven D'Aprano
On Mon, 16 Jul 2012 13:28:14 -0400, Dennis Lee Bieber wrote: > On 16 Jul 2012 02:38:35 GMT, Steven D'Aprano > declaimed the following in > gmane.comp.python.general: > >> On Sun, 15 Jul 2012 12:02:37 -0500, Andrew Berg wrote: >> >> >> > Okay, I s

Re: Implicit conversion to boolean in if and while statements

2012-07-16 Thread Steven D'Aprano
is is not *entirely* wrong, because SimpleNamespace certainly doesn't *claim* to be a container, nor does it expose the full container API. But it should, even if that means it is no longer quite so simple.) -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Implicit conversion to boolean in if and while statements

2012-07-16 Thread Steven D'Aprano
ed a real-world situation where you can't collapse the entire universe of valid values into just two, True and False, without losing information. Did you think that this would be surprising? Python developers often talk about interpreting objects "in a boolean context" -- that&

Re: Implicit conversion to boolean in if and while statements

2012-07-16 Thread Steven D'Aprano
On Mon, 16 Jul 2012 11:13:33 -0700, Ethan Furman wrote: > Steven D'Aprano wrote: >> On Sun, 15 Jul 2012 10:19:16 -0600, Ian Kelly wrote: >>> On Sun, Jul 15, 2012 at 4:56 AM, Steven D'Aprano wrote: >>>> (For the record, I can only think of one trap for th

Re: Implicit conversion to boolean in if and while statements

2012-07-16 Thread Steven D'Aprano
On Tue, 17 Jul 2012 00:18:28 -0400, Devin Jeanpierre wrote: > On Mon, Jul 16, 2012 at 12:03 AM, Steven D'Aprano > wrote: >> On Sun, 15 Jul 2012 22:15:13 -0400, Devin Jeanpierre wrote: >> >>> For example, instead of "if stack:" or "if bool(stack):

Re: Implicit conversion to boolean in if and while statements

2012-07-17 Thread Steven D'Aprano
NameError: name 'x' is not defined OH MAN, that would be SO AWESOME, we should like so do it!!! (I'm being sarcastic, in case it's not obvious.) -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Style question: metaclass self vs cls?

2012-07-17 Thread Steven D'Aprano
On Tue, 17 Jul 2012 05:23:22 -0700, Michele Simionato wrote: > The standard is to use `cls`. In the __new__ method you can use `mcl` or > `meta`. Thanks to everyone who answered. I think I will stick with "meta" and "cls". -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Encapsulation, inheritance and polymorphism

2012-07-18 Thread Steven D'Aprano
ces. The downside is, if you paste code into a dumb application (like many email clients!) that strips whitespace, your code will break. So don't do that. http://stromberg.dnsalias.org/~strombrg/significant-whitespace.html -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Encapsulation, inheritance and polymorphism

2012-07-18 Thread Steven D'Aprano
> but that's just not the way people write code in Python. Better is to use explicit type checks and raise an exception yourself: if not isinstance(x, int): raise TypeError('expected an int, got %r' % x) Better still is to duck-type whenever you can. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Encapsulation, inheritance and polymorphism

2012-07-18 Thread Steven D'Aprano
at every value. Why write code with unnecessary guard values and temporary variables out of a misplaced sense that functions must only have one exit? -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Encapsulation, inheritance and polymorphism

2012-07-18 Thread Steven D'Aprano
do just fine under the conditions I am talking about. If you need the check to run, then assert is not suitable, because it is not guaranteed to run. It's as simple as that. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Encapsulation, inheritance and polymorphism

2012-07-18 Thread Steven D'Aprano
ersonally, I think tabs make more sense for indents than spaces, but for compatibility with others who are not as enlightened and insist on using broken tools that cannot deal with tabs, I have reluctantly standardised on spaces for indentation. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Encapsulation, inheritance and polymorphism

2012-07-18 Thread Steven D'Aprano
On Wed, 18 Jul 2012 12:33:01 -0400, Dave Angel wrote: > On 07/18/2012 08:58 AM, Steven D'Aprano wrote: >> >> For bonus points, can you see the mistake? [...] >> > There are actually two bugs in that function. One is in the assertion, > but more importantly, t

Re: Encapsulation, inheritance and polymorphism

2012-07-18 Thread Steven D'Aprano
n't naturally support is logic programming. So Python is simultaneously more *and* less object-oriented than Java. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Encapsulation, inheritance and polymorphism

2012-07-18 Thread Steven D'Aprano
exits or just one, that is crap code in any language. But if the choice is to write a 20 line function with three exits, or a 30 line function with a single exit, there would have to be a good reason to prefer the single- exit version. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Odd csv column-name truncation with only one column

2012-07-19 Thread Steven D'Aprano
gt; s.seek(0) py> d = csv.Sniffer().sniff(s.read()) Traceback (most recent call last): File "", line 1, in File "/usr/local/lib/python2.7/csv.py", line 184, in sniff raise Error, "Could not determine delimiter" _csv.Error: Could not determine delimiter -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Encapsulation, inheritance and polymorphism

2012-07-19 Thread Steven D'Aprano
mental qualities, e.g. "he inherited his tendency to melancholy from his father"; 3) to come into possession of, e.g. "the meek shall inherit the earth"; 4) to receive from a predecessor, e.g. "the Prime Minister has inherited an economy in dire straits". It is clear that the sense of inheritance used in OO programming is sense #2, to have by nature. > Objects dont. Irrelevant. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Encapsulation, inheritance and polymorphism

2012-07-20 Thread Steven D'Aprano
onfusing! Writing good documentation is *hard*. I often end up writing more documentation than code, sometimes by a factor of two. Fortunately I love to write. As may be obvious. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Encapsulation, inheritance and polymorphism

2012-07-20 Thread Steven D'Aprano
nd is now 13, and the upper bound is *much* smaller than Graham's Number but still inconceivably ginormous.) http://en.wikipedia.org/wiki/Graham%27s_number -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Encapsulation, inheritance and polymorphism

2012-07-20 Thread Steven D'Aprano
ied out, "Does the government know about this? We have to do something!" The lecturer said "Don't worry sir, there's no need to panic, this won't happen for billions of years." The fellow looked relived and said "Oh thank god, I thought you said *million*!" -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Google the video blah blah jews blah blah 9/11 blah blah conspiracy blah cia blah blah blah zionist blah blah brainwashing blah blah blah

2012-07-20 Thread Steven D'Aprano
On Thu, 19 Jul 2012 10:27:02 -0400, Matty Sarro wrote: > I must be a Jew or a traitor as I keep deleting this email. You might be both. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Odd csv column-name truncation with only one column

2012-07-20 Thread Steven D'Aprano
. Perhaps the predefined > 'cvs.excel' dialect matches your data. If not, the easiest way might be > to manually define a csv.Dialect subclass. Perhaps the csv module could do with a pre-defined "one column" dialect. If anyone comes up with one, do consider proposing it as

Re: ANN: dbf.py 0.94

2012-07-20 Thread Steven D'Aprano
rks on PyPy (and > hopefully the other implementations as well ;), as well as CPython. > > Get your copy at http://python.org/pypi/dbf. I don't generally click on arbitrary links to find out whether or not the link is something that interests me enough to click on it. -- Ste

Re: ANN: dbf.py 0.94

2012-07-20 Thread Steven D'Aprano
wrong impression. Here are a few randomly selected examples of good release announcements: http://mail.python.org/pipermail/python-announce-list/2012-June/009528.html http://mail.python.org/pipermail/python-announce-list/2012-June/009509.html http://mail.python.org/pipermail/python-announce-list/2012-June/009524.html -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: ANN: dbf.py 0.94

2012-07-20 Thread Steven D'Aprano
ects that it will work with Stackless, Jython, IronPython, and any other compliant Python interpreter, but hasn't tested on them. > Works or hopefully works with CPython -- which is it? I agree that the sentence is unclear, but my reading of it is that it works on CPython. --

Re: PyPy, is it a 1:1 replacement for CPython?

2012-07-20 Thread Steven D'Aprano
the program incompatible with the normal compiler? I don't expect so. There may be special PyPy functions that other Python's won't have, but I don't know of any. If you stick to standard library and language features as described in the normal Python docs, you should be fine

Re: Basic question about speed/coding style/memory

2012-07-21 Thread Steven D'Aprano
ngElseInstead() block is the "normal" procedure, and the doSomething() block is a special case. Not necessarily rare, but nevertheless special in some sense. Of course, the decision as to which is the "special" case and which is the "normal" case is often entirely arbitrary. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Sudden doubling of nearly all messages

2012-07-21 Thread Steven D'Aprano
e low-end gateway. Some people also annoyingly send to both the newsgroup *and* the mailing list, not realising -- or not caring -- that they are the same thing. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Sudden doubling of nearly all messages

2012-07-21 Thread Steven D'Aprano
s 10 years ago, because an industry dominated by three big, competing entities who hate each other (Microsoft, Apple, Google) is better than a monopoly of one (Microsoft). But we, the users and consumers, should never make the mistake of thinking that *any* of the three have our best interest

Re: My first ever Python program, comments welcome

2012-07-21 Thread Steven D'Aprano
the input list. The list.sort method sorts the list in place. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: My first ever Python program, comments welcome

2012-07-21 Thread Steven D'Aprano
one of the slower ways of processing large numbers of input lines. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Converting a list of strings into a list of integers?

2012-07-22 Thread Steven D'Aprano
an map, and may be faster; both will be no slower than a for-loop, and may be faster. Or at least, this was the case last time I checked. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: default repr?

2012-07-22 Thread Steven D'Aprano
;tuple.__repr__([1,2,3])" threw a TypeError. Oh well. > There's a limit to the ways Python lets you shoot yourself in the foot. Of course -- [1,2,3] is not a tuple, so how would tuple know what to do with it? -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: default repr?

2012-07-22 Thread Steven D'Aprano
On Mon, 23 Jul 2012 10:29:33 +1000, Chris Angelico wrote: > On Mon, Jul 23, 2012 at 10:24 AM, Steven D'Aprano > wrote: >>> Methods are just functions, and you can call any method of any class >>> with any object as its first parameter. >> >> Not quite:

Re: the meaning of r’.......‘

2012-07-23 Thread Steven D'Aprano
Smart Quotes" characters r’‘ instead of good old fashioned typewriter-style quotes r'' or r"". If you're going to ask programming questions using an email client that changes what you type, including smart quotes, special hyphens or other characters, you're g

Re: dict: keys() and values() order guaranteed to be same?

2012-07-23 Thread Steven D'Aprano
deterministic": while it does not promise what order the keys will be returned, it does promise that whatever that order turns out to be, they will returned in the same order as the matching values (unless you modify the dict while iterating). -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: the meaning of r.......ïŸ

2012-07-23 Thread Steven D'Aprano
lay (not all fonts are capable of showing all characters) I wouldn't hold my breath for full Unicode syntax any time soon. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: the meaning of rユ.......�¾

2012-07-23 Thread Steven D'Aprano
ble, easy to remember mnemonics for additional characters. Back in 1984, Apple Macs made it trivial to enter useful non-ASCII characters from the keyboard. E.g.: Shift-4 gave $ Option-4 gave ¢ Option-c gave © Option-r gave ® Dead-keys made accented characters easy too: Option-u o gave ö Op

Re: the meaning of rユ.......ï¾

2012-07-23 Thread Steven D'Aprano
with dotless uppercase I, like in English. But in Turkish, you have ı <=> I and i <=> İ. http://en.wikipedia.org/wiki/Dotted_and_dotless_I And if this wasn't so serious, it would be hilarious: http://gizmodo.com/382026/a-cellphones-missing-dot-kills-two-people-puts-three-more-in-jail -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: the meaning of rユ.......ï¾

2012-07-23 Thread Steven D'Aprano
ightly complain that s and z look too similar, and b and d even more so. Perhaps they too should be banned from identifiers? -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: the meaning of rユ.......ï¾

2012-07-23 Thread Steven D'Aprano
http://entrian.com/goto/ And perhaps most relevant of all: http://www.python.org/dev/peps/pep-3117/ -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Gender, Representativeness and Reputation in StackOverflow

2012-07-23 Thread Steven D'Aprano
should not ask for valuable > free data from freely donated time. Well of course it is your time and your judgement to make, but in my opinion even non-free scientific knowledge is better than ignorance. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Gender, Representativeness and Reputation in StackOverflow

2012-07-23 Thread Steven D'Aprano
On Mon, 23 Jul 2012 22:51:07 -0400, Devin Jeanpierre wrote: > On Mon, Jul 23, 2012 at 9:30 PM, Steven D'Aprano > wrote: >>> Leaving aside the point that this is not directly related to Python, >>> my opinion is that if the authors will not make past and future pap

Re: python package confusion

2012-07-23 Thread Steven D'Aprano
ry start of the search path. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: groveling over a file for Q:: and A:: stmts

2012-07-24 Thread Steven D'Aprano
quot;except Exception" line above. > L.sort > print (L) > > # and what"s wrong with some of this, here! #myHash = set(L)# > uniqify > #pp.pprint(myHash) # july 23, 131001 hike! I don't know what's wrong with it. What do you expect it to do, and what does it actually do instead? -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: What's wrong with this code?

2012-07-24 Thread Steven D'Aprano
operates on the name "x", not the object. The object 1 does not know it has been bound to anything -- that's one weakness of the "tag" model, because it implies that objects know what tags they have attached. They don't. Imports: import x also operates o

Re: Gender, Representativeness and Reputation in StackOverflow

2012-07-24 Thread Steven D'Aprano
t; despite the reasons for the boycott, the product has some value. They >> > boycott it because by doing so, they can get something better than >> > or -- they can get > > badness>. (At least, in theory :) >> >> > On Jul 24, 10:34 am, Steven D'

Re: the meaning of rユ.......ï¾

2012-07-24 Thread Steven D'Aprano
which means that, like it or not, 22/7 *is* associated with π. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: from future import pass_function

2012-07-25 Thread Steven D'Aprano
of a statement would essentially take something that does *nothing at all* into something that (figuratively speaking) jumps up to its feet, runs around the room three times, and then sits back down again. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: from future import pass_function

2012-07-26 Thread Steven D'Aprano
o important that it has to be a built-in function; and 2) why it needs to be called "pass". Nobody is disputing the usefulness of do nothing functions. We're disputing that *pass* should be that function. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: from future import pass_function

2012-07-26 Thread Steven D'Aprano
On Thu, 26 Jul 2012 08:59:30 +0200, Ulrich Eckhardt wrote: > Am 26.07.2012 04:38, schrieb Steven D'Aprano: >> The examples of pass-as-a-function shown by the Original Poster don't >> give any clue of what advantage there is to make pass a function. > > Just read

Re: from future import pass_function

2012-07-26 Thread Steven D'Aprano
ade a guess based on the limited information I had, and based on my own history, and you tell me my guess was wrong. I accept that. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Generating valid identifiers

2012-07-26 Thread Steven D'Aprano
ddle. a.b.c.d.e.f.g.something goes to: a.b...g.something or similar. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Generating valid identifiers

2012-07-26 Thread Steven D'Aprano
ds won't be anywhere near that low. CRC32 is neither collision-resistant nor cryptographically random, and only generates eight hex digits, not ten. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: dynamic setattr

2012-07-27 Thread Steven D'Aprano
e 5, in __init__ NameError: global name 'keys' is not defined If you fix that and try again, you get this error: py> utility = Utility() Traceback (most recent call last): File "", line 1, in File "", line 7, in __init__ TypeError: get_value() takes exactly 2 arguments (3 given) The results you claim you get are not true. Please read this page and then try again: http://sscce.org/ -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Python Error

2012-07-29 Thread Steven D'Aprano
gested: print the list before you try to convert it to a set, and see what it actually contains. It will also help you to read this page and try to follow its advice: http://sscce.org/ -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Extracting bit fields from an IEEE-784 float

2012-07-29 Thread Steven D'Aprano
ask. Is this correct? 3) Any other problems with the way I am doing this? Thanks in advance, Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: simplified Python parsing question

2012-07-29 Thread Steven D'Aprano
xt/python-parsers.html Here's a Python parser using the pyparsing library. It's a bit old (written for Python 2.4) but it shouldn't be hard to update it to new syntax: http://pyparsing.wikispaces.com/file/view/pythonGrammarParser.py -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: simplified Python parsing question

2012-07-30 Thread Steven D'Aprano
penOffice or Abiword and read it. Something in Google Docs might as well be locked in a safe as far as I'm concerned. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: ANN: visage (interfaces)

2012-07-30 Thread Steven D'Aprano
On Mon, 30 Jul 2012 18:41:19 -0700, jwp wrote: >> BTW I think if you rename the ReStructured Text docs to .rst github >> will automatically render them. > > Did not know that. Gonna go do a lot of git mv's now. Do *one* and see if github actually does render it. Then do

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