Re: the slash & Windows paths

2011-12-19 Thread Steven D'Aprano
On Mon, 19 Dec 2011 15:02:50 -0700, Juan Declet-Barreto wrote: > xmlns:o="urn:schemas-microsoft-com:office:office" > xmlns:w="urn:schemas-microsoft-com:office:word" > xmlns:m="http://schemas.microsoft.com/office/2004/12/omml"; > xmlns="http://www.w3.org/TR/REC-html40";> http-equiv=Content-Type co

Re: Transform two tuples item by item

2011-12-19 Thread Steven D'Aprano
ool, bool, lambda obj: obj, bool, escape, ] then use zip to pair them up with their arguments: results = [f(x) for f,x in zip(ops, tup)] -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Pythonification of the asterisk-based collection packing/unpacking syntax

2011-12-19 Thread Steven D'Aprano
m'? Also "not in". Space-delimited tokens are hardly rare in Python, e.g.: import module as name for x in sequence if flag elif condition while condition with obj del name Nevertheless, I think the suggested syntax "@list args" is awful. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: JOKE OF THE YEAR

2011-12-19 Thread Steven D'Aprano
soft_Visual_Studio -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: check for a certain Python version

2011-12-20 Thread Steven D'Aprano
self, ...) except AttributeError: pass -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Learning Python 2.4

2011-12-20 Thread Steven D'Aprano
, 2.4 up to 2.7) and NOT Python 3. Python 3 intentionally breaks some backwards compatibility in ways that will confuse a beginner to the language unless you learn from a book designed for Python 3. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Elementwise -//- first release -//- Element-wise (vectorized) function, method and operator support for iterables in python.

2011-12-20 Thread Steven D'Aprano
On Tue, 20 Dec 2011 14:45:06 -0500, Nathan Rice wrote: > PyPi: http://pypi.python.org/pypi/elementwise/0.111220 Version 0.111220? What do you do, bump the version number after every keystroke? -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Pythonification of the asterisk-based collection packing/unpacking syntax

2011-12-20 Thread Steven D'Aprano
eads to ColorForth and APL. [1] Possibly because ed is the standard Unix editor. http://www.gnu.org/fun/jokes/ed.msg.html -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Elementwise -//- first release -//- Element-wise (vectorized) function, method and operator support for iterables in python.

2011-12-20 Thread Steven D'Aprano
opinion. Another opinion is that nobody cares what specific day you release a new version, and that versions 0.191231 and 0.200101 probably aren't that big a difference. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Elementwise -//- first release -//- Element-wise (vectorized) function, method and operator support for iterables in python.

2011-12-20 Thread Steven D'Aprano
On Tue, 20 Dec 2011 13:08:09 -0800, Paul Rubin wrote: > Steven D'Aprano writes: >> Not any date code I'm familiar with. 0.111220 doesn't look anything >> like a date to me. > > 0 is the major version number. 111220 (the minor version number) is the >

Re: Elementwise -//- first release -//- Element-wise (vectorized) function, method and operator support for iterables in python.

2011-12-20 Thread Steven D'Aprano
per day, unless you add an extra field to the version string. But whatever floats your boat. I'm just glad that you've put your money where your mouth is, and released the package, instead of demanding others do the work. Thank you. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Anyone still using Python 2.5?

2011-12-21 Thread Steven D'Aprano
ghting some 2.5 compatibility issues. I'm wondering > whether to fix those (lots of ugly "from __future__ import > with_statement" everywhere) or just to drop Python 2.5 support. > > What do people feel? It really depends on *your* users, not arbitrary developers. How m

Re: what does 'a=b=c=[]' do

2011-12-21 Thread Steven D'Aprano
separate them by commas. Newlines or semicolons will work. Or: x, y, z = [], [], [] Either is pretty Pythonic. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: what does 'a=b=c=[]' do

2011-12-21 Thread Steven D'Aprano
Americans reading). So the round brackets there are strictly redundant: a, b, c = [], [], [] The only times you need the brackets around a tuple is to control the precedence of operations, or for an empty tuple. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: [TIP] Anyone still using Python 2.5?

2011-12-21 Thread Steven D'Aprano
nt than the ability to write one-liner if statements. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Generator Question

2011-12-21 Thread Steven D'Aprano
othing, and then returns None (because Python doesn't have Pascal procedures or C void function). > def g(): >if 0: yield 0 > pass The pass is redundant. This creates a generator function which, when called, doesn't yield anything, then raises StopIteration. --

Re: Generator Question

2011-12-21 Thread Steven D'Aprano
et, I want to yield nothing. > How to do? Actually, there's an even easier way. >>> def h(): ... if not condition: ... for c in "abc": ... yield c ... >>> >>> condition = False >>> list(h()) ['a', '

Re: Pythonification of the asterisk-based collection packing/unpacking syntax

2011-12-22 Thread Steven D'Aprano
"confusing" too. So how about we say: class MyClass superclasslist A, B C: def method argumentlist self, x, y: t = tuple 1, 2 tuple 3, 4 endtuple endtuple return group x + y endgroup * group x - y endgroup Much less confusing! -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: what does 'a=b=c=[]' do

2011-12-23 Thread Steven D'Aprano
which allegedly causes more difficulties than benefits. I do not hold with that idea. But either way, it is not a bug to be fixed, but a deliberate consequence of intended semantics. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Idiom for shelling out to $EDITOR/$PAGER?

2011-12-23 Thread Steven D'Aprano
cess both files in their entirety. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Idiom for shelling out to $EDITOR/$PAGER?

2011-12-23 Thread Steven D'Aprano
On Fri, 23 Dec 2011 09:44:31 +, Steven D'Aprano wrote: > On Fri, 23 Dec 2011 09:28:52 +0100, Peter Otten wrote: > >>> -proper & efficient detection of file-change, to know whether the user >>> actually did anything >> >> Just read the whole thi

Re: Idiom for shelling out to $EDITOR/$PAGER?

2011-12-23 Thread Steven D'Aprano
On Thu, 22 Dec 2011 22:16:30 -0600, Tim Chase wrote: > I presume the code for spawning $PAGER on some content would look pretty > similar. Have a look at pydoc in the standard library, which implements pager-like functionality. -- Steven -- http://mail.python.org/mailman/listinfo/

Re: what does 'a=b=c=[]' do

2011-12-23 Thread Steven D'Aprano
is argument (2nd one)] When the facts are against you, argue semantics; when semantics are against you, argue the facts; when both are against you, claim to be above arguing. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Early and late binding [was Re: what does 'a=b=c=[]' do]

2011-12-23 Thread Steven D'Aprano
is outside the body of the function, usually in a global variable: _DEFAULT_Y = [] # Private constant, don't touch. def func(x, y=None): if y is None: y = _DEFAULT_Y ... This separates parts of the code that should be together, and relies on a global, with all th

Re: Early and late binding [was Re: what does 'a=b=c=[]' do]

2011-12-23 Thread Steven D'Aprano
On Sat, 24 Dec 2011 02:55:41 +1100, Chris Angelico wrote: > On Sat, Dec 24, 2011 at 2:49 AM, Steven D'Aprano > wrote: >> To fake early binding when the language provides late binding, you >> still use a sentinel value, but the initialization code creating the >> defa

Re: Get named module's file location

2011-12-23 Thread Steven D'Aprano
[] > for module in modules: >m = imp.find_module(module)[1] >my_list.append(m, os.path.getmtime(m)) +1 List comprehensions are so cool that sometimes people forget that not every loop has to be a list comp. There is no shortage of newlines in the world, and not everything needs

Re: Early and late binding [was Re: what does 'a=b=c=[]' do]

2011-12-24 Thread Steven D'Aprano
On Sat, 24 Dec 2011 09:50:04 +1100, Chris Angelico wrote: > On Sat, Dec 24, 2011 at 9:32 AM, Steven D'Aprano > wrote: >> Yes. But having to manage it *by hand* is still unclean: > > Well, my point was that Python's current behaviour _is_ that. Minus the managing

Re: Early and late binding [was Re: what does 'a=b=c=[]' do]

2011-12-24 Thread Steven D'Aprano
nd relies on >> a global, with all the disadvantages that implies. > > No, you can just do def func(x, y=_DEFAULT_Y): ... Point taken. Nevertheless, the semantics are still not the same as actual early binding: if the global name is deleted or changed, the function stops working. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Early and late binding [was Re: what does 'a=b=c=[]' do]

2011-12-24 Thread Steven D'Aprano
your code stops working. In other words, it violates encapsulation of the function. That's not to say that you shouldn't do this. It's a perfectly reasonable technique, and I've used it myself, but it's not as elegant as the current Python default argument behaviour. [...] > The greater efficiency was probably what decided this question for > Python, right? Since late-binding is so easy to fake, is hardly ever > what you want, and would make all code slower, why do it? Excellent point. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Adding an interface to existing classes

2011-12-25 Thread Steven D'Aprano
(x, y) # No, wrong, bad!!! Don't do this. Instead: return self.__class__(x, y) # Better. > Spencer, i would re-think this entire project from the beginning. You > are trying to make an object out of everything. You don't need to make > an object of EVERYTHING. Very true. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Pythonification of the asterisk-based collection packing/unpacking syntax

2011-12-25 Thread Steven D'Aprano
bj in enumerate(sequence): ... for a, b in zip(obj, range(100)): ... -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Pythonification of the asterisk-based collection packing/unpacking syntax

2011-12-25 Thread Steven D'Aprano
On Sat, 24 Dec 2011 06:45:01 -0800, Eelco wrote: > Can you give an example of a construct in python where two whitespace > delimited identifiers are legal? Not apart from the trivial case of two identifiers separated by newlines. What's your point? -- Steven -- http://mail

Re: Pythonification of the asterisk-based collection packing/unpacking syntax

2011-12-25 Thread Steven D'Aprano
t is an outcome. In normal usage, "constraint" refers to pre-conditions, not post- conditions. There are no pre-conditions on y in the above. It may not even exist. Contrast it with this example: y += list(x) where there are constraints on y: it must exist, and it must be a list, or

Re: Pythonification of the asterisk-based collection packing/unpacking syntax

2011-12-25 Thread Steven D'Aprano
with > collection unpacking within a function call. The :: on the right-hand side is redundant, because the left-hand side already explicitly signals collection unpacking of the RHS. Requiring :: on the RHS above is as unnecessary as it would be here: n = len(::sequence) -- Steven -- h

Re: what does 'a=b=c=[]' do

2011-12-25 Thread Steven D'Aprano
thout the round brackets, it is a syntax error. Correction noted. Nevertheless, the parentheses don't create the tuple, the comma operator does. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Adding an interface to existing classes

2011-12-25 Thread Steven D'Aprano
On Sun, 25 Dec 2011 23:32:41 +1100, Chris Angelico wrote: > On Sun, Dec 25, 2011 at 11:10 PM, Steven D'Aprano > wrote: >> class Point:  # An abstract class. >>    def intersect(self, other): >>        blah; blah; blah >>        return Point(x, y)  # No, wrong,

Re: Random string of digits?

2011-12-25 Thread Steven D'Aprano
x27;%20d' % random.randint(0, 10**20-1) -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Adding an interface to existing classes

2011-12-25 Thread Steven D'Aprano
On Mon, 26 Dec 2011 00:37:22 +1100, Chris Angelico wrote: > On Mon, Dec 26, 2011 at 12:27 AM, Steven D'Aprano > wrote: >> There's nothing in the above that assumes that other has the same type >> as self. It's just that the type of other is ignored, and the ty

Re: Test None for an object that does not implement ==

2011-12-25 Thread Steven D'Aprano
#x27;t think of any other un-subclassable classes other than NoneType. Which ones are you thinking of? -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Random string of digits?

2011-12-25 Thread Steven D'Aprano
erator, the old generator, Wichman-Hill, was moved into its own module whrandom (deprecated in 2.4; now gone) for those who needed backwards compatibility. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Random string of digits?

2011-12-25 Thread Steven D'Aprano
On Mon, 26 Dec 2011 00:54:40 +1100, Chris Angelico wrote: > On Mon, Dec 26, 2011 at 12:48 AM, Steven D'Aprano > wrote: >> On Sun, 25 Dec 2011 08:30:46 -0500, Roy Smith wrote: >> >>> I want to create a string of 20 random digits (I'm OK with leading &g

Re: Pythonification of the asterisk-based collection packing/unpacking syntax

2011-12-25 Thread Steven D'Aprano
grep "[*]args" *.py | wc -l 267 [steve@orac src]$ grep "{" *.py | wc -l 8 -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Pythonification of the asterisk-based collection packing/unpacking syntax

2011-12-25 Thread Steven D'Aprano
On Sun, 25 Dec 2011 07:38:17 -0800, Eelco wrote: > On Dec 25, 2:12 pm, Steven D'Aprano [email protected]> wrote: >> On Sat, 24 Dec 2011 06:39:39 -0800, Eelco wrote: >> > On Dec 20, 4:30 am, alex23 wrote: >> >> On Dec 19, 8:15 pm, Eelco wrote

Re: Random string of digits?

2011-12-25 Thread Steven D'Aprano
On Mon, 26 Dec 2011 03:11:56 +1100, Chris Angelico wrote: > On Mon, Dec 26, 2011 at 2:46 AM, Steven D'Aprano > wrote: >> Use the Source, Luke, er, Chris :) >> >> If I've read the source correctly, randint() will generate sufficient >> bits of randomness

Re: Test None for an object that does not implement ==

2011-12-25 Thread Steven D'Aprano
: > > (a==None) and (c==None) Replace == with 'is'. > Most of the replies you're getting here seem unnecessarily complicated. == is a more complicated operator than the 'is' operator. That's why the is operator is to be preferred when testing for None -- it is guaranteed to do the right thing, while == is not. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Random string of digits?

2011-12-25 Thread Steven D'Aprano
On Sun, 25 Dec 2011 12:41:29 -0500, Roy Smith wrote: > On Mon, 26 Dec 2011 03:11:56 +1100, Chris Angelico wrote: >> > I prefer not to rely on the source. That tells me what happens, not >> > what's guaranteed to happen. > > Steven D'Aprano wrote: >> In

Re: Python education survey

2011-12-26 Thread Steven D'Aprano
ate actual effort, and you may attract others who care. Otherwise, you're wasting our time. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Possible bug in string handling (with kludgy work-around)

2011-12-26 Thread Steven D'Aprano
vour and write your loops like this: for i in range(len(something)): obj = something[i] print obj, i instead of repeatedly indexing the list over and over and over and over again, as you do in your own code. The use of a temporary variable makes the code much easier to read and understand. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: confused about __new__

2011-12-26 Thread Steven D'Aprano
f the > preexisting classes instead of creating a new one each call. I'm surprised it works in Python3. Try this in Python 2 instead: Foo.__new__ = staticmethod(__Foo__new__) -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Pythonification of the asterisk-based collection packing/unpacking syntax

2011-12-27 Thread Steven D'Aprano
On Mon, 26 Dec 2011 13:41:34 -0800, Eelco wrote: > On Dec 25, 6:05 pm, Steven D'Aprano [email protected]> wrote: >> On Sun, 25 Dec 2011 07:38:17 -0800, Eelco wrote: [...] >> > How is 'head, *tail = sequence' or semantically entirely >> &g

Re: Pythonification of the asterisk-based collection packing/unpacking syntax

2011-12-27 Thread Steven D'Aprano
table and your reflexive memory, > than uncommonly used ones. Right. And since sequence packing and unpacking is a common idiom, it deserves to be given punctuation. That's my opinion. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Pythonification of the asterisk-based collection packing/unpacking syntax

2011-12-27 Thread Steven D'Aprano
tail). Your original use-case, where you want to change the type of tail from a list to something else, is simply solved by one extra line of code: head, *tail = sequence tail = tuple(tail) You have written thousands of words to save one line in an idiom which you claim is very uncommon. Perha

Re: Py-dea: Streamline string literals now!

2011-12-27 Thread Steven D'Aprano
ork of Python that throws out all the accumulated cruft of the language. I'm sure that the silent majority who agree with you are hanging out for your first release. I know I am. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Pythonification of the asterisk-based collection packing/unpacking syntax

2011-12-27 Thread Steven D'Aprano
On Wed, 28 Dec 2011 15:06:37 +1100, Chris Angelico wrote: > On Wed, Dec 28, 2011 at 10:10 AM, Steven D'Aprano > wrote: >> Your original use-case, where you want to change the type of tail from >> a list to something else, is simply solved by one extra line of code: >&

Re: Py-dea: Streamline string literals now!

2011-12-27 Thread Steven D'Aprano
is multi-line format. That's why he proposed it as a *statement* and not string-builder syntax. Without an end-delimiter, how do you embed string literals in expressions? -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Python education survey

2011-12-27 Thread Steven D'Aprano
at" when we already have "ship"? Why do you say "pseudo intellectuals" when you could say "fake intellectuals"? Why do I waste my time reading your pretentious self-important nonsense? [...] > This is group has the most dumbest smart people i have ever met! Considering I keep expecting you to stop trolling, I admit this applies to me. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Py-dea: Streamline string literals now!

2011-12-28 Thread Steven D'Aprano
elimiters. Problem solved! Thank you Rick for yet another brilliant, well-thought-out idea. I look forward to seeing your fork of Python with this change. How is it going? I hope you aren't going to disappoint the legions of your fans who are relying on you to save the Python commun

Re: Pythonification of the asterisk-based collection packing/unpacking syntax

2011-12-29 Thread Steven D'Aprano
hand side, you are increasing the number of punctuation characters from one to four. If your aim is to minimize the number of punctuation characters, you're doing it wrong. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Doing a HTTP DELETE operation with urllib2?

2011-12-30 Thread Steven D'Aprano
t to those reading, it is rather cryptic. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: mutually exclusive arguments to a constructor

2011-12-30 Thread Steven D'Aprano
more idiomatic than the use of static methods. Either method is acceptable, although the first is slightly more "pure" because it doesn't use isinstance. The second may fail if the user passes a string-like object which behaves identically to strings, but doesn

Re: mutually exclusive arguments to a constructor

2011-12-30 Thread Steven D'Aprano
will return a MyAzimuth instance instead of an azimuth instance. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: InvalidResponseError: headers must be str

2011-12-30 Thread Steven D'Aprano
RESS': str(remote_address), > } 'JSON' is already a string. Calling str() on it is a waste of time. What values do the various settings.* have? If they are already strings, calling str() again is a waste of time. I see you do this all through your class, needlessly calling str() on strings. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: InvalidResponseError: headers must be str

2011-12-31 Thread Steven D'Aprano
On Sat, 31 Dec 2011 12:04:13 +0200, Serhiy Storchaka wrote: > 31.12.11 08:40, Steven D'Aprano написав(ла): >> 'JSON' is already a string. Calling str() on it is a waste of time. > > from __future__ import unicode_literals Fair point. Your correction i

Re: InvalidResponseError: headers must be str

2011-12-31 Thread Steven D'Aprano
AE SDK uses > WSGI instead of CGI now. Any idea about my problem? > > Thank you Have patience. It has been less than a day since you first asked, and it is New Years Day or New Years Eve (depending on where you are). Most people will be away from their computers or busy celebrating.

Re: Spamming PyPI with stupid packages

2012-01-01 Thread Steven D'Aprano
uaking in his boots. Some random guy on the Internet is going to insult him based on a wild assumption about his nationality. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Spamming PyPI with stupid packages

2012-01-01 Thread Steven D'Aprano
e author, I'd be embarrassed to make them public. They aren't useful; they are rather immature; they don't demonstrate good Python knowledge or programming skill. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: .format vs. %

2012-01-02 Thread Steven D'Aprano
ve a task that doesn't *need* a regular expression solution, don't use a regular expression. For what it's worth, I like the syntax of % formatting. It's nice and simple and compact while still being readable. format() is more powerful, but when I don't need that power

Re: .format vs. %

2012-01-02 Thread Steven D'Aprano
ation. I'm sure he also knows that % formatting is NOT deprecated. Please stop spreading FUD about Python features. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: .format vs. %

2012-01-02 Thread Steven D'Aprano
On Mon, 02 Jan 2012 22:58:23 -0700, Ian Kelly wrote: > On Mon, Jan 2, 2012 at 8:52 PM, Steven D'Aprano > wrote: >> On Mon, 02 Jan 2012 17:59:43 -0800, Rick Johnson wrote: >> >>> On Jan 2, 4:00 pm, Ethan Furman wrote: >>>> %-style formatting isn'

Re: Spamming PyPI with stupid packages

2012-01-03 Thread Steven D'Aprano
x27;t. Stan: I want to have babies. Reg: You want to have babies?!?! Stan: It's every man's right to have babies if he wants them. Reg: But ... you can't HAVE babies! Stan: Don't you oppress me! Reg: I'm not oppressing you, Stan. You haven't got a womb! Where's the fetus gonna gestate? You gonna keep it in a box? - Life of Brian -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Newbie Help

2012-01-03 Thread Steven D'Aprano
widgets, but if you want something better, you might like to try wxPython. > 3. An integrated web server package for Win Vista Try cherrypy, which includes its own web server as well as a web framework. http://cherrypy.org/ -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Is there anyway to selectively inherit/import a class/module?

2012-01-03 Thread Steven D'Aprano
se > either the original serial class definition when I wanted the original > program functionality or the new class when I wanted the extra layer > present. No problem. Here's another way to do it: from moduleB import Serial as SimpleSerial class ComplexSerial(SimpleSerial): ...

Re: Python education survey

2012-01-03 Thread Steven D'Aprano
a repertoire of words with subtly different meanings in their natural > language, because there is a demand for this semantic richness. +1 QOTW -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Spamming PyPI with stupid packages

2012-01-03 Thread Steven D'Aprano
en to be believed. The original complaint is over a couple of entries in an RSS feed and showing up on the front page of PyPI, perhaps a dozen words in total. The reaction has been thousands of words arguing back and forth. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Spamming PyPI with stupid packages

2012-01-03 Thread Steven D'Aprano
On Wed, 04 Jan 2012 08:57:59 +1100, Ben Finney wrote: > Steven D'Aprano writes: > >> The joke cuts both ways. > > This is the Just World fallacy: you're implying that, because the same > joke can be applied equally well to women or men, that therefore it is >

Re: Spamming PyPI with stupid packages

2012-01-03 Thread Steven D'Aprano
On Wed, 04 Jan 2012 12:54:09 +1100, Ben Finney wrote: > Steven D'Aprano writes: [...] >> You're making an assumption there that I don't accept. There is no >> evidence that it is harmful to *anyone*, men or women. > > It objectifies women. So you claim. &

Re: can a subclass method determine if called by superclass?

2012-01-04 Thread Steven D'Aprano
False, you shouldn't do this! If the caller does do exact type checks, then almost certainly it should be considered a bug in their code and they should be beaten with a clue- bat and told to use isinstance (good) or duck-typing (better still). If I have misunderstood your prob

Re: replacing __dict__ with an OrderedDict

2012-01-06 Thread Steven D'Aprano
u wouldn't write a function called "func_009", why write one called "test_009"? -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: replacing __dict__ with an OrderedDict

2012-01-06 Thread Steven D'Aprano
neously*, due to clashes involving external resources, but you should be able to run them in random order. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: how to get id(function) for each function in stack?

2012-01-06 Thread Steven D'Aprano
umber. In Jython, and I think IronPython, id() returns a sequential number for each object created. The first object created by the Jython virtual machine gets ID 1, the second gets ID 2, and so on. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Calling a variable inside a function of another class

2012-01-07 Thread Steven D'Aprano
int(Test.shared) # prints 42 However, print(Test.dt) fails because no instance has been created yet, and so there is no dt attribute. You have to create an instance first, then __init__ will run and create the attribute: instance = Test() print(instance.dt) # prints 23 -- Steven -- http

Re: multiple inheritance from list and other class

2012-01-07 Thread Steven D'Aprano
On Sat, 07 Jan 2012 22:08:22 -0800, 8 Dihedral wrote: [...] > The class is defined in a silly way. > In python declaring a class with only trivial properties added is not > very python at all. The example given looks like a Mixin class, which is perfectly acceptable in Python. -

Re: multiple inheritance from list and other class

2012-01-07 Thread Steven D'Aprano
y fails the way you expect. It is perfectly fine to use multiple inheritance in the way you show. Here is an even simpler example: py> class Spam(object): ... pass ... py> class Ham(list, Spam): ... pass ... py> py> h = Ham([1, 2, 3]) py> And no exception is

Using an OrderedDict for __dict__ in Python 3 using __prepare__

2012-01-08 Thread Steven D'Aprano
, 'spam', 'method1', '__dict__', '__weakref__', '__doc__'] I expected that the output of MyClass.__dict__.keys would match the input OrderedDict (ignoring the entries added later, like __module__ and __doc__). And I'm completely flummoxed by the existence of MyClass.__dict__['__dict__']. What am I doing wrong? -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Newbie: Looking for code review on my first Python project.

2012-01-10 Thread Steven D'Aprano
rts are all literals. >>> from dis import dis >>> dis(compile(r's = "a\n" + "b\n"', '', 'single')) 1 0 LOAD_CONST 3 ('a\nb\n') 3 STORE_NAME 0 (s) 6 LOAD_CONST 2 (None) 9 RETURN_VALUE -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: ERROR:root:code for hash md5 was not found

2012-01-11 Thread Steven D'Aprano
hashlib.md5) import _md5 print(_md5.__file__) and copy and paste (do not retype) the full output of these commands. Thank you. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: ERROR:root:code for hash md5 was not found

2012-01-12 Thread Steven D'Aprano
hing to do with Sibelius the music composition software? It looks like the installation you are trying to use is missing modules. You might need to consult the pysibelius forums or mailing lists, if they have any, or the author, or possibly re-install it and see if the problem goes away. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Zealotry [was Re: how to install lxml in window xp?]

2012-01-12 Thread Steven D'Aprano
ng Windows Server 2000 for my needs, and don't need any Windows software that doesn't run on it. But my sympathies go out to those who are stuck (for whatever reason) on an OS (of any flavour) that doesn't do what they want. Just don't blame the messenger. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Zealotry [was Re: how to install lxml in window xp?]

2012-01-13 Thread Steven D'Aprano
On Thu, 12 Jan 2012 21:41:29 -0800, alex23 wrote: > On Jan 13, 3:02 pm, Steven D'Aprano [email protected]> wrote: >> Why is it that only Linux and Mac users are accused of being "zealots"? > > Oh please. Don't tar me with the Windows brush. I

Re: copy on write

2012-01-13 Thread Steven D'Aprano
ects in place. So for example: >>> a = 42 # binds the name 'a' to the object 42 >>> b = a # a and b point to the same object >>> a += 1 # creates a new object, and binds it to a >>> print b # leaving b still pointing to the old object 42 -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: copy on write

2012-01-13 Thread Steven D'Aprano
sorely > confusing to C programmers. But then, there's a lot about Python > that's sorely confusing to C programmers. I prefer to think of it as "there's a lot about C that is sorely confusing to anyone who isn't a C programmer" -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Zealotry [was Re: how to install lxml in window xp?]

2012-01-13 Thread Steven D'Aprano
On Fri, 13 Jan 2012 15:32:06 +, John Gordon wrote: > In <[email protected]> Steven D'Aprano > writes: > >> Why is it that only Linux and Mac users are accused of being "zealots"? > > Perhaps because Window

Re: ERROR:root:code for hash md5 was not found

2012-01-13 Thread Steven D'Aprano
On Fri, 13 Jan 2012 06:14:50 -0800, mike wrote: > On Jan 13, 5:41 am, alex23 wrote: >> On Jan 13, 1:34 pm, Steven D'Aprano > >> [email protected]> wrote: >> > What is pysibelius? I can't find it on the web. Does it have anything >&g

Hash stability

2012-01-13 Thread Steven D'Aprano
On the Python Dev mailing list, there is a discussion going on about the stability of the hash function for strings. How many people rely on hash(some_string) being stable across Python versions? Does anyone have code that will be broken if the string hashing algorithm changes? -- Steven

Re: NaN, Null, and Sorting

2012-01-13 Thread Steven D'Aprano
ds implementing the comparisons such that > Null objects are less than other objects so they will always sort > together. > > Thoughts/advice/criticisms/etc? Possibly the least-worst solution. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: PyWarts: time, datetime, and calendar modules

2012-01-14 Thread Steven D'Aprano
On Sat, 14 Jan 2012 10:54:57 -0800, Rick Johnson wrote: > The interface for these modules is not intuitive. Instead of creating > true OOP objects we have lists and strings. Lists and strings are true OOP objects. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: PyWarts: time, datetime, and calendar modules

2012-01-14 Thread Steven D'Aprano
d, but alas we've lost the opportunity for this. Any changes to datetime need to be backward compatible. If you want to actually do something useful, instead of just big-noting yourself and trolling about how bad Python is because it doesn't work like the language you have in your hea

Re: PyWarts: time, datetime, and calendar modules

2012-01-14 Thread Steven D'Aprano
uments", there is no easy way to get a reference to the object f. This makes functions second-class objects in Ruby, since you can't refer to them easily by name like you can other objects. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: PyWarts: time, datetime, and calendar modules

2012-01-14 Thread Steven D'Aprano
On Sat, 14 Jan 2012 21:27:32 -0800, Rick Johnson wrote: > On Jan 14, 10:23 pm, Steven D'Aprano [email protected]> wrote: > >> This is not Java, and we prefer Python terminology. >> >> A variable holding an int is an int variable. A variable holding

Re: Problem while doing a cat on a tabbed file with pexpect

2012-01-15 Thread Steven D'Aprano
tains tabs. That is not clear at all. How do you know it contains tabs? How was the file created in the first place? Try this: text = open('me.txt', 'r').read() print '\t' in text My guess is that it will print False and that the file does not conta

<    84   85   86   87   88   89   90   91   92   93   >