Re: The Cost of Dynamism (was Re: Pyhon 2.x or 3.x, which is faster?)

2016-03-22 Thread Steven D'Aprano
quot;hello world".find("goodbye") -1 py> "hello world".startswith("goodbye") False -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: The Cost of Dynamism (was Re: Pyhon 2.x or 3.x, which is faster?)

2016-03-22 Thread Steven D'Aprano
On Wednesday 23 March 2016 09:23, Chris Angelico wrote: > On Wed, Mar 23, 2016 at 6:43 AM, Michael Torrie wrote: >> And despite the impression you may have gotten, it is appropriate to >> look before you leap. Using os.exists() and other pre-flight checks are >> appropriate. > > Hmm, can you jus

[Not actually OT] Trouble in node.js land

2016-03-23 Thread Steven D'Aprano
This is not actually off-topic, as it has relevance to open source projects like Python: the importance of getting package management right, and not basing your development ecosystem on cowboys who might pull the rug out from under your feet at any time. Ironically, this also showcases what hap

Re: numpy arrays

2016-03-23 Thread Steven D'Aprano
[1, 2, 3, 4]]) py> arr.T array([[1, 1, 1, 1], [2, 2, 2, 2], [3, 3, 3, 3], [4, 4, 4, 4]]) -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Suggestion: make sequence and map interfaces more similar

2016-03-23 Thread Steven D'Aprano
behaves like this? The answer is, of course, *no* sort of mapping. Sequences are not mappings. The only reason we think of them as kinda-sorta like mappings is because of a superficial similarity between key:value and index:item. That similarity is real, but virtually everything else about mappings and sequences is different. > This way we will have a simpler way to let people to use sequences > or maps indifferently, and let the code untouched. Have you ever actually wanted to use sequences or maps indifferently? To do what? The only case I've ever seen of that is the dict constructor, and dict.update, which will accept either a mapping or a sequence of (key, value) pairs. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

os.rename on Windows

2016-03-23 Thread Steven D'Aprano
7;w') try: os.rename('a123.junk', 'b123.junk') except OSError as e: print(e.winerror) # Windows only print(e.errno) print(repr(e)) os.unlink('a123.junk') os.unlink('b123.junk') I'd test it myself, except I don't have acc

Re: os.rename on Windows

2016-03-23 Thread Steven D'Aprano
On Wed, 23 Mar 2016 11:28 pm, Random832 wrote: > On Wed, Mar 23, 2016, at 08:17, Steven D'Aprano wrote: >> Any Windows users here? >> >> print(e.winerror) # Windows only >> print(e.errno) >> print(repr(e)) > > 183 > 17 > FileEx

Re: [Not actually OT] Trouble in node.js land

2016-03-23 Thread Steven D'Aprano
On Thu, 24 Mar 2016 12:33 am, Random832 wrote: > On Wed, Mar 23, 2016, at 05:03, Steven D'Aprano wrote: >> https://medium.com/@azerbike/i-ve-just-liberated-my-modules-9045c06be67c >> >> Of course, moving his allegedly infringing package "kik" to github isn

Re: The Cost of Dynamism (was Re: Pyhon 2.x or 3.x, which is faster?)

2016-03-23 Thread Steven D'Aprano
etter; - the coefficient is in our favour (1/2); - string copying may be quite efficient (although not as efficient as in C, where they can be implemented by just a memcopy, more or less); - the strings are getting smaller all the time, which makes memory management easier, when compared to having to allocate growing strings; - although against that, perhaps this ends up fragmenting memory even more? - it *may* turn out that the cost of the rest of the work done dwarfs the cost of copying the string in the first place - but then again it might not. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: newbie question

2016-03-24 Thread Steven D'Aprano
On Thu, 24 Mar 2016 09:39 pm, ast wrote: > Hi > > I have a string which contains a tupe, eg: > > s = "(1, 2, 3, 4)" > > and I want to recover the tuple in a variable t > > t = (1, 2, 3, 4) > > how would you do ? py> import ast py> ast.liter

Re: The Cost of Dynamism (was Re: Pyhon 2.x or 3.x, which is faster?)

2016-03-24 Thread Steven D'Aprano
> > Do you understand why people aren't taking your results very seriously? You know what is missing from this conversation? For one of Bart's critics to actually show faster code. There's plenty of people telling him off for writing unpythonic and slow code, but I haven't seen anyone actually demonstrating that Python is faster than his results show. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: newbie question

2016-03-24 Thread Steven D'Aprano
n any code they like on your computer. You want malware? That's how you get malware. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: The Cost of Dynamism (was Re: Pyhon 2.x or 3.x, which is faster?)

2016-03-24 Thread Steven D'Aprano
On Fri, 25 Mar 2016 01:04 am, BartC wrote: > On 24/03/2016 13:50, Steven D'Aprano wrote: >> On Thu, 24 Mar 2016 02:24 pm, Chris Angelico wrote: >> >> >>> This is how you're currently evaluating Python. Instead of starting >>> with the most simpl

Re: The Cost of Dynamism (was Re: Pyhon 2.x or 3.x, which is faster?)

2016-03-24 Thread Steven D'Aprano
f Barack Obama cuts himself shaving, the POTUS will have the same cut, because they are one and the same person (at least for now). But in another year or so, if Obama cuts himself, the POTUS will not notice, because the name POTUS will have been rebound to a different person. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: The Cost of Dynamism (was Re: Pyhon 2.x or 3.x, which is faster?)

2016-03-24 Thread Steven D'Aprano
a second one and then do slice assignment than to iterate over it in a for loop changing each item in place. This demonstrates that what logically ought to be more efficient (changing values in place) is not necessarily *actually* more efficient. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: The Cost of Dynamism (was Re: Pyhon 2.x or 3.x, which is faster?)

2016-03-24 Thread Steven D'Aprano
starts. > > But I understand that most people aren't interested in this kind of sport. Checkout the benchmark game: http://benchmarksgame.alioth.debian.org/ -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Undefined behaviour in C [was Re: The Cost of Dynamism]

2016-03-25 Thread Steven D'Aprano
hoice that they wanted the language to be as fast and efficient as possible, even at the cost of safe, reproducible behaviour. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: The Cost of Dynamism (was Re: Pyhon 2.x or 3.x, which is faster?)

2016-03-25 Thread Steven D'Aprano
http://www.ibm.com/developerworks/library/l-psyco/index.html Pyscho is unmaintained and doesn't work on anything better than 2.6, but the author has gone on to be one of the lead devs in PyPy, and it has inspired newer projects like numba and theano. The attitude of the core developers, esp

Re: [OT'ish] Is there a list as good as this for Javascript

2016-03-25 Thread Steven D'Aprano
side from the fact that "real name" is subjective, you have no idea what is someone's real name and what isn't. Nobody appointed you as Real Name Sheriff. Just give it up. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: The Cost of Dynamism (was Re: Pyhon 2.x or 3.x, which is faster?)

2016-03-25 Thread Steven D'Aprano
On Sat, 26 Mar 2016 09:08 am, BartC wrote: > On 25/03/2016 16:22, Steven D'Aprano wrote: >> On Fri, 25 Mar 2016 10:06 pm, BartC wrote: > > (OK, I'll risk the wrath of Mark Lawrence et al by daring to post my > opinions.) Please ignore Mark Lawrence when he is acting

Re: Undefined behaviour in C [was Re: The Cost of Dynamism]

2016-03-25 Thread Steven D'Aprano
On Sat, 26 Mar 2016 03:57 am, Marko Rauhamaa wrote: > Steven D'Aprano : > >> Undefined behaviour in C is a minefield waiting to blow your program's >> legs off, because the designers of the language made the explicit >> choice that they wanted the langu

Re: Undefined behaviour in C [was Re: The Cost of Dynamism]

2016-03-26 Thread Steven D'Aprano
a role in ensuring Python's success.) -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Suggestion: make sequence and map interfaces more similar

2016-03-26 Thread Steven D'Aprano
e agreed would be broken for a dict or other mapping. We do not have stability of "key":value pairs. This violates the property that mapping key:value pairs should be stable. Inserting new entries into a mapping, or deleting them, shouldn't affect the remaining entries. But with a sequence, it can effect the relationship between index and item. That means that indexes are not keys, and sequences are not mappings. For a sequence, this does not matter. There is no promise that items will always be found at the same index you put them in. Many operations on sequences will move items around: sort reverse pop insert delete an item or slice some slice assignments shuffle and more. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: I need help

2016-03-26 Thread Steven D'Aprano
crosoft.com/fwlink/?LinkId=550986> for Windows > 10 is that correct? 32-bit or 64-bit? -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: PLEASE HELP -- TOTALLY NEW TO PYTHON

2016-03-26 Thread Steven D'Aprano
h of subgraphs, or the index. The smaller change would probably be the first, changing subgraphs. But the better change would probably be to change the for-loop. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: How to make Python interpreter a little more strict?

2016-03-26 Thread Steven D'Aprano
ou can do is use an editor which colours functions like "next" differently from statements like "continue". -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Undefined behaviour in C [was Re: The Cost of Dynamism]

2016-03-26 Thread Steven D'Aprano
On Sat, 26 Mar 2016 01:59 pm, Paul Rubin wrote: > Steven D'Aprano writes: >> Culturally, C compiler writers have a preference for using undefined >> behaviour to allow optimizations, even if it means changing the semantics >> of your code. > > If your code has

Re: Undefined behaviour in C [was Re: The Cost of Dynamism]

2016-03-26 Thread Steven D'Aprano
On Sun, 27 Mar 2016 04:43 am, Rustom Mody wrote: > On Saturday, March 26, 2016 at 4:09:41 PM UTC+5:30, Steven D'Aprano wrote: >> On Sat, 26 Mar 2016 04:30 pm, Rustom Mody wrote: >> >> > For one thing its good to remember that we wouldn't be here without >>

Re: help with program

2016-03-26 Thread Steven D'Aprano
3 version input('Press the Enter key to exit... ') That will halt and wait for you to press the exit key before closing the window. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Threading is foobared?

2016-03-26 Thread Steven D'Aprano
[email protected]> Notice the difference? Here the two values lined up: <[email protected]> <[email protected]> -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: How to make Python interpreter a little more strict?

2016-03-26 Thread Steven D'Aprano
the brackets (round brackets or parentheses for any Americans reading) and the list doesn't sort, but that's the exception rather than the rule. And if you're worried about that, you can run a "linter" which check your source code for such potential problems. Google for PyLint, PyFlakes, PyChecker, Jedi, etc if you want more information about linters, or just ask here. I can't tell you too much about them, as I don't use them, but somebody will probably answer. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Interpretation

2016-03-26 Thread Steven D'Aprano
d Python even has a built-in function called "compile" that takes source code and compiles it a code object: py> x = compile("value = 23", "", "single") py> type(x) py> print(x) at 0xb7993300, file "", line 1> py> eval(x) py>

Re: Interpretation

2016-03-26 Thread Steven D'Aprano
ells you that your code is written wrongly and Python doesn't understand what you mean. You have to look at the code and fix the syntax problem. If you show us the line of code that Python is complaining about, and maybe the line before it, we can help. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Undefined behaviour in C [was Re: The Cost of Dynamism]

2016-03-27 Thread Steven D'Aprano
On Sat, 26 Mar 2016 08:23 am, Chris Angelico wrote: > On Sat, Mar 26, 2016 at 2:50 AM, Steven D'Aprano > wrote: >> Undefined behaviour does not mean "implementation specific behaviour". >> Nor does it mean "something sensible will happen but we don't

Re: Undefined behaviour in C [was Re: The Cost of Dynamism]

2016-03-27 Thread Steven D'Aprano
On Sun, 27 Mar 2016 05:13 pm, Paul Rubin wrote: > Steven D'Aprano writes: >> For example, would you consider that this isolated C code is >> "meaningless"? >> int i = n + 1; > > It's meaningful as long as n is in a certain range of values so th

Re: Undefined behaviour in C [was Re: The Cost of Dynamism]

2016-03-27 Thread Steven D'Aprano
le to determine at compile-time whether or not n could ever, under any circumstances, be MAXINT. If n might conceivably ever be MAXINT, then the behaviour of foo is undefined. Not implementation-specific, or undocumented. Undefined, in the special C meaning of the term. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: help with program

2016-03-27 Thread Steven D'Aprano
please speak up. I don't know Windows very well and I'm not sure why the console is disappearing in the first place. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Statements as expressions [was Re: Undefined behaviour in C]

2016-03-27 Thread Steven D'Aprano
s as expressions seems to me to be well less than the extra difficulty it would produce. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Suggestion: make sequence and map interfaces more similar

2016-03-27 Thread Steven D'Aprano
On Mon, 28 Mar 2016 05:01 am, Marco S. wrote: > Steven D'Aprano wrote: > >> The point you might have missed is that treating lists as if they were >> mappings violates at least one critical property of mappings: that the >> relationship between keys and values are

Re: How to make Python interpreter a little more strict?

2016-03-27 Thread Steven D'Aprano
On Mon, 28 Mar 2016 07:49 am, BartC wrote: > On 27/03/2016 21:32, Tim Chase wrote: >> On 2016-03-27 14:28, Steven D'Aprano wrote: > >>> In this case, the two lines "fnc" and "next" simply look up the >>> function names, but without actua

Useless expressions [was Re: Undefined behaviour in C]

2016-03-27 Thread Steven D'Aprano
the code) that this is what you intend. In your language, you can make operator overloading illegal if you like, or discourage it by requiring special syntax, but in Python it is a first-class (pun not intended) programming style of equal standing to arithmetic, strings, method calls and modules. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Useless expressions [was Re: Undefined behaviour in C]

2016-03-27 Thread Steven D'Aprano
rfectly reasonable for a linter, but not for Python. Other languages may choose to be more restrictive. Pascal, for example, requires you to declare subroutines as functions or procedures depending on whether or not they return a value, and that's got much to recommend it too. But Python made different choices. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Useless expressions [was Re: Undefined behaviour in C]

2016-03-27 Thread Steven D'Aprano
name.validate The Zen of Python has something to say about special cases. import this Now, I happen to think that using "name.validate" for the side-effects of the attribute look-up is a terrible idea. But it's legal code, and the compiler shouldn't make value judgem

Re: When to use assert

2014-10-22 Thread Steven D'Aprano
Chris Angelico wrote: > On Wed, Oct 22, 2014 at 12:44 PM, Steven D'Aprano > wrote: >> def do_something(instance_or_id): >> instance = Model.get(instance_or_id) >> assert isinstance(instance, Model) >> # Code that assumes that instance is an objec

Re: (test) ? a:b

2014-10-22 Thread Steven D'Aprano
one! The advantage of the `x if cond else y` operator is that it is a short-cutting operator, it doesn't evaluate either x or y unless needed. But for many cases that's not important, and in those cases I won't say I prefer the old (y, x)[cond] idiom, but neither do I dislike it. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: I am out of trial and error again Lists

2014-10-22 Thread Steven D'Aprano
ike, and one which does print something might not be: py> mylist = [1, 5, 2, 6, 4, 3] py> sorted(mylist) # proper function returns a value [1, 2, 3, 4, 5, 6] py> mylist.sort() # procedure-like function returns None py> print(mylist) # and modifies the list in place [1, 2, 3, 4, 5, 6] -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: (test) ? a:b

2014-10-22 Thread Steven D'Aprano
abomination that no right-thinking person should ever use because the order of terms isn't identical to C, and now the attitude seems to be that anyone *not* using ternary if is a heretic who deserves to be set on fire :-) -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Truthiness

2014-10-23 Thread Steven D'Aprano
r built-ins and the standard library at least, a good distinction to make is that representations of Nothing (e.g. None, empty string, empty list, zero, empty set, etc.) are falsey, while representations of Something (e.g. non-empty strings, non-empty lists, numbers other than zero, non-empty sets,

Re: When to use assert

2014-10-24 Thread Steven D'Aprano
use assertions as checked comments. If the requirements change and you forget to update this part of the code, the assertions will fail: assert x in (a, b, c) if x == a: do_this() elif x == b: do_that() else: assert x == c do_something_else() >> Or is that insufficiently paranoid? > > With good tests, you're probably fine. Is it possible to be too paranoid when it comes to tests? :-) -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: (test) ? a:b

2014-10-24 Thread Steven D'Aprano
bobble("string%s" % carrot.gamma(r&s)* (this & that).fetch(83, 36, when=when or "now") ][cond or flag or foo(42)-1 > 17 or bar(b) < thingy(c) or not d] but re-writing that using ternary if operator won't help one iota. I don't see why `[a, b][flag]` is inherently less readable than `b if flag else a`. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: (test) ? a:b

2014-10-24 Thread Steven D'Aprano
Marko Rauhamaa wrote: > Steven D'Aprano : > >> So why is it hard to read when the index is a flag? >> >> value = [f, g][cond]() > > So, subjectively, which syntax would you prefer: Depends on what else the code is doing. But my personal preference is a r

Re: python student at university of jordan.

2014-10-24 Thread Steven D'Aprano
uot;", line 1 > import re, codecs ^ SyntaxError: invalid syntax If that is not the error message you are getting, you will need to tell us what error you actually are getting. Regards, -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: (test) ? a:b

2014-10-24 Thread Steven D'Aprano
alister wrote: > On Fri, 24 Oct 2014 10:20:30 -0700, Dan Stromberg wrote: > >> On Fri, Oct 24, 2014 at 1:38 AM, Steven D'Aprano >> wrote: >>> I don't get why that's considered hard to read. >> >>> So why is it hard to read when the

Re: I am out of trial and error again Lists

2014-10-25 Thread Steven D'Aprano
like this: old_lists = [a, b, c, d] new_lists = [thelist.append(x) for thelist in old_lists if len(thelist) < 5] only to be unpleasantly surprised to discover than new_lists now contains None instead of the lists. Having methods return a result rather than behave like a procedure is a valid (i.e. useful) design choice. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: (test) ? a:b

2014-10-25 Thread Steven D'Aprano
Ben Finney wrote: > Steven D'Aprano writes: > >> Of course it won't be clear to *everyone* but it should be clear >> enough to people who are familiar with standard Python idioms. A >> concrete example should be more obvious than the fake example: >>

Re: (test) ? a:b

2014-10-25 Thread Steven D'Aprano
Ben Finney wrote: > Steven D'Aprano writes: > >> I suspect that Guido and the core developers disagree with you, since >> they had the opportunity to fix that in Python 3 and didn't. > > That doesn't follow; there are numerous warts in Python 2 t

Side-effects [was Re: I am out of trial and error again Lists]

2014-10-25 Thread Steven D'Aprano
s (like numbers), and discourages the unnecessary use of global mutable state. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: When to use assert

2014-10-26 Thread Steven D'Aprano
Chris Angelico wrote: > On Fri, Oct 24, 2014 at 6:49 PM, Steven D'Aprano > wrote: >> addresses = [get_address(name) for name in database] >> assert all(address for address in addresses) >> # ... much later on ... >> for i, address in enumerate(a

Re: Status of side-effecting functions in python

2014-10-27 Thread Steven D'Aprano
lyWrittenError? I would expect it to raise an IOError, most likely with one of the following error codes: * errno.EIO (physical input/output error) * errno.EFBIG (file is too large) * errno.ENOSPC (no space left on device, disk is full) -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Python Style Question

2014-10-30 Thread Steven D'Aprano
functional form: def tolerant_load_int(obj, default=None): try: return load_int(obj) except (ValueError, TypeError): return default values = [n for n in map(tolerant_load_int, l) if n is not None] # alternative to using map values = [n for n in (tolerant_load_int(obj) for obj in l) if n is not None] -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Python Style Question

2014-10-30 Thread Steven D'Aprano
MRAB wrote: > On 2014-10-30 11:10, Steven D'Aprano wrote: >> Anton wrote: >> >>> Let's say I have an incoming list of values *l*. Every element of *l* >>> can be one of the following options: >>> 1) an integer value >>> 2) a string in f

Re: Python Style Question

2014-10-30 Thread Steven D'Aprano
Roy Smith wrote: > In article <[email protected]>, > Steven D'Aprano wrote: > >> Anton wrote: >> >> > Let's say I have an incoming list of values *l*. Every element of *l* >> > can be one of the followin

Re: Saving a file "in the background" -- How?

2014-10-31 Thread Steven D'Aprano
mit -a") if it looks okay.) I don't see how this sort of manual handling is less trouble than using a proper, reliable save routine. To start with, what do you mean "detect issues on startup" -- startup of what? -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Classes

2014-10-31 Thread Steven D'Aprano
: return self.value def set_message(self, message): self.message = message def get_message(self): return self.message obj = MyClass() obj.set_value(23.0) obj.set_message("hello world") print(obj.get_value()) print(obj.get_message()) If you'

Re: Popen class?

2014-10-31 Thread Steven D'Aprano
[email protected] wrote: > What is Popen class? Googling could answer that: https://duckduckgo.com/html/?q=python+popen+class If you have a specific question, please be more detailed when you ask your question, then we can give more specific answers. -- Steven -- ht

Re: Classes

2014-10-31 Thread Steven D'Aprano
t;) # calls __len__ method 12 Files have quite a few examples. fileno, isatty and writable could all be written as read-only properties, and seek/tell could be written as a file.position property. But they're not, they're written as methods. [1] Except for Jythonistas, who are allo

Re: Classes

2014-10-31 Thread Steven D'Aprano
makes us look like religious fanatics. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Challenge: optimizing isqrt

2014-10-31 Thread Steven D'Aprano
se the optimized version? Q3: What is the largest value of n beyond which you can never use the float optimization? You can assume that Python floats are IEEE-754 C doubles, and that math.sqrt() is correctly rounded. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: [Python-Dev] Dinamically set __call__ method

2014-11-06 Thread Steven D'Aprano
re per-instance state. If instance "a" needs an extra parameter that other instances don't, perhaps it can take it from an instance attribute instead of an argument. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Understanding "help" command description syntax - explanation needed

2014-11-06 Thread Steven D'Aprano
s-open.html Another way to look at this, not necessarily Voevodsky's approach, is to note that the existing proofs of PA's consistency are *relative* proofs of PA. E.g. they rely on the consistency of some other formal system, such as the Zermelo-Frankel axioms (ZF). If ZF is consistent, so is PA, but we don't know that ZF is consistent... -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Understanding "help" command description syntax - explanation needed

2014-11-07 Thread Steven D'Aprano
Dave Angel wrote: > Approximately 1968 for me. I wrote programs in 1967, but didn't > get to run them till 1968. I once used a compiler that slow too. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Call for information - What assumptions can I make about Unix users' access to Windows?

2014-11-07 Thread Steven D'Aprano
of Java provided by my Linux distro. I had to replace my system Java with Oracle's Java, symlink it to an alternate location, and have my browser lie about what it is in the user-agent. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Different behaviour in list comps and generator expressions

2014-11-07 Thread Steven D'Aprano
Has it caused difficulty in debugging code? If you had to keep one behaviour, which would you keep? -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: What is description attribute in python?

2014-11-09 Thread Steven D'Aprano
ntation for curs to know what it does. What is curs? Where does it come from? -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: What does zip mean?

2014-11-09 Thread Steven D'Aprano
) > colnames = [desc[0] for desc in curs.description] > rowdicts = [] > for row in curs.fetchall(): >rowdicts.append(dict(zip(colnames, row))) zip(colnames, row) will return: (first column name, first item of row), (second column name, second item of row), (third column

Re: Syncing audio and video for casual recording

2014-11-09 Thread Steven D'Aprano
27;t have any camera yet, other than a prosumer digital > camera that does take decent video. The problem that I'm > anticipating is the syncing of audio and video. [...] I think you may have sent this to the wrong mailing list (or newsgroup). This is about the Python programming language.

Re: What is rstrip() in python?

2014-11-09 Thread Steven D'Aprano
ite3.connect('dbase1') > curs = conn.cursor() > > file = open('data.txt') > rows = [line.rstrip().split(',') for line in file] -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: [Python-Dev] Dinamically set __call__ method

2014-11-09 Thread Steven D'Aprano
SomeClass() c.eggs = 23 from types import MethodType a.my_call = lambda x, y=1: x/y b.my_call = lambda spam: str(spam).upper() c.my_call = MethodType(lambda self: self.eggs + 1, c) -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: I don't read docs and don't know how to use Google. What does the print function do?

2014-11-14 Thread Steven D'Aprano
think that 99 out of 100 *programmers* can't program. It's probably more like 65, maybe 70 out of 100, tops. Ha ha only serious. More here: http://www.protocolostomy.com/2010/03/15/programmers-that-cant-program/ -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: What does zip mean?

2014-11-14 Thread Steven D'Aprano
r. While muxing and demuxing is extremely important in circuit design and telecommunications, I've never needed it in Python programming. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: I love assert

2014-11-14 Thread Steven D'Aprano
it doesn't absolve you of normal exception > responsibilities, and, most of all, it should be used for passive > inspection and not action. But given these guidelines, I still find it > very useful as "active comments". Agreed completely! -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: I love assert

2014-11-14 Thread Steven D'Aprano
re of process. If your process is so poor that you release code without running it with asserts enabled, then assert will not save you from bugs. No process is immune to sufficiently malicious or incompetent use. Assertions are just a tool, not a panacea. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: I love assert

2014-11-14 Thread Steven D'Aprano
de is great, code that crashes could use improvement, but incorrect code that doesn’t crash is a horrible nightmare." -- Chris Smith Assertions can help by this, by causing wrong code to fail as soon as possible (provided, of course, that you don't defeat the assertions by ru

Re: I love assert

2014-11-14 Thread Steven D'Aprano
pilation options: for a correct system -- one without bugs -- assertions will always hold, so the compilation option makes no difference to the semantics of the system. https://docs.eiffel.com/book/method/et-design-contract-tm-assertions-and-exceptions -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: I love assert

2014-11-14 Thread Steven D'Aprano
Ethan Furman wrote: > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > On 11/14/2014 03:33 AM, Steven D'Aprano wrote: >> >> I agree with Marko in this case. Marko's example of defensive programming >> is very similar to the one I gav

Re: Curious function argument

2014-11-15 Thread Steven D'Aprano
a global, use the global keyword. Otherwise, there are often better ways to get a similar effect, such as using a generator: def gen(): x = 0 while True: yield x x += 1 it = gen() next(it) # returns 0 next(it) # returns 1 next(it) # returns 2 You can turn that into funct

Re: How about some syntactic sugar for " __name__ == '__main__' "?

2014-11-15 Thread Steven D'Aprano
module's actual name (as taken from the file name). * But when Python runs a file, as in `python2.7 path/to/script.py`, it sets the global __name__ to the magic value '__main__' instead of "script". The consequence is that every module can tell whether it is bei

Re: How about some syntactic sugar for " __name__ == '__main__' "?

2014-11-15 Thread Steven D'Aprano
uot;done loading" (I haven't ever done *all* of these things in a *single* file, but I have done all these things at one time or another.) There's no way that any automatic system can match that for flexibility or simplicity. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: fileno() not supported in Python 3.1

2014-11-15 Thread Steven D'Aprano
ecause the OP states that he is using Python 3.1 (look at the subject line) and it doesn't work in 3.1. For what it is worth, I cannot confirm that alleged behaviour: steve@orac:~$ python3.1 -c "import sys; print(sys.stdout.fileno())" 1 I suspect that the OP may be using an IDE which does something funny to sys.stdout etc., or perhaps he has accidentally shadowed them. The OP failed to copy and paste the actual traceback, so who knows what is actually happening? -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: A Freudian slip of *EPIC PROPORTIONS*!

2014-11-15 Thread Steven D'Aprano
, the "phooey" could refer to: - the parse functions failing to understand Unicode; - it being a nasty hack that assumes that Python will never use Unicode characters for keywords or operators; - it being necessary because u''.translate fails to support a deletechars parameter. It's unlikely to refer to the Unicode character set itself. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Question about installing python and modules on Red Hat Linux 6

2014-11-15 Thread Steven D'Aprano
dules are and what errors the infrastructure team experienced, there is no way to tell whether four weeks to get this working was a heroic effort or a sign of utter incompetence. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Decorators (was: Re: I love assert)

2014-11-15 Thread Steven D'Aprano
for improving code reliability. > Perhaps I was spoiled by having this capability in some other languages. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Question about installing python and modules on Red Hat Linux 6

2014-11-15 Thread Steven D'Aprano
Grant Edwards wrote: > On 2014-11-15, Steven D'Aprano > wrote: >> pythonista wrote: >> >>> I am developing a python application as a contractor. >>> >>> I would like to know if someone can provide me with some insight into >>>

Re: [ANN] Brython 3.0.0 relased

2014-11-16 Thread Steven D'Aprano
avascript. Very nice! -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Using map()

2014-11-16 Thread Steven D'Aprano
builtin, it is perfectly fine. Some people don't like map. Pay no attention to them. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: How modules work in Python

2014-11-16 Thread Steven D'Aprano
ge = _temporary_name_123456.Image del _temporary_name_123456 except that no temporary name is actually created. So you can see, the PIL module has been imported (that's the only way Python can look up Image inside PIL), but you don't have access to it in your name space. But you

Re: How to fix those errors?

2014-11-16 Thread Steven D'Aprano
at do you think? Is it perhaps better suited to perl-ideas? Feeling-whimsical-at-the-moment-ly y'rs, -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: I love assert

2014-11-16 Thread Steven D'Aprano
Ethan Furman wrote: > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > On 11/14/2014 06:58 PM, Steven D'Aprano wrote: >> Ethan Furman wrote: >>> >>> My point being: a safety net that is so easily disabled does not count >>> (IMHO) as a back

Re: import graphics library; causes error

2014-11-17 Thread Steven D'Aprano
and tell them that based on your extensive experience (all ten minutes of it) they're obviously doing it wrong and Python is a toy language not suitable for critical business apps? I'm sure that they will be grateful to be set right. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: caught in the import web again

2014-11-17 Thread Steven D'Aprano
s and didn't > like how perl *requires* you to put everything into its own file. Now it > looks like python does, too, implicitly. You are mistaken about that. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

<    56   57   58   59   60   61   62   63   64   65   >