Re: Explanation of list reference

2014-02-17 Thread Steven D'Aprano
rce code at compile time, but it can't do anything about mock source code until runtime when you pass it to exec, eval or compile. That's because until that moment, it's just a string of characters, not source code. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Does CPython already has Peephole optimizations?

2014-02-17 Thread Steven D'Aprano
ation apart from some simple constant folding. If you're interested in optimizing Python, you should look at the JIT optimizing Python compiler, PyPy. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Google Cloud Platform and GlassSolver Project

2014-02-17 Thread Steven D'Aprano
3 tl;dr: you've announced a project that never existed as "back and better than ever", and asked others to write the code for you. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Import order question

2014-02-18 Thread Steven D'Aprano
Not in the least bit surprising. I expected nothing less from you. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Import order question

2014-02-18 Thread Steven D'Aprano
API, breaking large chunks of code up and > spreading them across individual files is the key to managing code > bases. You left out the word "badly". -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Help creating new module which inherits existing class from another module.

2014-02-18 Thread Steven D'Aprano
ce. That descriptor will create and populate the FooClass instance, which does the real work. Descriptors are how methods, classmethods, staticmethods and properties work, so they are a fundamental, powerful way of implementing things like this. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Commonly-used names in the Python standard library

2014-02-20 Thread Steven D'Aprano
supposed to solve? Do you often find that Python has introduced new keywords, breaking your code? -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Just For Inquiry

2014-02-20 Thread Steven D'Aprano
t; more): What does this have to do with Python? Please don't encourage people to choose a random, inappropriate newsgroup/ mailing list to ask unrelated questions. Some slack can be given to regulars who raise interesting OT questions, but not drive-by posters. -- Steven -- https://mail

Re: Commonly-used names in the Python standard library

2014-02-20 Thread Steven D'Aprano
It's hard enough for newbies to deal with *two* dialects, 2 and 3. And you want to introduce dozens. Thanks, but no thanks. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Commonly-used names in the Python standard library

2014-02-20 Thread Steven D'Aprano
On Thu, 20 Feb 2014 20:39:10 +1100, Chris Angelico wrote: > In working on a proposal that might result in the creation of a new > keyword, I needed to ascertain what names were used extensively in > existing Python code. I would love to steal^W see your script for doing this :-) -

Re: Commonly-used names in the Python standard library

2014-02-20 Thread Steven D'Aprano
hen I can write code like: for for in in: while while: if if: raise raise which will go a long way to ensuring that my code is an hostile and unreadable as possible. (Sometimes, less can be more. That's especially true of programming languages.) -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Can global variable be passed into Python function?

2014-02-21 Thread Steven D'Aprano
bject.htm and also see the Wikipedia article: http://en.wikipedia.org/wiki/Evaluation_strategy If you show us a sample of your code, together of a sample of how you expect it to work, we can suggest an alternate way to solve that problem. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Commonly-used names in the Python standard library

2014-02-21 Thread Steven D'Aprano
ode readability Or greatly destroy it, which is precisely the reason why Python doesn't have a macro system. When Guido van Rossum reads Python code, he wants it to look like Python code, not some arbitrary custom-built language. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: New to working with APIs, any good tutorials/books/guides?

2014-02-21 Thread Steven D'Aprano
e manual for a language or library, that's documenting the API. That's all there is to it. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: New to working with APIs, any good tutorials/books/guides?

2014-02-21 Thread Steven D'Aprano
e better for you to give us concrete examples of what you don't understand, rather than to continue talking in vague generalities. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Can global variable be passed into Python function?

2014-02-21 Thread Steven D'Aprano
ord "variable"). Now, I use the terms "variable" or "reference" or "name binding" as I feel makes the most sense in context, depending on my best guess of the risk of misunderstanding or confusion. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Storing the state of script between steps

2014-02-21 Thread Steven D'Aprano
ns of it that you need extra abstraction layers? Of course, I might be misinterpreting your post. Perhaps you do have so many steps, and so many different types of deployment, that you do need a more heavily abstracted system. In that case, I think you need to describe your system in more d

Re: Can global variable be passed into Python function?

2014-02-21 Thread Steven D'Aprano
out there reading this, please respond with more detail about what you are trying to do! -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Can global variable be passed into Python function?

2014-02-21 Thread Steven D'Aprano
oesn't it swap the two variables, but it raises an exception. Far from being a universal swap, it's merely an obfuscated function to swap a few hard-coded local variables. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Can global variable be passed into Python function?

2014-02-21 Thread Steven D'Aprano
not do that -- you have to manually manage the pointers yourself, while Pascal does it for you. And Python also has nothing like that. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Can global variable be passed into Python function?

2014-02-22 Thread Steven D'Aprano
b[1] > > Provably identical to: > > def swap(a, b): > return b, a > > The rest is just fluff. You don't even need the function call. a, b = b, a -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Can global variable be passed into Python function?

2014-02-22 Thread Steven D'Aprano
On Sat, 22 Feb 2014 18:29:02 +1100, Chris Angelico wrote: > On Sat, Feb 22, 2014 at 6:18 PM, Steven D'Aprano > wrote: >> Now I daresay that under the hood, Pascal is passing the address of foo >> (or bar) to the procedure plus, but inside plus you don't see that >&

Re: Can global variable be passed into Python function?

2014-02-22 Thread Steven D'Aprano
On Sat, 22 Feb 2014 09:28:10 +0200, Marko Rauhamaa wrote: > Steven D'Aprano : > >> But your code doesn't succeed at doing what it sets out to do. If you >> try to call it like this: >> >> py> x = 23 >> py> y = 42 >> py> swap(x, y) &

Re: Can global variable be passed into Python function?

2014-02-22 Thread Steven D'Aprano
y use the Mac Toolbox memory routines to allocate memory, create and destroy handles, etc. If you just used your programming language's normal pointers, they couldn't and wouldn't move. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Can global variable be passed into Python function?

2014-02-22 Thread Steven D'Aprano
the only difference. The big difference is that in "fixed location" languages, it makes sense to talk about the address of a *variable*. In C, you might ask for &xyz and get 123456 regardless of whether xyz is assigned the value 1, or 23, or 999. But in Python, you can't a

Re: Can global variable be passed into Python function?

2014-02-22 Thread Steven D'Aprano
On Sun, 23 Feb 2014 12:50:26 +1100, Chris Angelico wrote: > On Sun, Feb 23, 2014 at 12:39 PM, Steven D'Aprano > wrote: >> In C or Pascal-style languages, what we might call the "fixed address" >> style of variables, a variable assignment like xy

Re: Functions help

2014-02-23 Thread Steven D'Aprano
hat? Sorry, I don't really understand your question. Could you show an example of what you are doing? Do you mean "add 5" or "*5"? "Add *5 doesn't really mean anything to me. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Can global variable be passed into Python function?

2014-02-23 Thread Steven D'Aprano
On Sun, 23 Feb 2014 11:52:05 +0200, Marko Rauhamaa wrote: > Steven D'Aprano : > >> The big difference is that in "fixed location" languages, it makes >> sense to talk about the address of a *variable*. > > The address could be a symbol, too. > > The

Re: Can global variable be passed into Python function?

2014-02-23 Thread Steven D'Aprano
ode with the underlying implementation of the Python virtual machine. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Problem with the console on the new python.org site

2014-02-23 Thread Steven D'Aprano
ed soon ? Not unless somebody raises it as a bug, or uses the feedback form to notify the web developers. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Can global variable be passed into Python function?

2014-02-24 Thread Steven D'Aprano
On Mon, 24 Feb 2014 21:07:42 +1300, Gregory Ewing wrote: > Steven D'Aprano wrote: >> Yes, Pascal has pointers as a first-class data type. Syntax is similar >> to C, ^x is a pointer to x, p^ dereferences the pointer p. > > Actually, the prefix ^ is only used fo

Re: Python 3.5, bytes, and %-interpolation (aka PEP 461)

2014-02-24 Thread Steven D'Aprano
> What is under debate is whether we should also add %a: > >b'%a' % some_obj --> b'some_obj_repr' > > What %a would do: > >get the repr of some_obj > >convert it to ascii using backslashreplace (to handle any code points >over 127) > >encode to bytes using 'ascii' > > Can anybody think of a use-case for this particular feature? Not me. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Python 3.5, bytes, and %-interpolation (aka PEP 461)

2014-02-24 Thread Steven D'Aprano
human-readable, but *semantically meaningful*. That's why the subject line is labelled "Subject" rather than "Field 23" or "SJT". Fortunately, such headers are usually (always?) ASCII, and byte strings in Python privilege ASCII-encoded text. When you write b'Subject', you get the same sequence of bytes as 'Subject'.encode('ascii'). -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Python 3.5, bytes, and %-interpolation (aka PEP 461)

2014-02-24 Thread Steven D'Aprano
On Mon, 24 Feb 2014 16:10:53 -0800, Ethan Furman wrote: > On 02/24/2014 03:55 PM, Steven D'Aprano wrote: >> Will b'%s' take any arbitrary object, as in: >> >> b'Key: %s' % [1, 2, 3, 4] >> => b'Key: [1, 2, 3, 4]' > > No. Ver

Re: intersection, union, difference, symmetric difference for dictionaries

2014-02-25 Thread Steven D'Aprano
result. What, getting a set back? No, I disagree. If you want a set, it's easy to do: dicta.keys() | dictb.keys() (In Python 2, use viewkeys instead.) gives you a set of the intersection of the keys. The only point of having dicts support set-like operations directly is if you get a dict bac

Re: intersection, union, difference, symmetric difference for dictionaries

2014-02-25 Thread Steven D'Aprano
lues of a set*, but here "value" is being used as a synonym for "element" and not as a technical term for the thing which mappings associate with a key. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

exec and locals

2014-02-26 Thread Steven D'Aprano
exec, I need to do this instead: py> def eggs(): ... mylocals = {} ... exec( """x = 23""", globals(), mylocals) ... x = mylocals['x'] ... return x ... py> eggs() 23 The fact that it works in spam() above is perhaps an accident of imp

Re: exec and locals

2014-02-26 Thread Steven D'Aprano
On Wed, 26 Feb 2014 14:46:39 +0100, Peter Otten wrote: > Steven D'Aprano wrote: > >> I have to dynamically generate some code inside a function using exec, >> but I'm not sure if it is working by accident or if I can rely on it. >> >> Here is a

Re: exec and locals

2014-02-26 Thread Steven D'Aprano
On Wed, 26 Feb 2014 14:00:59 +, Alister wrote: > On Wed, 26 Feb 2014 13:15:25 +0000, Steven D'Aprano wrote: > >> I have to dynamically generate some code inside a function using exec, >> but I'm not sure if it is working by accident or if I can rely on it. [...]

Re: exec and locals

2014-02-26 Thread Steven D'Aprano
On Thu, 27 Feb 2014 16:34:33 +1300, Gregory Ewing wrote: > Steven D'Aprano wrote: >> except SyntaxError: >> def inner(): >> # manually operate the context manager call context manager >> __enter__ >>

Re: exec and locals

2014-02-26 Thread Steven D'Aprano
which can be called from multiple versions of Python from a single installation. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: exec and locals

2014-02-27 Thread Steven D'Aprano
On Fri, 28 Feb 2014 00:29:35 +1300, Gregory Ewing wrote: > Steven D'Aprano wrote: >> On Thu, 27 Feb 2014 16:34:33 +1300, Gregory Ewing wrote: >> >>>Why not just use this version all the time? It should work in both 2.x >>>and 3.x. >> >> B

Re: Descriptor type hinting

2014-02-27 Thread Steven D'Aprano
On Thu, 27 Feb 2014 22:21:31 +, Joseph L. Casale wrote: > How does one satisfy a lint/type checker with the return value of a > class method decorated with a descriptor? Surely the answer will depend on the linter you are using. Care to tell us, or shall we guess? -- Steven --

Re: Can global variable be passed into Python function?

2014-02-27 Thread Steven D'Aprano
gt; A is B > False > . and WHY that is or isn't If they point to the same piece of memory -- which, by the way, can be moved around if the garbage collector supports it -- then A is B cannot possibly return False. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: extend methods of decimal module

2014-02-27 Thread Steven D'Aprano
what value the caller wanted is to leave the choice of truncating floats up to them. That's what the decimal module does, and it is the right decision. If the user passes a float directly, they should get *exact conversion*, because you have no way of knowing whether they actually wanted the float to be truncated or not. If they do want to truncate, they can pass it to string themselves, or supply a string literal. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: extend methods of decimal module

2014-02-27 Thread Steven D'Aprano
and why can't all sorts of other types? And that's a huge can > of worms. I like Fractions, but I don't think they're important enough for the average users to require literal notation. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Can global variable be passed into Python function?

2014-02-28 Thread Steven D'Aprano
you can explain a good reason why, say, *this* instance "CONNECTED" should fail the test, while *that* instance with the same value passes, it's not a good use-case for "is". -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: extend methods of decimal module

2014-02-28 Thread Steven D'Aprano
On Fri, 28 Feb 2014 19:52:45 +1100, Chris Angelico wrote: > On Fri, Feb 28, 2014 at 6:34 PM, Steven D'Aprano > wrote: >> On Fri, 28 Feb 2014 16:00:10 +1100, Chris Angelico wrote: >> >>> If we had some other tag, like 'd', we could actually construct a

Re: Can global variable be passed into Python function?

2014-02-28 Thread Steven D'Aprano
On Fri, 28 Feb 2014 12:02:03 +0200, Marko Rauhamaa wrote: > PS On the topic of enums, when are we getting support for a switch > statement? http://legacy.python.org/dev/peps/pep-3103/ http://legacy.python.org/dev/peps/pep-0275/ -- Steven -- https://mail.python.org/mailman/listinfo/

Re: Can global variable be passed into Python function?

2014-02-28 Thread Steven D'Aprano
hing): ... @case(RED): def handle_red(something): ... dispatch[BLUE](something) There are all sorts of simple and neat ways to handle switches in Python. That's why the pressure on the language to grow special syntax is quite low. It simply isn't important enough. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Can global variable be passed into Python function?

2014-02-28 Thread Steven D'Aprano
e table itself: # instead of this dispatch[key](node) # do this dispatch.get(key, lambda node: float('nan'))(node) > Which do *you* find more readable? With proper code layout, the dict-based dispatch table is at least as readable, and it avoids needing any magic compiler support. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Can global variable be passed into Python function?

2014-02-28 Thread Steven D'Aprano
part from equality, so why would you bother to change the implementation? (If this sounds like a mild argument against Enums, I guess it is. After all, Python worked quite well for 20+ years without Enums. Using strings as "poor man's enums" works well enough. That's why it to

Re: Can global variable be passed into Python function?

2014-02-28 Thread Steven D'Aprano
On Sat, 01 Mar 2014 02:03:51 +0200, Marko Rauhamaa wrote: > Steven D'Aprano : > >> You can't have it both ways: you cannot claim that switch or case is >> more readable than a chain of if...elif, and then propose a syntax >> which is effectively a chain of if...

Re: Can global variable be passed into Python function?

2014-02-28 Thread Steven D'Aprano
;s an implementation detail. What we have here is the curse of the singleton design anti-pattern: http://accu.org/index.php/journals/337 https://molecularmusings.wordpress.com/2011/11/11/singleton-is-an-anti-pattern/ Since the symbols IDLE, CONNECTING etc. don't have state apart from their name, whether there is one or a million and one instances is irrelevant. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Can global variable be passed into Python function?

2014-02-28 Thread Steven D'Aprano
On Sat, 01 Mar 2014 03:06:38 +0200, Marko Rauhamaa wrote: > Steven D'Aprano : > >> I can only imagine you mean something like this: >> >> class Outer: >> class InnerOne: >> ... >> >> class InnerTwo: >> ... >>

Re: Can global variable be passed into Python function?

2014-02-28 Thread Steven D'Aprano
On Sat, 01 Mar 2014 13:03:53 +1100, Chris Angelico wrote: > On Sat, Mar 1, 2014 at 12:59 PM, Steven D'Aprano > wrote: >> However, the example as given won't quite work. You never instantiate >> the Idle etc. classes, which means the methods won't work. You need

Re: Python : parsing the command line options using optparse

2014-03-01 Thread Steven D'Aprano
t. Instead, just refer to the function object itself, without calling it: object_type_dictonary = { # no parens after the functions 'LIN' : corrupt_inode, 'INODE' : corrupt_lin, 'DATA' : corrupt_data, } Then, after you look up the object type, then and onl

Re: Can global variable be passed into Python function?

2014-03-01 Thread Steven D'Aprano
cannot fail. Still, I've repeatedly asked Marko to justify why we should care about the symbols being singletons, and unless I've missed something, he hasn't even attempted to justify that. It seems to me that he's just assuming that symbols ought to be singletons, hence his focus on identity rather than equality. -- Steven D'Aprano http://import-that.dreamwidth.org/ -- https://mail.python.org/mailman/listinfo/python-list

Re: Can global variable be passed into Python function?

2014-03-01 Thread Steven D'Aprano
ly important at the next step, when you replace the Symbol class with regular strings. If the caller happens to use "C" rather than ABC.C, why is this a problem? -- Steven D'Aprano http://import-that.dreamwidth.org/ -- https://mail.python.org/mailman/listinfo/python-list

Re: Can global variable be passed into Python function?

2014-03-01 Thread Steven D'Aprano
On Sat, 01 Mar 2014 20:25:51 +0200, Marko Rauhamaa wrote: > Steven D'Aprano : > >> It seems to me that he's just assuming that symbols ought to be >> singletons, hence his focus on identity rather than equality. > > Yes. > > A practical angle is this: i

Re: Can global variable be passed into Python function?

2014-03-02 Thread Steven D'Aprano
or performs the check we want, but over what check we want: do we want an identity test or an equality test? -- Steven D'Aprano http://import-that.dreamwidth.org/ -- https://mail.python.org/mailman/listinfo/python-list

Re: Can global variable be passed into Python function?

2014-03-02 Thread Steven D'Aprano
__eq__(). For all *you* know, perhaps, but since os.posix_fadvise is a thin wrapper around the POSIX C function fadvise, and that is documented as expecting ints for the advice parameter, that cannot be the case. Unfortunately Python has not had the money put into it to make it an ISO standard like Java, and so there are certain areas where the behaviour is known by common practice but not officially documented. (A bit like British common law.) That the os module is a thin wrapper around os- specific services may not be explicitly stated, but it is nevertheless true. -- Steven D'Aprano http://import-that.dreamwidth.org/ -- https://mail.python.org/mailman/listinfo/python-list

Re: Password validation security issue

2014-03-02 Thread Steven D'Aprano
here are a class of threats where you lose your key, or someone steals it, or makes a copy, but the risks are well-understood and can be managed even by your grandmother. We have good solutions for those problems that work well, and many of them apply just as well to sticky notes with secure passwords written on them. -- Steven D'Aprano http://import-that.dreamwidth.org/ -- https://mail.python.org/mailman/listinfo/python-list

Re: Can global variable be passed into Python function?

2014-03-02 Thread Steven D'Aprano
On Sun, 02 Mar 2014 13:33:11 +0200, Marko Rauhamaa wrote: > Steven D'Aprano : > >> On Sun, 02 Mar 2014 11:35:43 +0200, Marko Rauhamaa wrote: >>> Now, what kinds of object are those constants? We are not supposed to >>> know or care. >> >> Incorre

Re: Functional programming

2014-03-02 Thread Steven D'Aprano
rative paradigm (e.g. the import and del statements), and you can use iterators and generators to program using a pipelining paradigm. -- Steven D'Aprano http://import-that.dreamwidth.org/ -- https://mail.python.org/mailman/listinfo/python-list

Re: Error compressing tar file

2014-03-02 Thread Steven D'Aprano
g, but it looks like it is an open file object. I think that you probably expect this: dumpfile = "path to some file" tarfile.open(dumpfile + '.tar.gz','w:gz') but what you actually have is probably something like this: dumpfile = open("path to some fi

Re: Password validation security issue

2014-03-02 Thread Steven D'Aprano
hon script content is to code a simple binary program > to call it? I don't understand this question. Can you explain more? -- Steven D'Aprano http://import-that.dreamwidth.org/ -- https://mail.python.org/mailman/listinfo/python-list

Re: Password validation security issue

2014-03-02 Thread Steven D'Aprano
On Sun, 02 Mar 2014 18:52:40 -0700, Ian Kelly wrote: > On Sun, Mar 2, 2014 at 6:16 PM, Steven D'Aprano > wrote: >> People have managed physical keys for *centuries*. Yes, there are a >> class of threats where you lose your key, or someone steals it, or >> makes a

Re: Origin of 'self'

2014-03-02 Thread Steven D'Aprano
But Simula 67 was the inspiration for Smalltalk, invented by Alan Kay at Xerox PARC in the 1970s, and Smalltalk used "self". Virtually everything in OOP that followed was influenced by or derived from Smalltalk. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Password validation security issue

2014-03-03 Thread Steven D'Aprano
ll, it's annoying -- it's like having your identity stolen by a hermit on some mountain top who doesn't do anything with it, except prevent you from using it. -- Steven D'Aprano http://import-that.dreamwidth.org/ -- https://mail.python.org/mailman/listinfo/python-list

Re: Functional programming

2014-03-03 Thread Steven D'Aprano
an dynamic typing. But if you have static typing, there's *no point* to it if the type system cannot detect bugs, and having to declare types is like having to calculate your own GOTO addresses. With a good type system like ML or Haskell have, you're not fighting the compiler, *every* typ

Re: Password validation security issue

2014-03-03 Thread Steven D'Aprano
o print them on rice paper instead of a sticky note.) The concept is that writing down strong passwords is preferable to remembering weak passwords given the typical threats most people are exposed to. -- Steven D'Aprano http://import-that.dreamwidth.org/ -- https://mail.python.org/mailman/listinfo/python-list

Re: Reference

2014-03-03 Thread Steven D'Aprano
not. In > production code, 'is' tests that an object *is* a particular singular > object, such as None or a sentinel instance of class object. In test > code, 'is' can also be used to test details of a particular > implementation, such as pre-allocation of small ints. N

Re: Reference

2014-03-03 Thread Steven D'Aprano
hink of any good reason to treat it as a value where I would want to use an equality test. > except > for the fact that there has been 20 years of custom saying that > comparing to None with equality is wrong. It's not *necessarily* wrong, merely wrong the 99.9998% of the time that you want to treat None as a sentinel. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Reference

2014-03-03 Thread Steven D'Aprano
cared, you could implement your own None_ish_Type and create as many named sentinels as you wish. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Reference

2014-03-03 Thread Steven D'Aprano
instead of multiplication or division.) If your intention is to treat None as a singleton sentinel, not as a value, then you ought to use "is" to signal that intention, rather than using == even if you know that there won't be any false positives. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Functional programming

2014-03-03 Thread Steven D'Aprano
On Tue, 04 Mar 2014 05:37:27 +1100, Chris Angelico wrote: > On Tue, Mar 4, 2014 at 4:27 AM, Steven D'Aprano > wrote: >> On Tue, 04 Mar 2014 02:01:47 +1100, Chris Angelico wrote: >> >>> This is why it's tricky to put rules in based on type inference. The

Re: Working with the set of real numbers (was: Finding size of Variable)

2014-03-03 Thread Steven D'Aprano
bvious pattern. [1] To be pedantic, written as *two* continued fractions, one ending with the term 1, and one with one less term which isn't 1. That is: [a; b, c, d, ..., z, 1] == [a; b, c, d, ..., z+1] Any *finite* CF ending with one can be simplified to use one fewer term. Infinit

Re: Functional programming

2014-03-04 Thread Steven D'Aprano
On Tue, 04 Mar 2014 17:04:55 +1100, Chris Angelico wrote: > On Tue, Mar 4, 2014 at 4:35 PM, Steven D'Aprano > wrote: >> On Tue, 04 Mar 2014 05:37:27 +1100, Chris Angelico wrote: >>> x = 23 # Compiler goes: Okay, x takes ints. x += 5 # Compiler: No >>>

Re: Functional programming

2014-03-04 Thread Steven D'Aprano
On Tue, 04 Mar 2014 11:56:07 +0100, Antoon Pardon wrote: > Op 04-03-14 09:56, Steven D'Aprano schreef: > > >> >>> If you >>> explicitly say that this is an int, then yes, that should be >>> disallowed; >> It's that "explicitly&q

Re: Reference

2014-03-04 Thread Steven D'Aprano
On Tue, 04 Mar 2014 11:10:34 +, Alister wrote: > Definition of insanity > > Doing the same thing over and over again & expecting different results *rolls dice* :-) -- Steven D'Aprano http://import-that.dreamwidth.org/ -- https://mail.python.org/mailman/listinfo/python-list

Re: Origin of 'self'

2014-03-04 Thread Steven D'Aprano
;s window's title". Consistent, > yes, but bad English. > > That's why I prefer a programming language not to be too much like a > natural language. :-) But the problem with that is not that it is too much like a natural language, but too little like a natural language. -

OT Sine Rule [was Re: Functional programming]

2014-03-04 Thread Steven D'Aprano
On Wed, 05 Mar 2014 00:01:01 +1100, Chris Angelico wrote: > On Tue, Mar 4, 2014 at 10:47 PM, Steven D'Aprano > wrote: >> Not even close. I'd like to see the compiler that can work out for >> itself that this function is buggy: >> >> def sine_rule(side_a

Re: Functional programming

2014-03-04 Thread Steven D'Aprano
On Tue, 04 Mar 2014 14:05:44 +, Mark Lawrence wrote: > Once a statically typed language has been compiled the programmer can > head down to the pub. "It compiles? Quick! Ship it!" Well, that certainly explains the quality of some programs... -- Steven D'

Re: Functional programming

2014-03-04 Thread Steven D'Aprano
On Tue, 04 Mar 2014 13:30:04 +, BartC wrote: > "Steven D'Aprano" wrote in message > news:[email protected]... > >> It's that "explicitly" part that doesn't follow. Having to manage types >> is th

Re: Functional programming

2014-03-04 Thread Steven D'Aprano
f > there _is_ a comment, you have to reverse-engineer the code to see of > the comment is accurate. http://import-that.dreamwidth.org/956.html -- Steven D'Aprano http://import-that.dreamwidth.org/ -- https://mail.python.org/mailman/listinfo/python-list

Re: Reference

2014-03-04 Thread Steven D'Aprano
On Tue, 04 Mar 2014 10:19:22 -0500, Jerry Hill wrote: > On Mon, Mar 3, 2014 at 11:52 PM, Steven D'Aprano > wrote: >> If your intention is to treat None as a singleton sentinel, not as a >> value, then you ought to use "is" to signal that intention, rather than

Re: Functional programming

2014-03-04 Thread Steven D'Aprano
On Wed, 05 Mar 2014 02:28:17 +1100, Chris Angelico wrote: > On Wed, Mar 5, 2014 at 2:18 AM, Steven D'Aprano > wrote: >> You don't need to have static typing to have declared variables. The >> two are independent. E.g. one might have a system like Python, except

Re: Working with the set of real numbers (was: Finding size of Variable)

2014-03-04 Thread Steven D'Aprano
-computable numbers are useful or necessary for anything. They exist as mathematical abstractions, but they'll never be the result of any calculation or measurement that anyone might do. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Reference

2014-03-04 Thread Steven D'Aprano
n you explain what machine representations are leaked into Python by the is operator? Do you see this as an accident of implementation, a bug that might be fixed, or a misfeature that was deliberately designed? Can you elaborate on why id() is legitimate and "is" is not? -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Working with the set of real numbers (was: Finding size of Variable)

2014-03-04 Thread Steven D'Aprano
importance? Mark C-C thinks it's an important difference. Mathematicians who actually work on this stuff all the time think he's making a semantic trick to avoid facing up to the fact that sums of infinite sequences don't always behave like sums of finite sequences. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: How security holes happen

2014-03-05 Thread Steven D'Aprano
of the ways that Python has gotten faster.) Nevertheless, people did use it for serious work, at least by the time it got to version 1.4 and quite likely much earlier. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Working with the set of real numbers (was: Finding size of Variable)

2014-03-05 Thread Steven D'Aprano
Following up on my own post. On Wed, 05 Mar 2014 07:52:01 +, Steven D'Aprano wrote: > On Tue, 04 Mar 2014 23:25:37 -0500, Roy Smith wrote: > >> I stopped paying attention to mathematicians when they tried to >> convince me that the sum of all natural numbers is -1/12.

Re: How security holes happen

2014-03-05 Thread Steven D'Aprano
t the computer industry hasn't discovered Lisp, it is that they discovered it, gave it a solid workout for 20 years, and then said "Nope, this isn't for us." -- Steven D'Aprano http://import-that.dreamwidth.org/ -- https://mail.python.org/mailman/listinfo/python-list

Re: Working with the set of real numbers (was: Finding size of Variable)

2014-03-05 Thread Steven D'Aprano
On Wed, 05 Mar 2014 12:21:37 +, Oscar Benjamin wrote: > On 5 March 2014 07:52, Steven D'Aprano wrote: >> On Tue, 04 Mar 2014 23:25:37 -0500, Roy Smith wrote: >> >>> I stopped paying attention to mathematicians when they tried to >>> convince me that t

Re: Working with the set of real numbers

2014-03-05 Thread Steven D'Aprano
ased on theory which uses the same logic and mathematics that you are mocking. Laugh away, but the universe behaves as if the sum of the natural numbers is -1/12. -- Steven D'Aprano http://import-that.dreamwidth.org/ -- https://mail.python.org/mailman/listinfo/python-list

Re: Reference

2014-03-05 Thread Steven D'Aprano
On Tue, 04 Mar 2014 21:47:21 -0800, Rustom Mody wrote: > On Wednesday, March 5, 2014 10:36:37 AM UTC+5:30, Steven D'Aprano wrote: >> On Tue, 04 Mar 2014 19:36:38 -0800, Rustom Mody wrote: > >> > Python's 'is' leaks >> > the machine abst

Re: Reference

2014-03-05 Thread Steven D'Aprano
On Tue, 04 Mar 2014 22:03:36 -0800, Rustom Mody wrote: > On Wednesday, March 5, 2014 10:36:37 AM UTC+5:30, Steven D'Aprano wrote: >> On Tue, 04 Mar 2014 19:36:38 -0800, Rustom Mody wrote: > >> > Python's 'is' leaks >> > the machine abst

Re: How security holes happen

2014-03-05 Thread Steven D'Aprano
flash of inspiration. It was both designed and evolved through experimentation. That process of *trying things* and keeping those that work is usually called "design". -- Steven D'Aprano http://import-that.dreamwidth.org/ -- https://mail.python.org/mailman/listinfo/python-list

Re: Reference

2014-03-05 Thread Steven D'Aprano
rushing to Earth to invade to gain possession of that object; - it's the weight in metric tonnes of the electrons in the object; (Not *actual* electrons of course, just these arbitrary inventions of Marko's definition.) - it's the length measured in seconds of the b

<    61   62   63   64   65   66   67   68   69   70   >