Re: Why exception from os.path.exists()?

2018-06-10 Thread Marko Rauhamaa
Chris Angelico :
> It's important to pin down the true cause of the problem, and not
> blame something for doing the proper Pythonic thing.

So could you tell me what the proper Pythonic fix for the example server
in Python's documentation would be?

Here's the code in question:


import http.server
import socketserver

PORT = 8000

Handler = http.server.SimpleHTTPRequestHandler

with socketserver.TCPServer(("", PORT), Handler) as httpd:
print("serving at port", PORT)
httpd.serve_forever()


BTW, the proper response would be a 404. 500 means: "There's a bug in my
code".


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


Re: Why exception from os.path.exists()?

2018-06-10 Thread Chris Angelico
On Sun, Jun 10, 2018 at 7:06 PM, Marko Rauhamaa  wrote:
> Chris Angelico :
>> It's important to pin down the true cause of the problem, and not
>> blame something for doing the proper Pythonic thing.
>
> So could you tell me what the proper Pythonic fix for the example server
> in Python's documentation would be?
>
> Here's the code in question:
>
> 
> import http.server
> import socketserver
>
> PORT = 8000
>
> Handler = http.server.SimpleHTTPRequestHandler
>
> with socketserver.TCPServer(("", PORT), Handler) as httpd:
> print("serving at port", PORT)
> httpd.serve_forever()
> 
>
> BTW, the proper response would be a 404. 500 means: "There's a bug in my
> code".
>

The fix is a pull request against serve_forever to catch exceptions
and return 500s.

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


Re: Stefan's headers [was:Names and identifiers]

2018-06-10 Thread Jon Ribbens
On 2018-06-08, Chris Angelico  wrote:
> Yes, this is true. It's not copyright that is unenforceable, but the
> copyright notice in his message. Nobody is denying that he owns his
> own words; but by posting them on a public forum, he - like everyone
> else here - is implicitly granting us the right to read them.

Copyright law protects copying - you don't need permission to read
things, except inasmuch as the words must be copied onto your screen
in order for you to see them.

The question is whether he's implicitly granting the right for his
posts to be copied to all the places that Usenet posts will generally
get copied to when one posts them, or whether his header message
explicitly disavowing such permission overrides the implicit grant.

I'd suggest that since the processes he's purporting to disallow are
entirely standard and automated and he knows full well they exist and
that there is no mechanism by which they could be affected by his
notice, the notice has little effect.

> Right. Imagine if I write a poem, just like you say, and then I have
> the words posted on a gigantic billboard. In small print in the bottom
> corner of the billboard, I say "Copyright 2018 Chris Angelico. Taking
> photographs of this billboard is forbidden.". Do I still own copyright
> in the poem? Definitely. Can I stop people from (or sue people for)
> taking photos of the billboard? Probably not, although that's one for
> the lawyers to argue.

You probably can actually. I'm not an expert but I seem to recall the
rules are along the lines that you can't complain if your billboard
happens to appear incidentally in the background of a photograph,
but if someone takes a photo specifically *of* the billboard, your
copyright is infringed.

>> PS IMO copyright laws should be abolished altogether. At the very least
>> one should pay for copyright protection. One €1 for the first year, €2
>> for the second, €4 for the third and so on exponentially.
>
> Why should I have to pay money for the right to own my own creations?

Because ideas are not inherently property. Why should you get to "own"
a particular sequence of notes, or words, or colours? Why should the
government grant you and enforce an ability to prevent other people
singing those notes, or writing those words, or painting those colours?

> Copyright laws and international treaties are there to protect content
> creators and encourage creation. They need to have set expiration time
> (IMO 50 years is long enough - not "50 years since author's death" but
> 50 years since publication) after which the work becomes free to use,
> but the protections are important and extremely useful.

That was the original intention of copyright certainly, but I'd
hope that it is relatively non-controversial that the terms limits
on copyright these days have skewed the balance far too much in
favour of copyright owners and away from the public.

> Open source would not exist without copyright, because it is
> copyright law that gives license terms their meaning

That's patent nonsense. The only reason, in general, that open source
even requires any licence terms because of the existence of copyright
law. Sure, you couldn't do tricks like the GPL without copyright law,
but then there would be much less *need* for the GPL without copyright
law.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Why exception from os.path.exists()?

2018-06-10 Thread Peter J. Holzer
On 2018-06-07 12:47:15 +, Steven D'Aprano wrote:
> But it doesn't do that. "Pathnames cannot contain NUL" is a falsehood 
> that programmers wrongly believe about paths. HFS Plus and Apple File 
> System support NULs in paths.
[...]
> But in the spirit of compromise, okay, let's ignore the existence of file 
> systems like HFS which allow NUL. Apart from Mac users, who uses them 
> anyway? Let's pretend that every file system in existence, now and into 
> the future, will prohibit NULs in paths.

Could you (or anybody else who owns a Mac) please do the following:

* Create an empty directory
* In this directory, create two files:
  * One with an embedded \0 in the file name
  * One with an embedded / in the file name
* Compile and run this C program in the directory and post the output:

#include 
#include 
#include 

int main(void) {
DIR *dp;
struct dirent *de;
char *p;

dp = opendir(".");
while ((de = readdir(dp)) != NULL) {
printf("%ld -", (long)de->d_ino);
for (p = de->d_name; *p; p++) {
printf(" %02x", (unsigned char)*p);
}
printf("\n");
}
return 0;
}

Bonuspoints for doing this on an USB stick and then mounting the USB
stick on a Linux system and posting the output there as well.

I'm really curious how MacOS maps those characters in the POSIX API.

hp

-- 
   _  | Peter J. Holzer| we build much bigger, better disasters now
|_|_) || because we have much more sophisticated
| |   | h...@hjp.at | management tools.
__/   | http://www.hjp.at/ | -- Ross Anderson 


signature.asc
Description: PGP signature
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Stefan's headers [was:Names and identifiers]

2018-06-10 Thread Steven D'Aprano
On Sun, 10 Jun 2018 13:36:34 +1000, Chris Angelico wrote:

>> That's all speculation. It's impossible to say how things would have
>> turned out if copyrights didn't apply to software. Certainly different,
>> but not necessarily worse.
>>
>> In the early days, computer manufacturers didn't worry about people
>> copying their software, because it was no use without the hardware, and
>> selling hardware was how they made their money. There's no reason that
>> business model couldn't have continued into the PC era.
>>
>>
> It would have meant that third-party software would not exist.

Says the fellow using a free mail server (funded by advertising) on a 
free OS (funded by donations) on a free mailing list about a free 
programming language :-)

Lack of copyright for software would not affect software-as-a-service 
like Gmail. It would not affect FOSS licences like the MIT and BSD 
licence, although it might declaw the GPL.

It would not affect shareware and postcardware and freeware software to 
any appreciable amount. It would not affect the primary driver for FOSS, 
namely people scratching their own itch and being willing to share that 
solution with others.

So long as people had access to interpreters and compilers and the 
ability to write and distribute their own code, the lack of copyright for 
software would only have mattered for certain economic models for 
software, namely the paid, closed-source, non-free commercial software 
market. That's an important market, but it is not all of it.

The scenario you describe would require computers to be locked down 
behind paywalls with trusted computing hardware (a misnomer, because its 
about *not trusting the user* rather than trusting the computer) etc., or 
a wholesale move to SAS with no access to any sort of development 
environment beyond Excel spreadsheets.

While we are creeping ever closer to the day that the general purpose 
computer is extinct or only available to an elite few, while the rest of 
us are stuck in walled gardens using only approved software, the 
technology for that didn't exist in the early days of the home computer 
revolution.


-- 
Steven D'Aprano
"Ever since I learned about confirmation bias, I've been seeing
it everywhere." -- Jon Ronson

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


Re: Re: FULLSCREEN and DOUBLEBUF

2018-06-10 Thread Paul St George
To recap: this thread started with a question. How do I know whether 
DOUBLEBUF has been set with:


    screen = pygame.display.set_mode((720,480), pygame.DOUBLEBUF | 
pygame.FULLSCREEN)



On 09/06/2018 22:04, Mark Lawrence wrote:

On 09/06/18 20:31, Paul St George wrote:


 print pygame.display.get_surface()
gives


and
 print screen.get_flags()
gives
-2147483648

The lists of flags at 
 
and 



has nothing remotely like -2147483648. I would expect something more 
like 0x4000


Am I using the wrong code to determine whether I have successfully 
set DOUBLEBUF with


 screen = pygame.display.set_mode((720,480), pygame.FULLSCREEN | 
pygame.DOUBLEBUF)


AND

What does -2147483648 tell me? Does this number need converting?




From the interactive interpreter:-

>>> hex(-2147483648)
'-0x8000'
>>> hex(pygame.FULLSCREEN)
'-0x8000'
>>> hex(pygame.DOUBLEBUF)
'0x4000'


Thanks go to Mark Lawrence and Richard Damon.

Using
print hex(screen.get_flags())

I can see that the order of the two flags does not make a difference.

screen = pygame.display.set_mode((720,480), pygame.DOUBLEBUF | 
pygame.FULLSCREEN)
screen = pygame.display.set_mode((720,480), pygame.FULLSCREEN | 
pygame.DOUBLEBUF)

both report the same

print hex(screen.get_flags())

'-0x8000'


BUT
omitting DOUBLEBUF from the code

screen = pygame.display.set_mode((720,480), pygame.FULLSCREEN)

also makes no difference to the report

print hex(screen.get_flags())

'-0x8000'


AND

with with only DOUBLEBUF in the code

screen = pygame.display.set_mode((720,480), pygame.DOUBLEBUF)

does not give the expected and desired '-0x4000'

instead, the report is

print hex(screen.get_flags())

‘0x0’



0x0 (SWSURFACE) is consistent with

print pygame.display.get_surface()
‘’


It seems that DOUBLEBUF is *not* being set. I am guessing this is because the 
arguments passed by pygame.display.set_mode() are only requests.  The actual 
display will depend on the system, and what is available/possible.

More guessing leads me to wonder whether DOUBLEBUF is only available when 
HWSURFACE is being used so I tried three flags with:

flags = pygame.FULLSCREEN | pygame.DOUBLEBUF | pygame.HWSURFACE
screen = pygame.display.set_mode((0, 0), flags)

But no change (screen is still SW and DOUBLEBUF is not set):


print pygame.display.get_surface()


print hex(screen.get_flags())
-0x8000


QUESTIONS
Can anyone find an error in any of this? I hope so.

Is DOUBLEBUF dependent on HWSURFACE?

If so, how does one force the change to a Hardware surface? ‘set_mode’ is not 
doing it.


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


Re: Stefan's headers [was:Names and identifiers]

2018-06-10 Thread Chris Angelico
On Sun, Jun 10, 2018 at 9:08 PM, Steven D'Aprano
 wrote:
> On Sun, 10 Jun 2018 13:36:34 +1000, Chris Angelico wrote:
>
>>> That's all speculation. It's impossible to say how things would have
>>> turned out if copyrights didn't apply to software. Certainly different,
>>> but not necessarily worse.
>>>
>>> In the early days, computer manufacturers didn't worry about people
>>> copying their software, because it was no use without the hardware, and
>>> selling hardware was how they made their money. There's no reason that
>>> business model couldn't have continued into the PC era.
>>>
>>>
>> It would have meant that third-party software would not exist.
>
> Says the fellow using a free mail server (funded by advertising) on a
> free OS (funded by donations) on a free mailing list about a free
> programming language :-)
>
> Lack of copyright for software would not affect software-as-a-service
> like Gmail. It would not affect FOSS licences like the MIT and BSD
> licence, although it might declaw the GPL.

I'm not sure that these kinds of concepts would even exist, though. If
the business model had always been "sell hardware, it comes fully
programmed", what would bring people to try to create third-party
software at all? It's easy to look back NOW and say "even if software
had no copyright, this could still exist". It's not so easy to see
that such things would have come about. We live today in a world of
massive cross-compatibility and third-party software creations, where
your "computer" may have many different manufacturers and many
different software authors, all happily running together. While IBM
did create hardware compatibility standards (allowing other
manufacturers to create fully-compatible expansion cards etc) as a
viable commercial decision, I doubt very much that anyone other than
hobbyists would write software that they're unable to sell. Don't
forget that "software-as-a-service" is an extremely young concept; to
be a saleable form of software (as opposed to a saleable service
involving both hardware and software), it depends on people having the
clients AND a means of connecting to the servers - which today means
web browsers and internet connections. Possibly the oldest "SaaS"
concept for computers would be a dial-in BBS.

Would that sort of thing exist if copyright did not? I'm not sure.
Maybe it would, but it's certainly not "oh well saas wouldn't be
affected by this".

I'm also not sure that the MIT and BSD licenses would still be viable.
Without copyright, they have no teeth, which would mean that their
license terms of "don't sue me if it doesn't work" wouldn't apply.
IANAL, but I'm fairly sure that those terms are in the licenses for
good reason. The GPL, which has much stronger requirements, would be
completely powerless.

"Not affect" is far FAR too broad. Open source still depends on copyright.

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


Re: Stefan's headers [was:Names and identifiers]

2018-06-10 Thread Gregory Ewing

Chris Angelico wrote:

You cannot, to
my knowledge, publish a game for the PS4 or Xbox 360 without
permission from Nintendo or Microsoft.


That's because, since we *do* have copyright laws, the
manufacturers of the consoles are able to make money by
selling the software as well as the hardware -- and they
want a monopoly on that source of income.

If there was no copyright, they wouldn't be able to
make money from the software side alone, so there would
be no incentive for them to lock things down that way.
The opposite, in fact -- the more games are available
for a machine, the more people are going to want to
buy it.


Nobody can sell software without also selling
hardware, which is an expensive industry to get into.


I don't follow what you're saying here. Are you suggesting
that nobody would write any software for someone else's
hardware if they couldn't sell it for money? Experience
with the open source community that we do have suggests
otherwise.

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


Re: Stefan's headers [was:Names and identifiers]

2018-06-10 Thread Gregory Ewing

Chris Angelico wrote:

I doubt very much that anyone other than
hobbyists would write software that they're unable to sell.


Or, maybe, people who *use* the machines as part of their
livelihood, and have an incentive to produce good, reliable
software that does what they need.


I'm also not sure that the MIT and BSD licenses would still be viable.
Without copyright, they have no teeth, which would mean that their
license terms of "don't sue me if it doesn't work" wouldn't apply.


It's not clear that such terms are even enforcible now.
There are places where wording like "not even the implied
warranty of fitness for a particular purpose" etc. have
no meaning, because you're not allowed to contract out
of things like that.

But in any case, there's nothing stopping you from
attaching a notice like that to something you distribute,
it just wouldn't be called a licence, but a disclaimer
or something like that. It would have the same number of
teeth either way.

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


Re: UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in position 10442: character maps to

2018-06-10 Thread bellcanadardp
On Friday, 8 June 2018 07:42:34 UTC-4, Steven D'Aprano  wrote:
> On Fri, 08 Jun 2018 03:35:12 -0700, bellcanadardp wrote:
> 
> > hello steven are you there??
> > i posted the full error message...
> 
> No you didn't.
> 
> I saw your post, and ignored it, because you didn't follow instructions. 
> I told you we need to see the *full* traceback, starting from the line 
> beginning "Traceback". You only posted the end of the traceback.
> 
> I told you we needed to see the actual line of code you are trying to 
> run. You didn't show us the line of code you are trying to run.
> 
> We're not mind-readers. We can't fix code that we can't see, giving 
> errors from a line you won't tell us, using a file we don't have.
> 
> Please read this before replying:
> 
> http://sscce.org/
> 
> Thank you.
> 
> -- 
> Steven D'Aprano
> "Ever since I learned about confirmation bias, I've been seeing
> it everywhere." -- Jon Ronson
***
Traceback (most recent call last):

File "createIndex.py", line 132, in 
c.createindex()

File "creatIndex.py", line 102, in createIndex
pagedict=self.parseCollection()

File "createIndex.py", line 47, in parseCollection
for line in self.collFile:

File 
"C:\Users\Robert\AppData\Local\Programs\Python\Python36\lib\encodings\cp1252.py",
 line 23, in decode

return codecs.charmap_decode(input,self.errors,decoding_table[0]
UnicodeDecodeError: 'charmap'codec can't decode byte 0x9d in position 7414: 
character maps to  
*
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in position 10442: character maps to

2018-06-10 Thread Steven D'Aprano
Do you enjoy wasting your own time (as well as ours) by failing to follow 
instructions?

We can't read your mind to see the code you are using, and I am getting 
frustrated from telling you the same thing again and again.

PLEASE PLEASE PLEASE PLEASE help us to help you.

Start by reading this:

http://sscce.org/


What is self.collFile? How does it get opened?



-- 
Steven D'Aprano
"Ever since I learned about confirmation bias, I've been seeing
it everywhere." -- Jon Ronson

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


Re: Stefan's headers [was:Names and identifiers]

2018-06-10 Thread Peter J. Holzer
On 2018-06-09 10:15:43 +1000, Chris Angelico wrote:
> On Sat, Jun 9, 2018 at 8:19 AM, Marko Rauhamaa  wrote:
> > Chris Angelico :
> >> On Sat, Jun 9, 2018 at 6:59 AM, MRAB  wrote:
> >>> So those with the most money can buy the most protection?
> >>
> >> Yes, or more specifically, those who believe they can make the most
> >> money from that protection. Ownership becomes pay-to-win, literally.
> >
> > In the words of Scrooge McDuck:
> >
> >https://i.stack.imgur.com/rMeiB.png>
> >
> >
> > But guys, surely you are familiar with the exponential function:
> >
> >  * Everybody can afford a year for $1.
> 
> $1 per what, though? According to GitHub, I have 157 repositories. Is
> that 157 separate things that cost $1 for a single year of protection?
> Or do I pay per file of source code?

When I first read about the scheme Marko is proposing here it was
presented mainly as an alternative of the current patent scheme.
There it is obvious: You pay per patent.

The article also extended it to books. There it is also obvious: You pay
per book.

Patents and books are nice, distinctive "works". You might argue
whether "The Lord of the Rings" is one book or three, and whether each
edition of "Learning Python" (there are now 5 of them) is a separate
book, but these are relatively easy cases.

Software is harder. When software was still sold in a nice box with a
three-ring binder and a few floppies, it was similar to a book: If it
comes in one box, it is one work to be copyrighted.

But with online distribution (not necessarily github) the boundaries
become very fluid. When Debian still contained the Roxen webserver, it
comprised over 100 packages: The maintainer had put every plugin into a
separate package. I did something similar with my qpsmtpd plugins: Each
is in a separate .deb or .rpm file.

There is also the problem of how to treat revisions: If I always
register the newest revision and stop paying for older revisions, is
code I didn't change still protected or not?

I don't remember whether the article addressed these problems. I guess I
should read it again (it was in CACM, a few years ago).

Personally, I would let the author decide what constitutes one work.
If you think your 157 git repos are a single work, register it as one.
Whenever you think you have made enough changes that this is a new work
which should be protected, register it again. And if the fees for your
old versions become too high, let them lapse.


> >  * Every worthwhile creation is worth $1,000 for ten years.
> 
> Not true by a long shot, and if you don't believe me, you can pay me
> $1000 right now for ten years' use of any of my free software.

I think he meant it the other way around: If you can sell your software
for 10 years, you can affort $1000 to have your monopoly protected.


> >  * And if Disney can pay the fee for Mickey Mouse for fifty years, the
> >United States Government can quit all taxation, pay off the national
> >debt and buy every American a luxury yacht and a private island in
> >the Caribbean.
> 
> And if you think that Disney would actually let it compound according
> to your theoretical definition, you're a dupe AND a fool. They'd
> figure out some way to reset the counter every five years.

More likely they would prevent such law from being passed in the first
place.

hp

-- 
   _  | Peter J. Holzer| we build much bigger, better disasters now
|_|_) || because we have much more sophisticated
| |   | h...@hjp.at | management tools.
__/   | http://www.hjp.at/ | -- Ross Anderson 


signature.asc
Description: PGP signature
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Re: FULLSCREEN and DOUBLEBUF

2018-06-10 Thread Peter Otten
Paul St George wrote:

> So...
> 
>  print pygame.display.get_surface()
> gives
> 
> 
> and
>  print screen.get_flags()
> gives
> -2147483648

> To recap: this thread started with a question. How do I know whether
> DOUBLEBUF has been set with:
> 
> screen = pygame.display.set_mode((720,480), pygame.DOUBLEBUF |
> pygame.FULLSCREEN)

flags = screen.get_flags()
if flags & pygame.DOUBLEBUF:
print("DOUBLEBUF has been set")
if flags & pygame.FULLSCREEN:
print("FULLSCREEN has been set")

See the pattern?

The easiest way to argue about flags is in binary notation. Every flag 
corresponds to an integer with a single bit set, e. g.

HOT = 0b001
BLUE = 0b010
RIGHTEOUS = 0b100

You can combine the flags with bitwise or

hot_and_righteous = HOT | RIGHTEOUS # 0b101

and query them  with bitwise and:

>>> if hot_and_righteous & HOT: print("hot")
... 
hot
>>> if hot_and_righteous & BLUE: print("blue")
... 
>>> if hot_and_righteous & RIGHTEOUS: print("righteous")
... 
righteous

With your actual pygame flags it's very much the same. However, because 
integers in Python are signed numbers like

-2147483648

may be puzzling, even when you display them in binary

>>> bin(-2147483648)
'-0b1000'

You might think that only one flag is set because there is only one 1, but 
the - sign corresponds to an "infinite" number of leading 1s.

If you know that the flags are stored (for example) in a 32bit integer you 
can mask off these leading 1s and see the actual data more clearly:

>>> bin(-2147483648 & 0b)
'0b1000'

OK, so in this case it probably* was a single flag, but that's not always 
the case:

>>> bin(-7)
'-0b111'
>>> bin(-7 & 0b)
'0b1001'

(*) What if the flags were stored in a 64bit integer?

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


Re: Stefan's headers [was:Names and identifiers]

2018-06-10 Thread Steven D'Aprano
On Sun, 10 Jun 2018 16:25:24 +0200, Peter J. Holzer wrote:

> Personally, I would let the author decide what constitutes one work.

Ah yes...

Star Wars, Empire Strikes Back, Return of the Jedi, Phantom Menace, 
Attack of the Clones, Revenge of the Sith, Rogue One, Force Awakens, Last 
Jedi, Solo... they're all chapters in one work, yes?



-- 
Steven D'Aprano
"Ever since I learned about confirmation bias, I've been seeing
it everywhere." -- Jon Ronson

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


Re: Stefan's headers [was:Names and identifiers]

2018-06-10 Thread Marko Rauhamaa
Steven D'Aprano :

> On Sun, 10 Jun 2018 16:25:24 +0200, Peter J. Holzer wrote:
>
>> Personally, I would let the author decide what constitutes one work.
>
> Ah yes...
>
> Star Wars, Empire Strikes Back, Return of the Jedi, Phantom Menace,
> Attack of the Clones, Revenge of the Sith, Rogue One, Force Awakens,
> Last Jedi, Solo... they're all chapters in one work, yes?

If the author so decides, but they'll have to pay the registration fee
at the time of publication.


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


Posting warning message

2018-06-10 Thread T Berger
When I go to post a reply, I get a warning asking if I want my email address 
(or other email addresses listed) visible to all, and do I want to edit my 
post. What should I do?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Stefan's headers [was:Names and identifiers]

2018-06-10 Thread Marko Rauhamaa
Chris Angelico :
> It's easy to look back NOW and say "even if software had no copyright,
> this could still exist". It's not so easy to see that such things
> would have come about. [...] I doubt very much that anyone other than
> hobbyists would write software that they're unable to sell.

A lot of software is custom-written to the specific needs of one
customer. That software is extremely expensive but would get written
regardless because the work must be done and couldn't be directly
exploited by competitors.

Now, as far as off-the-shelf products go (say computer games), the price
can be low because the identical product is sold to more than one
customer, sometimes even millions of customers.

What would happen to software products that didn't have copyright
protections? Nothing would prevent a competitor from starting to sell
your product as theirs.

This question must be asked in business in general. Could someone build
another Mexican Restaurant? Could someone build a similar auction web
site? Could someone go after your customers? And often the answer is,
yes they could so it's not worth the investment.

In this situation, will someone do the work or will it not get done? In
some cases, it would not get done. I still don't think the existence of
copyright laws is the proper burden to put on the society. Instead, the
government should fund such needs as it already does for necessary
things that don't have a market.

The government won't see an incentive to build a computer game so some
lucrative markets would disappear with the copyright gone. However, you
will see lots of creative community efforts to build not only games but
business utilities to address real needs. For example, a doctor in my
hometown built an appointment web app that was easier to use than the
expensive, professional alternative. When there's no copyright
protection, development communities can arise around such tools and the
germs can become high-quality applications over time.

> I'm also not sure that the MIT and BSD licenses would still be viable.
> Without copyright, they have no teeth, which would mean that their
> license terms of "don't sue me if it doesn't work" wouldn't apply.

I think the MIT and BSD licenses are just silly variants of the Public
Domain. The no-warranty clauses might not be enforceable anyway. Their
main point is the requirement for attribution.


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


[no subject]

2018-06-10 Thread sagar daya
Couldn't install any module from pip
Plz help???
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Why exception from os.path.exists()?

2018-06-10 Thread Bev in TX


> On Jun 10, 2018, at 5:49 AM, Peter J. Holzer  wrote:
> 
> On 2018-06-07 12:47:15 +, Steven D'Aprano wrote:
>> But it doesn't do that. "Pathnames cannot contain NUL" is a falsehood 
>> that programmers wrongly believe about paths. HFS Plus and Apple File 
>> System support NULs in paths.
> [...]
>> But in the spirit of compromise, okay, let's ignore the existence of file 
>> systems like HFS which allow NUL. Apart from Mac users, who uses them 
>> anyway? Let's pretend that every file system in existence, now and into 
>> the future, will prohibit NULs in paths.
> 
> Could you (or anybody else who owns a Mac) please do the following:
> 
> * Create an empty directory
> * In this directory, create two files:
>  * One with an embedded \0 in the file name

I don’t know how to do this.  I can’t enter a Nul in Finder.  Bash silently 
converts it to a zero when using it as a file name.  C considers the previous 
character the end of the file name.  Python considers it an error.

>  * One with an embedded / in the file name

This is easily done in Finder, where I created a folder named "my/slash”.  
When I list it at the command line in Terminal, this shows up as "my:slash”, 
with the slash shown as a colon.  
If I create a file with a colon in its name at the command line, that file name 
acts the same way:

$ touch ‘my:colon"
$ ls
my:colon
my:slash

In Finder they both display as:
my/colon
my/slash

However, if you use Finder’s “Copy item as Pathname” option, then you will 
again see the colon.  

/Users/bev/Training/myPython/pygroup/files/my:colon
/Users/bev/Training/myPython/pygroup/files/my:slash

But if you paste that folder’s name in Finder’s “Go to Folder” option, it 
converts it to the following, and goes to that folder:

/Users/bev/Training/myPython/pygroup/files/my/slash/slash

So we can see three (3) separate behaviors for the same folder in Finder.  This 
is because at some higher level, Apple’s file systems reserve the colon for the 
path separator, in stead of the slash.  I know that AppleScript does use the 
colon as a path separator.  However at a lower level, macOS still uses the 
slash, rather than colon, as the path name separator.  IMO, this is confusing.  
Similarly in Finder file names are case insensitive, but case preserving.  At 
the command line they are still case sensitive.  Note that it’s possible to 
format a disk with a fully case sensitive file system, but that’s not the 
default.

Please note that I am not an Apple HFS+ or AFS file system expert, by any 
stretch of the imagination.  So please excuse me if I did’t state things 
perfectly.

> * Compile and run this C program in the directory and post the output:
> 
>#include 
>#include 
>#include 
> 
>int main(void) {
>DIR *dp;
>struct dirent *de;
>char *p;
> 
>dp = opendir(".");
>while ((de = readdir(dp)) != NULL) {
>printf("%ld -", (long)de->d_ino);
>for (p = de->d_name; *p; p++) {
>printf(" %02x", (unsigned char)*p);
>}
>printf("\n");
>}
>return 0;
>}

I added printing the file name.  As suspected, the “slash” is a colon:

. - 56096374 - 2e
.. - 56095464 - 2e 2e
.DS_Store - 56109197 - 2e 44 53 5f 53 74 6f 72 65
my:colon - 56095933 - 6d 79 3a 63 6f 6c 6f 6e
my:slash - 56095521 - 6d 79 3a 73 6c 61 73 68

> Bonuspoints for doing this on an USB stick and then mounting the USB
> stick on a Linux system and posting the output there as well.
> 
Sorry, I don’t have Linux, but I suspect it’s the same as the macOS command 
line.

> I'm really curious how MacOS maps those characters in the POSIX API.
> 
>hp

Bev in TX



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


Re: your mail

2018-06-10 Thread Karsten Hilbert
On Sun, Jun 10, 2018 at 06:58:17PM +0530, sagar daya wrote:

> Couldn't install any module from pip
> Plz help???

https://duckduckgo.com

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


Re: UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in position 10442: character maps to

2018-06-10 Thread bellcanadardp
On Sunday, 10 June 2018 10:23:47 UTC-4, Steven D'Aprano  wrote:
> Do you enjoy wasting your own time (as well as ours) by failing to follow 
> instructions?
> 
> We can't read your mind to see the code you are using, and I am getting 
> frustrated from telling you the same thing again and again.
> 
> PLEASE PLEASE PLEASE PLEASE help us to help you.
> 
> Start by reading this:
> 
> http://sscce.org/
> 
> 
> What is self.collFile? How does it get opened?
> 
> 
> 
> -- 
> Steven D'Aprano
> "Ever since I learned about confirmation bias, I've been seeing
> it everywhere." -- Jon Ronson

excuse but sorry
i took the time to manually write the code error from the traceback as you said
and thats because i cant seem to find a way to attach files here..which would 
make it so easier for me and also i could attach snippets of the actual source 
code..and i asked the forum how i can attach files or also i asked for an email 
adress but i didnt get a responsealso i find this is why programmers can 
have a bad reputation..cuz of examples of people like yourself barking out 
orders and getting upset for no good reason at tall..now one including myself 
is giving you obligations to answer my queires ok??..im not your slave the 
way you say that i have to follow instructions..so why do you kindly just buzz 
off of my thread since it makes you and myself really get annoyed..ok..
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: (no subject)

2018-06-10 Thread Rick Johnson
sagar daya wrote:
> Couldn't install any module from pip
> Plz help???

As with most actions, an algorithm is required. (shocking, i
know!)

What methodology have you implemented thus far to achieve
your goal of "installing modules from PIP"? Please enumerate
the steps you chose to take, and then we _might_ can offer
advice.

For instance, if someone is having trouble brushing their
teeth, the first question we might ask is: "Have you located
the toothbrush and toothpaste yet?". 

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


Re: Re: Re: FULLSCREEN and DOUBLEBUF

2018-06-10 Thread Paul St George

Paul St George wrote:


So...

  print pygame.display.get_surface()
gives


and
  print screen.get_flags()
gives
-2147483648
To recap: this thread started with a question. How do I know whether
DOUBLEBUF has been set with:

screen = pygame.display.set_mode((720,480), pygame.DOUBLEBUF |
pygame.FULLSCREEN)

On 10/06/2018 16:38, Peter Otten wrote:

flags = screen.get_flags()
if flags & pygame.DOUBLEBUF:
 print("DOUBLEBUF has been set")
if flags & pygame.FULLSCREEN:
 print("FULLSCREEN has been set")

See the pattern?
I do. I do. And also, I now know for certain that DOUBLEBUF is not being 
set.

The insights about flags will take more time to digest. Thank you for both!
--
https://mail.python.org/mailman/listinfo/python-list


Re: Why exception from os.path.exists()?

2018-06-10 Thread Rick Johnson
Marko Rauhamaa wrote:
> Chris Angelico :
> 
> > Marko Rauhamaa  wrote:
> >>
> >> This surprising exception can even be a security issue:
> >>
> >>>>> os.path.exists("\0")
> >>Traceback (most recent call last):
> >>  File "", line 1, in 
> >>  File "/usr/lib64/python3.6/genericpath.py", line 19, in exists
> >>os.stat(path)
> >>ValueError: embedded null byte
> >
> > [...]
> >
> > A Unix path name cannot contain a null byte, so what you
> > have is a fundamentally invalid name. ValueError is
> > perfectly acceptable.
> 
> At the very least, that should be emphasized in the
> documentation. The pathname may come from an external
> source. It is routine to check for "/", "." and ".." but
> most developers (!?) would not think of checking for "\0".
> That means few test suites would catch this issue and few
> developers would think of catching ValueError here. The end
> result is unpredictable.

I'd have to agree with this assessment. Either a filepath
exists, or it doesn't. Therefore, in the "worldview" of
os.path.exist, there should be no consideration of
conformity, as it is blatantly obvious that any malformed
path would _not_ and could _not_ possibly, exist. In fact,
the only case in which the method in question should raise
an Exception is when a non-stringy argument is passed. Which
-- at least in 2.x version -- i can confirm (with limited
testing) it does this correctly!

## PYTHON 2.X SESSION ##
py> os.path.exists('')
False
py> os.path.exists(None)
Traceback (most recent call last):
  File "", line 1, in 
os.path.exists(None)
  File "C:\Python27\lib\genericpath.py", line 26, in exists
os.stat(path)
TypeError: coercing to Unicode: need string or buffer, NoneType found
>>> os.path.exists(1)
Traceback (most recent call last):
  File "", line 1, in 
os.path.exists(1)
  File "C:\Python27\lib\genericpath.py", line 26, in exists
os.stat(path)
TypeError: coercing to Unicode: need string or buffer, int found

But if the argument is a string, either it exists as a
filepath or it doesn't. Case closed. Anything less would
constitute type discrimination. Which is not only
inconsistent, it's unethical.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Stefan's headers [was:Names and identifiers]

2018-06-10 Thread Ben Bacarisse
Jon Ribbens  writes:

> I'd suggest that since the processes he's purporting to disallow are
> entirely standard and automated and he knows full well they exist and
> that there is no mechanism by which they could be affected by his
> notice, the notice has little effect.

The Copyright notice is probably intended for human eyes.  IIRC his
posts don't show up on Google groups, for example, so there *is* a
mechanism by which *some* of the headers (it may be X-no-archive) do get
acted on.


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


Re: Stefan's headers [was:Names and identifiers]

2018-06-10 Thread Rick Johnson
On Friday, June 8, 2018 at 12:34:58 PM UTC-5, Marko Rauhamaa wrote:

> PS IMO copyright laws should be abolished altogether. At
> the very least one should pay for copyright protection. One
> €1 for the first year, €2 for the second, €4 for the third
> and so on exponentially.

I like your idea of a exponential punitive annual increase
to "secure the right" of copyright protection. However, your
pricing scheme seems a bit outdated. Like, a century or
_two_ outdated. ;-)

Heck, in the spirit of the Python tutorial, i say we utilize
the Fibonacci sequence (slightly modified) and finally put
that atrocious code example to some good use.

Yep, and pass it an initial argument reflecting the current
"year of our lord", would ya?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Stefan's headers [was:Names and identifiers]

2018-06-10 Thread Rick Johnson
Gene Heskett wrote:
> I rather like that idea. Unforch, who would be in charge of keeping the 
> books uptodate? The USTPO? Of course that would expand another guvmnt 
> agencies payroll x10, and its a waste of taxpayer dollars since Albert 
> retired anyway.

What century are you trapped in pal? Heck, all you need is a Godaddy(c) website
and a simple HTML form (Hell, they even gots templates for that!!!).

> Here in the hew hess aye, we originally had a copyright term of 7 years, 
> renewable just once for another 7. I will date myself by saying I can 
> actually remember those days.  But then Disney started buying senators 
> and congressmen, and we now have this asinine lifetime +70 years just to 
> keep Mickey Mouse and Company's (oh, and don't forget a widow named 
> Cher) income rolling in.

Yeah, and they've sucked up every independent animation house between here and
Kathmandu.

> Thats the sort of stuff usually found, warm and squishy, on the ground 
> behind the male of the bovine specie.

Huh? The female bovines don't defecate where you come from? Well then! i see!
Say hello to Qin-I, would ya?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Posting warning message

2018-06-10 Thread John Ladasky
On Sunday, June 10, 2018 at 7:47:01 AM UTC-7, T Berger wrote:
> When I go to post a reply, I get a warning asking if I want my email address 
> (or other email addresses listed) visible to all, and do I want to edit my 
> post. What should I do?

Are you posting through Google Groups?  Sometimes I see that warning as well.

Some, but not all, Usenet software deliberately mangles email addresses when 
composing posts.  It's a good thing to mangle email addresses when posting 
publicly, as it makes it harder for spammers to find new targets.  So answer 
"yes", and manually edit any email addresses you see in the post so that they 
can't be recovered.  For example, if my email address was posted undisguised, 
you could edit it to "j...@g...com" and that should do the trick.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re:

2018-06-10 Thread Timo Furrer
Can you be more specific.
What did you try? In which environment? What was the error message you got?

On Sun, Jun 10, 2018 at 6:32 PM sagar daya  wrote:

> Couldn't install any module from pip
> Plz help???
> --
> https://mail.python.org/mailman/listinfo/python-list
>


-- 
*Timo Furrer*

https://github.com/timofurrer
tuxt...@gmail.com
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: user defined modules

2018-06-10 Thread Rick Johnson
Sharan Basappa wrote:
> Is there a specific location where user defined modules
> need to be kept?

My advice is that any location is a good location so long as
the location you chose is _not_ a part of the PythonXY
directory tree. 

For example, on a windoze machine (and in Python2.x at
least), the PythonXY directory is placed (by default) at the
root of the default drive (usually C drive). Your scripts
(on a windows machine) should be (idealy) somewhere in the
os.path.expanduser('~/Documents') tree. 

Personally i use a .pth file to point Python in the
direction of my library modules. Unlike the old time
masochist, i just hate having to repeat myself. Thus, like
most modern folk, i have learned that copy+paste and "set-
it-and-forget-it" text file are a computer users best
friend and loyal companions.

## MAP ##
C:/
   PythonXY/
   config.pth

The contents of my .pth file is simply an unquoted string
representing the path to my library folders. (something like
this)

## PTH FILE CONTENT ##
C:/.../Documents/path/to/my/lib/folder

That's it!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Sorting NaNs

2018-06-10 Thread Anders Munch

Richard Damon wrote:


The two behaviors that I have heard suggested are:

1) If any of the inputs are a NaN, the median should be a NaN.
(Propagating the NaN as indicator of a numeric error)

2) Remove the NaNs from the input set and process what is left. If
nothing, then return a NaN (treating NaN as a 'No Data' placeholder).


3) Raise an exception.

I can't believe anyone even suggested 2).  "In the face of ambiguity, 
refuse the temptation to guess."


regards, Anders

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


Re: Stefan's headers [was:Names and identifiers]

2018-06-10 Thread Gene Heskett
On Sunday 10 June 2018 14:42:02 Rick Johnson wrote:

> Gene Heskett wrote:
> > I rather like that idea. Unforch, who would be in charge of keeping
> > the books uptodate? The USTPO? Of course that would expand another
> > guvmnt agencies payroll x10, and its a waste of taxpayer dollars
> > since Albert retired anyway.
>
> What century are you trapped in pal? Heck, all you need is a
> Godaddy(c) website and a simple HTML form (Hell, they even gots
> templates for that!!!).
>
> > Here in the hew hess aye, we originally had a copyright term of 7
> > years, renewable just once for another 7. I will date myself by
> > saying I can actually remember those days.  But then Disney started
> > buying senators and congressmen, and we now have this asinine
> > lifetime +70 years just to keep Mickey Mouse and Company's (oh, and
> > don't forget a widow named Cher) income rolling in.
>
> Yeah, and they've sucked up every independent animation house between
> here and Kathmandu.
>
Probably farther than that.

> > Thats the sort of stuff usually found, warm and squishy, on the
> > ground behind the male of the bovine specie.
>
> Huh? The female bovines don't defecate where you come from? Well then!
> i see! Say hello to Qin-I, would ya?

Oh they do, but have the great good sense to take several steps away from 
the evidence, if they can. :)

Qin-I? You lost me there.

-- 
Cheers, Gene Heskett
--
"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: UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in position 10442: character maps to

2018-06-10 Thread bellcanadardp
On Friday, 8 June 2018 18:26:28 UTC-4, Cameron Simpson  wrote:
> On 05Jun2018 06:42, bellcanada...@gmail.com  wrote:
> >On Sunday, 3 June 2018 20:11:43 UTC-4, Steven D'Aprano  wrote:
> >> Don't retype a summary of what you think the error is. "character
> >> undefieed" is not a thing, and there is no such thing as "byte 1x09".
> >>
> >> You need to COPY AND PASTE the EXACT error that you get. Not just the
> >> last line, the error message, but the FULL TRACEBACK starting from the
> >> line "Traceback" and going to the end.
> [...]
> >
> >here is the exact error full message
> >in the attachment...UPDATE..i am manually modifying this reply..i tried to 
> >answer by my gmail but i get errors and i couldnt find this webpage till 
> >today and it doesnt accept attachments..so many you can for future provide 
> >an email if thats ok...anyway i will write the error manually here:
> 
> Many of us read this group/list via the mailing list python-list@python.org.  
> I've CCed it here. Just avoid Google Groups, they're an awful interface to 
> both 
> usenet and mailing lists.
> 
> >File 
> >"C:\Users\Robert\AppData\Local\Programs\Python\Python36\lib\encodings\cp1252.py",
> > 
> >line 23, in decode
> >return codecs.charmap_decode(input,self.errors,decoding_table[0]
> >UnicodeDecodeError: 'charmap'codec can't decode byte 0x9d in position 7414: 
> >character maps to 
> 
> As Steven has remarked, this is not the complete traceback he requested, just 
> the end. We need to know the entire execution stack.
> 
> >for the record i did not puprosely set the code or decode o encode to 
> >cp-1252; 
> >this is a 3rd party script i have from the internet thats all
> 
> Can you say where it came from and how you fetched it? That may affect how 
> the 
> file got into this situation and how it might be repaired.
> 
> It might also let us fetch the file ourselves to look at it.
> 
> >this a  set of files that runs find in python 2.7
> >i am trying to run it in python 3 becuz i was told in 2020 python 2 will no 
> >longer be supported
> >not sure if that really matters for my script
> 
> It may not matter, but as a general rule you should try to use Python 3 for 
> new 
> stuff. Python 2 is effectively end of life.
> 
> >it runs completey fine in python 2, so for me the issue is with python 3 and 
> >its changes relative to python 2
> 
> It is possible that Python 2 is just glossing over the problem; Python 3 has 
> a 
> more rigorous view of character data.
> 
> Cheers,
> Cameron Simpson 

here is the full error once again
to summarize, my script works fine in python2 
i get this error trying to run it in python3
plz see below after the error, my settings for python 2 and python 3
for me it seems i need to change some settings to 'utf-8'..either just in 
python 3, since thats where i am having issues or change the settings to 
'utf-8' both in python 2 and 3i would appreciate feedback b4 i do some 
trial and error
thanks for the consideration
tommy

***
Traceback (most recent call last):

File "createIndex.py", line 132, in 
c.createindex()

File "creatIndex.py", line 102, in createIndex
pagedict=self.parseCollection()

File "createIndex.py", line 47, in parseCollection
for line in self.collFile:

File 
"C:\Users\Robert\AppData\Local\Programs\Python\Python36\lib\encodings\cp1252.py",
 line 23, in decode

return codecs.charmap_decode(input,self.errors,decoding_table[0]
UnicodeDecodeError: 'charmap'codec can't decode byte 0x9d in position 7414: 
character maps to 
* 

***
python 3 settings
import sys
 import locale
locale.getpreferredencoding()
'cp1252'
 sys.stdout.encoding
'cp1252'
 sys.getdefaultencoding()
'utf-8'
sys.getfilesystemencoding()
'utf-8'
 sys.stdin.encoding
'cp1252'
 sys.stderr.encoding
'cp1252'

PYTHON 2 settings
import sys
 import locale
 locale.getpreferredencoding()
'cp1252'
 sys.stdout.encoding
'cp1252'
 sys.getdefaultencoding()
'ascii'
 sys.getfilesystemencoding()
'mbcs'
 sys.stdin.encoding
'cp1252'
 sys.stderr.encoding
'cp1252'
***
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Distributing a Python module as .rpm and .deb packages across major distributions

2018-06-10 Thread Barry



> On 8 Jun 2018, at 18:04, adam.pre...@gmail.com wrote:
> 
> I have a situation where internally I need to distribute some Python code 
> using Linux packages rather than simply relying on wheel files. This seems to 
> be a solved problem because a lot of Python modules clearly get distributed 
> as .rpm and .deb. It's not completely unreasonable because soon I will have 
> some other modules that are depending on binary applications that are also 
> coming in from packages, and having the system package manage resolve and 
> install all this is convenient. I'm not really in a political position to 
> change that policy, for what it's worth.
> 
> I'm still stuck in Python 2.7 here for at least a few more months. Also, it 
> probably helps to know this is a pure Python module that doesn't have to 
> compile any native code.
> 
> Creating a package itself isn't a problem. In my case, I bandied with the 
> bdist_rpm rule in setup.py, and used stdeb to add a bdist_deb rule. I get rpm 
> and deb files from these, but they seem to be plagued with a problem of 
> making assumptions about paths based on my build environment. I'm building on 
> an Ubuntu rig where Python modules are installed into dist-packages. The rpm 
> package will try to install my module into dist-packages instead of 
> site-packages on a Red Hat rig. I haven't yet tried the Debian package on 
> different rigs, but the stdeb documentation did call out that this likely 
> won't work.
> 
> I'm wondering first if many of the modules we see in packages right now are 
> actually literally being built using Jenkins or some other CD tool on every 
> major OS distribution. If that's the case then at least I know and I can try 
> to do that. I was surprised that I couldn't easily provide some additional 
> flags. I believe I can specify a setup.cfg that can override the module 
> installation path, and I think I can do a little shell script to just rotate 
> different setup.cfg files through, but I can't help but wonder if I'm even on 
> the right path.
> -- 
> https://mail.python.org/mailman/listinfo/python-list

The way I learn about the details of RPM packaging is to look at examples like 
what I wish to achieve.

I would go get the source RPM for a python2 package from each distro you want 
to supoort and read its .spec file.

I see on fedora that the way they install packages that are from pypi makes it 
possible to use pip list to see them.

Barry


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


Re: UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in position 10442: character maps to

2018-06-10 Thread Chris Angelico
On Mon, Jun 11, 2018 at 2:49 AM,   wrote:
>
> excuse but sorry
> i took the time to manually write the code error from the traceback as you 
> said
> and thats because i cant seem to find a way to attach files here..which would 
> make it so easier for me and also i could attach snippets of the actual 
> source code..and i asked the forum how i can attach files or also i asked for 
> an email adress but i didnt get a responsealso i find this is why 
> programmers can have a bad reputation..cuz of examples of people like 
> yourself barking out orders and getting upset for no good reason at tall..now 
> one including myself is giving you obligations to answer my queires 
> ok??..im not your slave the way you say that i have to follow 
> instructions..so why do you kindly just buzz off of my thread since it makes 
> you and myself really get annoyed..ok..
> --

Nope, you're not our slave. But here's the thing: none of us is your
slave either. If you don't want help, we don't have to provide any.

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


Re: Why exception from os.path.exists()?

2018-06-10 Thread Chris Angelico
On Mon, Jun 11, 2018 at 12:45 AM, Bev in TX  wrote:
>>  * One with an embedded / in the file name
>
> This is easily done in Finder, where I created a folder named "my/slash”.
> When I list it at the command line in Terminal, this shows up as "my:slash”, 
> with the slash shown as a colon.
> If I create a file with a colon in its name at the command line, that file 
> name acts the same way:
>
> $ touch ‘my:colon"
> $ ls
> my:colon
> my:slash
>
> In Finder they both display as:
> my/colon
> my/slash
>
> However, if you use Finder’s “Copy item as Pathname” option, then you will 
> again see the colon.
>
> /Users/bev/Training/myPython/pygroup/files/my:colon
> /Users/bev/Training/myPython/pygroup/files/my:slash
>
> But if you paste that folder’s name in Finder’s “Go to Folder” option, it 
> converts it to the following, and goes to that folder:
>
> /Users/bev/Training/myPython/pygroup/files/my/slash/slash

Can you try creating "spam:ham" and "spam/ham"? If they're both legal,
I'd like to see what their file names are represented as.

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


Re: Stefan's headers [was:Names and identifiers]

2018-06-10 Thread Chris Angelico
On Sun, Jun 10, 2018 at 11:03 PM, Gregory Ewing
 wrote:
> Chris Angelico wrote:
>>
>> You cannot, to
>> my knowledge, publish a game for the PS4 or Xbox 360 without
>> permission from Nintendo or Microsoft.
>
>
> That's because, since we *do* have copyright laws, the
> manufacturers of the consoles are able to make money by
> selling the software as well as the hardware -- and they
> want a monopoly on that source of income.
>
> If there was no copyright, they wouldn't be able to
> make money from the software side alone, so there would
> be no incentive for them to lock things down that way.
> The opposite, in fact -- the more games are available
> for a machine, the more people are going to want to
> buy it.
>
>> Nobody can sell software without also selling
>> hardware, which is an expensive industry to get into.
>
>
> I don't follow what you're saying here. Are you suggesting
> that nobody would write any software for someone else's
> hardware if they couldn't sell it for money? Experience
> with the open source community that we do have suggests
> otherwise.
>

Nice work there. You trimmed key parts of my post, and then responded
to me out of context. Go back and read my actual post, then respond to
what I actually said. Thanks!

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


Re: Why exception from os.path.exists()?

2018-06-10 Thread Marko Rauhamaa
Chris Angelico :
> Can you try creating "spam:ham" and "spam/ham"? If they're both legal,
> I'd like to see what their file names are represented as.

I think Bev already explained it. At Unix level, you can't have slashes
in filenames. At GUI level, you can't have colons in filenames. Unix
slashes are bijectively mapped to colons in the GUI.

So what you are asking can't really be tried out.


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


Re: Sorting NaNs

2018-06-10 Thread Richard Damon
On 6/10/18 3:28 PM, Anders Munch wrote:
> Richard Damon wrote:
>
>> The two behaviors that I have heard suggested are:
>>
>> 1) If any of the inputs are a NaN, the median should be a NaN.
>> (Propagating the NaN as indicator of a numeric error)
>>
>> 2) Remove the NaNs from the input set and process what is left. If
>> nothing, then return a NaN (treating NaN as a 'No Data' placeholder).
>
> 3) Raise an exception.
>
> I can't believe anyone even suggested 2).  "In the face of ambiguity,
> refuse the temptation to guess."
>
> regards, Anders
>
Many people doing statistics (mis-)use 'NaN' as a flag for 'missing data
for this record'. If you want the statistic of a sample as an estimate
of the statistic of the population, then omitting 'missing data' can be
a reasonable option. I will agree that I see issues with this attitude,
but it isn't uncommon.

-- 
Richard Damon

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


Re: Why exception from os.path.exists()?

2018-06-10 Thread Chris Angelico
On Mon, Jun 11, 2018 at 6:22 AM, Marko Rauhamaa  wrote:
> Chris Angelico :
>> Can you try creating "spam:ham" and "spam/ham"? If they're both legal,
>> I'd like to see what their file names are represented as.
>
> I think Bev already explained it. At Unix level, you can't have slashes
> in filenames. At GUI level, you can't have colons in filenames. Unix
> slashes are bijectively mapped to colons in the GUI.
>
> So what you are asking can't really be tried out.
>

I'd like to find out about that. If it doesn't work, it'll be easily
provable that it can't be done.

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


Re: Why exception from os.path.exists()?

2018-06-10 Thread Peter J. Holzer
On 2018-06-10 09:45:06 -0500, Bev in TX wrote:
> On Jun 10, 2018, at 5:49 AM, Peter J. Holzer  wrote:
> > On 2018-06-07 12:47:15 +, Steven D'Aprano wrote:
> >> But it doesn't do that. "Pathnames cannot contain NUL" is a falsehood 
> >> that programmers wrongly believe about paths. HFS Plus and Apple File 
> >> System support NULs in paths.
> > [...]
> >> But in the spirit of compromise, okay, let's ignore the existence of file 
> >> systems like HFS which allow NUL. Apart from Mac users, who uses them 
> >> anyway? Let's pretend that every file system in existence, now and into 
> >> the future, will prohibit NULs in paths.
[...]
> >  * One with an embedded / in the file name
> 
> This is easily done in Finder, where I created a folder named "my/slash”.  
> When I list it at the command line in Terminal, this shows up as "my:slash”, 
> with the slash shown as a colon.  
> If I create a file with a colon in its name at the command line, that file 
> name acts the same way:
> 
> $ touch ‘my:colon"
> $ ls
> my:colon
> my:slash
> 
> In Finder they both display as:
> my/colon
> my/slash

Thanks. So they just map '/' to ':'. IIRC, MacOS <= 9 used ':' as the
directory separator, so that makes sense. They kept the old behaviour
for applications using the Mac API (and for the GUI), but for the POSIX
API they use '/' (as they have to). Since ':' wasn't previously allowed,
there is no conflict, just some confusion for the users who sees
different filenames depending on which tool they use.

It does, however, mean that on MacOS filenames can't contain all Unicode
characters, either.

[...]
> I added printing the file name.  As suspected, the “slash” is a colon:
> 
> . - 56096374 - 2e
> .. - 56095464 - 2e 2e
> .DS_Store - 56109197 - 2e 44 53 5f 53 74 6f 72 65
> my:colon - 56095933 - 6d 79 3a 63 6f 6c 6f 6e
> my:slash - 56095521 - 6d 79 3a 73 6c 61 73 68

Yup.


> > Bonuspoints for doing this on an USB stick and then mounting the USB
> > stick on a Linux system and posting the output there as well.
> > 
> Sorry, I don’t have Linux, but I suspect it’s the same as the macOS command 
> line.

Very likely, yes.

hp

-- 
   _  | Peter J. Holzer| we build much bigger, better disasters now
|_|_) || because we have much more sophisticated
| |   | h...@hjp.at | management tools.
__/   | http://www.hjp.at/ | -- Ross Anderson 


signature.asc
Description: PGP signature
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Stefan's headers [was:Names and identifiers]

2018-06-10 Thread Jon Ribbens
On 2018-06-10, Ben Bacarisse  wrote:
> Jon Ribbens  writes:
>
>> I'd suggest that since the processes he's purporting to disallow are
>> entirely standard and automated and he knows full well they exist and
>> that there is no mechanism by which they could be affected by his
>> notice, the notice has little effect.
>
> The Copyright notice is probably intended for human eyes.  IIRC his
> posts don't show up on Google groups, for example, so there *is* a
> mechanism by which *some* of the headers (it may be X-no-archive) do get
> acted on.

True - many Usenet headers are intended for automated processing - but
the meaning of X-No-Archive is not even slightly similar to what he
says in his copyright notice, and so any overlap between the effect of
the former and the intention of the latter is merely coincidental.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Stefan's headers [was:Names and identifiers]

2018-06-10 Thread Peter J. Holzer
On 2018-06-10 15:24:38 +, Steven D'Aprano wrote:
> On Sun, 10 Jun 2018 16:25:24 +0200, Peter J. Holzer wrote:
> > Personally, I would let the author decide what constitutes one work.
> 
> Ah yes...
> 
> Star Wars, Empire Strikes Back, Return of the Jedi, Phantom Menace, 
> Attack of the Clones, Revenge of the Sith, Rogue One, Force Awakens, Last 
> Jedi, Solo... they're all chapters in one work, yes?

Yes, that would be possible. But there were 40+ years between the
release of Star Wars and the release of Solo, so if George Lucas had
decided to wait until the series is complete before registering it for
copyright, he either couldn't have published it yet (Episode IX is
scheduled for next year) or he would have published the parts without
protection (effectively making them public domain).

So Lucas would have registered Star Wars in 1977, and when the Empire
Strikes Back came out in 1980, he would have had the option to register
it as a separate work or to register the series consisting of both
films. Wouldn't have made a difference since he would have had to
continue to pay for Star Wars to prevent it from falling into the public
domain.

At some point he probably would have decided that continued copyright
protection wasn't worth the cost, so the first three episodes would be
public domain by now (If the doubling period is only one year. The
article I read suggested different doubling periods for different kind
of works: 1 year for patents, 3 years for books, ... It also depends on
the initial fee: Start at $1 (a token amount), $100 (may cover the cost
of having a person actually looking at it), $1000, ...?)

hp

-- 
   _  | Peter J. Holzer| we build much bigger, better disasters now
|_|_) || because we have much more sophisticated
| |   | h...@hjp.at | management tools.
__/   | http://www.hjp.at/ | -- Ross Anderson 


signature.asc
Description: PGP signature
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Why exception from os.path.exists()?

2018-06-10 Thread Barry Scott

> On 10 Jun 2018, at 21:10, Chris Angelico  wrote:
> 
> On Mon, Jun 11, 2018 at 12:45 AM, Bev in TX  wrote:
>>> * One with an embedded / in the file name
>> 
>> This is easily done in Finder, where I created a folder named "my/slash”.
>> When I list it at the command line in Terminal, this shows up as "my:slash”, 
>> with the slash shown as a colon.
>> If I create a file with a colon in its name at the command line, that file 
>> name acts the same way:
>> 
>> $ touch ‘my:colon"
>> $ ls
>> my:colon
>> my:slash
>> 
>> In Finder they both display as:
>> my/colon
>> my/slash
>> 
>> However, if you use Finder’s “Copy item as Pathname” option, then you will 
>> again see the colon.
>> 
>> /Users/bev/Training/myPython/pygroup/files/my:colon
>> /Users/bev/Training/myPython/pygroup/files/my:slash
>> 
>> But if you paste that folder’s name in Finder’s “Go to Folder” option, it 
>> converts it to the following, and goes to that folder:
>> 
>> /Users/bev/Training/myPython/pygroup/files/my/slash/slash
> 
> Can you try creating "spam:ham" and "spam/ham"? If they're both legal,
> I'd like to see what their file names are represented as.

On Classic Mac OS the folder separator was : not /. /usr/bin/ls would be 
usr:bin:ls for example.

It looks like a hang over from Classic that the macOS Finder maps between : to 
/ for presentation.
In bash you see the ":" in Finder you see a /.

In the Finder attempting to use a : in a filename gets an error message "Name 
cannot be uses a:b".
In macOS bash you cannot use a / in a filename.

I think what all boils down to this:

Windows, macOS and Linux etc all use a 0 as the end of string marker. (Windows 
uses 16bit 0 not 8bit 0).
The os file functions call the underlying OS and map its results into successes 
or exceptions.

The \0 means that the OS functions cannot be passed the data from the user.
Therefore you cannot get an error code from the OS.

All the other file systems rules are checked by the OS itself and any errors 
are reported to the user as OSError etc.

For example on windows the OS will prevent use '<' in a filename and it is the 
OS that returned the error.

Python 3.6.5 (v3.6.5:f59c0932b4, Mar 28 2018, 17:00:18) [MSC v.1900 64 bit 
(AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> open('a", line 1, in 
OSError: [Errno 22] Invalid argument: 'a>> open('a\0b', 'w')
Traceback (most recent call last):
  File "", line 1, in 
ValueError: embedded null character
>>>

Singling out os.path.exists as a special case I do think is reasonable.
All functions that take paths need to have a consistent response to data that 
is impossible to pass to the OS.

When it is impossible to get the OS to see all of the users data I'm not sure 
what else is reasonable for python
to do then what it already does not NUL.

With the exception that I do not think this is documented and the docs should 
be fixed.

Barry

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


Re: UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in position 10442: character maps to

2018-06-10 Thread Cameron Simpson

On 10Jun2018 13:04, bellcanada...@gmail.com  wrote:

here is the full error once again
to summarize, my script works fine in python2
i get this error trying to run it in python3
plz see below after the error, my settings for python 2 and python 3
for me it seems i need to change some settings to 'utf-8'..either just in 
python 3, since thats where i am having issues or change the settings to 
'utf-8' both in python 2 and 3i would appreciate feedback b4 i do some 
trial and error
thanks for the consideration
tommy

***
Traceback (most recent call last):
File "createIndex.py", line 132, in 
c.createindex()
File "creatIndex.py", line 102, in createIndex
pagedict=self.parseCollection()
File "createIndex.py", line 47, in parseCollection
for line in self.collFile:
File 
"C:\Users\Robert\AppData\Local\Programs\Python\Python36\lib\encodings\cp1252.py", 
line 23, in decode

return codecs.charmap_decode(input,self.errors,decoding_table[0]
UnicodeDecodeError: 'charmap'codec can't decode byte 0x9d in position 7414: character 
maps to 


Ok, this is more helpful. It says that the decoding error, which occurred in 
...\cp1252.py, was decoding lines from the file self.collFile.


What is that file? And how was it opened?

Also, your settings below may indeed be important.


***
python 3 settings
import sys
import locale
locale.getpreferredencoding()
'cp1252'


The setting above is the default encoding used when you open a file in text 
mode in Python 3, but you can override it.


In Python 3 this matters a lot, because Python 3 strings are Unicode. In Python 
2, strings are just bytes, and are not "decoded" (there is a whole separate 
"unicode" type for that when it matters).


So in Python 3 the text file reader is decoding the text in the file according 
to what it expects the encoding to be.


Find the place where self.collFile is opened. You can specify the decoding 
method there by adding the "encoding=" parameter to the open() call. It is 
defaulting to "cp1252" because that is what locale.getpreferredencoding() 
returns, but presumably the actual file data are not encoded that way.


You can (a) find out what encoding _is_ used in the file and specify that or 
(b) tell Python to be less picky. Choice (a) is better if it is feasible.


If you have to guess because you don't know the encoding, one possibility is 
that collFile contains utf-8 or utf-16; of these 2, utf-8 seems more likely 
given the 0x9d byte causing the trouble.  Try adding:


 encoding='utf-8'

to the open() call, eg:

 self.collFile = open('path-to-the-coll-file', encoding='utf-8')

at the appropriate place.

If that just produces a different decoding error, you have 2 choices: pick an 
encoding where every byte is "valid", such as 'iso8859-1', or to tell the 
decode to just cope with th errors by adding the errors="replace" or 
"errors="ignore" or errors="namereplace" parameter to the open() call.


Both these choices have downsides.

There are several ISO8859 encodings, and they might all be wrong for your file, 
leading to _incorrect_ text lines.


The errors="..." parameter also has downsides: you will also end up with 
missing (errors="ignore") or incorrect (errors="replace" or 
errors="namereplace") text, because the decoder has to do something with the 
data: drop it or replace it with something wrong. The former loses data while 
the latter puts in bad data, but at least it is visible if you inspect the data 
later.


The full documentation for Python 3's open() call is here:

 https://docs.python.org/3/library/functions.html#open

where the various encoding= and errors= choices are described.

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


Re: Posting warning message

2018-06-10 Thread Chris Angelico
On Mon, Jun 11, 2018 at 4:26 AM, John Ladasky
 wrote:
> On Sunday, June 10, 2018 at 7:47:01 AM UTC-7, T Berger wrote:
>> When I go to post a reply, I get a warning asking if I want my email address 
>> (or other email addresses listed) visible to all, and do I want to edit my 
>> post. What should I do?
>
> Are you posting through Google Groups?  Sometimes I see that warning as well.
>
> Some, but not all, Usenet software deliberately mangles email addresses when 
> composing posts.  It's a good thing to mangle email addresses when posting 
> publicly, as it makes it harder for spammers to find new targets.  So answer 
> "yes", and manually edit any email addresses you see in the post so that they 
> can't be recovered.  For example, if my email address was posted undisguised, 
> you could edit it to "j...@g...com" and that should do the trick.
>

Or just use the mailing list and do things honestly. Much easier AND
safer than using Google Groups.

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


Re: Why exception from os.path.exists()?

2018-06-10 Thread Marko Rauhamaa
Barry Scott :
> Singling out os.path.exists as a special case I do think is
> reasonable.

I don't think anyone has proposed that. While I brought up
os.path.exists() in my bug report, os.path.isfile(), os.path.isdir() etc
should obviously be addressed simultaneously. It may even be that the
fix needs to go to os.stat(). That's for the Python gods to decide.

> All functions that take paths need to have a consistent response to
> data that is impossible to pass to the OS.

Possibly.


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


Re: Stefan's headers [was:Names and identifiers]

2018-06-10 Thread Chris Angelico
On Mon, Jun 11, 2018 at 12:25 AM, Peter J. Holzer  wrote:
> But with online distribution (not necessarily github) the boundaries
> become very fluid. When Debian still contained the Roxen webserver, it
> comprised over 100 packages: The maintainer had put every plugin into a
> separate package. I did something similar with my qpsmtpd plugins: Each
> is in a separate .deb or .rpm file.

Python has long been distributed as a single .msi file on Windows, but
as many separate .deb packages on Debian Linux. One work or many?

Back in the 90s, my family sold books, many of them imported and/or
exported. We had a few books by Earl Rodd, all looking like books and
behaving like books. And we also had the "Rodd Papers", which are
individual photocopied leaflets (A5, maybe 20-32 pages tops). They're
also copyrightable, right? Well here's the thing. One of the books was
simply a published compilation of a large number of the papers. So
what is the "work"? Is the book a brand-new work? If you cease to
register the papers and start registering the book (one work, not
dozens, and also a new work so the stupid exponentiation resets),
people can't copy the papers either, because they're entirely
contained within the book.

So... all you have to do is, every couple of years, gather everything
you've ever written into a brand new book and register it.

>> >  * Every worthwhile creation is worth $1,000 for ten years.
>>
>> Not true by a long shot, and if you don't believe me, you can pay me
>> $1000 right now for ten years' use of any of my free software.
>
> I think he meant it the other way around: If you can sell your software
> for 10 years, you can affort $1000 to have your monopoly protected.

Except that I'm not selling it. What if I want to give it away, but
with the proviso that the document credits me properly? "Go ahead, use
it, publish it, but keep my name on it" is a common thing for people
to request. And it's toothless [1] without copyright; so if you have
to pay money for the right to be credited, there's going to be a lot
of corporate bullying.

ChrisA

[1] No, it's not a dragon. I can't imagine why you would think that.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Posting warning message

2018-06-10 Thread Cameron Simpson

On 10Jun2018 11:26, John Ladasky  wrote:

On Sunday, June 10, 2018 at 7:47:01 AM UTC-7, T Berger wrote:

When I go to post a reply, I get a warning asking if I want my email address 
(or other email addresses listed) visible to all, and do I want to edit my 
post. What should I do?


Are you posting through Google Groups?  Sometimes I see that warning as well.
Some, but not all, Usenet software deliberately mangles email addresses when 
composing posts.


Ah, interesting.

It's a good thing to mangle email addresses when posting publicly, as it makes 
it harder for spammers to find new targets.  So answer "yes", and manually 
edit any email addresses you see in the post so that they can't be recovered.  


"Good" is subjective. I don't think it is a good thing, but many people do.

My reasoning is that I'm never going to successfully hide my email address, so 
usually I won't bother. If I need to post somewhere I'd like private, I can 
always invent a random address like:


 c2d56bb1edc5a...@mailinator.com

for that special purpose and move on.

GMail has good spam filtering tech on the whole, so its users should be 
relatively comfortable about spam.


So when I post to a public forum I usually use my normal email address.

This is a personal decision and anyone might choose differently.

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


Re: Why exception from os.path.exists()?

2018-06-10 Thread Peter J. Holzer
On 2018-06-11 00:28:11 +0300, Marko Rauhamaa wrote:
> Barry Scott :
> > Singling out os.path.exists as a special case I do think is
> > reasonable.
> 
> I don't think anyone has proposed that. While I brought up
> os.path.exists() in my bug report, os.path.isfile(), os.path.isdir() etc
> should obviously be addressed simultaneously.

Yes.

> It may even be that the fix needs to go to os.stat(). That's for the
> Python gods to decide.

I'm not a Python god, but I don't think os.stat() should be changed.
That already throws different exceptions for different errors:

>>> os.stat("nix")
Traceback (most recent call last):
  File "", line 1, in 
FileNotFoundError: [Errno 2] No such file or directory: 'nix'
>>> os.stat("/lost+found/foo")
Traceback (most recent call last):
  File "", line 1, in 
PermissionError: [Errno 13] Permission denied: '/lost+found/foo'
>>> os.stat("\0")
Traceback (most recent call last):
  File "", line 1, in 
ValueError: embedded null byte

I think this is worth keeping, and "I couldn't pass that file name to
the OS" is a different error than "the OS told me the file doesn't
exist", so I think it should be a different exception.

hp

-- 
   _  | Peter J. Holzer| we build much bigger, better disasters now
|_|_) || because we have much more sophisticated
| |   | h...@hjp.at | management tools.
__/   | http://www.hjp.at/ | -- Ross Anderson 


signature.asc
Description: PGP signature
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Stefan's headers [was:Names and identifiers]

2018-06-10 Thread Peter J. Holzer
On 2018-06-11 06:35:27 +1000, Chris Angelico wrote:
> Back in the 90s, my family sold books, many of them imported and/or
> exported. We had a few books by Earl Rodd, all looking like books and
> behaving like books. And we also had the "Rodd Papers", which are
> individual photocopied leaflets (A5, maybe 20-32 pages tops). They're
> also copyrightable, right? Well here's the thing. One of the books was
> simply a published compilation of a large number of the papers. So
> what is the "work"? Is the book a brand-new work? If you cease to
> register the papers and start registering the book (one work, not
> dozens, and also a new work so the stupid exponentiation resets),
> people can't copy the papers either, because they're entirely
> contained within the book.

But they can, because each of the papers is now public domain.

This situation also exists with current copyright law. If a book is out
of copyright (either because the author has been dead for 70 years or
because it fell through one of the gaps of the various copyright law
changes in the US), you can re-publish it. Now you do have the copyright
for the new book, but that stops others only from copying your book, not
the original.


> So... all you have to do is, every couple of years, gather everything
> you've ever written into a brand new book and register it.

That would be stupid. Fortunately the solution is obvious.


> >> >  * Every worthwhile creation is worth $1,000 for ten years.
> >>
> >> Not true by a long shot, and if you don't believe me, you can pay me
> >> $1000 right now for ten years' use of any of my free software.
> >
> > I think he meant it the other way around: If you can sell your software
> > for 10 years, you can affort $1000 to have your monopoly protected.
> 
> Except that I'm not selling it. What if I want to give it away, but
> with the proviso that the document credits me properly? "Go ahead, use
> it, publish it, but keep my name on it" is a common thing for people
> to request. And it's toothless [1] without copyright; so if you have
> to pay money for the right to be credited,

Depends on the details of the law. For example, in most of Europe there
is a difference between the "Urheberrecht" (creator's rights) and the
"Verwertungsrecht" (exploitation rights) (there are no exact equivalent
in English, so I'm using the German words). The former is always bound
to the person who created the work and cannot be sold. The latter can
(and usually is). The right of a person to be credited could be part of
the former. There is also much less incentive to pretend you wrote
something you didn't if there is no financial advantage, so it may not
be that important.

> there's going to be a lot of corporate bullying.

I don't really see why there would be more than now.

hp

-- 
   _  | Peter J. Holzer| we build much bigger, better disasters now
|_|_) || because we have much more sophisticated
| |   | h...@hjp.at | management tools.
__/   | http://www.hjp.at/ | -- Ross Anderson 


signature.asc
Description: PGP signature
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Multiprocessing on a remote host

2018-06-10 Thread Peter J. Holzer
On 2018-03-21 09:27:37 -0400, Larry Martell wrote:
> Yeah, I saw that and I wasn't trying to reinvent the wheel. On this
> page https://docs.python.org/2/library/multiprocessing.html it says
> this:
> 
> The multiprocessing package offers both local and remote concurrency,
> effectively side-stepping the Global Interpreter Lock by using
> subprocesses instead of threads. Due to this, the multiprocessing
> module allows the programmer to fully leverage multiple processors on
> a given machine.
> 
> I took 'remote concurrency' to mean I could use it run a process on
> another host.

Yes.

> But I don't see how to do that, and I was asking if it was possible or
> am I misinterpreting the docs.

It is described on the same page, a little bit farther down:
https://docs.python.org/2/library/multiprocessing.html#using-a-remote-manager

hp

-- 
   _  | Peter J. Holzer| we build much bigger, better disasters now
|_|_) || because we have much more sophisticated
| |   | h...@hjp.at | management tools.
__/   | http://www.hjp.at/ | -- Ross Anderson 


signature.asc
Description: PGP signature
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: your mail

2018-06-10 Thread Bob Gailer
On Jun 10, 2018 12:44 PM, "Karsten Hilbert"  wrote:
>
> On Sun, Jun 10, 2018 at 06:58:17PM +0530, sagar daya wrote:
>
> > Couldn't install any module from pip
> > Plz help???

The only help I can give at this point is to suggest that you tell us what
you tried and how it failed. Please copy and paste any relevant terminal
entries and error messages. No screenshots no attempts to rephrase just the
facts. Once we have those we can take the next step. Just out of curiosity
did you think there could be any other answer to your question? In the
future please think about what you're asking otherwise it cost us time to
have to ask you for the information we need got
>
> https://duckduckgo.com
>
> kh
> --
> --
> https://mail.python.org/mailman/listinfo/python-list
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Sorting NaNs

2018-06-10 Thread Steven D'Aprano
On Sun, 10 Jun 2018 21:28:02 +0200, Anders Munch wrote:

> Richard Damon wrote:
> 
>> The two behaviors that I have heard suggested are:
>>
>> 1) If any of the inputs are a NaN, the median should be a NaN.
>> (Propagating the NaN as indicator of a numeric error)
>>
>> 2) Remove the NaNs from the input set and process what is left. If
>> nothing, then return a NaN (treating NaN as a 'No Data' placeholder).
> 
> 3) Raise an exception.
> 
> I can't believe anyone even suggested 2).  "In the face of ambiguity,
> refuse the temptation to guess."

It is not a guess if the user explicitly specifies that as the behaviour.

It would be no more of a guess than if the user called

data = [x for x in data if not math.isnan(x)]

on their data first.



-- 
Steven D'Aprano
"Ever since I learned about confirmation bias, I've been seeing
it everywhere." -- Jon Ronson

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


Re: FULLSCREEN and DOUBLEBUF

2018-06-10 Thread Gregory Ewing

Dennis Lee Bieber wrote:

Both may be dependent upon the actual hardware graphics board and the
drivers for said board.


My guess is that if your surface is not fullscreen or is not
a hardware surface, then you're always drawing into an ofscreen
buffer that gets copied to the screen when display.flip() is
called. In other words, it's effectively double-buffered
whether you request it or not.

The only time it's an issue is when you're drawing directly
to the screen memory, i.e. both FULLSCREEN and HWSURFACE
where your hardware and drivers support that.

My suggestion is to just always specify DOUBLEBUF and not
worry about what's going on behind the scenes. That will
almost always give the result you want, i.e. a flicker-free
display.

The only time it would be an issue is if you wanted your
surface to *not* be double-buffered for some reason, but
that would be a rare situation.

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


Re: Why exception from os.path.exists()?

2018-06-10 Thread Steven D'Aprano
On Mon, 11 Jun 2018 06:10:26 +1000, Chris Angelico wrote:

> Can you try creating "spam:ham" and "spam/ham"? If they're both legal,
> I'd like to see what their file names are represented as.

The Finder could very easily be substituting another character, like 
Konqueror (the KDE 3 file manager) does. In Konqueror, you can create a 
file named "spam/ham" and it quietly substitutes "spam%2fham" instead. 
But Konqueror's GUI treats it completely transparently: it is displayed 
as a slash, and if you copy the file name from the GUI you get a slash.

I seem to recall Gnome doing something similar, except it quietly 
substitutes U+2044 FRACTION SLASH or U+2215 DIVISION SLASH instead.

To really be sure what is going on, you would have to bypass the Finder 
and any shell and write the file name using the OS X low-level API.

Or create the file using a classic Mac (system 8 or older), where slashes 
definitely are not treated as special. Not the Mac OS classic emulation 
layer.


Hmmm... you know I might just be able to do that. Write a file to a 
floppy, then mount it under Linux. If I had a Linux computer with a 
floppy disk drive.

(The march of technology is sometimes a nuisance.)

By the way, for some reason I don't seem to have received Bev's post.


-- 
Steven D'Aprano
"Ever since I learned about confirmation bias, I've been seeing
it everywhere." -- Jon Ronson

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


Re: UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in position 10442: character maps to

2018-06-10 Thread bellcanadardp
On Sunday, 10 June 2018 17:29:59 UTC-4, Cameron Simpson  wrote:
> On 10Jun2018 13:04, bellcanada...@gmail.com  wrote:
> >here is the full error once again
> >to summarize, my script works fine in python2
> >i get this error trying to run it in python3
> >plz see below after the error, my settings for python 2 and python 3
> >for me it seems i need to change some settings to 'utf-8'..either just in 
> >python 3, since thats where i am having issues or change the settings to 
> >'utf-8' both in python 2 and 3i would appreciate feedback b4 i do some 
> >trial and error
> >thanks for the consideration
> >tommy
> >
> >***
> >Traceback (most recent call last):
> >File "createIndex.py", line 132, in 
> >c.createindex()
> >File "creatIndex.py", line 102, in createIndex
> >pagedict=self.parseCollection()
> >File "createIndex.py", line 47, in parseCollection
> >for line in self.collFile:
> >File 
> >"C:\Users\Robert\AppData\Local\Programs\Python\Python36\lib\encodings\cp1252.py",
> > 
> >line 23, in decode
> >return codecs.charmap_decode(input,self.errors,decoding_table[0]
> >UnicodeDecodeError: 'charmap'codec can't decode byte 0x9d in position 7414: 
> >character maps to 
> 
> Ok, this is more helpful. It says that the decoding error, which occurred in 
> ...\cp1252.py, was decoding lines from the file self.collFile.
> 
> What is that file? And how was it opened?
> 
> Also, your settings below may indeed be important.
> 
> >***
> >python 3 settings
> >import sys
> > import locale
> >locale.getpreferredencoding()
> >'cp1252'
> 
> The setting above is the default encoding used when you open a file in text 
> mode in Python 3, but you can override it.
> 
> In Python 3 this matters a lot, because Python 3 strings are Unicode. In 
> Python 
> 2, strings are just bytes, and are not "decoded" (there is a whole separate 
> "unicode" type for that when it matters).
> 
> So in Python 3 the text file reader is decoding the text in the file 
> according 
> to what it expects the encoding to be.
> 
> Find the place where self.collFile is opened. You can specify the decoding 
> method there by adding the "encoding=" parameter to the open() call. It is 
> defaulting to "cp1252" because that is what locale.getpreferredencoding() 
> returns, but presumably the actual file data are not encoded that way.
> 
> You can (a) find out what encoding _is_ used in the file and specify that or 
> (b) tell Python to be less picky. Choice (a) is better if it is feasible.
> 
> If you have to guess because you don't know the encoding, one possibility is 
> that collFile contains utf-8 or utf-16; of these 2, utf-8 seems more likely 
> given the 0x9d byte causing the trouble.  Try adding:
> 
>   encoding='utf-8'
> 
> to the open() call, eg:
> 
>   self.collFile = open('path-to-the-coll-file', encoding='utf-8')
> 
> at the appropriate place.
> 
> If that just produces a different decoding error, you have 2 choices: pick an 
> encoding where every byte is "valid", such as 'iso8859-1', or to tell the 
> decode to just cope with th errors by adding the errors="replace" or 
> "errors="ignore" or errors="namereplace" parameter to the open() call.
> 
> Both these choices have downsides.
> 
> There are several ISO8859 encodings, and they might all be wrong for your 
> file, 
> leading to _incorrect_ text lines.
> 
> The errors="..." parameter also has downsides: you will also end up with 
> missing (errors="ignore") or incorrect (errors="replace" or 
> errors="namereplace") text, because the decoder has to do something with the 
> data: drop it or replace it with something wrong. The former loses data while 
> the latter puts in bad data, but at least it is visible if you inspect the 
> data 
> later.
> 
> The full documentation for Python 3's open() call is here:
> 
>   https://docs.python.org/3/library/functions.html#open
> 
> where the various encoding= and errors= choices are described.
> 
> Cheers,
> Cameron Simpson 

thank you for the reply
let me try these tips and suggestions and i will update here
thanxz alot
and thnxz also to all who post ..i appreciate it..
regards
tommy
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Stefan's headers [was:Names and identifiers]

2018-06-10 Thread Steven D'Aprano
On Mon, 11 Jun 2018 06:21:31 +1000, Chris Angelico wrote:
[...]
> Nice work there. You trimmed key parts of my post, and then responded to
> me out of context. Go back and read my actual post, then respond to what
> I actually said. Thanks!

I didn't trim any part of your post when I read it, but I took away the 
same message as Greg. Perhaps your point was not as clear as you thought 
it was.




-- 
Steven D'Aprano
"Ever since I learned about confirmation bias, I've been seeing
it everywhere." -- Jon Ronson

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


Re: Why exception from os.path.exists()?

2018-06-10 Thread Chris Angelico
On Mon, Jun 11, 2018 at 9:52 AM, Steven D'Aprano
 wrote:
> On Mon, 11 Jun 2018 06:10:26 +1000, Chris Angelico wrote:
>
>> Can you try creating "spam:ham" and "spam/ham"? If they're both legal,
>> I'd like to see what their file names are represented as.
>
> The Finder could very easily be substituting another character, like
> Konqueror (the KDE 3 file manager) does. In Konqueror, you can create a
> file named "spam/ham" and it quietly substitutes "spam%2fham" instead.
> But Konqueror's GUI treats it completely transparently: it is displayed
> as a slash, and if you copy the file name from the GUI you get a slash.

Speculation is all very well, but I was wanting to see what actually
happened. :)

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


Re: Why exception from os.path.exists()?

2018-06-10 Thread Bev in TX
I accidentally did not send this to the list...

> On Jun 10, 2018, at 7:10 PM, Bev in TX  wrote:
> 
> 
>> On Jun 10, 2018, at 3:10 PM, Chris Angelico > > wrote:
>>> ...
>> 
>> Can you try creating "spam:ham" and "spam/ham"? If they're both legal,
>> I'd like to see what their file names are represented as.
>> 
> I dug around and found this very old article, in which it says:
> 
> "Another obvious problem is the different path separators between HFS+ 
> (colon, ':') and UFS (slash, '/'). This also means that HFS+ file names may 
> contain the slash character and not colons, while the opposite is true for 
> UFS file names. This was easy to address, though it involves transforming 
> strings back and forth. The HFS+ implementation in the kernel's VFS layer 
> converts colon to slash and vice versa when reading from and writing to the 
> on-disk format. So on disk the separator is a colon, but at the VFS layer 
> (and therefore anything above it and the kernel, such as libc) it's a slash. 
> However, the traditional Mac OS toolkits expect colons, so above the BSD 
> layer, the core Carbon toolkit does yet another translation. The result is 
> that Carbon applications see colons, and everyone else sees slashes. This can 
> create a user-visible schizophrenia in the rare cases of file names 
> containing colon characters, which appear to Carbon applications as slash 
> characters, but to BSD programs and Cocoa applications as colons.”
> 
> That was from, "USENIX 2000 Invited Talks Presentation” at:
> http://www.wsanchez.net/papers/USENIX_2000/ 
> 
> 
> 

Bev in TX




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


Re: Why exception from os.path.exists()?

2018-06-10 Thread Steven D'Aprano
On Sun, 10 Jun 2018 22:09:39 +0100, Barry Scott wrote:

> Singling out os.path.exists as a special case I do think is reasonable.
> All functions that take paths need to have a consistent response to data

The *mere existence* of os.path.exists means that there is not a 
consistent response to file names:

open(foo) raises an exception if foo doesn't exist;

os.path.exists(foo) returns False if foo doesn't exist.

There is no requirement that different functions do the same thing with 
the same bad input. The *whole point* of o.p.exists is to return False, 
not raise an exception.


> that is impossible to pass to the OS.

Even if it were true that file names cannot contain certain characters, 
and it is not, why is that a distinction that anyone gives a shit about?

I do not expect that there are more than a handful of use-cases for 
distinguishing "file names which cannot be passed to the OS" versus "any 
other illegal file name". And even that is generous.

Besides, it is certainly not true that there are no OSes that can deal 
with NULs in file names. Classic Mac OS can, as filenames there are 
represented as Pascal strings (a length byte followed by an array of 
arbitrary bytes), not NUL-terminated C strings.




-- 
Steven D'Aprano
"Ever since I learned about confirmation bias, I've been seeing
it everywhere." -- Jon Ronson

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


Re: Why exception from os.path.exists()?

2018-06-10 Thread Charles Hixson

On 06/07/2018 12:45 AM, Chris Angelico wrote:

On Thu, Jun 7, 2018 at 1:55 PM, Steven D'Aprano
 wrote:

On Tue, 05 Jun 2018 23:27:16 +1000, Chris Angelico wrote:


And an ASCIIZ string cannot contain a byte value of zero. The parallel
is exact.

Why should we, as Python programmers, care one whit about ASCIIZ strings?
They're not relevant. You might as well say that file names cannot
contain the character "π" because ASCIIZ strings don't support it.

No they don't, and yet nevertheless file names can and do contain
characters outside of the ASCIIZ range.

Under Linux, a file name contains bytes, most commonly representing
UTF-8 sequences. So... an ASCIIZ string *can* contain that character,
or at least a representation of it. Yet it cannot contain "\0".

ChrisA
This seems like an argument for allowing byte strings to be used as file 
names, not for altering text strings.  If file names are allowed to 
contain values that are illegal for text strings, then they shouldn't be 
necessarily considered as text strings.


The unicode group sets one set of rules, and their rules should apply in 
their area.  The Linux group sets another set of rules, and their rules 
should apply in their area.  Just because there is a large area of 
overlap doesn't mean that the two areas are congruent.  Byte strings are 
designed to handle any byte pattern, but text strings are designed to 
handle a subset of those patterns. Most byte strings are readable as 
text, but not all of them.

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


Re: Why exception from os.path.exists()?

2018-06-10 Thread Steven D'Aprano
On Sun, 10 Jun 2018 23:57:35 +0200, Peter J. Holzer wrote:

> I think this is worth keeping, and "I couldn't pass that file name to
> the OS" is a different error than "the OS told me the file doesn't
> exist", so I think it should be a different exception.

What makes you think that NUL bytes are a fundamental limitation that no 
OS could every cope with?

Classic Mac OS takes file names as Pascal strings, with a length byte and 
an array of arbitrary bytes, no NUL terminator required. Despite what far 
too many C programmers appear to believe, NUL-terminated strings are not 
a fundamental requirement.

Navigating Apple's documentation is a nightmare, but I've found the 
deprecated Carbon file manager APIs. For example, creating a file with 
PBCreateFileUnicodeSync:

https://developer.apple.com/documentation/coreservices/1566896-
pbcreatefileunicodesync?language=objc

takes a FSRefParam argument:

https://developer.apple.com/documentation/coreservices/fsrefparam?
language=objc

which includes a name field which is a pointer to an array of Unicode 
characters, and a separate name length.

The evidence suggests that using the Carbon APIs, NUL is just another 
Unicode character. Whatever API replaces Carbon, it will have to deal 
with file names created under Carbon, and classic Mac, and so likely will 
support the same.

Baking a limitation of some file systems into the high-level interface is 
simply a *bad idea*. There is no good reason to treat file names 
containing NUL as special in the API (even if, for implementation 
reasons, it has to be treated specially in the implementation).

How would you feel if there were a whole lot of ignorant Pascal 
programmers arguing that it was fundamentally impossible for file names 
to exceed 255 characters, and therefore os.path.exists() out to raise 
ValueError when passed a file name of 256 characters?

"But it is impossible to pass a string of 256 characters to the OS" is no 
more foolish than "it is impossible to pass a string with an embedded NUL 
to the OS". Both are implementation details. Neither should be baked into 
the high-level language as a fundamental requirement.



-- 
Steven D'Aprano
"Ever since I learned about confirmation bias, I've been seeing
it everywhere." -- Jon Ronson

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


Re: Why exception from os.path.exists()?

2018-06-10 Thread Chris Angelico
On Mon, Jun 11, 2018 at 11:06 AM, Steven D'Aprano
 wrote:
> On Sun, 10 Jun 2018 23:57:35 +0200, Peter J. Holzer wrote:
>
>> I think this is worth keeping, and "I couldn't pass that file name to
>> the OS" is a different error than "the OS told me the file doesn't
>> exist", so I think it should be a different exception.
>
> What makes you think that NUL bytes are a fundamental limitation that no
> OS could every cope with?

I didn't say that. If you have an OS that can't handle more than 255
bytes of file name, it's allowed to raise ValueError just the same.

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


NUL in file names verified [was Re: Why exception from os.path.exists()?]

2018-06-10 Thread Steven D'Aprano
Straight from the horse's mouth, Apple's HFS Plus volumes do indeed
support NULs in file names. Quote:


Indirect node files exist in a special directory called the
metadata directory. This directory exists in the volume's root
directory. The name of the metadata directory is four null
characters followed by the string "HFS+ Private Data".


and:

The case-insensitive Unicode string comparison used by
HFS Plus and case-insensitive HFSX sorts null characters
after all other characters, so the metadata directory
will typically be the last item in the root directory.
On case-sensitive HFSX volumes, null characters sort
before other characters, so the metadata directory will
typically be the first item in the root directory.


https://developer.apple.com/library/archive/technotes/tn/tn1150.html#HFSPlusNames




-- 
Steven D'Aprano
"Ever since I learned about confirmation bias, I've been seeing
it everywhere." -- Jon Ronson

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


Re: Why exception from os.path.exists()?

2018-06-10 Thread Gregory Ewing

Chris Angelico wrote:

I'd like to find out about that. If it doesn't work, it'll be easily
provable that it can't be done.


Using the shell:

% touch colonic:name
% ls
colonic:name
% touch slashy/name
touch: slashy/name: No such file or directory

(It's trying to create a file in a directory called "slashy",
which doesn't exist.)

Using Python:

>>> open("colonic:name", "w").close()
>>> os.listdir(".")
['colonic:name']
>>> open("slashy/name", "w").close()
Traceback (most recent call last):
  File "", line 1, in 
FileNotFoundError: [Errno 2] No such file or directory: 'slashy/name'

(Same reason as before.)

Using the GUI: I tried to use TextEdit to save a file with
a colon in the name. When I typed ":" into the filename box,
it substituted "-".

I was able to type "slashy/textfile" into the filename box
and save. In the shell it shows as:

% ls
slashy:textfile.rtf

Is that proof enough for you?

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


Re: Posting warning message

2018-06-10 Thread T Berger
Thanks, everyone, for your suggestions. I didn't respond to your posts earlier 
because I wasn't notified by email updates. I don't understand why they've 
stopped coming. I didn't change any settings.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Why exception from os.path.exists()?

2018-06-10 Thread Gregory Ewing

Steven D'Aprano wrote:
Hmmm... you know I might just be able to do that. Write a file to a 
floppy, then mount it under Linux.


That still might not tell you much. The Linux system will need
a filesystem driver that understands the Mac HFS file system,
which is what your classic Mac system will be writing. And that
driver will have its own way of handling file names with
slashes in them, probably by substituting something else.
So you still won't know what's actually stored on the disk.

The only way to be really sure would be to make a dump of
the raw disk contents and go looking for the file name in it.


(The march of technology is sometimes a nuisance.)


BTW, another problem there would be if your Mac was old
enough, it would be using a variable speed floppy drive,
which I doubt any PC-based system would be able to cope
with...

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