Embroidermodder2 Kickstarter for Python also!

2014-03-29 Thread Metallicow
Dear Pythoneers,

Just letting you know we got a Kickstarter going on for Embroidermodder2 
finally.
We are going to need all the support we can get.
https://www.kickstarter.com/projects/redteam316/embroidermodder-2-for-windows-mac-linux-pi-and-ard

What is the program for you may ask...?
It is for making designs and stuff that can be embroidered on just about any 
fabric.

It is the first real decent open-source embroidery software that handles many 
formats that would meet
standard business/artists needs.
https://en.wikipedia.org/wiki/Comparison_of_embroidery_software

As an unofficial developer at this point my involvement hinders in the pure 
python
side of things, but only upon project success.
So what that means for everyone is that if the project IS successful,
then I will be doing a pure python port of the application also(In PySide/PyQt 
first, then possibly a wxPy port)
working closely with the two lead developers whom of which I know both well and 
respect
and can attest to the level of devotion to quality being put into it.
I already have the majority of the GUI code ported at alpha stage ATM so am off 
to a good start,
but what is needed is at least initial funding before more work on the python 
side can continue,
because we can't sustain self-funding this forever.
Python bindings is a stretch goal also that was initially set.

I don't recall exactly who it was here that joked about wanting the 
"Guido Van Rossum World Tour" Shirt, but it can be possible for anyone now
with some basic skills and a machine(or you could take it to a local embroidery 
shop).

The program aims to make the designer clothing side of the industry affordable 
and introducable for not only a small fry just starting a business, it also 
applies to
shops that already exist as it provides open tools easily customizable to meet 
the jobs special purpose needs.

So what we need is for the project to succeed by being funded 
and custom clothing design will then be finally open to the masses and 
so everyone can profit from it.

There are many other rewards to consider also for your pledge.
The campaign is going on until April 20th(Easter), so I encourage everyone 
interested 
in cheaper quality tools and clothes/etc to pledge what you can.
Lets help these guys out.

Thanks.

Pic to python port WIPz
http://i861.photobucket.com/albums/ab180/metallicow/Python/PySide-PyQt_Port.png
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Explanation of this Python language feature? [x for x in x for x in x] (to flatten a nested list)

2014-03-29 Thread Mark H Harris

On 3/29/14 1:03 AM, Chris Angelico wrote:


http://forum.ecomstation.ru/

Prominent discussion forum, although that strives to be at least
partially bilingual in deference to those of us who are so backward as
to speak only English.


   Yes. Well, as the joke goes, if you're trilingual you speak three 
languages, if you're bilingual you speak two languages, if you're 
monolingual you're an American (well, that might go for Australia too, 
maybe). When whole continents speak the same language that tends to happen.


So, pre-Unicode, people didn't use any of those languages or writing
systems with computers, is that what you're saying? That code pages
86x are a total myth?


   No, no, no... don't over-read my post please. Think in orders of 
magnitudes. In computer history very little is even mentioned outside 
the U.S.  This is, of course, not fair.  The folks in the U.K. played a 
huge role (the Alan Turing story, The Baby, Blakeley &c). The entire 
world used ASCII, like, forever.  Heck, its still being used!


   Code pages are not a myth,  but they were not prominent, either. And 
of course prejudice is relatively spoken; I don't want to define it.
   What I can tell you in my own experience, as an amateur radio 
operator (W0MHH, general class) who has communicated all over the earth 
(even to Soviet Russia), all my computer|radio comm was in English using 
Morse code sets, Latin characters, and ASCII.  No one ever asked me to 
comm in Russian, or French, nor Italian, nor Tswana...



Unicode didn't even begin to exist until 1987, and the first version
of the standard wasn't published until 1991. You're seriously saying
that until 1991 (plus however long it took to get implementations into
people's hands) everyone spoke English with computers?!?


   No. see above.   I'm saying that (for the most part) international 
communication has been Latin code pages and ASCII all over the earth, 
until very recently (as you point out).. By the way, in my view, 1991 is 
very recently; from a computer historical standpoint too. I mean, think 
about it, computers have only existed since late 1940s and only in their 
modern context since about 1989. I didn't really start using unicode 
until about 5 years ago; python has only really used it since python3. 
right?



See this quote from the consortium FAQ:

>  So, for example, there is only one set of Latin characters
> defined, despite the fact that the Latin script
> is used for the alphabets of thousands of different languages.

http://www.unicode.org/faq/basic_q.html#3


Huh?


   The consortium designates scripts vs. languages. When folks ask them 
about how many languages they support its a difficult answer.  Do you 
mean scripts ( of which there is only one Latin script ) or are you 
referring to the *thousands* of different languages that are scripted in 
Latin characters?  Latin script is used in thousands of languages 
world-wide;  true story.  (that's what the quote is above)



I'm not sure whether you're trolling or genuinely ignorant of all
history and other languages.


   Neither.  I never troll, and I'm not ignorant. We are only getting 
cross-ways on this point more because of overlapping time frames I'm 
guessing, and numbers. I know that people groups and various languages 
were being used around the world in pockets for various purposes. I was 
part of the support group at IBM, for instance, that helped with the 
debugging process when we started supporting Kanji on the system36 
system38.  I know that kind of stuff was happening. But when it came to 
communicating world-wide for business (or in my case with radiography) 
it was always ASCII, Latin character sets, and in my case English Morse 
or international Morse code sets (derived from English).




Please clarify. If you really are just
trolling, say so, and I'll start ignoring all your posts.


No, Chris.  I never troll.  (that would make my fingers itch)

:)




--
https://mail.python.org/mailman/listinfo/python-list


Re: Keyboard standards

2014-03-29 Thread Ian Kelly
On Fri, Mar 28, 2014 at 11:40 PM, Mark H Harris  wrote:
> On 3/29/14 12:13 AM, Chris Angelico wrote:
>>
>> When I first met Windows keys, I just popped 'em off and left a gap.
>> Worked fine.
>
> ha!   see.. it popped you off too!   :-))  I found it arrogant to the max to
> place their stupid logo on (my) keyboard. What if every company out there
> wanted "their" own keytop too?  geeze

It's interesting to note that the Command key on Apple keyboards was
originally designed with the Apple logo, but Steve Jobs felt that the
logo was overused by having it plastered all over menu shortcuts, so
they replaced it prior to release with the cloverleaf symbol it now
bears.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Explanation of this Python language feature? [x for x in x for x in x] (to flatten a nested list)

2014-03-29 Thread Marko Rauhamaa
Steven D'Aprano :

> Under what circumstances do you see yourself needing a keyboard capable 
> of typing Hindi?
>
> I don't wish to pay for a keyboard for entering Arabic

Everybody should be able to have a keyboard for their needs. If I should
need an APL keyboard, I would have it in a jiffy.

At the moment, I have a keyboard that is optimized for Python, Finnish,
English, Hebrew and Esperanto. I use it at home and at the office. The
magic is called .Xmodmap.

(But no, I wouldn't name my variables in Hebrew because the next
maintainer might not have a keyboard like mine.)


Marko
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Explanation of this Python language feature? [x for x in x for x in x] (to flatten a nested list)

2014-03-29 Thread Roy Smith
In article <[email protected]>,
 Marko Rauhamaa  wrote:

> (But no, I wouldn't name my variables in Hebrew because the next
> maintainer might not have a keyboard like mine.)

Have you ever done any work in PHP?  Many of the error messages are 
Hebrew, transliterated into English.  I've gotten many a 
T_PAAMAYIM_NEKUDOTAYIM error.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Explanation of this Python language feature? [x for x in x for x in x] (to flatten a nested list)

2014-03-29 Thread Marko Rauhamaa
Roy Smith :

> Have you ever done any work in PHP? Many of the error messages are
> Hebrew, transliterated into English. I've gotten many a
> T_PAAMAYIM_NEKUDOTAYIM error.

I hate localization. You get a error message in Finnish from "make" or
"grep" and then you try to google it.

So mine is en_US, but I know people who do fi_FI.


Marko
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Explanation of this Python language feature? [x for x in x for x in x] (to flatten a nested list)

2014-03-29 Thread Mark Lawrence

On 29/03/2014 08:21, Mark H Harris wrote:


Yes. Well, as the joke goes, if you're trilingual you speak three
languages, if you're bilingual you speak two languages, if you're
monolingual you're an American (well, that might go for Australia too,
maybe). When whole continents speak the same language that tends to happen.


You mean like the USA, where I saw an ad in a shop for a bilingual shop 
assistant?  Or is Spanish so like US English it doesn't count as a 
separate language?


--
My fellow Pythonistas, ask not what our language can do for you, ask 
what you can do for our language.


Mark Lawrence

---
This email is free from viruses and malware because avast! Antivirus protection 
is active.
http://www.avast.com


--
https://mail.python.org/mailman/listinfo/python-list


Re: Howto flaten a list of lists was (Explanation of this Python language feature)

2014-03-29 Thread Mark Lawrence

On 29/03/2014 03:21, Rustom Mody wrote:

On Saturday, March 29, 2014 8:34:19 AM UTC+5:30, Mark H. Harris wrote:

On 3/28/14 9:33 PM, Steven D'Aprano wrote:

Mark, please stop posting to the newsgroup comp.lang.python AND the
mailing list (...). They mirror each other. Your posts
are not so important that we need to see everything twice.



Its not my fault, Steven. Something goofy is going on. My address says
only comp.lang.python



I have no idea why some of these messages are being duplicated on the
mailing list. I only post to the news group.



Anyways, sorry.  I'll keep checking this.



regards,


Just use the amazing, fool-safe, fail-proof google-groups.
And enjoy bliss.

[Uh... And now I need to run... Out of sprinting practice...]



Blast, you beat me to it, and I never could sprint :)

--
My fellow Pythonistas, ask not what our language can do for you, ask 
what you can do for our language.


Mark Lawrence

---
This email is free from viruses and malware because avast! Antivirus protection 
is active.
http://www.avast.com


--
https://mail.python.org/mailman/listinfo/python-list


Re: Howto flaten a list of lists was (Explanation of this Python language feature)

2014-03-29 Thread mm0fmf

On 28/03/2014 22:12, Mark Lawrence wrote:

As for the stupid symbol that you're using, real programmers don't give
a damn about such things, they prefer writing plain, simple, boring code
that is easy to read


What he said.


--
https://mail.python.org/mailman/listinfo/python-list


Re: Keyboard standards

2014-03-29 Thread Steven D'Aprano
On Sat, 29 Mar 2014 00:40:43 -0500, Mark H Harris wrote:

> On 3/29/14 12:13 AM, Chris Angelico wrote:
>>
>> When I first met Windows keys, I just popped 'em off and left a gap.
>> Worked fine.
> 
> ha!   see.. it popped you off too!   :-))  I found it arrogant to the
> max to place their stupid logo on (my) keyboard. 

My keyboard has IBM's logo on it. My keyboard at work has Dell's logo on 
it. In the cupboard, I have a Mac with Apple's logo on it. Do you have a 
problem with that?


> What if every company
> out there wanted "their" own keytop too?  geeze

They're welcome to try. Without support from the operating system, what 
good do you think it will do?

Apple used to have an Apple key. Later they changed it to ⌘ (Command), 
but everyone knows that ⌘ is only available on Apple keyboards.



-- 
Steven D'Aprano
http://import-that.dreamwidth.org/
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Explanation of this Python language feature? [x for x in x for x in x] (to flatten a nested list)

2014-03-29 Thread Gene Heskett
On Saturday 29 March 2014 13:47:13 Marko Rauhamaa did opine:

> Roy Smith :
> > Have you ever done any work in PHP? Many of the error messages are
> > Hebrew, transliterated into English. I've gotten many a
> > T_PAAMAYIM_NEKUDOTAYIM error.
> 
> I hate localization. You get a error message in Finnish from "make" or
> "grep" and then you try to google it.
> 
> So mine is en_US, but I know people who do fi_FI.
> 
> 
> Marko

I don't hate it at all.  If, by reporting the error in the persons 1st 
language, he learns faster, that is a huge plus to me.

Cheers, Gene
-- 
"There are four boxes to be used in defense of liberty:
 soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author)
Genes Web page 

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Explanation of this Python language feature? [x for x in x for x in x] (to flatten a nested list)

2014-03-29 Thread Gene Heskett
On Saturday 29 March 2014 13:12:06 Roy Smith did opine:

> In article <[email protected]>,
> 
>  Marko Rauhamaa  wrote:
> > (But no, I wouldn't name my variables in Hebrew because the next
> > maintainer might not have a keyboard like mine.)
> 
> Have you ever done any work in PHP?  Many of the error messages are
> Hebrew, transliterated into English.  I've gotten many a
> T_PAAMAYIM_NEKUDOTAYIM error.

Ok, I'll bite, does that have an American English translation?

We did the majority of our web page at WDTV in the earlier years from a 
server we wrote in ARexx running PHP scripts on a souped up Amiga, (we 
farmed it out about the time we made the digital switch because Jim no 
longer had the time to do it full time, and of course the farmed out 
version sucks) but while that wasn't my forte, I don't recall Jim ever 
mentioning PHP error messages as being in Hebrew.

I recall from a mailing list discussion about why English was the dominant 
language, probably a decade or more back up the log so it is not in my 
email corpus now, and a Turkish professor of one of the other latin 
languages nailed it at the time. In terms of the language moving to keep up 
with the state of the art, English moves, rapidly and smoothly and our 
dictionaries are updated to add the new words at many times the pace of the 
older languages.

Some progress is being made of course, we now have what, 18 language linux 
can speak, I'd assume with a certain amount of kicking and screaming, but 
it seems to me that it is still pretty true. Engrish, as exported from 
Japan in their tech manuals doesn't count, we can usually figure out what 
the Sony engineers were trying to say.

Not that it will be appreciated by those younger English speakers here, 
who, because their schools failed them, never got any phonetic tutoring.  I 
did, and as I approach my 80th birthday, I truly feel like the last of a 
dying breed because they dropped that from the elementary school curriculum 
a year later.  That loss, to the language as a whole, is very telling in 
what one hears being spoken on the streets of small town America today, 
much of which would have earned me an F back in the 1940's.  Today, saying 
that the language has been butchered, gives the skilled butcher a bad 
reputation.  But we muddle along, somehow managing to survive all those 
legal warnings on a bottle of aspirin. :)

Cheers, Gene
-- 
"There are four boxes to be used in defense of liberty:
 soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author)
Genes Web page 

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Explanation of this Python language feature? [x for x in x for x in x] (to flatten a nested list)

2014-03-29 Thread Steven D'Aprano
On Fri, 28 Mar 2014 23:40:01 -0500, Mark H Harris wrote:

> On 3/28/14 10:51 PM, Steven D'Aprano wrote:
>> You are being patronising to the 94% of the world that is not from the
>> USA. Do you honestly think that people all over the world have been
>> using computers for 30 or 40 years without any way to enter their
>> native language?
> 
> uh, pretty much.

Then be educated. That is not the case.

People have had localised code pages, and localised keyboards to enter 
characters in those code pages, for up to 30 years, if not longer.

In some of those cases, the localisation was done by companies like IBM, 
Microsoft and Apple, realising that if they wanted to sell computers 
outside of the US, they needed to supply computers that were localised to 
their market. In other cases, it was the national governments of the 
nations which set up their own standards, then insisted that computer 
vendors supported them.

This code page system actually worked pretty well, so long as you only 
exchange documents with people using the same code page. Until the 
Internet, that was mostly the case.


> That's why they called it ASCII American Standard
> Code for Information Interchange...

Yes. So what? Just because ASCII exists doesn't mean everyone uses it 
*exclusively*.

With the demise of EBCDIC as the standard character encoding (actually 
plural encodings, because EBCDIC has code pages too), ASCII has become 
the lowest common denominator for most (but not all) character sets. Pre-
Unicode, most (but definitely not all!) code pages were based on ASCII, 
either with a few changes, or extending it to a full 8 bits.

But that's the point: most people with access to computing in the first 
place, also had access to input methods and code pages for their native 
language. Your idea that they were forced to use ASCII exclusively, with 
no way of entering their own language, is simply wrong.


-- 
Steven D'Aprano
http://import-that.dreamwidth.org/
-- 
https://mail.python.org/mailman/listinfo/python-list


checking if two things do not equal None

2014-03-29 Thread contact . trigon
if (a, b) != (None, None):
or
if a != None != b:

Preference? Pros? Cons? Alternatives?

:D
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: checking if two things do not equal None

2014-03-29 Thread Steven D'Aprano
On Sat, 29 Mar 2014 11:56:50 -0700, contact.trigon wrote:

> if (a, b) != (None, None):
> or
> if a != None != b:
> 
> Preference? Pros? Cons? Alternatives?

Do you actually want to check for arbitrary objects which may claim to 
equal None, or do you want to check for objects which are None?


Nearly always when people test for == to None, they don't really mean it. 
They actually want to use an identity test. I'm going to assume the same 
holds here.

if not (a is b is None): ...


Or if you prefer:

if a is not b is not None: ...




-- 
Steven D'Aprano
http://import-that.dreamwidth.org/
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: checking if two things do not equal None

2014-03-29 Thread Lele Gaifax
Steven D'Aprano  writes:

> if not (a is b is None): ...
>
> Or if you prefer:
>
> if a is not b is not None: ...

>>> 1 is not 1 is not None
False

So definitely the former!

ciao, lele.
-- 
nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri
real: Emanuele Gaifas | comincerò ad aver paura di chi mi copia.
[email protected]  | -- Fortunato Depero, 1929.

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: checking if two things do not equal None

2014-03-29 Thread contact . trigon
> Do you actually want to check for arbitrary objects which may claim to  
> equal None, or do you want to check for objects which are None?

Arbitrary objects are not a concern.

> if not (a is b is None): ...
> 
> if a is not b is not None: ...

Thanks for the examples.

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Keyboard standards

2014-03-29 Thread Larry Hudson

On 03/28/2014 09:26 PM, Mark H Harris wrote:


PS   Thunderbird puts *both* the list and the news group addys in the to: 
header field on
reply-to-list.   ~nice, huh.


Must be the way YOU set it up.  MY Thunderbird (currently version 24.4.0 on Mint Linux 16) 
doesn't do any such thing.  Besides, "Reply" sends private e-mail to the poster -- "Followup" 
sends to the newsgroup.


 -=- Larry -=-

--
https://mail.python.org/mailman/listinfo/python-list


Re: Keyboard standards

2014-03-29 Thread Michael Torrie
On 03/29/2014 01:27 PM, Larry Hudson wrote:
> On 03/28/2014 09:26 PM, Mark H Harris wrote:
>>
>> PS   Thunderbird puts *both* the list and the news group addys in the to: 
>> header field on
>> reply-to-list.   ~nice, huh.
> 
> Must be the way YOU set it up.  MY Thunderbird (currently version 24.4.0 on 
> Mint Linux 16) 
> doesn't do any such thing.  Besides, "Reply" sends private e-mail to the 
> poster -- "Followup" 
> sends to the newsgroup.

No, Mark describes the standard way Thunderbird works.  Reply-to-List
does what he says it does. Not sure why your installation works
differently.  I guess maybe you are talking about something different.
The mailing list vs the NNTP list.

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: checking if two things do not equal None

2014-03-29 Thread Johannes Bauer
On 29.03.2014 20:05, Steven D'Aprano wrote:
> On Sat, 29 Mar 2014 11:56:50 -0700, contact.trigon wrote:
> 
>> if (a, b) != (None, None):
>> or
>> if a != None != b:
>>
>> Preference? Pros? Cons? Alternatives?
>
> if not (a is b is None): ...
> 
> Or if you prefer:
> 
> if a is not b is not None: ...

Is this an obfuscated coding contest? Why do you opt for a solution that
one has to at least think 2 seconds about when the simplest solution:

if (a is not None) or (b is not None):

is immediately understandable by everyone?

Cheers,
Johannes

-- 
>> Wo hattest Du das Beben nochmal GENAU vorhergesagt?
> Zumindest nicht öffentlich!
Ah, der neueste und bis heute genialste Streich unsere großen
Kosmologen: Die Geheim-Vorhersage.
 - Karl Kaos über Rüdiger Thomas in dsa 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: checking if two things do not equal None

2014-03-29 Thread Roy Smith
In article ,
 Johannes Bauer  wrote:

> On 29.03.2014 20:05, Steven D'Aprano wrote:
> > On Sat, 29 Mar 2014 11:56:50 -0700, contact.trigon wrote:
> > 
> >> if (a, b) != (None, None):
> >> or
> >> if a != None != b:
> >>
> >> Preference? Pros? Cons? Alternatives?
> >
> > if not (a is b is None): ...
> > 
> > Or if you prefer:
> > 
> > if a is not b is not None: ...
> 
> Is this an obfuscated coding contest? Why do you opt for a solution that
> one has to at least think 2 seconds about when the simplest solution:
> 
> if (a is not None) or (b is not None):
> 
> is immediately understandable by everyone?

I agree with that.  But

> if (a, b) != (None, None):

seems pretty straight-forward to me too.  In fact, if anything, it seems 
easier to understand than

> if (a is not None) or (b is not None):

I certainly agree that things like

> if a is not b is not None: ...

belong in an obfuscated coding contest.  Code gets read a lot more often 
than it get written.  Make it dead-ass simple to understand, and future 
generations of programmers who inherit your code will thank you for it.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Keyboard standards

2014-03-29 Thread Dave Angel
 Larry Hudson  Wrote in message:
> On 03/28/2014 09:26 PM, Mark H Harris wrote:
>>
>> PS   Thunderbird puts *both* the list and the news group addys in the to: 
>> header field on
>> reply-to-list.   ~nice, huh.
> 
> Must be the way YOU set it up.  MY Thunderbird (currently version 24.4.0 on 
> Mint Linux 16) 
> doesn't do any such thing.  Besides, "Reply" sends private e-mail to the 
> poster -- "Followup" 
> sends to the newsgroup.
> 
>   -=- Larry -=-
> 
> 

That depends on whether you're using Thunderbird as a newsreader, 
 or Thunderbird with the mailing list.  Mark Harris is apparently
 doing the latter. 

-- 
DaveA

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: checking if two things do not equal None

2014-03-29 Thread Dave Angel
 Roy Smith  Wrote in message:
> In article ,
>  Johannes Bauer  wrote:
> 
>> On 29.03.2014 20:05, Steven D'Aprano wrote:
>> > On Sat, 29 Mar 2014 11:56:50 -0700, contact.trigon wrote:
>> > 
>> >> if (a, b) != (None, None):
>> >> or
>> >> if a != None != b:
>> >>
>> >> Preference? Pros? Cons? Alternatives?
>> >
>> > if not (a is b is None): ...
>> > 
>> > Or if you prefer:
>> > 
>> > if a is not b is not None: ...
>> 
>> Is this an obfuscated coding contest? Why do you opt for a solution that
>> one has to at least think 2 seconds about when the simplest solution:
>> 
>> if (a is not None) or (b is not None):
>> 
>> is immediately understandable by everyone?
> 
> I agree with that.  But
> 
>> if (a, b) != (None, None):
> 
> seems pretty straight-forward to me too.  In fact, if anything, it seems 
> easier to understand than
> 
>> if (a is not None) or (b is not None):
> 
> I certainly agree that things like
> 
>> if a is not b is not None: ...
> 
> belong in an obfuscated coding contest.  Code gets read a lot more often 
> than it get written.  Make it dead-ass simple to understand, and future 
> generations of programmers who inherit your code will thank you for it.
> 

The other advantage to keeping it simple is it's more than likely
 to be right.  If we take the original form as the spec, we'll
 find that two of the alternatives are not even equivalent.
 

def trigon1(a, b):
return (a,b) != (None, None)  #master

def trigon2(a, b):
return a != None != b.  #different

def steven1(a, b):
return not(a is b is None)

def steven2(a, b):
return a is not b is not None  #different

def johannes(a, b):
return (a is not None) or (b is not None)

table = [
trigon1,
trigon2,
steven1,
steven2,
johannes
]

for func in table:
print func.__name__
print func(None, None), func(None, 42), func(42, None),
 func(42, 42), func(42, "never")




-- 
DaveA

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: checking if two things do not equal None

2014-03-29 Thread Johannes Bauer
On 29.03.2014 22:07, Roy Smith wrote:

> I agree with that.  But
> 
>> if (a, b) != (None, None):
> 
> seems pretty straight-forward to me too.  In fact, if anything, it seems 
> easier to understand than
> 
>> if (a is not None) or (b is not None):

Yes, probably. I liked the original, too. If I were writing the code,
I'd probably try to aim to invert the condition though and simply do

if (a is None) and (b is None)

Which is pretty easy to understand for even a rookie programmer.

> I certainly agree that things like
> 
>> if a is not b is not None: ...
> 
> belong in an obfuscated coding contest.  Code gets read a lot more often 
> than it get written.  Make it dead-ass simple to understand, and future 
> generations of programmers who inherit your code will thank you for it.

Absolutely.

Cheers,
Johannes

-- 
>> Wo hattest Du das Beben nochmal GENAU vorhergesagt?
> Zumindest nicht öffentlich!
Ah, der neueste und bis heute genialste Streich unsere großen
Kosmologen: Die Geheim-Vorhersage.
 - Karl Kaos über Rüdiger Thomas in dsa 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: unicode as valid naming symbols

2014-03-29 Thread Chris Angelico
On Sun, Mar 30, 2014 at 5:11 AM, Dennis Lee Bieber
 wrote:
> Considering that a 5x8 bitmap font (which is unlikely to even have
> enough pixels to produce even 65536 unique glyphs) would take 5.6MB for
> your (17*65536), I wouldn't want to see what an algorithmic description
> would require.
>
> Looking at some of my collection of fonts, TTF and some PS, seem to be
> running around 100kB per font, and those fonts likely have around 128-192
> glyphs.
>
> For 1114112 glyphs (17*65536) at, say 164 glyphs pre 100kB gives 680MB
> per FONT. Assume the standards: normal, bold, italic, bold-italic -- one is
> now up to 2.7GB per typeface. 5.4GB to support just one serif and one sans
> serif typeface.

Most fonts these days are vector, not bitmap, but a 5x8 bitmap has
forty pixels, any of which can be either on or off - that gives
roughly twice as much data space as the 21-bit Unicode spec. Plenty of
room for 17*65536 unique glyphs. But you're right that it'd then take
~5-6MB to store that, minimum.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: checking if two things do not equal None

2014-03-29 Thread Johannes Bauer
On 29.03.2014 22:55, Johannes Bauer wrote:

>>> if (a is not None) or (b is not None):
> 
> Yes, probably. I liked the original, too. If I were writing the code,
> I'd probably try to aim to invert the condition though and simply do
> 
> if (a is None) and (b is None)
> 
> Which is pretty easy to understand for even a rookie programmer.

Let me expand on that thought one or two more sentences: Although it may
seem really trivial, inversions ("not") in my opinion can really make
code unreadable. One thing that I regularly see when peer-reviewing code
is something like:

if not feature_disabled:

or one that I've seen in-field (modulo the programming language and the
variable names):

if (not no_delayed_commit) and (not data_unchanged):

instead of:

if immediate_commit and data_changed:

Enough of my two cents for today :-)
Cheers,
Johannes


-- 
>> Wo hattest Du das Beben nochmal GENAU vorhergesagt?
> Zumindest nicht öffentlich!
Ah, der neueste und bis heute genialste Streich unsere großen
Kosmologen: Die Geheim-Vorhersage.
 - Karl Kaos über Rüdiger Thomas in dsa 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: checking if two things do not equal None

2014-03-29 Thread Tim Chase
On 2014-03-29 17:07, Roy Smith wrote:
> > if (a is not None) or (b is not None):
> > 
> > is immediately understandable by everyone?  
> 
> I agree with that.  But
> 
> > if (a, b) != (None, None):  
> 
> seems pretty straight-forward to me too.  In fact, if anything, it
> seems easier to understand than

And for cases where you have more than one or two things to test for
None-itude, you could use

  if all(x is None for x in [a, b, c, d]):
do_something_if_theyre_all_None()

or

  if all(x is not None for x in [a, b, c, d]):
do_something_if_no_Nones()

or

  if not any(x is None for x in [a, b, c, d]):
do_something_if_no_Nones()

which I find *much* more readable from a maintenance point of view.

-tkc



-- 
https://mail.python.org/mailman/listinfo/python-list


Re: checking if two things do not equal None

2014-03-29 Thread Roy Smith
On Mar 29, 2014, at 6:36 PM, Tim Chase wrote:

> And for cases where you have more than one or two things to test for
> None-itude, you could use
> 
>  if all(x is None for x in [a, b, c, d]):
>do_something_if_theyre_all_None()

I might have written that as:

if set([a, b, c, d]) == set(None)

That's even clearer if you happen to already have the items in an iterable:

if set(conditions) == set(None)


--
Roy Smith
[email protected]



-- 
https://mail.python.org/mailman/listinfo/python-list


Re: checking if two things do not equal None

2014-03-29 Thread Tim Chase
On 2014-03-29 18:41, Roy Smith wrote:
> On Mar 29, 2014, at 6:36 PM, Tim Chase wrote:
> 
> > And for cases where you have more than one or two things to test
> > for None-itude, you could use
> > 
> >  if all(x is None for x in [a, b, c, d]):
> >do_something_if_theyre_all_None()
> 
> I might have written that as:
> 
> if set([a, b, c, d]) == set(None)
> 
> That's even clearer if you happen to already have the items in an
> iterable:
> 
> if set(conditions) == set(None)

Though am I correct that your iteration tests for equality, while
mine tests for identity?  Also, my version bails early in the event
quitting early is possible.  That's particularly useful in the case
of doing something like

  if all(x() is None for x in [func1, func2, func3, costly_func]):
do_something()

-tkc



-- 
https://mail.python.org/mailman/listinfo/python-list


Re: checking if two things do not equal None

2014-03-29 Thread Roy Smith
In article ,
 Tim Chase  wrote:

> On 2014-03-29 18:41, Roy Smith wrote:
> > On Mar 29, 2014, at 6:36 PM, Tim Chase wrote:
> > 
> > > And for cases where you have more than one or two things to test
> > > for None-itude, you could use
> > > 
> > >  if all(x is None for x in [a, b, c, d]):
> > >do_something_if_theyre_all_None()
> > 
> > I might have written that as:
> > 
> > if set([a, b, c, d]) == set(None)
> > 
> > That's even clearer if you happen to already have the items in an
> > iterable:
> > 
> > if set(conditions) == set(None)
> 
> Though am I correct that your iteration tests for equality, while
> mine tests for identity?

Hmmm, you're almost certainly correct on that, but you would have to 
have a perversely designed class for that to make a difference.  I'll 
take the increased readability.

> Also, my version bails early in the event
> quitting early is possible.  That's particularly useful in the case
> of doing something like
> 
>   if all(x() is None for x in [func1, func2, func3, costly_func]):
> do_something()

Again, you're correct.  But, I'll take the increased readability over 
the premature optimization :-)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: checking if two things do not equal None

2014-03-29 Thread Terry Reedy

On 3/29/2014 2:56 PM, [email protected] wrote:

if (a, b) != (None, None):
or
if a != None != b:

Preference? Pros? Cons? Alternatives?


if a is not None is not b
==
if a is not None and None is not b
==
if a is not None and b is not None
which is what I would write if not trying to be cute.
a < x < b is more readable as a chained comparison than the double is not.

--
Terry Jan Reedy

--
https://mail.python.org/mailman/listinfo/python-list


Re: checking if two things do not equal None

2014-03-29 Thread Chris Angelico
On Sun, Mar 30, 2014 at 9:46 AM, Tim Chase  wrote:
> Though am I correct that your iteration tests for equality, while
> mine tests for identity?  Also, my version bails early in the event
> quitting early is possible.  That's particularly useful in the case
> of doing something like
>
>   if all(x() is None for x in [func1, func2, func3, costly_func]):
> do_something()

Presumably you mean to actually call those functions, as checking the
identity of a costly function is still cheap :)

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: checking if two things do not equal None

2014-03-29 Thread contact . trigon
Thanks everyone; it has been very educational.

> Dave Angel:
> ...we'll find that two of the alternatives are not even equivalent.

That helped me realize (a,b) != (None, None) is not correct for the function.

It's a case where two parameters have None as the default argument. What I want 
is to make sure that both are not None. I am now considering:

if None not in (a,b):
or
if (a is not None) and (b is not None):
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: checking if two things do not equal None

2014-03-29 Thread Ethan Furman

On 03/29/2014 02:01 PM, Johannes Bauer wrote:

On 29.03.2014 20:05, Steven D'Aprano wrote:

On Sat, 29 Mar 2014 11:56:50 -0700, contact.trigon wrote:


if (a, b) != (None, None):
or
if a != None != b:

Preference? Pros? Cons? Alternatives?


if not (a is b is None): ...

Or if you prefer:

if a is not b is not None: ...


Is this an obfuscated coding contest? Why do you opt for a solution that
one has to at least think 2 seconds about when the simplest solution:

if (a is not None) or (b is not None):

is immediately understandable by everyone?


+1

--
~Ethan~
--
https://mail.python.org/mailman/listinfo/python-list


Re: checking if two things do not equal None

2014-03-29 Thread Tim Chase
On 2014-03-30 10:17, Chris Angelico wrote:
> On Sun, Mar 30, 2014 at 9:46 AM, Tim Chase 
> wrote:
>> Though am I correct that your iteration tests for equality, while
>> mine tests for identity?  Also, my version bails early in the
>> event quitting early is possible.  That's particularly useful in
>> the case of doing something like
>>
>>   if all(x() is None for x in [func1, func2, func3, costly_func]):
^^^
>> do_something()
> 
> Presumably you mean to actually call those functions, as checking
> the identity of a costly function is still cheap :)

Which is what I do...calling only those necessary until the all/any
condition has been met. :-)

If you create the list of things to iterate over by calling them as
you create the list, then you don't save much of anything.  If you
only call until one of them breaks the any/all construct, you save
all the subsequent function calls.

-tkc




-- 
https://mail.python.org/mailman/listinfo/python-list


Re: checking if two things do not equal None

2014-03-29 Thread Chris Angelico
On Sun, Mar 30, 2014 at 12:19 PM, Tim Chase
 wrote:
> On 2014-03-30 10:17, Chris Angelico wrote:
>> On Sun, Mar 30, 2014 at 9:46 AM, Tim Chase 
>> wrote:
>>> Though am I correct that your iteration tests for equality, while
>>> mine tests for identity?  Also, my version bails early in the
>>> event quitting early is possible.  That's particularly useful in
>>> the case of doing something like
>>>
>>>   if all(x() is None for x in [func1, func2, func3, costly_func]):
> ^^^
>>> do_something()
>>
>> Presumably you mean to actually call those functions, as checking
>> the identity of a costly function is still cheap :)
>
> Which is what I do...calling only those necessary until the all/any
> condition has been met. :-)
>
> If you create the list of things to iterate over by calling them as
> you create the list, then you don't save much of anything.  If you
> only call until one of them breaks the any/all construct, you save
> all the subsequent function calls.

*facepalm* Yep, you do indeed. My bad! Take no notice of the man
behind the curtain...

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: checking if two things do not equal None

2014-03-29 Thread Steven D'Aprano
On Sat, 29 Mar 2014 17:07:20 -0400, Roy Smith wrote:

> I certainly agree that things like
> 
>> if a is not b is not None: ...
> 
> belong in an obfuscated coding contest. 

Apart from the fact that I got it wrong (that's what happens when I post 
at 6am after being up all night, thanks for the correction Lele), if you 
consider chained comparisons to be "obfuscated", I think you're not 
really fluent at Python. The OP even suggested  `a != None != b` so I 
think that (s)he at least understands chained comparisons.

However, I agree with Johannes that inverted conditions (using "not") are 
sometimes harder to reason about than "regular" conditions.



-- 
Steven D'Aprano
http://import-that.dreamwidth.org/
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: checking if two things do not equal None

2014-03-29 Thread Chris Angelico
On Sun, Mar 30, 2014 at 1:04 PM, Steven D'Aprano
 wrote:
> On Sat, 29 Mar 2014 17:07:20 -0400, Roy Smith wrote:
>
>> I certainly agree that things like
>>
>>> if a is not b is not None: ...
>>
>> belong in an obfuscated coding contest.
>
> Apart from the fact that I got it wrong (that's what happens when I post
> at 6am after being up all night, thanks for the correction Lele), if you
> consider chained comparisons to be "obfuscated", I think you're not
> really fluent at Python. The OP even suggested  `a != None != b` so I
> think that (s)he at least understands chained comparisons.
>
> However, I agree with Johannes that inverted conditions (using "not") are
> sometimes harder to reason about than "regular" conditions.

Chained comparisons where you're checking a single variable against
two constants make perfect sense:

2 < x < 5

Chained comparisons where you check a single constant against two
variables don't, so much:

x < 2 < y

What exactly does that mean, and why is it written that way? We can
figure out how the interpreter will parse that, but does that
correspond to the programmer's intention?

It'd be more useful but less clear if one of the conditions points the
other way:

x < 2 > y

which checks that they're both less than two, but IMO in a less-than-clear way.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: checking if two things do not equal None

2014-03-29 Thread Steven D'Aprano
On Sat, 29 Mar 2014 17:36:55 -0500, Tim Chase wrote:

> And for cases where you have more than one or two things to test for
> None-itude, you could use
> 
>   if all(x is None for x in [a, b, c, d]):
> do_something_if_theyre_all_None()
> 
> or
> 
>   if all(x is not None for x in [a, b, c, d]):
> do_something_if_no_Nones()
> 
> or
> 
>   if not any(x is None for x in [a, b, c, d]):
> do_something_if_no_Nones()
> 
> which I find *much* more readable from a maintenance point of view.

With one or two things, I would stick to a regular comparison (skipping 
the "not"):

a is None
a is b is None

With three, I would consider either idiom:

a is b is c is None
all(x is None for x in (a, b, c))

but lean towards the use of all(). From four onwards I would definitely 
use all(), and of course if there is an arbitrary number of items, I 
would definitely use all().



-- 
Steven D'Aprano
http://import-that.dreamwidth.org/
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: checking if two things do not equal None

2014-03-29 Thread Roy Smith
In article ,
 Chris Angelico  wrote:

> Chained comparisons where you're checking a single variable against
> two constants make perfect sense:
> 
> 2 < x < 5
> 
> Chained comparisons where you check a single constant against two
> variables don't, so much:
> 
> x < 2 < y

To me, chained comparisons make intuitive sense when they're all "<" (or 
"<=").  I just think back to junior high school algebra class, with the 
big number line above the blackboard.  Thus,

 a < b < c

means if you put a, b, and c on the number line, a is to the left of b, 
which is to the left of c.  I have no problem extending that to more 
than three values:

 a < b < c < d < e

still makes intuitive sense.  I have no particular problem with

 x < 2 < y

because it fits the same pattern.  But, if you show me

 a != None != b:

my brain just goes into overload.  Honestly, I don't even know what that 
means.  My brain keeps trying to stick a, None, and b on Mrs. Albaum's 
number line and keeps walking into the wall.  If you (the editorial you) 
tell me that my failure to grok that expression means I'm not fluent in 
Python, well then, guilty as charged.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: checking if two things do not equal None

2014-03-29 Thread Roy Smith
In article <[email protected]>,
 Steven D'Aprano  wrote:

> a is b is c is None

And we are all together.  See how they run like pigs from a gun, see how 
they fly.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Dynamically reference member of array

2014-03-29 Thread R. Michael Weylandt
On Wed, Mar 26, 2014 at 7:43 AM, Ben Collier  wrote:
> Hi all,
>
> I know that I can dynamically reference a variable with locals()["i"], for 
> instance, but I'd like to know how to do this with a variable in an object.
>
> If I have an object called "device", with variables called attr1, attr2 .. 
> attr50, how could I dynamically reference these?
>

I think the pythonic term you're looking for is "attribute". See
getattr() and setattr()

Cheers,
Michael
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: checking if two things do not equal None

2014-03-29 Thread Rustom Mody
On Sunday, March 30, 2014 8:09:45 AM UTC+5:30, Roy Smith wrote:
> I have no particular problem with

>  x < 2 < y

> because it fits the same pattern.  But, if you show me

>  a != None != b:

> my brain just goes into overload.  Honestly, I don't even know what that 
> means.  My brain keeps trying to stick a, None, and b on Mrs. Albaum's 
> number line and keeps walking into the wall.  If you (the editorial you) 
> tell me that my failure to grok that expression means I'm not fluent in 
> Python, well then, guilty as charged.


A relation that is reflexive antisymmetric and transitive is a partial order
Strict order: Irreflexive asymmetric and transitive
Both are strongly related
For general R (partial) S (strict)

S from R
xSy = xRy ∧ x ≠ y
R from S
xRy = xSy ∨ x=y


For both these chained comparisons are natural

!= is not transitive: 2 != 3 and 3  != 2 ⊬ 2 == 2

So for != chained comparisons are not natural (or IMHO appropriate)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: checking if two things do not equal None

2014-03-29 Thread Zachary Ware


On March 29, 2014 9:43:00 PM CDT, Roy Smith  wrote:
>In article <[email protected]>,
> Steven D'Aprano  wrote:
>
>> a is b is c is None
>
>And we are all together.  See how they run like pigs from a gun, see
>how 
>they fly.

I'm cryin'.

(Really, that was terrible.)

Walrus-ly y'rs,

Zach

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: checking if two things do not equal None

2014-03-29 Thread Steven D'Aprano
On Sun, 30 Mar 2014 13:15:18 +1100, Chris Angelico wrote:

> On Sun, Mar 30, 2014 at 1:04 PM, Steven D'Aprano
>  wrote:
>> On Sat, 29 Mar 2014 17:07:20 -0400, Roy Smith wrote:
>>
>>> I certainly agree that things like
>>>
 if a is not b is not None: ...
>>>
>>> belong in an obfuscated coding contest.
>>
>> Apart from the fact that I got it wrong (that's what happens when I
>> post at 6am after being up all night, thanks for the correction Lele),
>> if you consider chained comparisons to be "obfuscated", I think you're
>> not really fluent at Python. The OP even suggested  `a != None != b` so
>> I think that (s)he at least understands chained comparisons.
>>
>> However, I agree with Johannes that inverted conditions (using "not")
>> are sometimes harder to reason about than "regular" conditions.
> 
> Chained comparisons where you're checking a single variable against two
> constants make perfect sense:
> 
> 2 < x < 5
> 
> Chained comparisons where you check a single constant against two
> variables don't, so much:
> 
> x < 2 < y
> 
> What exactly does that mean, and why is it written that way? 

It checks that 2 is strictly bounded between x on the left and y on the 
right, i.e. that 2 is inside the open interval x...y. I don't know why 
you think that's unclear. But then I do have a maths background and I'm 
used to chaining comparisons.

Write it like this:

low = x
high = y
a = 2

low < a < high

Does that make more sense? Well-chosen names are good. The fact that a is 
a constant rather than a variable is no big deal:

low < 2 < high


> We can
> figure out how the interpreter will parse that, but does that correspond
> to the programmer's intention?

That applies to just about anything:

(x % 2 == 1) or (x > 0)

What that my intention, or did I intend to write

(x % 2 == 0) and (x < 0)


At some point you just have to accept that, in the absence of clearly 
nonsensical code or a contradiction between the documentation and the 
behaviour (i.e. a bug), the programmer will have written what she 
intended to write.


> It'd be more useful but less clear if one of the conditions points the
> other way:
> 
> x < 2 > y
> 
> which checks that they're both less than two, 

which is quite different from what you wrote the first time.


> but IMO in a less-than-clear way.

That's an understatement. If I saw code chaining comparisons in that 
fashion, I would assume the second operator > was a typo.

Chaining less-than and greater than operators should, for clarity, always 
be written in a single order. E.g. a <= b < c < d, not a <= b < d > c.

(The second contains a subtle bug too.)



-- 
Steven D'Aprano
http://import-that.dreamwidth.org/
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Explanation of this Python language feature? [x for x in x for x in x] (to flatten a nested list)

2014-03-29 Thread Mark H Harris

On 3/29/14 10:45 AM, Mark Lawrence wrote:

On 29/03/2014 08:21, Mark H Harris wrote:


Yes. Well, as the joke goes, if you're trilingual you speak three
languages, if you're bilingual you speak two languages, if you're
monolingual you're an American (well, that might go for Australia too,
maybe). When whole continents speak the same language that tends to
happen.


You mean like the USA, where I saw an ad in a shop for a bilingual shop
assistant?  Or is Spanish so like US English it doesn't count as a
separate language?


I'm not sure what point you are trying to make. We have people here from 
all over the earth, and enough illegal immigrants speaking Spanish to 
account for a population about the size of Ohio. But, Americans are 
mostly monolingual. ...point of fact.


The people of the United States are in a smallish battle over whether 
the official language of the United States should be English? In other 
words, no special signs, if you're going to live here you're going to 
learn English (end of the story, for some people).


I'm not in that camp. I am preparing to start French studies soon. My 
son and daughter are fifth year fluent in Spanish (my daughter is 
minoring in Spanish, and plans study abroad for that purpose as she 
prepares for medical school.


There is no nice way to say this... we have a lot of pin-headed bigots 
living here that have to intention nor inclination to learn another 
language. Some of them even think that if English was good enough for 
Jesus , its got to be good enough for them (I'm not kidding).


Sadly, true.

But then, more than half of our population is not aware that the earth 
revolves around the sun, either.:-}


Cheers
--
https://mail.python.org/mailman/listinfo/python-list


Re: Explanation of this Python language feature? [x for x in x for x in x] (to flatten a nested list)

2014-03-29 Thread Mark H Harris

On 3/29/14 6:59 AM, Marko Rauhamaa wrote:

I hate localization. You get a error message in Finnish from "make" or
"grep" and then you try to google it.

So mine is en_US, but I know people who do fi_FI.


... this is my point precisely.


--
https://mail.python.org/mailman/listinfo/python-list


Re: checking if two things do not equal None

2014-03-29 Thread Steven D'Aprano
On Sat, 29 Mar 2014 19:54:09 -0700, Rustom Mody wrote:

> On Sunday, March 30, 2014 8:09:45 AM UTC+5:30, Roy Smith wrote:
>> I have no particular problem with
> 
>>  x < 2 < y
> 
>> because it fits the same pattern.  But, if you show me
> 
>>  a != None != b:
> 
>> my brain just goes into overload.  Honestly, I don't even know what
>> that means.  My brain keeps trying to stick a, None, and b on Mrs.
>> Albaum's number line and keeps walking into the wall.  If you (the
>> editorial you) tell me that my failure to grok that expression means
>> I'm not fluent in Python, well then, guilty as charged.
> 
> 
[...]
> So for != chained comparisons are not natural (or IMHO appropriate)

I tend to agree they're "not natural", although appropriate is another 
thing. The problem is that we tend to read something like:

a != b != c

as "all of a, b and c are unequal", corresponding to:

a == b == c

as "all of a, b and c are equal". But that's not what it means. It means 
that a != b and b != c, but it says nothing about a and c. And that was 
my mistake. The OP actually got it right in their first post, but 
sticking None in the middle to ensure it partakes of both comparisons.

a is not None is not b

Still, that's not easily extended to a third item, this would be wrong:

a is not None is not b is not c

since c only gets compared against b, not None. Better is to factor the 
"not" out:

not (a is b is c is None)


which now should be clear: you're testing whether or not *all* of a, b 
and c are None. If you prefer:

not all(x is None for x in (a, b, c))


Which is more readable is a matter of personal preference.

I think Johannes got it right: boolean logic is easier to reason about 
when there is a minimum of "not"s.


-- 
Steven D'Aprano
http://import-that.dreamwidth.org/
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: checking if two things do not equal None

2014-03-29 Thread Chris Angelico
On Sun, Mar 30, 2014 at 4:54 PM, Steven D'Aprano
 wrote:
> On Sun, 30 Mar 2014 13:15:18 +1100, Chris Angelico wrote:
>
>> Chained comparisons where you're checking a single variable against two
>> constants make perfect sense:
>>
>> 2 < x < 5
>>
>> Chained comparisons where you check a single constant against two
>> variables don't, so much:
>>
>> x < 2 < y
>>
>> What exactly does that mean, and why is it written that way?
>
> It checks that 2 is strictly bounded between x on the left and y on the
> right, i.e. that 2 is inside the open interval x...y. I don't know why
> you think that's unclear. But then I do have a maths background and I'm
> used to chaining comparisons.
>
> Write it like this:
>
> low = x
> high = y
> a = 2
>
> low < a < high
>
> Does that make more sense? Well-chosen names are good. The fact that a is
> a constant rather than a variable is no big deal:
>
> low < 2 < high

The problem isn't that I can't see what the comparisons are. It makes
very good sense to bound a variable within constants; but you already
know exactly where 2 is on the number line, so asking "Is 2 between
these two variables" seems a bit odd. Maybe it's less so with the
strong mathematical background, but it seems odd to me.

>> It'd be more useful but less clear if one of the conditions points the
>> other way:
>>
>> x < 2 > y
>>
>> which checks that they're both less than two,
>
> which is quite different from what you wrote the first time.
>
>
>> but IMO in a less-than-clear way.
>
> That's an understatement. If I saw code chaining comparisons in that
> fashion, I would assume the second operator > was a typo.
>
> Chaining less-than and greater than operators should, for clarity, always
> be written in a single order. E.g. a <= b < c < d, not a <= b < d > c.
>
> (The second contains a subtle bug too.)

Agreed.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: unicode as valid naming symbols

2014-03-29 Thread Gregory Ewing

Chris Angelico wrote:

a 5x8 bitmap has
forty pixels, any of which can be either on or off - that gives
roughly twice as much data space as the 21-bit Unicode spec.


We don't need a font, then -- just map the pixels
straight onto bits in the character code!

Might require some user re-education, but that's
a small price to pay for saving so much memory
space.

--
Greg
--
https://mail.python.org/mailman/listinfo/python-list


Re: Explanation of this Python language feature? [x for x in x for x in x] (to flatten a nested list)

2014-03-29 Thread Mark H Harris

On 3/29/14 12:53 PM, Steven D'Aprano wrote:

People have had localised code pages, and localised keyboards to enter
characters in those code pages, for up to 30 years, if not longer.


   Nobody is arguing otherwise, Steven. Having a code page for a local 
language is not the same thing as having software that supports your 
local language code page! Software and code pages improved over time, 
but international communication (which is what I'm talking about) has 
always been done in English, using ASCII. Well except when Guido brought 
the ABC stuff to the states back in the day and had no way to do that 
except to fly himself (and the tape) personally.


In some of those cases, the localisation was done by companies like IBM,
Microsoft and Apple, realising that if they wanted to sell computers
outside of the US, they needed to supply computers that were localised to
their market.


   Unfortunately that happened way late. And even then, international 
communication was still done (and is still done) in English. Only until 
very recently (see my post to Chris) has unicode improved to the point 
where international comm can occur reliably enough (input, font, code 
points) to allow comm in languages other than English. And yet, although 
Kanji has been around for a while, most international comm is still 
handled in English because its the lingua franca.




This code page system actually worked pretty well, so long as you only
exchange documents with people using the same code page. Until the
Internet, that was mostly the case.


   My point exactly. With the advent of the Internet, almost *all* comm 
is English with minor notable exceptions in today's environment. Just 
look around, you need not argue with me. You can find places for local 
comm, but they are sparse.





That's why they called it ASCII American Standard
Code for Information Interchange...


Yes. So what? Just because ASCII exists doesn't mean everyone uses it
*exclusively*.


   Yeah, well, that's exactly what happened; its still happening. Only 
today its UTF-8, a Latin script (there is only one) and thousands of 
people all over the earth on the Internet speaking English around the 
globe.  Yeah, I know, there are localized pockets and people using their 
computer in their heart language, but for international communication 
you're going to find (primarily) people communicating in English.



With the demise of EBCDIC as the standard character encoding (actually
plural encodings, because EBCDIC has code pages too),


   Ha!  That's funny.   EBCIDIC is | was  standard only at IBM. Those 
stubborn people (I used to be one of them) stuck with EBCIDIC and 
SNA/SDLC until they realized that they could not communicate with the 
rest of the world using ASCII and TCP/IP.  ... just hilarious!



ASCII has become
the lowest common denominator for most (but not all) character sets. Pre-
Unicode, most (but definitely not all!) code pages were based on ASCII,
either with a few changes, or extending it to a full 8 bits.


   Yup.


But that's the point:


   Yes it is.


most people with access to computing in the first
place, also had access to input methods and code pages for their native
language. Your idea that they were forced to use ASCII exclusively, with
no way of entering their own language, is simply wrong.


   I'm not arguing that, Steven. You're just being silly. I'm talking 
about be forced to communicate around the world when most of the people 
communicating are speaking English and using ASCII.
   Look, I can unplug my computer from the Internet and use it to 
translate biblical Greek and O.T. Hebrew and be happy as a clam that I'm 
locally doing my own thing in my own language (so what)? The moment I 
want to communicate outside my local space I better know English, and I 
better have a code page that supports it.
   If you live in Israel, and only communicate with people in Israel, 
you can use your modern Hebrew font and code page and be happy as a 
clam; but if you want to communicate with somebody in IOWA, perhaps Iowa 
State for some reason, you better know English. Just say'n.
   On the other hand, just look around  the Internet. 98% of all 
communication is English using UTF-8 today. Yes, you can find pockets 
where this is not true, but primarily, the world is using a modern 
lingua franca.


   I am very interested with the intense interest in this topic.


marcus

--
https://mail.python.org/mailman/listinfo/python-list


OFF TOPIC Spanish in the USA [was Re: Explanation of this Python language feature?]

2014-03-29 Thread Steven D'Aprano
On Sun, 30 Mar 2014 00:52:20 -0500, Mark H Harris wrote:

> On 3/29/14 10:45 AM, Mark Lawrence wrote:
>> On 29/03/2014 08:21, Mark H Harris wrote:
>>>
>>> Yes. Well, as the joke goes, if you're trilingual you speak three
>>> languages, if you're bilingual you speak two languages, if you're
>>> monolingual you're an American (well, that might go for Australia too,
>>> maybe). When whole continents speak the same language that tends to
>>> happen.
>>
>> You mean like the USA, where I saw an ad in a shop for a bilingual shop
>> assistant?  Or is Spanish so like US English it doesn't count as a
>> separate language?
> 
> I'm not sure what point you are trying to make. We have people here from
> all over the earth, and enough illegal immigrants speaking Spanish to
> account for a population about the size of Ohio.

*raises eyebrow*

Did you intend to imply that it is only illegal immigrants who speak 
Spanish in the USA?

The most recent US census found there are 38.5 million people in the US 
who primarily speak Spanish, and 45 million who speak it as their first 
or second language. In comparison, there are only an estimated 11 million 
illegal immigrants (of which only 7 million is from Mexico).

https://en.wikipedia.org/wiki/Spanish_language_in_the_United_States



-- 
Steven D'Aprano
http://import-that.dreamwidth.org/
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: OFF TOPIC Spanish in the USA [was Re: Explanation of this Python language feature?]

2014-03-29 Thread Chris Angelico
On Sun, Mar 30, 2014 at 5:31 PM, Steven D'Aprano
 wrote:
> Did you intend to imply that it is only illegal immigrants who speak
> Spanish in the USA?

I think he's correct there. After all, anyone who doesn't fit the
white-skinned monolingual (barely-one-language, really) middle-class
stereotype *MUST* be an illegal immigrant - right? That's how you
recognize who to be rude to.

http://notalwaysright.com/pepperoni-extremism/3163
http://notalwaysright.com/no-obamacare-for-you/17102
http://notalwaysworking.com/they-are-rotten-to-the-corps-part-2/32108
... and plenty more stories besides.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: checking if two things do not equal None

2014-03-29 Thread Gregory Ewing

Roy Smith wrote:

But, if you show me

 a != None != b:

my brain just goes into overload.


Chained comparisons get weird with not-equal operators.
If you see

  a == b == c

then it implies that a == c, but

  a != b != c

does *not* imply that a != c. At least it doesn't in
Python; I've never seen any mathematicians write that, so
I don't know what they would make of it.

--
Greg
--
https://mail.python.org/mailman/listinfo/python-list


Re: OFF TOPIC Spanish in the USA [was Re: Explanation of this Python language feature?]

2014-03-29 Thread Mark H Harris

On 3/30/14 1:31 AM, Steven D'Aprano wrote:

I'm not sure what point you are trying to make. We have people here from
all over the earth, and enough illegal immigrants speaking Spanish to
account for a population about the size of Ohio.


*raises eyebrow*

Did you intend to imply that it is only illegal immigrants who speak
Spanish in the USA?


   Don't be silly, Steven, it doesn't become you.


The most recent US census found there are 38.5 million people in the US
who primarily speak Spanish, and 45 million who speak it as their first
or second language. In comparison, there are only an estimated 11 million
illegal immigrants (of which only 7 million is from Mexico).

https://en.wikipedia.org/wiki/Spanish_language_in_the_United_States


   Hilarious!   That's part of the problem, um, its because they are 
*illegal* that the census bureau does not know about them in terms of 
exact numbers; its a nice effort though.


   America is a melting pot (always has been). We have thousands of 
ethnic groups living here and thousands of languages spoken here. All of 
them are in some place on the continuum of English as a second language; 
its the only way to survive here.



marcus


--
https://mail.python.org/mailman/listinfo/python-list


Re: checking if two things do not equal None

2014-03-29 Thread Ben Finney
Chris Angelico  writes:

> The problem isn't that I can't see what the comparisons are. It makes
> very good sense to bound a variable within constants; but you already
> know exactly where 2 is on the number line, so asking "Is 2 between
> these two variables" seems a bit odd. Maybe it's less so with the
> strong mathematical background, but it seems odd to me.

I don't feel odd about asking the question “Is 2 between these two
values?”. It's straightforward and concise. Can you explain better why
you find it odd?

-- 
 \ “You are welcome to visit the cemetery where famous Russian and |
  `\Soviet composers, artists, and writers are buried daily except |
_o__)   Thursday.” —Russian orthodox monastery, Moscow |
Ben Finney

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Keyboard standards

2014-03-29 Thread Larry Hudson

On 03/29/2014 12:41 PM, Michael Torrie wrote:

On 03/29/2014 01:27 PM, Larry Hudson wrote:

On 03/28/2014 09:26 PM, Mark H Harris wrote:


PS   Thunderbird puts *both* the list and the news group addys in the to: 
header field on
reply-to-list.   ~nice, huh.


Must be the way YOU set it up.  MY Thunderbird (currently version 24.4.0 on 
Mint Linux 16)
doesn't do any such thing.  Besides, "Reply" sends private e-mail to the poster -- 
"Followup"
sends to the newsgroup.


No, Mark describes the standard way Thunderbird works.  Reply-to-List
does what he says it does. Not sure why your installation works
differently.  I guess maybe you are talking about something different.
The mailing list vs the NNTP list.

You're right -- I use the NNTP list only.  I've never looked at the Python mailing list.  The 
very few mailing lists I subscribe to, I only read--never reply to.  Come to think of it, 
currently there's only one, and I rarely do more than skim it briefly--and frequently not even 
that.  I should drop it altogether, just haven't bothered to do so.


 -=- Larry -=-

--
https://mail.python.org/mailman/listinfo/python-list