Re: for / while else doesn't make sense

2016-05-21 Thread Steven D'Aprano
On Sat, 21 May 2016 02:01 pm, Chris Angelico wrote: > On Sat, May 21, 2016 at 1:50 PM, Steven D'Aprano > wrote: >> Would you classify the second line here: >> >> print("Hello World!") >> pass >> >> >> as a bug? What exactly would y

Education [was Re: for / while else doesn't make sense]

2016-05-21 Thread Steven D'Aprano
badly, is a bonus. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: for / while else doesn't make sense

2016-05-21 Thread Steven D'Aprano
On Sat, 21 May 2016 05:20 pm, Erik wrote: > On 20/05/16 01:06, Steven D'Aprano wrote: > >> In my experience, some people (including me) misunderstand "for...else" >> to mean that the else block runs if the for block *doesn't*. It took me >> the longes

Re: for / while else doesn't make sense

2016-05-21 Thread Steven D'Aprano
On Sat, 21 May 2016 08:08 pm, Chris Angelico wrote: > On Sat, May 21, 2016 at 7:56 PM, Steven D'Aprano > wrote: >> On Sat, 21 May 2016 02:01 pm, Chris Angelico wrote: >> >>> On Sat, May 21, 2016 at 1:50 PM, Steven D'Aprano >>> wrote: &

Re: for / while else doesn't make sense

2016-05-21 Thread Steven D'Aprano
ery rare for Python to innovate in language features. (I wonder if it came from ABC?) -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: for / while else doesn't make sense

2016-05-21 Thread Steven D'Aprano
se" "otherwise" fails for the same reason that "else" fails: it suggests that the else block is an alternative to the for block, which is exactly what it is NOT. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: for / while else doesn't make sense

2016-05-21 Thread Steven D'Aprano
he docstring, some prefer to leave a blank line: def spam(): """Docs""" code def eggs(): """Docs""" code Your suggestion to raise a syntax error in the case of for...else without break strikes me as no different from the idea that we should raise a syntax error if there is/isn't a blank line after the docstring. (Choose one.) -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: what is new with int conversion in Python 3

2016-05-22 Thread Steven D'Aprano
ike python vectorsum.py -f 27 instead of python vectorsum.py 27 -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: for / while else doesn't make sense

2016-05-22 Thread Steven D'Aprano
ngs that I think make it an excellent programming language, so it > is a shame that in the Python 2 to Python 3 change when mistakes were > being rectified, a new one was introduced. *shrug* I've programmed in Python using classic integer division and true division, and in my exper

Re: for / while else doesn't make sense

2016-05-22 Thread Steven D'Aprano
On Mon, 23 May 2016 01:52 am, Jon Ribbens wrote: > On 2016-05-22, Steven D'Aprano wrote: >> How is this any better though? Complicated or not, people want to divide >> 1 by 2 and get 0.5. That is the functional requirement. Furthermore, they >> want to use the ordinar

Re: for / while else doesn't make sense

2016-05-23 Thread Steven D'Aprano
On Monday 23 May 2016 03:25, Random832 wrote: > Why shouldn't Python do this? > > Imagine some future version of Python: x = 2/3 x > (2/3) type(x) > You would have a lot of trouble convincing Guido that this was a good idea, because that's what ABC used to do, and it was a perf

Re: for / while else doesn't make sense

2016-05-23 Thread Steven D'Aprano
On Monday 23 May 2016 16:09, Rustom Mody wrote: > Steven is making wild and disingenuous statements; to wit: > > On Monday, May 23, 2016 at 3:39:19 AM UTC+5:30, Steven D'Aprano wrote: >> I'm not defining the result. 4000+ years of mathematics defines the result. >

Re: for / while else doesn't make sense

2016-05-23 Thread Steven D'Aprano
On Monday 23 May 2016 10:36, Jon Ribbens wrote: > OK, I'm bored of you now. You clearly are not willing to imagine > a world beyond your own preconceptions. I am not saying that my view > is right, I'm just saying that yours is not automatically correct. > If you won't even concede that much then

Re: Interfacing a dynamic shared library gives me different results in 2.7 versus 3.5

2016-05-23 Thread Steven D'Aprano
On Monday 23 May 2016 13:15, Siyi Deng wrote: > I have a dynamic library doing some numerical computations. > > I used ctypes to interact it by passing numpy arrays back and forth. > > Python 3.5 gives me the correct results. > > Python 2.7 gives me different, erroneous results, but it never cr

Re: for / while else doesn't make sense

2016-05-23 Thread Steven D'Aprano
) defines 1/3 to be something very very very very close to one >> third, and *that* idea is very very very very new! > > Have you ever written one third as 0. ? Because that's also > something very very close to one third. For many purposes, 0.33 is close enough to one

Re: for / while else doesn't make sense

2016-05-23 Thread Steven D'Aprano
On Tue, 24 May 2016 12:29 am, Ben Bacarisse wrote: > Ian Kelly writes: > >> On Mon, May 23, 2016 at 2:09 AM, Steven D'Aprano >> wrote: >>> Are you saying that the Egyptians, Babylonians and Greeks didn't know >>> how to work with f

Re: for / while else doesn't make sense

2016-05-23 Thread Steven D'Aprano
#x27;) Whereas this Decimal 1 is inexact: py> d = Decimal("1.0001") py> assert d != Decimal(1) py> d.sqrt() == 1 True We can trap the inexact calculation: py> with localcontext(Context(traps=[Inexact])): ... d.sqrt() ... Traceback (most recen

Numerical methods [was Re: for / while else doesn't make sense]

2016-05-23 Thread Steven D'Aprano
On Tue, 24 May 2016 06:17 am, Mark Dickinson signed his post: > (who should probably take a numerical methods class someday) Really? I would have thought you could have taught a numerical methods class. You certainly know more about it than I do, and I have taken one! (Twice!) -- Ste

Re: for / while else doesn't make sense

2016-05-23 Thread Steven D'Aprano
O-8859-2, MacRoman, and many more. None of these are ASCII, although they contain ASCII as a subset of their characters (just as Unicode does). -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: for / while else doesn't make sense

2016-05-23 Thread Steven D'Aprano
On Tue, 24 May 2016 03:09 am, Jon Ribbens wrote: > On 2016-05-23, Steven D'Aprano wrote: >> But one thing is certain: very few people, Jon Ribbens being one of them, >> expects 1/3 to return 0. And that is why Python changed the meaning of >> the / operator: because usi

Re: Interfacing a dynamic shared library gives me different results in 2.7 versus 3.5

2016-05-24 Thread Steven D'Aprano
w us the code you are using. Do you expect that we will just take your word for it? If so, then what? We can't fix this bug (if it is a bug) if we can't identify it. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

META Culture of this place [was Re: for / while else doesn't make sense]

2016-05-24 Thread Steven D'Aprano
haps this place simply isn't a good fit for you, just like #python isn't a good fit for me. I'm not trying to push you away, I really aren't, and if you decide to leave I will miss your contributions, but this is not just a forum for Q&A. It's also a forum for (often spir

Re: Spurious issue in CPython 2.7.5

2016-05-24 Thread Steven D'Aprano
gevent and I'm suspecting some "threading" could cause >this, as I'm able to replicate it locally with the same data. Typo: you said later that you are *not* able to replicate it. You're using a global variable with threaded code? You're a brave (or foolhardy) man... -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: for / while else doesn't make sense

2016-05-24 Thread Steven D'Aprano
On Tue, 24 May 2016 08:54 pm, Jon Ribbens wrote: > On 2016-05-24, Steven D'Aprano wrote: >> On Tue, 24 May 2016 03:09 am, Jon Ribbens wrote: >>> On 2016-05-23, Steven D'Aprano wrote: [...] >> In Australia, we have an 11% consumption tax, the GST. I cannot tell

Re: Question about imports and packages

2016-05-24 Thread Steven D'Aprano
ent directory will do, but to be absolutely clear, that means that the package directory itself must be IN the current directory: ./ +-- pkgtest/ +-- __init__.py +-- testimport.py +-- testimported.py Or you can use any other directory found in sys.path. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Extended ASCII [was Re: for / while else doesn't make sense]

2016-05-25 Thread Steven D'Aprano
On Wednesday 25 May 2016 16:38, Gregory Ewing wrote: > Christopher Reimer wrote: >> Nope. I meant 8-bit ASCII (0-255). >> >> http://www.ascii-code.com > > That page is talking about latin-1, which is just one of many > possible 8-bit extensions of ascii. Yes. It even says "There are *several*

Re: Question about imports and packages

2016-05-25 Thread Steven D'Aprano
On Wednesday 25 May 2016 14:39, Ben Finney wrote: > What the Python import system expects you to do is:: > > cd ../ > python3 -m fnord.foo I don't think you even need to do the cd provided the fnord directory is inside a directory on the path. It only gets complicated if fnord cannot be found b

Exended ASCII and code pages [was Re: for / while else doesn't make sense]

2016-05-25 Thread Steven D'Aprano
On Wednesday 25 May 2016 19:10, Christopher Reimer wrote: > Back in the early 1980's, I grew up on 8-bit processors and latin-1 was all > we had for ASCII. It really, truly wasn't. But you can be forgiven for not knowing that, since until the rise of the public Internet most people weren't expos

Format a timedelta object

2016-05-25 Thread Steven D'Aprano
I have a timedelta object, and I want to display it in a nice human-readable format like 03:45:17 for "three hours, forty five minutes, 17 seconds". Is there a standard way to do this? -- Steve -- https://mail.python.org/mailman/listinfo/python-list

Re: ValueError: I/O operation on closed file

2016-05-25 Thread Steven D'Aprano
On Thursday 26 May 2016 15:47, San wrote: > Following is the code i used. > > def test_results(filename): > import csv > with open(filename,"rU") as f: > reader = csv.reader(f,delimiter="\t") > result = {} You should use more consistent indents. Can you set your editor to auto

Re: Exended ASCII and code pages [was Re: for / while else doesn't make sense]

2016-05-26 Thread Steven D'Aprano
ncompasses all of the world's natural languages (not even the "important" ones) than "everyone is using Internet Explorer and Windows XP, right?" describes the state of the Internet. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Exended ASCII and code pages [was Re: for / while else doesn't make sense]

2016-05-26 Thread Steven D'Aprano
On Fri, 27 May 2016 04:10 pm, Marko Rauhamaa wrote: > Steven D'Aprano : >> This concept of ASCII = "all character sets", or "nearly all", or >> "okay, maybe not nearly all of them, but just the important ones" is >> terribly Euro-centric

Re: Exended ASCII and code pages [was Re: for / while else doesn't make sense]

2016-05-27 Thread Steven D'Aprano
On Fri, 27 May 2016 05:04 pm, Marko Rauhamaa wrote: > They are all ASCII derivatives. Those that aren't don't exist. *plonk* -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Handling exceptions with Py2 and Py3

2016-05-27 Thread Steven D'Aprano
ror as ConnectionRefusedError If neither of these techniques help, please give more context and we can be more specific. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Format a timedelta object

2016-05-27 Thread Steven D'Aprano
On Thu, 26 May 2016 03:28 pm, Zachary Ware wrote: > On Thu, May 26, 2016 at 12:16 AM, Steven D'Aprano > wrote: >> I have a timedelta object, and I want to display it in a nice >> human-readable format like 03:45:17 for "three hours, forty five minutes, >> 17 s

Re: Exended ASCII and code pages [was Re: for / while else doesn't make sense]

2016-05-28 Thread Steven D'Aprano
On Sat, 28 May 2016 01:53 am, Rustom Mody wrote: > On Friday, May 27, 2016 at 7:21:41 PM UTC+5:30, Random832 wrote: >> On Fri, May 27, 2016, at 05:56, Steven D'Aprano wrote: >> > On Fri, 27 May 2016 05:04 pm, Marko Rauhamaa wrote: >> > >> > > They

Re: why for loop print only once after add if statement

2016-05-28 Thread Steven D'Aprano
tem in enumerate(aa): ... if item == findit: ... print i, item ... 2 e 3 e 5 e -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Package setup best practice style question

2016-05-28 Thread Steven D'Aprano
package.redblack import Tree from package.avl import Tree from package.scapegoat import Tree and let the user choose which implementation they wanted. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Package setup best practice style question

2016-05-28 Thread Steven D'Aprano
On Sun, 29 May 2016 03:00 am, Steven D'Aprano wrote: > On Sun, 29 May 2016 02:15 am, Gerald Britton wrote: > >> suppose I have a simple python project setup like this: [...] To which I responded: > If this is a single project, why do you set it up like this? Is there a &g

Re: Coding systems are political (was Exended ASCII and code pages)

2016-05-28 Thread Steven D'Aprano
and emoji. The idea that a bunch of Western corporations and academics are pushing them around is laughable. [1] The worst being that my US English keyboard doesn't have a proper curly apostrophe, forcing me to use a straight ' mark in my name like some sort of animal. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Best way to inplace alter a list going into postgres

2016-05-30 Thread Steven D'Aprano
On Tuesday 31 May 2016 14:27, Sayth Renshaw wrote: > > Hi > > What is the best way to inplace alter a list going into a postgres database Is it relevant where it is going? What you do with the list after you alter it is irrelevant -- perhaps you will insert it into an Oracle database, or a pl

Re: reduction

2016-05-31 Thread Steven D'Aprano
t; 0 ['a','b','d','l'] => 0 ['x','y','z','l'] => 0 ... then it sounds like you need a dict storing each letter individually: d = {'a': 1, 'b': 1, 'c': 1, 'l': 0} for letter in ['a','b','c','l']: if d[letter] == 0: print("Black sheep") break which can be written more compactly as: if not all(d[letter] for letter in 'abcl'): print("Black sheep") If your items actually are letters, then you can reduce the fiddly typing with something a bit easier: # instead of # d = {'a': 1, 'b': 1, 'c': 1, 'l': 0} letters = 'abcdefghijklmno' bits ='1110111' d = {k: int(b) for k, b in zip(letters, bits)} -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Multiple inheritance, super() and changing signature

2016-05-31 Thread Steven D'Aprano
https://www.python.org/download/releases/2.3/mro/ > Of course, this would require Python to calculate an MRO that depends on > the name of the method, and not just the class hierarchy. I don't even know what that means. > And also the > signatures of the methods, but those can also be changed dynamically. So > this may be a bad idea after all. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Don't put your software in the public domain

2016-06-01 Thread Steven D'Aprano
://linuxmafia.com/faq/Licensing_and_Law/public-domain.html -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Don't put your software in the public domain

2016-06-01 Thread Steven D'Aprano
On Thursday 02 June 2016 07:00, John Wong wrote: > On Wed, Jun 1, 2016 at 4:45 PM, Lawrence D’Oliveiro > wrote: > >> On Thursday, June 2, 2016 at 3:00:05 AM UTC+12, Steven D'Aprano wrote: >> > ... because it is extremely unlikely to work. >> >> Whi

Re: Don't put your software in the public domain

2016-06-01 Thread Steven D'Aprano
On Thursday 02 June 2016 06:45, Lawrence D’Oliveiro wrote: > On Thursday, June 2, 2016 at 3:00:05 AM UTC+12, Steven D'Aprano wrote: >> ... because it is extremely unlikely to work. > > Which is why CC0 https://creativecommons.org/publicdomain/zero/1.0/ was > invented. Ve

Re: for / while else doesn't make sense

2016-06-01 Thread Steven D'Aprano
On Thursday 02 June 2016 09:39, Lawrence D’Oliveiro wrote: > Also, they let me declare a variable that is scoped to the loop Why do you want variables scoped to the loop? -- Steve -- https://mail.python.org/mailman/listinfo/python-list

Re: Beginner Question

2016-06-01 Thread Steven D'Aprano
On Thursday 02 June 2016 10:55, Marcin Rak wrote: > Hi to all > > I have a beginner question to which I have not found an answer I was able to > understand. Could someone explain why the following program: > > def f(a, L=[]): > L.append(a) > return L The default value is set once, and

Re: Beginner Question

2016-06-01 Thread Steven D'Aprano
On Thursday 02 June 2016 14:21, Igor Korot wrote: > Hi, guys, > > On Wed, Jun 1, 2016 at 9:42 PM, boB Stepp wrote: >> On Wed, Jun 1, 2016 at 7:55 PM, Marcin Rak >> wrote: >>> Hi to all >>> >>> I have a beginner question to which I have not found an answer I was able >>> to understand. Could so

Just for fun: creating zombies with Python

2016-06-02 Thread Steven D'Aprano
Just for fun, I thought I'd create some zombie processes using Linux. (This will probably only work on POSIX-compliant operating systems. I don't know that Windows has zombies.) I started with the C code given here: https://en.wikipedia.org/wiki/Zombie_process#Examples and re-wrote it into Pyt

Re: Don't put your software in the public domain

2016-06-02 Thread Steven D'Aprano
On Thu, 2 Jun 2016 04:41 pm, Gregory Ewing wrote: > Steven D'Aprano wrote: > >> http://linuxmafia.com/faq/Licensing_and_Law/public-domain.html > > From that: >> It might be ruled to create a global licence for unrestricted use. That > > licence might or

Re: Multiple inheritance, super() and changing signature

2016-06-02 Thread Steven D'Aprano
-allocated class instance. Not in Python circles it isn't. But since the constructor/initialiser methods are so closely linked, many people are satisfied to speak loosely and refer to "the constructor" as either, unless they specifically wish to distinguish between __new__ and __init__. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Don't put your software in the public domain

2016-06-03 Thread Steven D'Aprano
On Thu, 2 Jun 2016 04:41 pm, Gregory Ewing wrote: > Steven D'Aprano wrote: > >> http://linuxmafia.com/faq/Licensing_and_Law/public-domain.html > > From that: >> It might be ruled to create a global licence for unrestricted use. That > > licence might or

Re: Multiple inheritance, super() and changing signature

2016-06-03 Thread Steven D'Aprano
On Fri, 3 Jun 2016 07:18 am, Random832 wrote: > On Thu, Jun 2, 2016, at 13:36, Steven D'Aprano wrote: [...] >> But since the constructor/initialiser methods are so closely linked, many >> people are satisfied to speak loosely and refer to "the constructor" as >&

Re: Don't put your software in the public domain

2016-06-03 Thread Steven D'Aprano
ir best interest to test the GPL in court, and Monsoon was no exception. http://torquemag.io/2013/03/busybox/ They preferred to pay a financial settlement (in other words, a fine) and come into compliance, rather than risk having a judge tell them they were infringing copyright. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Don't put your software in the public domain

2016-06-03 Thread Steven D'Aprano
On Sat, 4 Jun 2016 02:15 am, Lawrence D’Oliveiro wrote: > On Friday, June 3, 2016 at 9:53:47 PM UTC+12, Steven D'Aprano wrote: > >> A licence is something like a contract... > > A licence is quite different from a contract. A contract requires some > indication of

Re: for / while else doesn't make sense

2016-06-03 Thread Steven D'Aprano
mbers you have to add. It is ONE way to add, composed as many times as you need it. For-loops are no different: you can exit the loop by reaching the end and exiting, or you can exit early by using break. The number of breaks is just composition. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Don't put your software in the public domain

2016-06-03 Thread Steven D'Aprano
n Patagonia). The courts in Germany have already found that the GPL satisfies the conditions to be considered a contract; it is likely that so would US courts. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: I'm wrong or Will we fix the ducks limp?

2016-06-03 Thread Steven D'Aprano
r can you add one to a number until the number exists. x = 0 x += 1 Why should lists be different? How is Python supposed to know pf is a list with an append method if pf doesn't exist? # pf = [] pf.append(thing) -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Catch exception with message?

2016-06-03 Thread Steven D'Aprano
even bug-fix releases of Python can change error messages. So don't do this, it is a terrible idea. You should never rely on the error message of an exception. But if you insist: try: something() except Exception as e: if e.args[0] = "An error occurred": pri

Re: Multiple inheritance, super() and changing signature

2016-06-03 Thread Steven D'Aprano
never using super. But in MI, not using super almost certainly means you're doing it wrong. (If you're lucky, you can get away with it if the methods you fail to call aren't needed, or do nothing, and the methods you call twice are harmless.) -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: for / while else doesn't make sense

2016-06-03 Thread Steven D'Aprano
on has been met. The canonical example is a search, where you need to process differently depending on whether a match was found or not. In pseudo-code: for item in items: if condition(item): # found match, exit loop break if match was found: process match else: no match -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: I'm wrong or Will we fix the ducks limp?

2016-06-04 Thread Steven D'Aprano
LD "hello world" creates a string. Then you call .upper() on that string. Perhaps a better example (demonstrating the impossibility) would be: s = .upper() but I thought that would not be clear. > This works in Python 3. Not sure if s.uppercase() was meant as an > exampl

Re: for / while else doesn't make sense

2016-06-04 Thread Steven D'Aprano
On Sat, 4 Jun 2016 01:41 pm, Lawrence D’Oliveiro wrote: > On Saturday, June 4, 2016 at 2:22:18 PM UTC+12, Steven D'Aprano wrote: >> and a loop with two or more exits a *trivially different* way: >> >> for x in seq: >> do_something() >> if

Re: Multiple inheritance, super() and changing signature

2016-06-04 Thread Steven D'Aprano
ould not solve with single inheritance + composition/delegation in a better and more maintainable way than using multiple inheritance." and I think that is the most valuable lesson here. MI itself is, if not an anti-pattern, at least a dangerous one. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: I'm wrong or Will we fix the ducks limp?

2016-06-04 Thread Steven D'Aprano
an implementation detail which is irrelevant to the language and its execution model. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: for / while else doesn't make sense

2016-06-04 Thread Steven D'Aprano
On Sun, 5 Jun 2016 01:29 pm, Lawrence D’Oliveiro wrote: > On Saturday, June 4, 2016 at 11:37:18 PM UTC+12, Ned Batchelder wrote: >> On Friday, June 3, 2016 at 11:43:33 PM UTC-4, Lawrence D’Oliveiro wrote: >> > On Saturday, June 4, 2016 at 3:00:36 PM UTC+12, Steven D'Apran

Re: Spreading a class over multiple files

2016-06-05 Thread Steven D'Aprano
x27;): ... # file b.py def throw_lightening(self): ... # file c.py def turn_into_a_shower_of_gold(self): ... Notice that in files b and c you define the functions with an explicit self, even though they are at the top level. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: I'm wrong or Will we fix the ducks limp?

2016-06-05 Thread Steven D'Aprano
On Mon, 6 Jun 2016 03:42 am, Random832 wrote: > On Sun, Jun 5, 2016, at 02:37, Steven D'Aprano wrote: >> No they don't. You are confusing the implementation with the programming >> model. >> >> Following the assignment: >> >> x = 99 >> &

Re: I'm wrong or Will we fix the ducks limp?

2016-06-06 Thread Steven D'Aprano
On Mon, 6 Jun 2016 02:08 pm, Random832 wrote: > On Sun, Jun 5, 2016, at 23:52, Steven D'Aprano wrote: >> Certainly not. x = y = 999 is required to bind the same object to x and >> y. > > My statement was that if two variables can be bound to the same object, > th

Re: Don't put your software in the public domain

2016-06-06 Thread Steven D'Aprano
On Mon, 6 Jun 2016 03:54 pm, Nobody wrote: > On Sat, 04 Jun 2016 12:28:33 +1000, Steven D'Aprano wrote: > >>> OTOH, a Free software licence is unilateral; the author grants the user >>> certain rights, with the user providing nothing in return. >> >> Tha

Re: I'm wrong or Will we fix the ducks limp?

2016-06-06 Thread Steven D'Aprano
On Mon, 6 Jun 2016 04:37 pm, Gregory Ewing wrote: > Steven D'Aprano wrote: >> The *name* "x" is an entity which is bound to (i.e. a reference to) the >> object 99, in some specific namespace, at some specific time. The name >> itself is an English wo

Re: Operator precedence problem

2016-06-06 Thread Steven D'Aprano
mp; > and |, and that "and" has a higher precedence than "or", Do they? https://docs.python.org/2/reference/expressions.html#operator-precedence Blimey, you're right. I always thought `and` and `or` had the same precedence. And now that I know better, I have no doubt that I will forget it again. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: I'm wrong or Will we fix the ducks limp?

2016-06-06 Thread Steven D'Aprano
On Tue, 7 Jun 2016 02:57 am, Random832 wrote: > On Mon, Jun 6, 2016, at 12:19, Steven D'Aprano wrote: >> (2) The "variables are like boxes" metaphor applies to static languages >> like >> C and Pascal, where the compiler has knowledge of what variables will >

Re: for / while else doesn't make sense

2016-06-07 Thread Steven D'Aprano
On Tuesday 07 June 2016 17:52, Lawrence D’Oliveiro wrote: > On Tuesday, June 7, 2016 at 4:36:37 PM UTC+12, Ian wrote: >> A 500-line function? Yikes, what an eyesore. When you have to include >> #end comments in order to visually match things up, that should be a >> smell that your code is excessiv

Re: I'm wrong or Will we fix the ducks limp?

2016-06-07 Thread Steven D'Aprano
On Tuesday 07 June 2016 15:42, Gregory Ewing wrote: > Steven D'Aprano wrote: >> Even if you were right that objects must exist at >> a single well-defined location, that is strictly irrelevant. That's >> implementation, not interface. > > We're talking

Re: I'm wrong or Will we fix the ducks limp?

2016-06-07 Thread Steven D'Aprano
On Tue, 7 Jun 2016 10:32 pm, Antoon Pardon wrote: > That people often use the shortcut "x is 999" doesn't make the statement > wrong that variables are essentially references in Python. No, I'm sorry, you're wrong, variables are essentially arrays of bits in P

Re: I'm wrong or Will we fix the ducks limp?

2016-06-08 Thread Steven D'Aprano
On Wednesday 08 June 2016 17:53, Antoon Pardon wrote: > Python could go the simula route, which has two kinds of > assignment. One with the python semantics and one with C > semantics. > > Let as use := for the C sematics assignment and <- for the > python sematics assignment. We could then do so

Re: how to extract a variable as parameter which has index using by a for loop?

2016-06-08 Thread Steven D'Aprano
On Wednesday 08 June 2016 17:31, meInvent bbird wrote: > b = [str(i)+str(j)+str(k) for i in range(m) for j in range(m) for k in > range(m)] > b[21][0:1]+b[21][1:2] > b[21][1:2]+b[21][2:3] > b[21][0:1]+b[21][2:3] > > > originally, > > mmm = 5 > H2 = [MM[mmm][b[i][0:1]+b[i][1:2]] for i in range(l

Re: Creating A Pythonic API Binding

2016-06-08 Thread Steven D'Aprano
On Wednesday 08 June 2016 12:31, Lawrence D’Oliveiro wrote: > The wrong way: [...] > The right way : That's quite good. A few minor issues: I don't understand why you have a method that returns files called "get_children". And I would expect that if you passed a

Re: I'm wrong or Will we fix the ducks limp?

2016-06-09 Thread Steven D'Aprano
On Wednesday 08 June 2016 19:41, Antoon Pardon wrote: >> What you seem to be describing is similar to reference parameter semantics >> from Pascal. Assignment doesn't work that way in C, or Python. > > I disagree. In python the assignment does work similar to the reference > parameter semantics i

Re: what is wrong with this property setter

2016-06-09 Thread Steven D'Aprano
On Thursday 09 June 2016 17:28, Nagy László Zsolt wrote: > class Test: Are you using Python 3 or 2? In Python 2, property doesn't work correctly with classes unless they inherit from object (directly or indirectly). > def __init__(self): > self._parent = None > > @property >

Re: for / while else doesn't make sense

2016-06-09 Thread Steven D'Aprano
On Thursday 09 June 2016 10:34, Lawrence D’Oliveiro wrote: > In my undergraduate Comp Sci classes, we used to discuss arbitrary rules like > limiting functions to n lines. With real-world experience, it soon became > clear that such rules were a waste of time. A function should be just as big > as

Re: how to solve memory

2016-06-10 Thread Steven D'Aprano
do not do the same thing. After nearly crashing my computer running your version, I am not going to spend the time trying to debug this. If you want our help, I suggest that you clean up the code. Currently it is an incomprehensible mess to me. Even after the cleanup, I have no idea what this

Re: for / while else doesn't make sense

2016-06-10 Thread Steven D'Aprano
to tell the difference between 0 and 0 or 1 I and l, or S and 5, and to be honest periods and commas are completely invisible, but that's a small price to pay for the extra efficiency of having all 641 thousand lines of code on screen all at once. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: the global keyword:

2016-06-11 Thread Steven D'Aprano
e you assign to it, but some invisible, unreachable "reference". x = 999 The value of x is 999, not some invisible reference. x = [] The value of x is an empty list, not some invisible reference. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: for / while else doesn't make sense

2016-06-12 Thread Steven D'Aprano
On Sunday 12 June 2016 17:01, [email protected] wrote: > On Thursday, May 19, 2016 at 9:43:56 AM UTC-7, Herkermer Sherwood wrote: >> Most keywords in Python make linguistic sense, but using "else" in for and >> while structures is kludgy and misleading. I am under the assumption that >> thi

Re: Indentation example?

2016-06-12 Thread Steven D'Aprano
("hello") # four spaces \ print("goodbye") # two spaces, then backslash, then two more The second example will be a SyntaxError. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: how to handle surrogate encoding: read from fs write to database

2016-06-12 Thread Steven D'Aprano
them. IOW let terminal print garbage > where surrogate letters appear. Is this possible in python? That's nothing to do with Python, it depends on the database, and the terminal. > So what do you think: is usage unicode strings and explicit conversion to > latin-1 a good option? Absolutely not. > Also related question: is it possible to detect surrogate symbols in > strings? any('\uD800' <= c <= '\uDFFF' for c in the_string) -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: for / while else doesn't make sense

2016-06-12 Thread Steven D'Aprano
On Mon, 13 Jun 2016 04:44 am, Michael Selik wrote: > On Sun, Jun 12, 2016 at 6:11 AM Steven D'Aprano < > [email protected]> wrote: > >> - run the for block >> - THEN unconditionally run the "else" block >> > > Saying

Re: base64.b64encode(data)

2016-06-12 Thread Steven D'Aprano
on > that variable have to apply the decode('utf-8') method to get a string > object holding the exact same sequence of characters as was held by > b64_encoded_data bytes variable. You could also use decode('ascii'), which is probably more "correct", as the base64 data shouldn't include anything which isn't ASCII. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: base64.b64encode(data)

2016-06-12 Thread Steven D'Aprano
On Mon, 13 Jun 2016 01:20 pm, Random832 wrote: > On Sun, Jun 12, 2016, at 22:22, Steven D'Aprano wrote: >> That's because base64 is a bytes-to-bytes transformation. It has >> nothing to do with unicode encodings. > > Nonsense. base64 is a binary-to-text encodin

Re: base64.b64encode(data)

2016-06-13 Thread Steven D'Aprano
re characters, like England. And users of earlier versions of ASCII, or users of variants of ASCII that differ ever so slightly differently. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: for / while else doesn't make sense

2016-06-13 Thread Steven D'Aprano
On Tue, 14 Jun 2016 09:45 am, Michael Selik wrote: > On Sun, Jun 12, 2016 at 10:16 PM Steven D'Aprano > wrote: > >> On Mon, 13 Jun 2016 04:44 am, Michael Selik wrote: >> >> > On Sun, Jun 12, 2016 at 6:11 AM Steven D'Aprano < >> > steve+comp.la

Re: for / while else doesn't make sense

2016-06-14 Thread Steven D'Aprano
On Wed, 15 Jun 2016 01:33 am, Rustom Mody wrote: > On Tuesday, June 14, 2016 at 8:13:53 AM UTC+5:30, Steven D'Aprano wrote: >> No. The sun exploding was me gently mocking you for your comment >> disputing the "unconditional" part. Yes, you are technically right

Re: log file.

2016-06-14 Thread Steven D'Aprano
t;Starting") ... stop(pump) logging.info("Stopping") More information in the logging tutorial: https://docs.python.org/2/howto/logging.html https://docs.python.org/3/howto/logging.html -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: for / while else doesn't make sense

2016-06-15 Thread Steven D'Aprano
On Wed, 15 Jun 2016 09:19 pm, Rustom Mody wrote: > On Wednesday, June 15, 2016 at 8:42:33 AM UTC+5:30, Steven D'Aprano wrote: >> On Wed, 15 Jun 2016 01:33 am, Rustom Mody wrote: [...] >> > And break is a euphemism for goto >> >> Sort of. A break is a jump, a

Re: Bulk Adding Methods Pythonically

2016-06-15 Thread Steven D'Aprano
ould take that as a cold-smell. Why do you have so many almost identical methods? (That doesn't mean it is *necessarily* wrong, only that you have to think carefully about whether it is or not.) -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: for / while else doesn't make sense

2016-06-15 Thread Steven D'Aprano
ll whether the fnord feature makes the language unstructured or not? -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: is there a concurrent list for append in parallel programming in python? how to pass parameter in this parallel program with pool?

2016-06-16 Thread Steven D'Aprano
On Thursday 16 June 2016 17:28, meInvent bbird wrote: > is there like c# have concurrent list ? What is a concurrent list? Can you link to the C# documentation for this? To me, "concurrent" describes a style of execution flow, and "list" describes a data structure. I am struggling to understan

<    30   31   32   33   34   35   36   37   38   39   >