Re: Is there a way to globally set the print function separator?

2017-10-10 Thread Steve D'Aprano
On Tue, 10 Oct 2017 03:05 pm, John Black wrote:

>> functools.partial(print, sep='') is the winner, IMO.
> 
> Ok, I got that working too after someone told me I have to import
> functools.  Can you explain what it means?  It looks like it is not
> defining another function like the other solutions but is truly changing
> the defaults for the existing function print?

No. You are absolutely not changing the defaults for the actual built-in print
function. There is no support for that in Python.

What is happening is a bit more complex, but simplified:

- functools.partial is creating a new function-like object, almost
  identical to the built-in print in every way that matters except
  that it uses sep='';

- this special function-like object actually calls the true built-in
  print (which is why we can trust it will be almost identical);

- but you have changed the name "print" to refer to the customised
  version instead of the original.

(That change of name will only apply to the current module. Other modules will
still see the original print function.)


One way to convince yourself that this is the case is to look at the ID of the
print function before and after:


py> import functools
py> id(print)
19
py> print = functools.partial(print, sep='')
py> id(print)
20


The ID numbers are different, which proves they are different objects.

(If you try this on your computer, you will almost certainly get different ID
numbers than I did. The ID numbers are opaque integers with no inherent
meaning, and will vary according to the version of Python you have, and even
the history of what you have run in the current interpreter session.)

We can dig a little deeper, and inspect the new "print" function:

py> print.func


It is holding onto a reference to the original (which is how it can call the
original). We can confirm this:

py> id(print.func)
19


Same ID as the original.

(Note that this test is not *quite* definitive: ID numbers are only guaranteed
to be unique between objects which exist at the same time. If you delete an
object, so the garbage collector reclaims its memory and reuses it, it is
possible that the ID number may be reused as well.)



-- 
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.

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


pathlib PurePosixPath

2017-10-10 Thread Sayth Renshaw
Hi

How do I create a valid file name and directory with pathlib?

When I create it using PurePosixPath I end up with an OSError due to an 
obvously invlaid path being created.

import pathlib

for dates in fullUrl:
# print(dates)
time.sleep(0.3)
r = requests.get(dates)
data = r.json()
if data["RaceDay"] is not None:
file_name = data["RaceDay"]["Meetings"][0]["VenueName"] + 
data["RaceDay"]["MeetingDate"] + '.json'
result_path = pathlib.PurePosixPath(r'C:\Users\Sayth\Projects\results', 
file_name)
with open(result_path, 'a') as f:
f.write(data)


##Output
C:\Users\Sayth\Anaconda3\envs\json\python.exe 
C:/Users/Sayth/PycharmProjects/ubet_api_mongo/json_download.py
Traceback (most recent call last):
  File "C:/Users/Sayth/PycharmProjects/ubet_api_mongo/json_download.py", line 
40, in 
with open(result_path, 'a') as f:
OSError: [Errno 22] Invalid argument: 
'C:\\Users\\Sayth\\Projects\\results/Warwick Farm2017-09-06T00:00:00.json'

Process finished with exit code 1

Not sure exactly which way to fix it.

Cheers

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


Re: pathlib PurePosixPath

2017-10-10 Thread Chris Angelico
On Tue, Oct 10, 2017 at 6:21 PM, Sayth Renshaw  wrote:
> Hi
>
> How do I create a valid file name and directory with pathlib?
>
> When I create it using PurePosixPath I end up with an OSError due to an 
> obvously invlaid path being created.

You're on Windows. The rules for POSIX paths don't apply to your file
system, and...

> OSError: [Errno 22] Invalid argument: 
> 'C:\\Users\\Sayth\\Projects\\results/Warwick Farm2017-09-06T00:00:00.json'

... the colon is invalid on Windows file systems. You'll have to
replace those with something else.

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


Re: pathlib PurePosixPath

2017-10-10 Thread Sayth Renshaw

> > Hi
> >
> > How do I create a valid file name and directory with pathlib?
> >
> > When I create it using PurePosixPath I end up with an OSError due to an 
> > obvously invlaid path being created.
> 
> You're on Windows. The rules for POSIX paths don't apply to your file
> system, and...
> 
> > OSError: [Errno 22] Invalid argument: 
> > 'C:\\Users\\Sayth\\Projects\\results/Warwick Farm2017-09-06T00:00:00.json'
> 
> ... the colon is invalid on Windows file systems. You'll have to
> replace those with something else.
> 
> ChrisA

Thanks. Updated the script. But shouldn't it create the file if it doesn't 
exist? Which none of them will.

for dates in fullUrl:
# print(dates)
time.sleep(0.3)
r = requests.get(dates)
data = r.json()
if data["RaceDay"] is not None:
a = data["RaceDay"]["MeetingDate"]
b = a[:7]
file_name = data["RaceDay"]["Meetings"][0]["VenueName"] + '_' + b + 
'.json'
result_path = pathlib.PurePath(r'C:\Users\Sayth\Projects\results', 
file_name)
with open(result_path, 'a') as f:
f.write(data)

##Output
File "C:/Users/Sayth/PycharmProjects/ubet_api_mongo/json_download.py", line 42, 
in 
with open(result_path, 'a') as f:
FileNotFoundError: [Errno 2] No such file or directory: 
'C:\\Users\\Sayth\\Projects\\results\\Warwick Farm_2017-09.json'

Process finished with exit code 1

Cheers

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


Re: The "loop and a half"

2017-10-10 Thread Paul Moore
On 9 October 2017 at 01:37, boB Stepp  wrote:
> I follow this list in an effort to learn as much as I can even though
> I am usually a fish out of water here.  But this thread in all its
> twists and turns and various subject line changes seems to have gotten
> totally out of hand.  Even though I am quoting only part of this one
> message, there are actually many others that I am responding to here.
>
> In my opinion (Honestly admitting my lack of technical competence.),
> this insatiable thirst on this list to get every bit of technical
> minutiae exactly correct is doing a severe disservice to the
> friendliness of this community.  Yes, gently correct the (perceived)
> errors, because we all want to have it right, but please cease this
> incessant pounding of points (and people) into the ground to prove we
> are right and they are wrong!
>
> I doubt any of this is going to change Bart's mind.  Why can we not
> allow him to make his points, respond to them appropriately, and then
> let it go when it is clear he has strongly held opinions that are not
> likely to change?
>
> And Bart, when large numbers of technical experts in their fields have
> spent many hours/months/years, yea, even several decades, developing
> these software systems, why do you think that you, all by yourself,
> know better?  Can you not see how frustrating this is for people who
> have spent good chunks of their lives trying to do the best they can
> on these software systems?  Don't you think it is a better approach to
> perhaps do some self-examination and approach things from a more
> humble learner's perspective?  And BTW, there are many users of
> non-*nix systems on this list, or who do work on multiple operating
> system platforms.
>
> Can we not let people be who they are, perceived warts (valid or not)
> and all, and after responding (hopefully gently) to technical errors
> just let them be???

+1

Thank you for saying this.
Paul
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: pathlib PurePosixPath

2017-10-10 Thread BlindAnagram
On 10/10/2017 08:44, Sayth Renshaw wrote:
> 
>>> Hi
>>>
>>> How do I create a valid file name and directory with pathlib?
>>>
>>> When I create it using PurePosixPath I end up with an OSError due to an 
>>> obvously invlaid path being created.
>>
>> You're on Windows. The rules for POSIX paths don't apply to your file
>> system, and...
>>
>>> OSError: [Errno 22] Invalid argument: 
>>> 'C:\\Users\\Sayth\\Projects\\results/Warwick Farm2017-09-06T00:00:00.json'
>>
>> ... the colon is invalid on Windows file systems. You'll have to
>> replace those with something else.
>>
>> ChrisA
> 
> Thanks. Updated the script. But shouldn't it create the file if it doesn't 
> exist? Which none of them will.

The documentation says "Pure path objects provide path-handling
operations which don’t actually access a filesystem".

But the "Concrete paths" subclass is described later with support for a
number of file system operations.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: pathlib PurePosixPath

2017-10-10 Thread Peter Otten
Sayth Renshaw wrote:

> Thanks. Updated the script. But shouldn't it create the file if it doesn't
> exist? Which none of them will.

> pathlib.PurePath(r'C:\Users\Sayth\Projects\results', file_name)
> with open(result_path, 'a') as f:
> f.write(data)
 
> ##Output
> File "C:/Users/Sayth/PycharmProjects/ubet_api_mongo/json_download.py",
> line 42, in 
> with open(result_path, 'a') as f:
> FileNotFoundError: [Errno 2] No such file or directory:
> 'C:\\Users\\Sayth\\Projects\\results\\Warwick Farm_2017-09.json'

Read the error message carefully. My crystal ball says that the directory

C:\Users\Sayth\Projects\results

does not exist.

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


Re: Introducing the "for" loop

2017-10-10 Thread Peter Otten
Stefan Ram wrote:

>   Which advice do you refer to?

Teach the parts that are most useful first, i. e. for loops over anything 
but range rather than while loops.

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


Re: pathlib PurePosixPath

2017-10-10 Thread Thomas Jollans
On 2017-10-10 09:44, Sayth Renshaw wrote:
> 
>>> Hi
>>>
>>> How do I create a valid file name and directory with pathlib?
>>>
>>> When I create it using PurePosixPath I end up with an OSError due to an 
>>> obvously invlaid path being created.
>>
>> You're on Windows. The rules for POSIX paths don't apply to your file
>> system, and...
>>
>>> OSError: [Errno 22] Invalid argument: 
>>> 'C:\\Users\\Sayth\\Projects\\results/Warwick Farm2017-09-06T00:00:00.json'
>>
>> ... the colon is invalid on Windows file systems. You'll have to
>> replace those with something else.
>>
>> ChrisA
> 
> Thanks. Updated the script. But shouldn't it create the file if it doesn't 
> exist? Which none of them will

It should, but only if the directory exists. Does it?

> 
> for dates in fullUrl:
> # print(dates)
> time.sleep(0.3)
> r = requests.get(dates)
> data = r.json()
> if data["RaceDay"] is not None:
> a = data["RaceDay"]["MeetingDate"]
> b = a[:7]
> file_name = data["RaceDay"]["Meetings"][0]["VenueName"] + '_' + b + 
> '.json'
> result_path = pathlib.PurePath(r'C:\Users\Sayth\Projects\results', 
> file_name)
> with open(result_path, 'a') as f:
> f.write(data)
> 
> ##Output
> File "C:/Users/Sayth/PycharmProjects/ubet_api_mongo/json_download.py", line 
> 42, in 
> with open(result_path, 'a') as f:
> FileNotFoundError: [Errno 2] No such file or directory: 
> 'C:\\Users\\Sayth\\Projects\\results\\Warwick Farm_2017-09.json'
> 
> Process finished with exit code 1
> 
> Cheers
> 
> Sayth
> 


-- 
Thomas Jollans

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


Re: pathlib PurePosixPath

2017-10-10 Thread Tim Golden

On 2017-10-10 08:29, Chris Angelico wrote:
On Tue, Oct 10, 2017 at 6:21 PM, Sayth Renshaw  
wrote:

Hi

How do I create a valid file name and directory with pathlib?

When I create it using PurePosixPath I end up with an OSError due to 
an obvously invlaid path being created.


You're on Windows. The rules for POSIX paths don't apply to your file
system, and...

OSError: [Errno 22] Invalid argument: 
'C:\\Users\\Sayth\\Projects\\results/Warwick 
Farm2017-09-06T00:00:00.json'


... the colon is invalid on Windows file systems. You'll have to
replace those with something else.


I haven't followed closely, so this may well not be an issue here, but 
the colon is valid on a Windows file system; it introduces an alternate 
data stream:


https://msdn.microsoft.com/en-us/library/windows/desktop/aa364404(v=vs.85).aspx

So this is perfectly valid on Windows:

with open("temp.txt:abc", "w") as f:
f.write("abc")


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


Re: pathlib PurePosixPath

2017-10-10 Thread Chris Angelico
On Tue, Oct 10, 2017 at 8:22 PM, Tim Golden  wrote:
> On 2017-10-10 08:29, Chris Angelico wrote:
>>
>> On Tue, Oct 10, 2017 at 6:21 PM, Sayth Renshaw 
>> wrote:
>>>
>>> Hi
>>>
>>> How do I create a valid file name and directory with pathlib?
>>>
>>> When I create it using PurePosixPath I end up with an OSError due to an
>>> obvously invlaid path being created.
>>
>>
>> You're on Windows. The rules for POSIX paths don't apply to your file
>> system, and...
>>
>>> OSError: [Errno 22] Invalid argument:
>>> 'C:\\Users\\Sayth\\Projects\\results/Warwick Farm2017-09-06T00:00:00.json'
>>
>>
>> ... the colon is invalid on Windows file systems. You'll have to
>> replace those with something else.
>
>
> I haven't followed closely, so this may well not be an issue here, but the
> colon is valid on a Windows file system; it introduces an alternate data
> stream:
>
> https://msdn.microsoft.com/en-us/library/windows/desktop/aa364404(v=vs.85).aspx
>
> So this is perfectly valid on Windows:
>
> with open("temp.txt:abc", "w") as f:
> f.write("abc")

Have you tested that? My understanding of the document you linked to
is that the colon still has special meaning, and thus you can't use it
in arbitrary file names. (Now, if the question were "can I ever see a
colon in a file name", then you'd be correct to use this as proof that
you can; but trying to use a file name such as the OP's is not thus
proven.)

And no, I haven't tested my theory on this either. Any Windows guinea
pigs want to give this a try?

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


Re: pathlib PurePosixPath

2017-10-10 Thread Tim Golden

On 2017-10-10 10:28, Chris Angelico wrote:
On Tue, Oct 10, 2017 at 8:22 PM, Tim Golden  
wrote:

On 2017-10-10 08:29, Chris Angelico wrote:


On Tue, Oct 10, 2017 at 6:21 PM, Sayth Renshaw 


wrote:


Hi

How do I create a valid file name and directory with pathlib?

When I create it using PurePosixPath I end up with an OSError due to 
an

obvously invlaid path being created.



You're on Windows. The rules for POSIX paths don't apply to your file
system, and...


OSError: [Errno 22] Invalid argument:
'C:\\Users\\Sayth\\Projects\\results/Warwick 
Farm2017-09-06T00:00:00.json'



... the colon is invalid on Windows file systems. You'll have to
replace those with something else.



I haven't followed closely, so this may well not be an issue here, but 
the
colon is valid on a Windows file system; it introduces an alternate 
data

stream:

https://msdn.microsoft.com/en-us/library/windows/desktop/aa364404(v=vs.85).aspx

So this is perfectly valid on Windows:

with open("temp.txt:abc", "w") as f:
f.write("abc")


Have you tested that?


Yes. I ran it before posting.


My understanding of the document you linked to
is that the colon still has special meaning, and thus you can't use it
in arbitrary file names.


In fact its presence in that filename creates a (usually hidden) data 
stream piggybacked onto that file which has the name "abc" into which 
the data is written.


So, following on, the follow works:

assert open("temp.txt:abc").read() == "abc"

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


Re: pathlib PurePosixPath

2017-10-10 Thread Chris Angelico
On Tue, Oct 10, 2017 at 8:56 PM, Tim Golden  wrote:
>> My understanding of the document you linked to
>> is that the colon still has special meaning, and thus you can't use it
>> in arbitrary file names.
>
>
> In fact its presence in that filename creates a (usually hidden) data stream
> piggybacked onto that file which has the name "abc" into which the data is
> written.
>
> So, following on, the follow works:
>
> assert open("temp.txt:abc").read() == "abc"

Cool. Does it require that temp.txt exist first? And if you have
multiple colons (as in the OP's), does the part after the second colon
have to be a type indicator?

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


Re: pathlib PurePosixPath

2017-10-10 Thread Tim Golden

On 2017-10-10 10:58, Chris Angelico wrote:
On Tue, Oct 10, 2017 at 8:56 PM, Tim Golden  
wrote:

My understanding of the document you linked to
is that the colon still has special meaning, and thus you can't use 
it

in arbitrary file names.



In fact its presence in that filename creates a (usually hidden) data 
stream
piggybacked onto that file which has the name "abc" into which the 
data is

written.

So, following on, the follow works:

assert open("temp.txt:abc").read() == "abc"


Cool. Does it require that temp.txt exist first? And if you have
multiple colons (as in the OP's), does the part after the second colon
have to be a type indicator?

ChrisA


No. temp.txt is created empty.

Multiple colons *does* appear to be a syntax error in the filename.

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


Re: Lies in education [was Re: The "loop and a half"]

2017-10-10 Thread Rhodri James

On 09/10/17 20:06, Stefan Ram wrote:

r...@zedat.fu-berlin.de (Stefan Ram) writes:

Steve D'Aprano  writes:

At various stages of education, we teach many lies-to-children, including:

Many of those lies can be perfectly true in some sense.
I pick some examples:


   Another noun phrase with "lie" is "white lie".

   In his book about programming, Bjarne Stroustrup writes:

|We try hard to avoid "white lies"; that is, we refrain from
|oversimplified explanations that are clear and easy to
|understand, but not true in the context of real languages and
|real problems.


That would go a long way to explaining why I tried and failed to learn 
C++ three times from Stroustrup's books.


--
Rhodri James *-* Kynesim Ltd
--
https://mail.python.org/mailman/listinfo/python-list


Re: on = style

2017-10-10 Thread Rhodri James

On 09/10/17 08:46, Steve D'Aprano wrote:

I truly believe that, with*very*  few exceptions (*ALL*  of which are some form
of in-line data table, and even then only rarely) any programmer who worries
about lining up assignments on different lines like this is just engaged in a
time-wasting exercise to make themselves look busy while actually taking it
easy. It is a pure avoidance activity.


I'm inclined to disagree, at least in as much as I think the exceptions 
are more common than you do.  For me at least there are two opposed 
principles:


* Columnar data is easier to read.
* Big gaps in the middle of a line make it hard to read.

I fairly often line up initialisers

  height  = 5
  width   = 10
  length  = 2
  density = 0.75

...or other related groups of assignments, but that takes a minute at 
most.  When there is a huge mismatch in name length, aligning the 
columns is more tedious and gives you less visual advantage, so I don't 
bother.  Somewhere in the middle is a tipping point.


--
Rhodri James *-* Kynesim Ltd
--
https://mail.python.org/mailman/listinfo/python-list


Re: Lies in education [was Re: The "loop and a half"]

2017-10-10 Thread Bill

Rhodri James wrote:

On 09/10/17 20:06, Stefan Ram wrote:

r...@zedat.fu-berlin.de (Stefan Ram) writes:

Steve D'Aprano  writes:
At various stages of education, we teach many lies-to-children, 
including:

Many of those lies can be perfectly true in some sense.
I pick some examples:


   Another noun phrase with "lie" is "white lie".

   In his book about programming, Bjarne Stroustrup writes:

|We try hard to avoid "white lies"; that is, we refrain from
|oversimplified explanations that are clear and easy to
|understand, but not true in the context of real languages and
|real problems.


That would go a long way to explaining why I tried and failed to learn 
C++ three times from Stroustrup's books.


He is surely one of the best authors in computer science (at least based 
upon "The C++ Programming Language", 3rd ed.).  He indicates that he 
assumes that the reader has some experience developing serious 
software.  Beazley's, "Python: Essential Reference" is one of the best 
books I've seen since. It doesn't have the same depth, but it (too) 
provides articulate answers, head-on. Both books have 5-star rankings on 
Amazon.com. That doesn't mean that either of them is right for 
everybody. Come back to Stroustrup's book "after" you learn C++ 
somewhere else, and maybe you'll enjoy it more.


Bill

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


Re: on = style

2017-10-10 Thread sjmsoft
Being an old-timer, I was brought up on languages like COBOL, where programmers 
love to line up MOVE, COMPUTE and some other statements.  I still do that when 
I write COBOL, as it is expected by other programmers and somehow just seems 
right.

But I resist the urge in Python and never do it.  Previous posters have given 
good reasons for this.  My main reason is to keep diffs as small as possible.

Small diffs would apply to COBOL too, of course.  Even programmers are not 
always completely rational.  Tradition and common practice have their say, too. 
 (And COBOL is so verbose that perhaps it's a lost cause!)

Cheers,
  Steve J. Martin
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: The "loop and a half"

2017-10-10 Thread bartc

On 09/10/2017 01:37, boB Stepp wrote:

On Sun, Oct 8, 2017 at 5:36 AM, bartc  wrote:



And Bart, when large numbers of technical experts in their fields have
spent many hours/months/years, yea, even several decades, developing
these software systems, why do you think that you, all by yourself,
know better?


In some fields, then yes!

The problem with experts is that they do like to pile layer upon layer, 
plus another layer to deal with the complexity created by the previous 
layers!


For example, I write compilers, including a C compiler. But I couldn't 
start compiling the CPython sources (with any compiler actually), 
because the first step was running a 30,000-line configure script, for 
Linux. I work on Windows.


However there is now a solution using VS2015. There was a thread on this 
subject in May 2017, and there I recounted my attempts at using VS2015 
to build CPython. A copy of that I've put here:


 https://pastebin.com/raw/V76WP1Ha (Raw text so no adverts.)

CPython is 250K lines I think; a fast compiler ought to be able to deal 
with a program like that in one second (depending on how many files it's 
split up into). Now look at that link.


Experts

Building big cumbersome, complicated systems is easy. Making them small 
and simple is harder.



Can you not see how frustrating this is for people who
have spent good chunks of their lives trying to do the best they can
on these software systems?


Only if they concede I might have a point. I haven't seen much sign of that!

I doubt anyone using *nix systems, which are massively popular, is going 
to start feeling insecure due to the opinions of one guy.


You say (in a bit I see I've snipped), that non *nix people read these 
forums. But my experience is that the majority of people who post (in 
c.l.p and comp.lang.c) are using *nix. It's unbalanced.


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


Re: The "loop and a half"

2017-10-10 Thread Paul Moore
On 10 October 2017 at 13:44, bartc  wrote:
>> Can you not see how frustrating this is for people who
>> have spent good chunks of their lives trying to do the best they can
>> on these software systems?
>
> Only if they concede I might have a point. I haven't seen much sign of that!

You have a point, if you're willing to work in a simplified
environment. Like most older, larger systems, a lot of the complexity
comes from trying to support a large number of
environments/configurations, many more than anyone could have
envisioned at the start. Code gets layered on top of older code to
support extra situations. Refactoring and simplification is possible,
but often really hard because not all of the peculiar situations that
prompted the complexity can be reproduced (or even remembered, much of
the time) by the developers. Strict "no fix is allowed without a
failing test demonstrating the bug" policies can help with that, but
in practice such policies are *really* onerous, and tend to risk
preventing necessary fixes being applied.

The problem is that someone coming in saying "it could be so much
simpler" is probably only considering a very small subset of the
situations that have come up over the lifetime of the project.

Summary: "Things don't need to be this complicated" is likely true.
But the cost of simplifying is likely to either be massive coding
effort, or reintroduction of obscure bugs that were previously fixed.

So I've conceded that you might have a point. Are *you* willing to
concede that you may have missed something when making your
assertions?

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


Re: pathlib PurePosixPath

2017-10-10 Thread eryk sun
On Tue, Oct 10, 2017 at 11:18 AM, Tim Golden  wrote:
> On 2017-10-10 10:58, Chris Angelico wrote:
>> On Tue, Oct 10, 2017 at 8:56 PM, Tim Golden  wrote:
>>
>>> In fact its presence in that filename creates a (usually hidden) data
>>> stream piggybacked onto that file which has the name "abc" into which the
>>> data is written.
>>>
>>> So, following on, the follow works:
>>>
>>> assert open("temp.txt:abc").read() == "abc"
>>
>> Cool. Does it require that temp.txt exist first? And if you have
>> multiple colons (as in the OP's), does the part after the second colon
>> have to be a type indicator?
>>
>> ChrisA
>
> No. temp.txt is created empty.
>
> Multiple colons *does* appear to be a syntax error in the filename.

Colon in a file path (not a device name) is a reserved character
that's used to reference NTFS file streams. The colon is not part of
the name of either the base file/directory or the stream. You can
check whether a volume supports named streams by calling
GetVolumeInformation. If they're supported, then lpFileSystemFlags
will contain the flag FILE_NAMED_STREAMS.

The complete spec is "FileName:StreamName:StreamType". When a regular
file is opened, NTFS defaults to opening the anonymous data stream,
"FileName::$DATA". When a directory is opened, NTFS defaults to
opening "DirName:$I30:$INDEX_ALLOCATION", i.e. the $I30 stream of type
$INDEX_ALLOCATION. A directory can also have named $DATA streams, but
it can't have an anonymous $DATA stream because that would be
ambiguous in general.

Other stream types used internally in NTFS include $FILE_NAME,
$REPARSE_POINT, $OBJECT_ID, $ATTRIBUTE_LIST, $INDEX_ROOT, and $BITMAP.
But these are of little interest unless you specialize in forensics or
are supporting NTFS on another OS.
-- 
https://mail.python.org/mailman/listinfo/python-list


about 'setattr(o, name, value)' and 'inspect.signature(f)'

2017-10-10 Thread xieyuheng
in CPython,

instead of trying each object and function,

is there any rules can help me answer the following questions ?

or is there any third part documentations
[community driven docs ? wiki ?]
that can answer them ?

1. 'setattr(o, name, value)' can be used for what kind of objects ?

   section '2. Built-in Functions'
   of the official documentation says :

   > The function assigns the value to the attribute, provided the object 
allows it.

2. what kind of functions does not have signature,
   so that 'inspect.signature(f)' can be used for them ?

   section '29.12.3. Introspecting callables with the Signature object'
   of the official documentation says :

   > Some callables may not be introspectable in certain implementations of 
Python.
   > For example, in CPython, some built-in functions defined in C
   > provide no metadata about their arguments.

   this is depends on implementation, so I ask for CPython.

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


about 'setattr(o, name, value)' and 'inspect.signature(f)'

2017-10-10 Thread xieyuheng
in CPython,

instead of trying each object and function,

is there any rules can help me answer the following questions ?

or is there any third part documentations
[community driven docs ? wiki ?]
that can answer them ?

1. 'setattr(o, name, value)' can be used for what kind of objects ?

   section '2. Built-in Functions'
   of the official documentation says :

   > The function assigns the value to the attribute, provided the object 
allows it.

2. what kind of functions does not have signature,
   so that 'inspect.signature(f)' can be used for them ?

   section '29.12.3. Introspecting callables with the Signature object'
   of the official documentation says :

   > Some callables may not be introspectable in certain implementations of 
Python.
   > For example, in CPython, some built-in functions defined in C
   > provide no metadata about their arguments.

   this is depends on implementation, so I ask for CPython.

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


Re: Python GUI application embedding a web browser - Options?

2017-10-10 Thread oliver
Can you elaborate what is not sufficient with Qt's web components?
http://doc.qt.io/qt-5/topics-web-content.html. This allows for HTML, CSS,
Javascript, via either native C++ Qt, QML, or Python (PyQt) or mixtures of
these 3. That said, I have not yet used Qt`s web engine so I don`t know how
full-featured it is, how robust, etc. I have used PyQt for several years in
production grade project and it is very solid and well documented and easy
to program with and easy to write tests for.
Oliver

On Mon, 9 Oct 2017 at 12:59 fpp  wrote:

> Paul Moore  said :
>
> > On 9 October 2017 at 04:25,   wrote:
> >> Did you find out the answer for that?
> >
> > Nothing much beyond the pointer to PyQt (which basically said "a lot
> > of the info on the web is out of date" so I should check the latest
> > docs). I didn't take it much further, though, as it was a hobby
> > project and the learning curve for PyQt (any GUI framework, really)
> > was a bit high for the amount of spare time I had at the time.
> >
> > Paul
>
> Have you looked at CEFpython ?
> It seems to work with all major GUIs (Qt, wx, Tk, gtk..)
> https://github.com/cztomczak/cefpython/tree/master/examples
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
Oliver
My StackOverflow contributions
My CodeProject articles
My Github projects
My SourceForget.net projects
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: about 'setattr(o, name, value)' and 'inspect.signature(f)'

2017-10-10 Thread Paul Moore
On 10 October 2017 at 15:37, xieyuheng  wrote:
> 1. 'setattr(o, name, value)' can be used for what kind of objects ?
>
>section '2. Built-in Functions'
>of the official documentation says :
>
>> The function assigns the value to the attribute, provided the object 
> allows it.

Anything for which o. = value will work. However, user defined
types can choose to raise an exception if you try to assign to certain
attributes, types with slots will raise an exception if you try to
assign to an attribute not defined in __slots__, etc.

These are all run-time behaviours, and so there's no way you can check
for them ahead of time. If you want to be sure setattr is allowed, you
need to handle possible exceptions:

try:
setattr(o, name, value)
except Exception:
# deal with the problem

Example:

>>> class C:
... __slots__ = ['a', 'b']
...
>>> c = C()
>>> c.c = 1
Traceback (most recent call last):
  File "", line 1, in 
AttributeError: 'C' object has no attribute 'c'
>>> setattr(c, 'c', 1)
Traceback (most recent call last):
  File "", line 1, in 
AttributeError: 'C' object has no attribute 'c'
>>> try:
... setattr(c, 'c', 1)
... except AttributeError:
... pass
...
>>>

> 2. what kind of functions does not have signature,
>so that 'inspect.signature(f)' can be used for them ?
>
>section '29.12.3. Introspecting callables with the Signature object'
>of the official documentation says :
>
>> Some callables may not be introspectable in certain implementations of 
> Python.
>> For example, in CPython, some built-in functions defined in C
>> provide no metadata about their arguments.
>
>this is depends on implementation, so I ask for CPython.

Again, it's a runtime issue, so the answer is the same "it's easier to
ask for forgiveness than permission" - try the operation and handle
any exception:

>>> import inspect
>>> inspect.signature(type)
Traceback (most recent call last):
  File "", line 1, in 
  File "C:\Users\me\AppData\Local\Programs\Python\Python36\Lib\inspect.py",
line 3033, in signature
return Signature.from_callable(obj, follow_wrapped=follow_wrapped)
  File "C:\Users\me\AppData\Local\Programs\Python\Python36\Lib\inspect.py",
line 2783, in from_callable
follow_wrapper_chains=follow_wrapped)
  File "C:\Users\me\AppData\Local\Programs\Python\Python36\Lib\inspect.py",
line 2262, in _signature_from_callable
skip_bound_arg=skip_bound_arg)
  File "C:\Users\me\AppData\Local\Programs\Python\Python36\Lib\inspect.py",
line 2087, in _signature_from_builtin
raise ValueError("no signature found for builtin
{!r}".format(func))
ValueError: no signature found for builtin 
>>> try:
... sig = inspect.signature(type)
... except ValueError:
... sig = None
...
>>> print(repr(sig))
None

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


Re: Python GUI application embedding a web browser - Options?

2017-10-10 Thread Paul Moore
On 10 October 2017 at 16:07, oliver  wrote:
> Can you elaborate what is not sufficient with Qt's web components?

I can't, sorry. Douglas was resurrecting a thread from a year ago. At
the time I was trying to do a quick proof of concept project and asked
for help on here. The project never really went anywhere, because it
ended up being more complex than I had time for. I don't recall the
details any more.

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


Keyboard Input [was: The "loop and a half"]

2017-10-10 Thread Mikhail V
Chris Angelico wrote:

> On Mon, Oct 9, 2017 at 7:05 PM, Mikhail V  wrote:
> > The first thing a developer should provide - the keys and mouse input
> > should be
> > *customizable* by the user. It is so by most serious application I have
> > ever used.
>
> And they most certainly are. Often, in something in the host platform.
> For instance, Xfce allows me to change the keys used for various
> purposes, by going into the menu and choosing "Settings" and then
> "Keyboard". (Or, of course, by editing the config files.) The most
> obvious and dramatic change you can do is to choose a specific
> keyboard layout - Qwerty vs Dvorak, US vs German, etc, etc, etc. Do
> you think that sort of thing should be in the hands of the
> application, or the platform? (Note that I'm not saying "OS" here.
> Usually the platform is at a higher level than that; in my case, I
> would consider Xfce (my desktop manager) to be that.)


I am not sure I correctly understand your question.
Do you ask whether the application should bypass the OS
selected layout and use own character input tables?
It is of course possible, but since the OS provides
input events, why not use those?
We were speaking about a text editor, so yes this
will be useful if one wants multilingual text input.

Also I am almost sure I can programmatically switch
the layout pages from Python (some Winapi calls I suppose)
So theoretically, based only on keyb scancodes, one
can use own LUTS and flags to replicate the unicode
input. I personally never wrote apps with multilingual text input though.

Seems that for keyboard input everything is already invented and
well-established.
Below is a minimal app showing pressed keys.
Try switching layouts and see 'unicode'  field changing for
same key scancode.


import pygame
pygame.init()
window_w = 300# display width
window_h = 200# display height
pygame.display.set_mode((window_w, window_h))
clock = pygame.time.Clock( )
FPS = 15
MainLoop = True
while MainLoop :
clock.tick(FPS)
for E in pygame.event.get():
if E.type == pygame.QUIT:
MainLoop = False
if E.type == pygame.KEYDOWN:
print (E)
if E.key == pygame.K_ESCAPE:
MainLoop = False
pygame.quit( )




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


Re: about 'setattr(o, name, value)' and 'inspect.signature(f)'

2017-10-10 Thread Terry Reedy

On 10/10/2017 10:37 AM, xieyuheng wrote:


2. what kind of functions does not have signature,
so that 'inspect.signature(f)' can be used for them ?


When .signature was added, it may not have been usable with *any* 
C-coded function.  About the same, a mechanism was added to make 
signatures available with C-coded functions.  Using the mechanism 
requires recoding for each file.  By now, many CPython functions have 
been recoded.



section '29.12.3. Introspecting callables with the Signature object'
of the official documentation says :

> Some callables may not be introspectable in certain implementations of 
Python.


So 'some' is a gradually shrinking set.


> For example, in CPython, some built-in functions defined in C
> provide no metadata about their arguments.

this is depends on implementation, so I ask for CPython.


--
Terry Jan Reedy

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


Re: about 'setattr(o, name, value)' and 'inspect.signature(f)'

2017-10-10 Thread Thomas Jollans
On 2017-10-10 16:37, xieyuheng wrote:
>> Some callables may not be introspectable in certain implementations of 
> Python.
>> For example, in CPython, some built-in functions defined in C
>> provide no metadata about their arguments.
> 
>this is depends on implementation, so I ask for CPython.

There's not really much more to say than what the docs you're quoting say.

As far as I'm aware, all callables defined in Python will have a
signature, while the default for "built-in" functions (anything written
in C) in CPython is for them not to have a signature. This applies to
__builtins__ and other modules written in C equally.

In __builtins__, most callables have NO signature as of Python 3.6.
However, around 3/4 of the *functions* there (i.e. not types) DO have
signatures. In particular none of the built-in exceptions have signatures.

>>> import inspect
>>> no_sig = []
>>> has_sig = []
>>> for name, val in __builtins__.__dict__.items():
... try:
... tmp = inspect.signature(val)
... except TypeError:
... pass # not callable
... except ValueError:
... no_sig.append(name)
... else:
... has_sig.append(name)
...
>>>
>>> len(no_sig)
101
>>> len(has_sig)
40

Look at only "functions":

>>> [name for name in no_sig if type(getattr(__builtins__, name)) ==
type(print)]
['__build_class__', '__import__', 'dir', 'getattr', 'iter', 'max',
'min', 'next', 'print', 'round', 'vars']
>>> len([name for name in no_sig if type(getattr(__builtins__, name)) ==
type(print)])
11
>>> [name for name in has_sig if type(getattr(__builtins__, name)) ==
type(print)]
['abs', 'all', 'any', 'ascii', 'bin', 'callable', 'chr', 'compile',
'delattr', 'divmod', 'eval', 'exec', 'format', 'globals', 'hasattr',
'hash', 'hex', 'id', 'input', 'isinstance', 'issubclass', 'len',
'locals', 'oct', 'ord', 'pow', 'repr', 'setattr', 'sorted', 'sum', 'open']
>>> len([name for name in has_sig if type(getattr(__builtins__, name))
== type(print)])
31

Take out the exceptions and warnings:

>>> [name for name in no_sig if name[0] == name[0].lower()]
['__build_class__', '__import__', 'dir', 'getattr', 'iter', 'max',
'min', 'next', 'print', 'round', 'vars', 'bool', 'bytearray', 'bytes',
'classmethod', 'complex', 'dict', 'enumerate', 'filter', 'float',
'frozenset', 'property', 'int', 'list', 'map', 'range', 'reversed',
'set', 'slice', 'staticmethod', 'str', 'super', 'tuple', 'type', 'zip']
>>> len([name for name in no_sig if name[0] == name[0].lower()])
35
>>> [name for name in has_sig if name[0] == name[0].lower()]
['__loader__', 'abs', 'all', 'any', 'ascii', 'bin', 'callable', 'chr',
'compile', 'delattr', 'divmod', 'eval', 'exec', 'format', 'globals',
'hasattr', 'hash', 'hex', 'id', 'input', 'isinstance', 'issubclass',
'len', 'locals', 'oct', 'ord', 'pow', 'repr', 'setattr', 'sorted',
'sum', 'memoryview', 'object', 'open', 'quit', 'exit', 'copyright',
'credits', 'license', 'help']
>>> len([name for name in has_sig if name[0] == name[0].lower()])
40
>>>


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


Re: about 'setattr(o, name, value)' and 'inspect.signature(f)'

2017-10-10 Thread Ned Batchelder

On 10/10/17 11:00 AM, Stefan Ram wrote:

xieyuheng  writes:

1. 'setattr(o, name, value)' can be used for what kind of objects ?

   It takes three objects as arguments.

   The first object should have an attribute named by the value
   of »name« that should allow this attribute to be set to
   »value« as if by

o.=value

   where  is the value of »name« (which should be a string).



One tweak to this: the object doesn't need to have the attribute 
initially.  setattr() can create new attributes that don't already exist.


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


RE: Printing to a file and a terminal at the same time

2017-10-10 Thread Vail, Rick
I have a script for Cisco devices that will do configuration or any CLI 
command.  What I would like to do is print the output to my terminal(windows) 
and to a file. I can come up with stdout parameters
To print to a file but not to the screen and when I remove the stdout part it 
prints to the screen only.

This prints to a file
filename  = open("outputfile",'w')
sys.stdout = filename
print ("Anything printed will go to the output file")

Remove the above and it prints to the terminal, help



Rick Vail | Network Engineer
Presidio (NASDAQ: PSDO) | www.presidio.com
12272 Hancock St, Carmel, IN 46032
D: 317.428.6399 | C: 317.847.0493 | 
rv...@presidio.com



[Future. Built.]


Follow us:

[Follow Presidio on Twitter]





This message w/attachments (message) is intended solely for the use of the 
intended recipient(s) and may contain information that is privileged, 
confidential or proprietary. If you are not an intended recipient, please 
notify the sender, and then please delete and destroy all copies and 
attachments. Please be advised that any review or dissemination of, or the 
taking of any action in reliance on, the information contained in or attached 
to this message is prohibited.
-- 
https://mail.python.org/mailman/listinfo/python-list


FW: Printing to a file and a terminal at the same time

2017-10-10 Thread Vail, Rick



Rick Vail | Network Engineer
Presidio (NASDAQ: PSDO) | www.presidio.com
12272 Hancock St, Carmel, IN 46032
D: 317.428.6399 | C: 317.847.0493 | 
rv...@presidio.com



[Future. Built.]


Follow us:

[Follow Presidio on Twitter]



From: Vail, Rick
Sent: Tuesday, October 10, 2017 7:04 AM
To: 'python-list@python.org' 
Subject: Printing to a file and a terminal at the same time

I have a script for Cisco devices that will do configuration or any CLI 
command.  What I would like to do is print the output to my terminal(windows) 
and to a file. I can come up with stdout parameters
To print to a file but not to the screen and when I remove the stdout part it 
prints to the screen only.

This prints to a file
filename  = open("outputfile",'w')
sys.stdout = filename
print ("Anything printed will go to the output file")

Remove the above and it prints to the terminal, help




This message w/attachments (message) is intended solely for the use of the 
intended recipient(s) and may contain information that is privileged, 
confidential or proprietary. If you are not an intended recipient, please 
notify the sender, and then please delete and destroy all copies and 
attachments. Please be advised that any review or dissemination of, or the 
taking of any action in reliance on, the information contained in or attached 
to this message is prohibited.
-- 
https://mail.python.org/mailman/listinfo/python-list


Unable to run pip in Windows 10

2017-10-10 Thread Michael Cuddehe
I have tried multiple versions, 32 & 64 bit. Same problem.

"This app can't run on your PC. To find a version for your PC, check with
the software publisher."

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


Re: Printing to a file and a terminal at the same time

2017-10-10 Thread MRAB

On 2017-10-10 17:00, Vail, Rick wrote:

I have a script for Cisco devices that will do configuration or any CLI 
command.  What I would like to do is print the output to my terminal(windows) 
and to a file. I can come up with stdout parameters
To print to a file but not to the screen and when I remove the stdout part it 
prints to the screen only.

This prints to a file
filename  = open("outputfile",'w')
sys.stdout = filename
print ("Anything printed will go to the output file")

Remove the above and it prints to the terminal, help


Why not define a function that does both?

def my_print(*args, **kwargs):
print(*args, **kwargs)
print(*args, **kwargs, file=output_file)
--
https://mail.python.org/mailman/listinfo/python-list


Re: Lies in education [was Re: The "loop and a half"]

2017-10-10 Thread Bill

Steve D'Aprano wrote:

On Tue, 10 Oct 2017 06:06 am, Stefan Ram wrote:


In his book about programming, Bjarne Stroustrup writes:

|We try hard to avoid "white lies"; that is, we refrain from
|oversimplified explanations that are clear and easy to
|understand, but not true in the context of real languages and
|real problems.


Bjarne Stroustrup is famous for designing one of the most heavyweight,
baraque, hard-to-understand, difficult-to-use programming languages in common
use. While C++ has many excellent features, and is constrained by the need to
be compatible with C, I don't think many people believe that it is a
well-designed language.



It is a well-designed language.  It is and was carefully thought out. 
One could argue that there are perhaps "too many ways" to do a given 
thing in Python (one could say it's features are "not orthogonal"). I'm 
sure you are familiar with where the language drew its name.   I'm not 
here to "cast stones", I like Python. I just think that you shouldn't 
cast stones at C/C++.  People started programming in C in the late 70's, 
and before that some were programming in B ("B Programming Language"), 
if I recall correctly. Python generally runs "further ways from the 
hardware" than these other languages, and in some sense, it still would, 
*even if* you were able to statically compile it to machine language. To 
me if feels like Python runs like an application.   I don't wish to 
debate this as I have other needs this week. But I felt compelled to try 
to explain why maybe you shouldn't be casting stones at C/C++.


One thing you didn't bring up at all, is that the audiences for the 
languages appears to be different. You still need folks who can encode 
data structures and write device drivers, from scratch.  And "woe" if 
you need performance, such as applications involving AI.


Cheers,
Bill


But even if it were the best language in the world, and Stroustrup the
greatest language designer in the history of computing, what makes you think
that he knows anything about teaching?




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


Re: about 'setattr(o, name, value)' and 'inspect.signature(f)'

2017-10-10 Thread Steve D'Aprano
On Wed, 11 Oct 2017 02:15 am, Paul Moore wrote:

> These are all run-time behaviours, and so there's no way you can check
> for them ahead of time. If you want to be sure setattr is allowed, you
> need to handle possible exceptions:
> 
> try:
> setattr(o, name, value)
> except Exception:
> # deal with the problem


I would say that you should only catch AttributeError here. Anything else is,
in my opinion, a bug in the object o that needs to be spotted and fixed.

Even catching AttributeError is a bit... suspicious. Why exactly are we trying
to attach attributes to arbitrary objects like None or "Hello World"?

But certainly if you get something like UnicodeDecodeError or ImportError from
trying to set an attribute, that's a bug in o.__setattr__ that needs fixing.


-- 
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.

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


Re: FW: Printing to a file and a terminal at the same time

2017-10-10 Thread Michael Torrie
On 10/10/2017 10:09 AM, Vail, Rick wrote:
> I have a script for Cisco devices that will do configuration or any CLI 
> command.  What I would like to do is print the output to my terminal(windows) 
> and to a file. I can come up with stdout parameters
> To print to a file but not to the screen and when I remove the stdout part it 
> prints to the screen only.
> 
> This prints to a file
> filename  = open("outputfile",'w')
> sys.stdout = filename
> print ("Anything printed will go to the output file")

Is this script interactive?  I'm guessing not. In any case, the
recommended course for any Unix OS is to just use the tee command to
redirect the output both to the terminal and to a file.  Works with
anything that outputs text to standard out.

As for doing it in Python, maybe you can implement your own print-like
function that prints everything out twice. Once to the file and once to
std out.



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


Re: Lies in education [was Re: The "loop and a half"]

2017-10-10 Thread Bill

Dennis Lee Bieber wrote:

On Tue, 10 Oct 2017 20:48:26 -0400, Bill 
declaimed the following:


cast stones at C/C++.  People started programming in C in the late 70's,
and before that some were programming in B ("B Programming Language"),

Preceded by BCPL (which leads to the joke that the language that
supplants C will be named P)


PL-I has already been taken.  That is a pretty free-wheeling language 
compared to Fortran, where, IIRC, you had to start in the 7th column. 
Oops, hand me another punch card... :)


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


[Q] days -> months

2017-10-10 Thread Byung-Hee HWANG (황병희, 黃炳熙)
In real life, i am breeding Hanwoo(Korean cattle), about 100 head of
cattle. About 50 days ago, i got one young cattle. The name is
"Bullseye". I love Bullseye. Until the Bullseye is released by butchery,
i would like to maintain him with his age. So thus i did write some
humble code to identify his age [1]. 

By the way i did fail to chage the format "days" to "months". How? Of
course i want Python way!

Sincerely, 

[1]
https://raw.githubusercontent.com/soyeomul/Gnus/MaGnus/thanks-bullseye-age.rb.gnus

-- 
^고맙습니다 _地平天成_ 감사합니다_^))//
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Lies in education [was Re: The "loop and a half"]

2017-10-10 Thread Marko Rauhamaa
Bill :

> Steve D'Aprano wrote:
>> Bjarne Stroustrup is famous for designing one of the most
>> heavyweight, baraque, hard-to-understand, difficult-to-use
>> programming languages in common use. While C++ has many excellent
>> features, and is constrained by the need to be compatible with C, I
>> don't think many people believe that it is a well-designed language.
>
> It is a well-designed language.  It is and was carefully thought out.
> One could argue that there are perhaps "too many ways" to do a given
> thing in Python (one could say it's features are "not orthogonal"). I'm
> sure you are familiar with where the language drew its name.   I'm not
> here to "cast stones", I like Python. I just think that you shouldn't
> cast stones at C/C++.

One is allowed to have opinions and express them. We are not talking
about religion here.

I don't like everything in Python. On the whole, though, it is an
excellent language. In practice, it is the best available tool for most
programming needs I face.

There are situations where C++ is suitable. Its primary advantage over C
is the automatic generation of the virtual table. However, having
programmed in C++ for a decade or so, it has left a bad taste in my
mouth. Its core philosophy (ie, do the utmost at compile time) is
cumbersome and misplaced. Until very recently, C++ didn't offer a good
way to implement callback functions, for example.

> People started programming in C in the late 70's,

For the most part, I like C much better than C++, even though the
standards committees have been working hard to sabotage it.

> One thing you didn't bring up at all, is that the audiences for the
> languages appears to be different. You still need folks who can encode
> data structures and write device drivers, from scratch. And "woe" if
> you need performance, such as applications involving AI.

For performance-critical stuff, I use C. For the rest, I use Python and
bash. There are other excellent languages, but they don't have a real
market niche between C and Python.


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