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

2018-06-12 Thread Steven D'Aprano
On Tue, 12 Jun 2018 16:40:47 +1000, Chris Angelico wrote:

> On Tue, Jun 12, 2018 at 4:32 PM, Gregory Ewing
>  wrote:
>> There are some historical and present-day facts that don't support that
>> idea.
>>
>> * Software existed in the days before it became seen as something to be
>> sold for money per-copy. Both computer companies and programmers seemed
>> to to all right in that environment.
> 
> Third-party software? Can you give examples?
> 
> It doesn't count if the same organization (company, etc) created the
> hardware and the programming. It also doesn't count if it's hobbyists
> reprogramming their own units.

Why not? Historically, that's exactly where the software industry 
started. Commercial third-party software didn't exist until long after 
the software industry was well-established in the business market, and 
when the home computer industry began, the same process occurred again: 
the commercial third-party software market followed long afterwards, 
driven on the back of hobbyists writing their own software and sharing it 
around.


> I'm looking for examples of *third-party*
> software, of the sort that can today be saleable, but which - in this
> proposed alternate universe where copyright does not exist - would by
> force be given away for nothing.

Ah, its one of *those* challenges... "If we ignore all the facts that 
refutes my position, I challenge you to find a fact that refutes my 
position!"

*wink*

I don't think there would be any doubt that, minus copyright laws, the 
commercial third-party software industry would probably be much smaller. 
The biggest threat wouldn't be piracy in the "you wouldn't download a 
car" sense, but competitors mass duplicating your product and selling it 
more cheaply.

But even there, historically we've seen that consumers in Western 
countries will pirate software for free, they'll pay full price, but the 
majority won't pay for pirated software even if its cheaper. So its not 
clear that lack of copyright would necessarily have killed the commercial 
third-party software industry stone dead.

But to jump from there to the conclusion that there would be user-
generated software, no open source software, no public domain software, 
no corporate or academic in-house software, no freeware, no shareware, no 
hobbyist software, no freemium or advertising driven software or SAAS... 
that's a mighty big leap.



-- 
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: Posting warning message

2018-06-12 Thread Cameron Simpson

On 11Jun2018 22:51, Tamara Berger  wrote:

On Monday, June 11, 2018 at 7:24:58 PM UTC-4, Gregory Ewing wrote:

Tamara Berger wrote:
> I typed these 2 lines in the terminal:
> 192:~ TamaraB$ sudo python3
python3 -m pip install pytest

You need to enter this *single* line in the Terminal:
sudo python3 -m pip install pytest

> What does the "-m" stand for in the line of code?
It's a cmmand-line option to the python interpreter
telling it to execute a module.


Thanks, Greg. But I got a permission error. Here is my command at the prompt 
and the terminal's response.

192:~ TamaraB$ sudo python3 -m pip install pytest
Password:
The directory '/Users/TamaraB/Library/Caches/pip/http' or its parent directory 
is not owned by the current user and the cache has been disabled. Please check 
the permissions and owner of that directory. If executing pip with sudo, you 
may want sudo's -H flag.


sudo leaves the $HOME environment variable unchanged, at least on my Mac. So it 
is using your personal cache directory. And rejecting it becuse it is 
(correctly) owned by you.


The directory '/Users/TamaraB/Library/Caches/pip' or its parent directory is 
not owned by the current user and caching wheels has been disabled. check the 
permissions and owner of that directory. If executing pip with sudo, you may 
want sudo's -H flag.


Have a look at the sudo command's manual page, by running the command:

 man sudo

In that we can read this:

  -H  The -H (HOME) option option sets the HOME environment
  variable to the home directory of the target user (root by
  default) as specified by the password database.  The
  default handling of the HOME environment variable depends
  on sudoers(5) settings.  By default, sudo will set HOME if
  env_reset or always_set_home are set, or if set_home is
  set and the -s option is specified on the command line.

So the message is a reasonable suggestion, and it is suggesting that you run 
this command:


 sudo -H python3 -m pip install pytest

Regarding the other messages:


Requirement already satisfied: pytest in 
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages
Requirement already satisfied: setuptools in 
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages 
(from pytest)
Requirement already satisfied: pluggy<0.7,>=0.5 in 
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages (from 
pytest)
Requirement already satisfied: atomicwrites>=1.0 in 
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages 
(from pytest)
Requirement already satisfied: more-itertools>=4.0.0 in 
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages 
(from pytest)
Requirement already satisfied: six>=1.10.0 in 
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages 
(from pytest)
Requirement already satisfied: py>=1.5.0 in 
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages 
(from pytest)
Requirement already satisfied: attrs>=17.4.0 in 
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages 
(from pytest)


This is all fine - it is just saying that various prerequisites are already 
there.



You are using pip version 9.0.1, however version 10.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.


This is just a suggestion to upgrade pip. Since you're running pip from 
Python's "pip" builtin module this effectively suggests upgrading your Python 3 
install.  Not important or urgent.


So I'm stuck again. I thought "sudo" was supposed to take care of permissions. 
Do you have a suggestion?


Sudo isn't magic, and treating it like magic is very common, which is one 
reason I discourage unthinking use of it.


Sudo exists to let your run specific commands as root, the system superuser.  
(It also has modes to run as other users, but root is the default and also the 
most dangerous.)


When you use sudo you have almost unlimited power to change things. This is 
handy for installation activities, and also handy for doing unbound damage to 
the OS install.


I still recommend that you avoid sudo here and use pip's --user option, 
installing the packages in your personal Python tree. It will work just as well 
for almost every purpose and avoid risk to your machine's OS.


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


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

2018-06-12 Thread Marko Rauhamaa
Gregory Ewing :

> * Charging money for copies of software is not the only way to make
> money from programming. You can charge for support services. You can
> charge for writing custom one-off software. There are people who make
> a good living from doing these things.

Maybe so. It can't be denied, though, that there are business models
that would collapse without copyright laws.

So be it. If your business model doesn't work, do something else. The
society is not responsible for upholding a particular business model.

The only relevant question is, is society gaining or losing by
sustaining copyright protections? This is not a question of any
fundamental individual rights.


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


Re: Question : Input after all prompts in python

2018-06-12 Thread Bart

On 11/06/2018 12:16, Steven D'Aprano wrote:

On Mon, 11 Jun 2018 01:44:19 -0700, mohan4h wrote:


Everyone,

I am very new to python. I am trying to achieve the below in it, but i
am unable to find suitable documentation to guide me on the same.

I want to prompt 3 questions together and then get input for the first
question next to question as below.

1. Enter your name : _
2. Enter your age :
3. Enter your gender :

After showing the below prompts, the cursor waits in first question for
an input.


How else do you expect to tell the three inputs apart?

But okay.


print("1. Enter your name :")
print("2. Enter your age :")
print("3. Enter your gender :")
name = input("")
age = input("")
gender = input("")


This will do the job, eventually:

print("1. Enter your name :")
print("2. Enter your age :")
print("3. Enter your gender :")
name = input("")
age = input("")
gender = input("")

print("1. Enter your name :",name)
print("2. Enter your age :",age)
print("3. Enter your gender :",gender)

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


Re: Posting warning message

2018-06-12 Thread T Berger
On Tuesday, June 12, 2018 at 3:28:29 AM UTC-4, Cameron Simpson wrote:
> On 11Jun2018 22:51, Tamara Berger  wrote:
> >On Monday, June 11, 2018 at 7:24:58 PM UTC-4, Gregory Ewing wrote:
> >> Tamara Berger wrote:
> >> > I typed these 2 lines in the terminal:
> >> > 192:~ TamaraB$ sudo python3
> >> python3 -m pip install pytest
> >>
> >> You need to enter this *single* line in the Terminal:
> >> sudo python3 -m pip install pytest
> >>
> >> > What does the "-m" stand for in the line of code?
> >> It's a cmmand-line option to the python interpreter
> >> telling it to execute a module.
> >
> >Thanks, Greg. But I got a permission error. Here is my command at the prompt 
> >and the terminal's response.
> >
> >192:~ TamaraB$ sudo python3 -m pip install pytest
> >Password:
> >The directory '/Users/TamaraB/Library/Caches/pip/http' or its parent 
> >directory 
> >is not owned by the current user and the cache has been disabled. Please 
> >check 
> >the permissions and owner of that directory. If executing pip with sudo, you 
> >may want sudo's -H flag.
> 
> sudo leaves the $HOME environment variable unchanged, at least on my Mac. So 
> it 
> is using your personal cache directory. And rejecting it becuse it is 
> (correctly) owned by you.
> 
> >The directory '/Users/TamaraB/Library/Caches/pip' or its parent directory is 
> >not owned by the current user and caching wheels has been disabled. check 
> >the 
> >permissions and owner of that directory. If executing pip with sudo, you may 
> >want sudo's -H flag.
> 
> Have a look at the sudo command's manual page, by running the command:
> 
>   man sudo
> 
> In that we can read this:
> 
>-H  The -H (HOME) option option sets the HOME environment
>variable to the home directory of the target user (root by
>default) as specified by the password database.  The
>default handling of the HOME environment variable depends
>on sudoers(5) settings.  By default, sudo will set HOME if
>env_reset or always_set_home are set, or if set_home is
>set and the -s option is specified on the command line.
> 
> So the message is a reasonable suggestion, and it is suggesting that you run 
> this command:
> 
>   sudo -H python3 -m pip install pytest
> 
> Regarding the other messages:
> 
> >Requirement already satisfied: pytest in 
> >/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages
> >Requirement already satisfied: setuptools in 
> >/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages
> > (from pytest)
> >Requirement already satisfied: pluggy<0.7,>=0.5 in 
> >/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages
> > (from pytest)
> >Requirement already satisfied: atomicwrites>=1.0 in 
> >/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages
> > (from pytest)
> >Requirement already satisfied: more-itertools>=4.0.0 in 
> >/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages
> > (from pytest)
> >Requirement already satisfied: six>=1.10.0 in 
> >/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages
> > (from pytest)
> >Requirement already satisfied: py>=1.5.0 in 
> >/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages
> > (from pytest)
> >Requirement already satisfied: attrs>=17.4.0 in 
> >/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages
> > (from pytest)
> 
> This is all fine - it is just saying that various prerequisites are already 
> there.
> 
> >You are using pip version 9.0.1, however version 10.0.1 is available.
> >You should consider upgrading via the 'pip install --upgrade pip' command.
> 
> This is just a suggestion to upgrade pip. Since you're running pip from 
> Python's "pip" builtin module this effectively suggests upgrading your Python 
> 3 
> install.  Not important or urgent.
> 
> >So I'm stuck again. I thought "sudo" was supposed to take care of 
> >permissions. 
> >Do you have a suggestion?
> 
> Sudo isn't magic, and treating it like magic is very common, which is one 
> reason I discourage unthinking use of it.
> 
> Sudo exists to let your run specific commands as root, the system superuser.  
> (It also has modes to run as other users, but root is the default and also 
> the 
> most dangerous.)
> 
> When you use sudo you have almost unlimited power to change things. This is 
> handy for installation activities, and also handy for doing unbound damage to 
> the OS install.
> 
> I still recommend that you avoid sudo here and use pip's --user option, 
> installing the packages in your personal Python tree. It will work just as 
> well 
> for almost every purpose and avoid risk to your machine's OS.
> 
> Cheers,
> Cameron Simpson 

Thanks a lot, Cameron. I was going to try the --user option this morning, if no 
one had responded to my post.
-

Re: Posting warning message

2018-06-12 Thread T Berger
On Monday, June 11, 2018 at 7:24:58 PM UTC-4, Gregory Ewing wrote:
> Tamara Berger wrote:
> > I typed these 2 lines in the terminal:
> > 
> > 192:~ TamaraB$ sudo python3
>  > ...
> python3 -m pip install pytest
> 
> You need to enter this *single* line in the Terminal:
> 
> sudo python3 -m pip install pytest
> 
> > What does the "-m" stand for in the line of code?
> 
> It's a cmmand-line option to the python interpreter
> telling it to execute a module.
> 
> (What you did was first launch the Python interpreter and
> then tell it to run "python3 -m pip install pytest" as a
> Python statement. But it's not Python code, it's a shell
> command.)
> 
> -- 
> Greg

Thanks, Greg, for your answer. It helped me out of that hole.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Posting warning message

2018-06-12 Thread T Berger
On Tuesday, June 12, 2018 at 3:28:29 AM UTC-4, Cameron Simpson wrote:
> On 11Jun2018 22:51, Tamara Berger  wrote:
> >On Monday, June 11, 2018 at 7:24:58 PM UTC-4, Gregory Ewing wrote:
> >> Tamara Berger wrote:
> >> > I typed these 2 lines in the terminal:
> >> > 192:~ TamaraB$ sudo python3
> >> python3 -m pip install pytest
> >>
> >> You need to enter this *single* line in the Terminal:
> >> sudo python3 -m pip install pytest
> >>
> >> > What does the "-m" stand for in the line of code?
> >> It's a cmmand-line option to the python interpreter
> >> telling it to execute a module.
> >
> >Thanks, Greg. But I got a permission error. Here is my command at the prompt 
> >and the terminal's response.
> >
> >192:~ TamaraB$ sudo python3 -m pip install pytest
> >Password:
> >The directory '/Users/TamaraB/Library/Caches/pip/http' or its parent 
> >directory 
> >is not owned by the current user and the cache has been disabled. Please 
> >check 
> >the permissions and owner of that directory. If executing pip with sudo, you 
> >may want sudo's -H flag.
> 
> sudo leaves the $HOME environment variable unchanged, at least on my Mac. So 
> it 
> is using your personal cache directory. And rejecting it becuse it is 
> (correctly) owned by you.
> 
> >The directory '/Users/TamaraB/Library/Caches/pip' or its parent directory is 
> >not owned by the current user and caching wheels has been disabled. check 
> >the 
> >permissions and owner of that directory. If executing pip with sudo, you may 
> >want sudo's -H flag.
> 
> Have a look at the sudo command's manual page, by running the command:
> 
>   man sudo
> 
> In that we can read this:
> 
>-H  The -H (HOME) option option sets the HOME environment
>variable to the home directory of the target user (root by
>default) as specified by the password database.  The
>default handling of the HOME environment variable depends
>on sudoers(5) settings.  By default, sudo will set HOME if
>env_reset or always_set_home are set, or if set_home is
>set and the -s option is specified on the command line.
> 
> So the message is a reasonable suggestion, and it is suggesting that you run 
> this command:
> 
>   sudo -H python3 -m pip install pytest
> 
> Regarding the other messages:
> 
> >Requirement already satisfied: pytest in 
> >/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages
> >Requirement already satisfied: setuptools in 
> >/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages
> > (from pytest)
> >Requirement already satisfied: pluggy<0.7,>=0.5 in 
> >/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages
> > (from pytest)
> >Requirement already satisfied: atomicwrites>=1.0 in 
> >/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages
> > (from pytest)
> >Requirement already satisfied: more-itertools>=4.0.0 in 
> >/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages
> > (from pytest)
> >Requirement already satisfied: six>=1.10.0 in 
> >/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages
> > (from pytest)
> >Requirement already satisfied: py>=1.5.0 in 
> >/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages
> > (from pytest)
> >Requirement already satisfied: attrs>=17.4.0 in 
> >/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages
> > (from pytest)
> 
> This is all fine - it is just saying that various prerequisites are already 
> there.
> 
> >You are using pip version 9.0.1, however version 10.0.1 is available.
> >You should consider upgrading via the 'pip install --upgrade pip' command.
> 
> This is just a suggestion to upgrade pip. Since you're running pip from 
> Python's "pip" builtin module this effectively suggests upgrading your Python 
> 3 
> install.  Not important or urgent.
> 
> >So I'm stuck again. I thought "sudo" was supposed to take care of 
> >permissions. 
> >Do you have a suggestion?
> 
> Sudo isn't magic, and treating it like magic is very common, which is one 
> reason I discourage unthinking use of it.
> 
> Sudo exists to let your run specific commands as root, the system superuser.  
> (It also has modes to run as other users, but root is the default and also 
> the 
> most dangerous.)
> 
> When you use sudo you have almost unlimited power to change things. This is 
> handy for installation activities, and also handy for doing unbound damage to 
> the OS install.
> 
> I still recommend that you avoid sudo here and use pip's --user option, 
> installing the packages in your personal Python tree. It will work just as 
> well 
> for almost every purpose and avoid risk to your machine's OS.
> 
> Cheers,
> Cameron Simpson 

Just one more thing, Cameron. I was looking at an Apple support page, and it 
says "When you're logged in to you

Re: Question : Input after all prompts in python

2018-06-12 Thread mohan4h
On Tuesday, June 12, 2018 at 7:37:25 PM UTC+8, Bart wrote:
> On 11/06/2018 12:16, Steven D'Aprano wrote:
> > On Mon, 11 Jun 2018 01:44:19 -0700, mohan4h wrote:
> > 
> >> Everyone,
> >>
> >> I am very new to python. I am trying to achieve the below in it, but i
> >> am unable to find suitable documentation to guide me on the same.
> >>
> >> I want to prompt 3 questions together and then get input for the first
> >> question next to question as below.
> >>
> >> 1. Enter your name : _
> >> 2. Enter your age :
> >> 3. Enter your gender :
> >>
> >> After showing the below prompts, the cursor waits in first question for
> >> an input.
> > 
> > How else do you expect to tell the three inputs apart?
> > 
> > But okay.
> > 
> > 
> > print("1. Enter your name :")
> > print("2. Enter your age :")
> > print("3. Enter your gender :")
> > name = input("")
> > age = input("")
> > gender = input("")
> 
> This will do the job, eventually:
> 
> print("1. Enter your name :")
> print("2. Enter your age :")
> print("3. Enter your gender :")
> name = input("")
> age = input("")
> gender = input("")
> 
> print("1. Enter your name :",name)
> print("2. Enter your age :",age)
> print("3. Enter your gender :",gender)
> 
> -- 
> bart

Everyone,

I want to thank you all for your support, As advised Steven D'Aprano and 
Wolfgang Maier, I tried the same code in python3 and it worked like a wonder.
I would like to thank Peter Otten for the solution.

I learned something new.

Thanks for all your support.

Regards
Mohan C
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Posting warning message

2018-06-12 Thread T Berger
On Tuesday, June 12, 2018 at 3:28:29 AM UTC-4, Cameron Simpson wrote:
> On 11Jun2018 22:51, Tamara Berger  wrote:
> >On Monday, June 11, 2018 at 7:24:58 PM UTC-4, Gregory Ewing wrote:
> >> Tamara Berger wrote:
> >> > I typed these 2 lines in the terminal:
> >> > 192:~ TamaraB$ sudo python3
> >> python3 -m pip install pytest
> >>
> >> You need to enter this *single* line in the Terminal:
> >> sudo python3 -m pip install pytest
> >>
> >> > What does the "-m" stand for in the line of code?
> >> It's a cmmand-line option to the python interpreter
> >> telling it to execute a module.
> >
> >Thanks, Greg. But I got a permission error. Here is my command at the prompt 
> >and the terminal's response.
> >
> >192:~ TamaraB$ sudo python3 -m pip install pytest
> >Password:
> >The directory '/Users/TamaraB/Library/Caches/pip/http' or its parent 
> >directory 
> >is not owned by the current user and the cache has been disabled. Please 
> >check 
> >the permissions and owner of that directory. If executing pip with sudo, you 
> >may want sudo's -H flag.
> 
> sudo leaves the $HOME environment variable unchanged, at least on my Mac. So 
> it 
> is using your personal cache directory. And rejecting it becuse it is 
> (correctly) owned by you.
> 
> >The directory '/Users/TamaraB/Library/Caches/pip' or its parent directory is 
> >not owned by the current user and caching wheels has been disabled. check 
> >the 
> >permissions and owner of that directory. If executing pip with sudo, you may 
> >want sudo's -H flag.
> 
> Have a look at the sudo command's manual page, by running the command:
> 
>   man sudo
> 
> In that we can read this:
> 
>-H  The -H (HOME) option option sets the HOME environment
>variable to the home directory of the target user (root by
>default) as specified by the password database.  The
>default handling of the HOME environment variable depends
>on sudoers(5) settings.  By default, sudo will set HOME if
>env_reset or always_set_home are set, or if set_home is
>set and the -s option is specified on the command line.
> 
> So the message is a reasonable suggestion, and it is suggesting that you run 
> this command:
> 
>   sudo -H python3 -m pip install pytest
> 
> Regarding the other messages:
> 
> >Requirement already satisfied: pytest in 
> >/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages
> >Requirement already satisfied: setuptools in 
> >/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages
> > (from pytest)
> >Requirement already satisfied: pluggy<0.7,>=0.5 in 
> >/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages
> > (from pytest)
> >Requirement already satisfied: atomicwrites>=1.0 in 
> >/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages
> > (from pytest)
> >Requirement already satisfied: more-itertools>=4.0.0 in 
> >/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages
> > (from pytest)
> >Requirement already satisfied: six>=1.10.0 in 
> >/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages
> > (from pytest)
> >Requirement already satisfied: py>=1.5.0 in 
> >/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages
> > (from pytest)
> >Requirement already satisfied: attrs>=17.4.0 in 
> >/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages
> > (from pytest)
> 
> This is all fine - it is just saying that various prerequisites are already 
> there.
> 
> >You are using pip version 9.0.1, however version 10.0.1 is available.
> >You should consider upgrading via the 'pip install --upgrade pip' command.
> 
> This is just a suggestion to upgrade pip. Since you're running pip from 
> Python's "pip" builtin module this effectively suggests upgrading your Python 
> 3 
> install.  Not important or urgent.
> 
> >So I'm stuck again. I thought "sudo" was supposed to take care of 
> >permissions. 
> >Do you have a suggestion?
> 
> Sudo isn't magic, and treating it like magic is very common, which is one 
> reason I discourage unthinking use of it.
> 
> Sudo exists to let your run specific commands as root, the system superuser.  
> (It also has modes to run as other users, but root is the default and also 
> the 
> most dangerous.)
> 
> When you use sudo you have almost unlimited power to change things. This is 
> handy for installation activities, and also handy for doing unbound damage to 
> the OS install.
> 
> I still recommend that you avoid sudo here and use pip's --user option, 
> installing the packages in your personal Python tree. It will work just as 
> well 
> for almost every purpose and avoid risk to your machine's OS.
> 
> Cheers,
> Cameron Simpson 

Sorry, to bother you again. But is there some way to edit a message once its 
posted? Or do I have to delete it 

Re: Posting warning message

2018-06-12 Thread Chris Angelico
On Wed, Jun 13, 2018 at 12:17 AM, T Berger  wrote:
>
> Sorry, to bother you again. But is there some way to edit a message once its 
> posted? Or do I have to delete it and rewrite it?

Nope. And you can't delete it either.

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


Filters

2018-06-12 Thread T Berger
Why doesn't the system allow me to set filters for my own posts? I was able to 
do it once, but when I returned to the forum, I was back among the unfiltered 
posts. When I tried to reapply the filter, the option was grayed out.

Also, I've selected the option to get email updates to my posts, but the option 
seems to work only selectively.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Posting warning message

2018-06-12 Thread T Berger
On Tuesday, June 12, 2018 at 10:27:06 AM UTC-4, Chris Angelico wrote:
> On Wed, Jun 13, 2018 at 12:17 AM, T Berger  wrote:
> >
> > Sorry, to bother you again. But is there some way to edit a message once 
> > its posted? Or do I have to delete it and rewrite it?
> 
> Nope. And you can't delete it either.
> 
> ChrisA

I deleted them a number of time, then got a bar across the page indicating that 
a post had been deleted. It's nuts that you can't edit your own post.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Posting warning message

2018-06-12 Thread T Berger
On Tuesday, June 12, 2018 at 3:28:29 AM UTC-4, Cameron Simpson wrote:
> On 11Jun2018 22:51, Tamara Berger  wrote:
> >On Monday, June 11, 2018 at 7:24:58 PM UTC-4, Gregory Ewing wrote:
> >> Tamara Berger wrote:
> >> > I typed these 2 lines in the terminal:
> >> > 192:~ TamaraB$ sudo python3
> >> python3 -m pip install pytest
> >>
> >> You need to enter this *single* line in the Terminal:
> >> sudo python3 -m pip install pytest
> >>
> >> > What does the "-m" stand for in the line of code?
> >> It's a cmmand-line option to the python interpreter
> >> telling it to execute a module.
> >
> >Thanks, Greg. But I got a permission error. Here is my command at the prompt 
> >and the terminal's response.
> >
> >192:~ TamaraB$ sudo python3 -m pip install pytest
> >Password:
> >The directory '/Users/TamaraB/Library/Caches/pip/http' or its parent 
> >directory 
> >is not owned by the current user and the cache has been disabled. Please 
> >check 
> >the permissions and owner of that directory. If executing pip with sudo, you 
> >may want sudo's -H flag.
> 
> sudo leaves the $HOME environment variable unchanged, at least on my Mac. So 
> it 
> is using your personal cache directory. And rejecting it becuse it is 
> (correctly) owned by you.
> 
> >The directory '/Users/TamaraB/Library/Caches/pip' or its parent directory is 
> >not owned by the current user and caching wheels has been disabled. check 
> >the 
> >permissions and owner of that directory. If executing pip with sudo, you may 
> >want sudo's -H flag.
> 
> Have a look at the sudo command's manual page, by running the command:
> 
>   man sudo
> 
> In that we can read this:
> 
>-H  The -H (HOME) option option sets the HOME environment
>variable to the home directory of the target user (root by
>default) as specified by the password database.  The
>default handling of the HOME environment variable depends
>on sudoers(5) settings.  By default, sudo will set HOME if
>env_reset or always_set_home are set, or if set_home is
>set and the -s option is specified on the command line.
> 
> So the message is a reasonable suggestion, and it is suggesting that you run 
> this command:
> 
>   sudo -H python3 -m pip install pytest
> 
> Regarding the other messages:
> 
> >Requirement already satisfied: pytest in 
> >/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages
> >Requirement already satisfied: setuptools in 
> >/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages
> > (from pytest)
> >Requirement already satisfied: pluggy<0.7,>=0.5 in 
> >/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages
> > (from pytest)
> >Requirement already satisfied: atomicwrites>=1.0 in 
> >/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages
> > (from pytest)
> >Requirement already satisfied: more-itertools>=4.0.0 in 
> >/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages
> > (from pytest)
> >Requirement already satisfied: six>=1.10.0 in 
> >/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages
> > (from pytest)
> >Requirement already satisfied: py>=1.5.0 in 
> >/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages
> > (from pytest)
> >Requirement already satisfied: attrs>=17.4.0 in 
> >/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages
> > (from pytest)
> 
> This is all fine - it is just saying that various prerequisites are already 
> there.
> 
> >You are using pip version 9.0.1, however version 10.0.1 is available.
> >You should consider upgrading via the 'pip install --upgrade pip' command.
> 
> This is just a suggestion to upgrade pip. Since you're running pip from 
> Python's "pip" builtin module this effectively suggests upgrading your Python 
> 3 
> install.  Not important or urgent.
> 
> >So I'm stuck again. I thought "sudo" was supposed to take care of 
> >permissions. 
> >Do you have a suggestion?
> 
> Sudo isn't magic, and treating it like magic is very common, which is one 
> reason I discourage unthinking use of it.
> 
> Sudo exists to let your run specific commands as root, the system superuser.  
> (It also has modes to run as other users, but root is the default and also 
> the 
> most dangerous.)
> 
> When you use sudo you have almost unlimited power to change things. This is 
> handy for installation activities, and also handy for doing unbound damage to 
> the OS install.
> 
> I still recommend that you avoid sudo here and use pip's --user option, 
> installing the packages in your personal Python tree. It will work just as 
> well 
> for almost every purpose and avoid risk to your machine's OS.
> 
> Cheers,
> Cameron Simpson 

One more thing about PEP8. My workbook is a bit skimpy on details. Is there a 
quick way to make the edits or am

Re: Filters

2018-06-12 Thread pyotr filipivich
T Berger  on Tue, 12 Jun 2018 07:45:58 -0700 (PDT)
typed in comp.lang.python  the following:
>Why doesn't the system allow me to set filters for my own posts? I was able to 
>do it once, but when I returned to the forum, I was back among the unfiltered 
>posts. When I tried to reapply the filter, the option was grayed out.

Message-ID:
<57e2e5cf-3d17-4127-ba0b-16eaea1ab...@googlegroups.com>

That says it all.  "It is not a bug, it is a feature."

Google has totally screwed up their archiving of Usenet, and
doesn't care bugger all for those who use it.  You must conform to the
new Method of Web based Fora.

>Also, I've selected the option to get email updates to my posts, but the 
>option seems to work only selectively.

It is Google.  They will decide what is evil. and not do that.
-- 
pyotr filipivich
Next month's Panel: Graft - Boon or blessing?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Re: FULLSCREEN and DOUBLEBUF

2018-06-12 Thread Paul St George




Dennis Lee Bieber wrote:
Both may be dependent upon the actual hardware graphics board and 
the

drivers for said board.

On 11/06/2018 01:47, Gregory Ewing wrote:
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.

Thank you! Your intervention could not have been more timely. I was just 
about to throw away the screen and try again with another. I want to use 
display.flip() and thought that was dependent on being able to set 
DOUBLEBUF. The surface is fullscreen.


I had considered meddling with the config.txt to try to enable* 
HWSURFACE but from what you say, this is unnecessary. Have I understood 
you right?


Paul

* Perhaps by uncommenting #dtparam=spi=on
--
https://mail.python.org/mailman/listinfo/python-list


Re: Posting warning message

2018-06-12 Thread Grant Edwards
On 2018-06-12, Chris Angelico  wrote:
> On Wed, Jun 13, 2018 at 12:17 AM, T Berger  wrote:
>
>> Sorry, to bother you again. But is there some way to edit a message
>> once its posted? Or do I have to delete it and rewrite it?
>
> Nope. And you can't delete it either.

That depends.

If you're posting via NNTP, and your NNTP server supports CANCEL
messages, and the posting hasn't been passed on to any peers yet, then
you _can_ delete it.

But, I'd bet cash money those conditions are not true for T Berger.

-- 
Grant Edwards   grant.b.edwardsYow! Are we live or on
  at   tape?
  gmail.com

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


Re: Filters

2018-06-12 Thread Grant Edwards
On 2018-06-12, pyotr filipivich  wrote:

> It is Google.  They will decide what is evil. and not do that.

They've found it simpler to just declare than anything they do is, by
definition, therefore not evil.

-- 
Grant Edwards   grant.b.edwardsYow! There's enough money
  at   here to buy 5000 cans of
  gmail.comNoodle-Roni!

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


Re: Filters

2018-06-12 Thread Mark Lawrence

On 12/06/18 15:45, T Berger wrote:

Why doesn't the system allow me to set filters for my own posts? I was able to 
do it once, but when I returned to the forum, I was back among the unfiltered 
posts. When I tried to reapply the filter, the option was grayed out.

Also, I've selected the option to get email updates to my posts, but the option 
seems to work only selectively.



A solution is to point any (semi-)decent email client/news 
reader/whatever the things are called, at news.gmane.org and read 
hundreds of python forums and thousands of other technical forums whilst 
leaving your own inbox clear.


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

Mark Lawrence

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


[RELEASE] Python 3.7.0rc1 and 3.6.6rc1 are now available

2018-06-12 Thread Ned Deily
Python 3.7.0rc1 and 3.6.6rc1 are now available. 3.7.0rc1 is the final
planned release preview of Python 3.7, the next feature release of
Python. 3.6.6rc1 is the the release preview of the next maintenance
release of Python 3.6, the current release of Python. Assuming no
critical problems are found prior to *2018-06-27*, the scheduled
release dates for 3.7.0 and 3.6.6, no code changes are planned
between these release candidates and the final releases. These
release candidates are intended to give you the opportunity to test
the new features and bug fixes in 3.7.0 and 3.6.6 and to prepare your
projects to support them. We strongly encourage you to test your
projects and report issues found to bugs.python.org as soon as
possible. Please keep in mind that these are preview releases and,
thus, their use is not recommended for production environments.
Attention macOS users: there is now a new installer variant for macOS
10.9+ that includes a built-in version of Tcl/Tk 8.6. This variant
will become the default version when 3.7.0 releases. Check it out!

You can find these releases and more information here:
https://www.python.org/downloads/release/python-370rc1/
https://www.python.org/downloads/release/python-366rc1/

--
  Ned Deily
  n...@python.org -- []

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


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

2018-06-12 Thread Rick Johnson
Gregory Ewing wrote:

[...]

> * Charging money for copies of software is not the only way
> to make money from programming. You can charge for support
> services. You can charge for writing custom one-off
> software. There are people who make a good living from
> doing these things.

Microsoft not only demands to be paid for writing the
software *and* maintaining it, but they also demand that you
pay to have it upgraded every couple of years after it
"mysteriously" becomes exponentially more laggy and exploit
prone than usual.

 "Hmm, i wonder how that happened?"

 *SCRATCHES-HEAD*

 *LOOKS-AT-INSTRUMENT-PANEL*

 "Oh noes!" O_O

 "The software fuel tank is almost _empty_!"

How else will they convince you to buy the latest copy of
windoze 95?
-- 
https://mail.python.org/mailman/listinfo/python-list


Splitting up large python module impact on performance?

2018-06-12 Thread Bill Deegan
Greetings,

I'm doing some refactoring on a fairly large python codebase.
Some of the files are > 4000 lines long and contain many classes.

Should I expect any performance hit from splitting some of the classes out
to other files?

Thanks,
Bill
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: FULLSCREEN and DOUBLEBUF

2018-06-12 Thread Greg Ewing

Paul St George wrote:
I had considered meddling with the config.txt to try to enable* 
HWSURFACE but from what you say, this is unnecessary.


I don't really have much idea what effect HWSURFACE would have,
if any. It will certainly depend a lot on your hardware and
drivers.

My suggestion would be not to bother with it unless you're
having performance issues, and then try it to see if it
makes any difference.

Note that it's conceivable that HWSURFACE could actually
make things slower in some situations, e.g. if it results
in more movement of data between main memory and video
memory. Experimentation is the only way to be sure.

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


Re: Posting warning message

2018-06-12 Thread Michael Torrie
On 06/12/2018 08:48 AM, T Berger wrote:
> I deleted them a number of time, then got a bar across the page indicating 
> that a post had been deleted. It's nuts that you can't edit your own post.

This "forum" is actually a mailing list mirrored to Usenet, so whatever
you post gets instantly emailed out to the list members, and also gets
sent to all the Usenet servers throughout the world.  So by the time you
want to edit your post, it's already in my email box.  You're accessing
it via Google Groups, but it's not really an online forum.  It just
looks like one.  Google Groups may let you delete your message within
Groups, but out here on the mailing list where I am, and on Usenet where
others read, you definitely can't.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Posting warning message

2018-06-12 Thread Cameron Simpson

On 12Jun2018 07:48, Tamara Berger  wrote:

On Tuesday, June 12, 2018 at 10:27:06 AM UTC-4, Chris Angelico wrote:

On Wed, Jun 13, 2018 at 12:17 AM, T Berger  wrote:
> Sorry, to bother you again. But is there some way to edit a message once 
> its posted? Or do I have to delete it and rewrite it?


Nope. And you can't delete it either.


I deleted them a number of time, then got a bar across the page indicating 
that a post had been deleted.


As has been mentioned, any "delete" you do on Google Groups is pretty limited, 
possibly only to Google's copy. The message has already gone planetwide.


Google's delete _may_ propagate to the rest of usenet, and _may_ be obeyed in 
some of those places. But it certainly doesn't propagate to the mailing list, 
and even if it did, those of use who pull the list down to our personal mail 
folders would ignore such a thing.



It's nuts that you can't edit your own post.


No, it is actually good:

- there's not one copy of your post that google can modify: it gets copied 
 planet wide, to thousands or millions of independent places


- how do people discover that you've modified a post, to review your change?  
 how do their replies before your modification make any kind of sense if the 
 preceeding message is no longer what they replied to?


The correct way to correct a post is to follow up to it (reply to it) with a 
correction or clarification. That way everyone sees the change/fix as a new 
messge. And it works even though the messages get copied everywhere, because 
all that has to happen is to copy your own new message.


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


Re: Posting warning message

2018-06-12 Thread Cameron Simpson

On 12Jun2018 07:14, Tamara Berger  wrote:

On Tuesday, June 12, 2018 at 3:28:29 AM UTC-4, Cameron Simpson wrote:

On 11Jun2018 22:51, Tamara Berger  wrote:

[...]

>192:~ TamaraB$ sudo python3 -m pip install pytest
>Password:
>The directory '/Users/TamaraB/Library/Caches/pip/http' or its parent directory
>is not owned by the current user and the cache has been disabled. Please check
>the permissions and owner of that directory. If executing pip with sudo, you
>may want sudo's -H flag.

sudo leaves the $HOME environment variable unchanged, at least on my Mac. So it
is using your personal cache directory. And rejecting it becuse it is
(correctly) owned by you.

[...]


Just one more thing, Cameron. I was looking at an Apple support page, and it says 
"When you're logged in to your Mac using an administrator account, you can use the 
sudo command in the Terminal app to execute commands as a different user, such as the 
root user." (https://support.apple.com/en-us/HT202035). I am logged in as 
administrator. So why isn't sudo working for me?


Please trim the quoted material of the irrelevant bits. Like the above. It 
makes things managable for others.


Sudo is working just fine: it is running pip as the root user. That's _all_ it 
does.


Pip itself makes certain sanity checks before it proceeds, and here it is 
complaining that its cache directory is not entirely owned by the user it is 
running as (root). That is because without the -H option it is trying to use 
_your_ cache directory.


Now, as root, it _could_ tread all over that directory with updates. But that 
would be rude, specificly because later, when _you_ go to run pip without sudo 
and with the --user option, portions of that cache directory will not be owned 
by you, and may not be readable or modifiable etc. So it refuses.



P.S. How would I make the link I provided live?


What link? This is why we trim quoted text and reply below the relevant bit 
directly: I don't know what link you provided or even whether it is there, just 
buried in the huge quoted text. Just cite it again, eg:


 How would I make this link (link here) live?

And then, of course, tell us what "live" means :-)

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


pep8 Re: Posting warning message

2018-06-12 Thread Cameron Simpson

On 12Jun2018 07:51, Tamara Berger  wrote:
[... snip ...]
One more thing about PEP8. My workbook is a bit skimpy on details. Is there a 
quick way to make the edits


PEP8 is a style recommendation for Python code:

 https://www.python.org/dev/peps/pep-0008/

It is followed pretty rigorously in the Python standard library, and most 
Python code follows a lot of it as a matter of good practice, in that (a) it is 
a fairly good style, producing easy to read code and (b) when everyone uses the 
same or similar styes, we all find other people's code easier to read.


But it is not enforced.

There are several "lint" tools around which will look at your code and complain 
about violations of PEP8 and various other constraints generally held to be 
good to obey, particularly some kinds of initialisation errors and other 
practices that while syntacticly legal may indicate bugs or lead to header to 
debug or maintain code.


Also, some text editors have facilities for autostyling code, sometimes as you 
type it and sometimes as a final step when you save the modified file.


For example, there are tools like autopep8 (https://pypi.org/project/autopep8/) 
which will modify python code directly to apply the PEP8 style.


Personally, I run a few lint commands against my Python code by hand, and hand 
repair. Typical workflow goes:


- modify code for whatever reason (add feature, fix bugs, etc) and test

- when happy, _then_ run a lint tool and tidy up most of what it reports

- _then_ instal the code where other things may use it (eg pip install)

My personal kit has a "lint" shell script:

 https://bitbucket.org/cameron_simpson/css/src/tip/bin-cs/lint

which runs my preferred linters against code files, and for Python it runs:

- pyflakes: https://pypi.org/project/pyflakes/

- pep8: https://pypi.org/project/pep8/

- pylint: https://pypi.org/project/pylint/, 
 https://pylint.readthedocs.io/en/latest/


These can all be installed using pip:

 pip install --user pyflakes pep8 pylint

As you can see from my lint script I run them with various options that 
oveeride their default checks to better match my preffered code style.



or am I supposed to root around for my module and make the edits one by one?


Finally, no you don't normally root around and change an installed module.  
Instead, modify your original copy and reinstall the newer version!


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


Re: Splitting up large python module impact on performance?

2018-06-12 Thread Cameron Simpson

On 12Jun2018 15:00, Bill Deegan  wrote:

I'm doing some refactoring on a fairly large python codebase.
Some of the files are > 4000 lines long and contain many classes.

Should I expect any performance hit from splitting some of the classes out
to other files?


In general, nothing significant. Yes, your programs will load more files than 
before. But only once per invocation.


If you really have concerns here you would need to measure the change, not just 
in a stub "import old_module and quit" vs "import new module in pieces and 
quit" but against a larger program doing significant work. The former will let 
you measure how big the impact generally is, but the latter will tell you if it 
matters.


Also, where does the cost go? In reading the .py code, or in compiling the code 
to whatever internal form your Python interpreter runs against?


If the (time) cost is greater for the compilation versus the opening a few 
files, then you might actually win with the breakup if most programmes do not 
need to import _all_ the library pieces.


I think I'm saying: don't worry unless your applications are very time critical 
(eg invoked very frequently and/or doing almost nothing after the "import" 
phase) or you notice a significant slowdown after your changes. And it is 
usually easier to stick things back together than it was to pull them apart if 
that happens.


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


Re: Splitting up large python module impact on performance?

2018-06-12 Thread Chris Angelico
On Wed, Jun 13, 2018 at 10:32 AM, Cameron Simpson  wrote:
> I think I'm saying: don't worry unless your applications are very time
> critical (eg invoked very frequently and/or doing almost nothing after the
> "import" phase) or you notice a significant slowdown after your changes. And
> it is usually easier to stick things back together than it was to pull them
> apart if that happens.

^^ This.

You may find some speed-ups from loading only the parts you want. You
may find some slowdowns from extra levels of indirection. But more
than likely, neither matters. Design your code to be logical. If
splitting the files up lets you more logically organize your code, do
it; if it's arbitrary (piece1, piece2, piece3), don't.

A general rule for refactoring: For any piece of code you could
describe, you should be able to say instantly which file it belongs
in. That way, when you notice a behavioural bug, you go "oh that's in
class X, so I need to edit file Y". If you can't do that, refactoring
your code may help.

There are no arbitrary file size limits in Python. Four thousand lines
of code is fine if they logically go together; you could go as far as
ten thousand or even more, and it won't be a problem. Split things up
exactly as far as they logically need to be split, and no further.

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


Re: pep8 Re: Posting warning message

2018-06-12 Thread Gregory Ewing

Cameron Simpson wrote:

PEP8 is a style recommendation for Python code:

 https://www.python.org/dev/peps/pep-0008/


Specifically, it's a style guide for *code in the Python
standard library*, as it says in the Introduction:


This document gives coding conventions for the Python code comprising

> the standard library in the main Python distribution.

Some of its recommendations are also good to follow in
general Python code, but whether you do so is entirely
up to you.

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


Re: pep8 Re: Posting warning message

2018-06-12 Thread Chris Angelico
On Wed, Jun 13, 2018 at 10:46 AM, Gregory Ewing
 wrote:
> Cameron Simpson wrote:
>>
>> PEP8 is a style recommendation for Python code:
>>
>>  https://www.python.org/dev/peps/pep-0008/
>
>
> Specifically, it's a style guide for *code in the Python
> standard library*, as it says in the Introduction:
>
>> This document gives coding conventions for the Python code comprising
>
>> the standard library in the main Python distribution.
>
> Some of its recommendations are also good to follow in
> general Python code, but whether you do so is entirely
> up to you.

Many of its recommendations are good to follow in code written in
other languages, too :)

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


Re: Index of entity in List with a Condition

2018-06-12 Thread Cameron Simpson

On 11Jun2018 13:48, Subhabrata Banerjee  wrote:

I have the following sentence,

"Donald Trump is the president of United States of America".

I am trying to extract the index 'of', not only for single but also
for its multi-occurance (if they occur), from the list of words of the
string, made by simply splitting the sentence.
index1=[index for index, value in enumerate(words) if value == "of"],
where words=sentence.split()

I could do this part more or less nicely.

But I am trying to say if the list of words has the words "United"
and "States" and it has "of " in the sentence then the previous
word before of is, president.

I am confused how may I write this, if any one may help it.


You will probably have to drop the list comprehension and go with something 
more elaborate.


Also, lists have an "index" method:

 >>> L = [4,5,6]
 >>> L.index(5)
 1

though it doesn't solve your indexing problems on its own.

I would be inclined to deconstuct the sentence into a cross linked list of 
elements. Consider making a simple class to encapsulate the knowledge about 
each word (totally untested):


 class Word:
   def __init__(word):
 self.word = word

 words = []
 for index, word in sentence.split():
   W = Word(word)
   W.index = index
   words.append(W)
   W.wordlist = words

Now you have a list of Word objects, each of which knows its list position 
_and_ also knows about the list itself, _and_ you have the list of Word objects 
correspnding to your sentence words.


You'll notice we can just hang whatever attributes we like off these "Word" 
objects: we added a .wordlist and .index on the fly. It isn't great formal 
object design, but it makes building things up very easy.


You can add methods or properties to your class, such as ".next":

 @property
 def next(self):
   return self.wordlist[self.index - 1]

and so forth. That will let you write expressions about Words:

 for W in wordlist:
   if W.word == 'of' and W.next.word == 'the' and W.next.next.word == 'United' 
...:
 if W.previous.word != 'president':
   ... oooh, unexpected preceeding word! ...

You can see that you could also write methods like "is_preceeded_by":

 def is_preceed_by(self, word2):
   return self.previous.word == word2

and test "W.is_preceeded_by('president')".

In short, write out what you would like to express. Then write methods that 
implement the smaller parts of what you just wrote.


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


Re: Splitting up large python module impact on performance?

2018-06-12 Thread Gregory Ewing

Bill Deegan wrote:

Should I expect any performance hit from splitting some of the classes out
to other files?


I doubt it. Time taken to load modules is mostly dependent on
the total amount of code, not how many files it lives in.

If you had a *very* large number of tiny files, it might be a
bit slower due to all the stat calls required, but I wouldn't
worry about it too much. Just structure you code in a way that
makes sense, and deal with performance problems if and when
the occur.

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


Re: Splitting up large python module impact on performance?

2018-06-12 Thread Steven D'Aprano
On Tue, 12 Jun 2018 15:00:44 -0700, Bill Deegan wrote:

> Greetings,
> 
> I'm doing some refactoring on a fairly large python codebase. Some of
> the files are > 4000 lines long and contain many classes.
> 
> Should I expect any performance hit from splitting some of the classes
> out to other files?

Depends on whether you split it out to 4000 one-line files or 10 100 line 
files.

But in practice, no, there will be no runtime performance hit aside from 
the very small cost of needing to import X files instead of a single 
file. The actual performance of the classes themselves should be 
unchanged.

However, you'll need to be careful to manage circular dependencies, where 
module A depends on B which depends on C which depends on A. (Linear 
dependencies are fine: A depends on B which depends on C, which depends 
on nothing.) Circular dependencies can be managed in various ways, but 
the best way to manage them is to avoid them altogether.

In other words: if your classes are very tightly coupled, you might have 
a hard time splitting them into multiple files. If they are loosely 
coupled, you shouldn't have any trouble at all.


-- 
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


helpfulness Re: Index of entity in List with a Condition

2018-06-12 Thread Cameron Simpson

On 11Jun2018 18:03, Rick Johnson  wrote:

subhaba...@gmail.com wrote:

I have the following sentence,

"Donald Trump is the president of United States of America".

[...]


Typically when you ask us to do your homework for you, it is
considered bad taste to present the teacher's assignment
verbatim and then expect that we will provide a turn-key
solution. And although you _did_ provide some sort of
"Pythony looking" code, unfortunately the code is poorly
formatted.


Rick, this is unhelpful.

Firstly, Subhabrata isn't getting us to do his work for him; he's posted here 
several times in the past and clearly is working on probems in good faith with 
demonstrated willingness _and_ ability to think things through in detail. He 
comes here having tried things, with specific questions following from problems 
he has encountered.


Secondly, his question is reasonably expressed. Lacking a lot of code, it is 
perfectly feasible and reasonable to respond in general prose form instead of 
purely code.


Finally, adding in political editorial in your code response doesn't improve 
the discussion environment.


If you want to encourage more detail from him, just ask without overtones.

If you're unwilling to engage with his post for whatever criteria, just don't 
engage. Easy!


It is better for all concerned, both the OP and we the list readers.

Thanks,
Cameron Simpson 


Next time, please try to present your question in a formal,
well-though-out manner. Source code should either be
executable, or conspicuously labeled as psuedo code. Not
because we don't _know_ what pseudo code looks like, but
because we can intuit your level of knowledge from the
presentation. And i gotta tell ya, this presentation is not
exactly screaming valedictorian -- but i digress.

Now, as to your problem...

Well, first, hold on a second, because, i want to correct your
sentence. You presented your target string as:

   "Donald Trump is the president of United States of America"

No-no-no. This sentence seems to be missing a few things.
The first is a three letter word. And let's insert that word
now...

   >>> s = "Donald Trump is the president of United States of America"
   >>> s.index('U')
   33
   >>> s = s[:33] + 'the ' + s[33:]
   >>> s
   'Donald Trump is the president of the United States of America'

Ah yes. You see how much more smoothly that rolls off the
ol' tongue? Now, in the interest of public awareness, let's
add an addendum, shall we?

   >>> s += ", who was duly elected to office by the great people of this fine 
country in a free and open election. And no amount of whining; pouting; sniveling; conspiratorial 
hoopla; flailing of the arms; the legs; or any combination thereof for that matter; will change 
the reality that Donald *BIG JOHN* Trump is now the president of this fine country. Seriously 
folks. It's been an interesting ride. But the circus is over now. Elvis left the building over a 
_year_ ago. Heck, Jimmy Hoffa has already rolled over in his grave *THREE* times! But most 
disturbing of all, is that the dozens of emaciated cats trapped in each of your apartments are on 
the verge of cannibalism (yesh, you forgot about them, didn't you?), and the toxic ammonia fumes 
are melting the paint off the walls! It's time to go home and lick your wounds folks. Better luck 
next time. Aloha."

Whew! (*wipes brow*) Now that we've gotten all of that out of
the way... what was your question again? o_O
-- https://mail.python.org/mailman/listinfo/python-list

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


Re: Splitting up large python module impact on performance?

2018-06-12 Thread Rick Johnson
Bill Deegan wrote:
> I'm doing some refactoring on a fairly large python
> codebase. Some of the files are > 4000 lines long and
> contain many classes.

I would argue that files of such size are a total pain to
navigate and thus, edit. I prefer to place only one -- or
only a handful of classes -- in each file. One class per
file is _most_ preferred. But if you have a small group of
classes that are closely dependent on one another, and, the
source definitions can fit comfortably in a single file,
well then, i say do it. You just have to decide what is
comfortable for _you_; your coworkers; and anyone who may be
forced to maintain your code in the future.

When in doubt, and when it comes to style issues, there is
one universal rule you should always strive to follow, and
that rule is to be _consistent_. PEP8 underscores the
importance of consistency, and you may want to read it.

> Should I expect any performance hit from splitting some of
> the classes out to other files?

I think you should worry less about the startup performance
hit and more about the possibility of circular imports. I'm
not a big fan of Python's import or packaging systems, as
neither mesh nicely with my style of programming.

But i've found some ways to work around them...

So if you're using the OOP paradigm (like i am), and if you
write your OOP code in a strict formal style (hail java!),
then you can leverage some of the machinery of OOP to get
_around_ the limitations inherent in the aforementioned
components of the Python language. 

I may exaggerate on this a bit more if you're interested.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Splitting up large python module impact on performance?

2018-06-12 Thread Chris Angelico
On Wed, Jun 13, 2018 at 1:23 PM, Rick Johnson
 wrote:
> Bill Deegan wrote:
>> I'm doing some refactoring on a fairly large python
>> codebase. Some of the files are > 4000 lines long and
>> contain many classes.
>
> I would argue that files of such size are a total pain to
> navigate and thus, edit. I prefer to place only one -- or
> only a handful of classes -- in each file. One class per
> file is _most_ preferred. But if you have a small group of
> classes that are closely dependent on one another, and, the
> source definitions can fit comfortably in a single file,
> well then, i say do it. You just have to decide what is
> comfortable for _you_; your coworkers; and anyone who may be
> forced to maintain your code in the future.

A few thousand lines in a file is only a problem if you're using an
editor that lacks a Find feature. Or if you use bad function/class
names that you can't search for.

> When in doubt, and when it comes to style issues, there is
> one universal rule you should always strive to follow, and
> that rule is to be _consistent_. PEP8 underscores the
> importance of consistency, and you may want to read it.

Yep! It does. Let me see...

https://www.python.org/dev/peps/pep-0008/#a-foolish-consistency-is-the-hobgoblin-of-little-minds

"""However, know when to be inconsistent -- sometimes style guide
recommendations just aren't applicable."""

> I may exaggerate on this a bit more if you're interested.

Isn't it normal for you to exaggerate everything?

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


Re: pep8 Re: Posting warning message

2018-06-12 Thread Tamara Berger
Hi Cameron,

Thanks for the in-depth answer. I'm going to have to read it
carefully, with the help of a Python glossary. Some of the terms you
use are new to me.

>or am I supposed to root around for my module and make the edits one by one?

I was trying to be amusing and didn't get my point across.

>Finally, no you don't normally root around and change an installed module.
>Instead, modify your original copy and reinstall the newer version!

What I meant was, do I have to open the file, search for, e.g., colons
and insert space after them? These were the sorts of picayune errors
picked up by PEP8 on my program. I deliberately omit such spaces when
I code because I like to do as little unnecessary work as possible.
There is enough repetitive coding as it is. I know some IDEs have word
completion suggestion for variables, etc, that the user creates. But
I'm practicing in barebones IDLE and that means a lot of extra work.

Thanks,

Tamara

On Tue, Jun 12, 2018 at 8:17 PM Cameron Simpson  wrote:
>
> On 12Jun2018 07:51, Tamara Berger  wrote:
> [... snip ...]
> >One more thing about PEP8. My workbook is a bit skimpy on details. Is there a
> >quick way to make the edits
>
> PEP8 is a style recommendation for Python code:
>
>   https://www.python.org/dev/peps/pep-0008/
>
> It is followed pretty rigorously in the Python standard library, and most
> Python code follows a lot of it as a matter of good practice, in that (a) it 
> is
> a fairly good style, producing easy to read code and (b) when everyone uses 
> the
> same or similar styes, we all find other people's code easier to read.
>
> But it is not enforced.
>
> There are several "lint" tools around which will look at your code and 
> complain
> about violations of PEP8 and various other constraints generally held to be
> good to obey, particularly some kinds of initialisation errors and other
> practices that while syntacticly legal may indicate bugs or lead to header to
> debug or maintain code.
>
> Also, some text editors have facilities for autostyling code, sometimes as you
> type it and sometimes as a final step when you save the modified file.
>
> For example, there are tools like autopep8 
> (https://pypi.org/project/autopep8/)
> which will modify python code directly to apply the PEP8 style.
>
> Personally, I run a few lint commands against my Python code by hand, and hand
> repair. Typical workflow goes:
>
> - modify code for whatever reason (add feature, fix bugs, etc) and test
>
> - when happy, _then_ run a lint tool and tidy up most of what it reports
>
> - _then_ instal the code where other things may use it (eg pip install)
>
> My personal kit has a "lint" shell script:
>
>   https://bitbucket.org/cameron_simpson/css/src/tip/bin-cs/lint
>
> which runs my preferred linters against code files, and for Python it runs:
>
> - pyflakes: https://pypi.org/project/pyflakes/
>
> - pep8: https://pypi.org/project/pep8/
>
> - pylint: https://pypi.org/project/pylint/,
>   https://pylint.readthedocs.io/en/latest/
>
> These can all be installed using pip:
>
>   pip install --user pyflakes pep8 pylint
>
> As you can see from my lint script I run them with various options that
> oveeride their default checks to better match my preffered code style.
>
> >or am I supposed to root around for my module and make the edits one by one?
>
> Finally, no you don't normally root around and change an installed module.
> Instead, modify your original copy and reinstall the newer version!
>
> Cheers,
> Cameron Simpson 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Splitting up large python module impact on performance?

2018-06-12 Thread Cameron Simpson

On 13Jun2018 13:35, Chris Angelico  wrote:

On Wed, Jun 13, 2018 at 1:23 PM, Rick Johnson
 wrote:

Bill Deegan wrote:

I'm doing some refactoring on a fairly large python
codebase. Some of the files are > 4000 lines long and
contain many classes.


I would argue that files of such size are a total pain to
navigate and thus, edit. I prefer to place only one -- or
only a handful of classes -- in each file. One class per
file is _most_ preferred. But if you have a small group of
classes that are closely dependent on one another, and, the
source definitions can fit comfortably in a single file,
well then, i say do it. You just have to decide what is
comfortable for _you_; your coworkers; and anyone who may be
forced to maintain your code in the future.


A few thousand lines in a file is only a problem if you're using an
editor that lacks a Find feature. Or if you use bad function/class
names that you can't search for.


I was going to say something along these lines, but to some extent this feels 
like an unfair finger pointing exercise. Huge files can be a PITA; having 
something that aids moving around them reduces the pain, but doesn't remove the 
fact that sometimes something is too big.


The flip side is that editor support is amazingly important, or amazingly 
useful.


I'm a long time vi user, and its tags feature is outstandingly useful (go to 
identifier, type ctlr-[, you're transported to the file and line defining it, 
with luck).  I recently spent some time updating my support for this, getting 
ctags to run whenever I save a file, with good context for what to tag and 
not).


Recently part of that movitation came from spending a year as a software 
engineer in a fast moving agile environment, and seeing first hand just how 
much an advantage good tooling can be. Editor support. Multiple panes, 
autoformat on save, vim extensions for finding files (big codebase, many many 
files in a deep tree).


Tools matter, it turns out.


"""However, know when to be inconsistent -- sometimes style guide
recommendations just aren't applicable."""


I may exaggerate on this a bit more if you're interested.


Isn't it normal for you to exaggerate everything?


Shhh! Don't discourage his restraint!

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


Re: Index of entity in List with a Condition

2018-06-12 Thread subhabangalore
On Wednesday, June 13, 2018 at 6:30:45 AM UTC+5:30, Cameron Simpson wrote:
> On 11Jun2018 13:48, Subhabrata Banerjee wrote:
> >I have the following sentence,
> >
> >"Donald Trump is the president of United States of America".
> >
> >I am trying to extract the index 'of', not only for single but also
> >for its multi-occurance (if they occur), from the list of words of the
> >string, made by simply splitting the sentence.
> > index1=[index for index, value in enumerate(words) if value == "of"],
> >where words=sentence.split()
> >
> >I could do this part more or less nicely.
> >
> >But I am trying to say if the list of words has the words "United"
> >and "States" and it has "of " in the sentence then the previous
> >word before of is, president.
> >
> >I am confused how may I write this, if any one may help it.
> 
> You will probably have to drop the list comprehension and go with something 
> more elaborate.
> 
> Also, lists have an "index" method:
> 
>   >>> L = [4,5,6]
>   >>> L.index(5)
>   1
> 
> though it doesn't solve your indexing problems on its own.
> 
> I would be inclined to deconstuct the sentence into a cross linked list of 
> elements. Consider making a simple class to encapsulate the knowledge about 
> each word (totally untested):
> 
>   class Word:
> def __init__(word):
>   self.word = word
> 
>   words = []
>   for index, word in sentence.split():
> W = Word(word)
> W.index = index
> words.append(W)
> W.wordlist = words
> 
> Now you have a list of Word objects, each of which knows its list position 
> _and_ also knows about the list itself, _and_ you have the list of Word 
> objects 
> correspnding to your sentence words.
> 
> You'll notice we can just hang whatever attributes we like off these "Word" 
> objects: we added a .wordlist and .index on the fly. It isn't great formal 
> object design, but it makes building things up very easy.
> 
> You can add methods or properties to your class, such as ".next":
> 
>   @property
>   def next(self):
> return self.wordlist[self.index - 1]
> 
> and so forth. That will let you write expressions about Words:
> 
>   for W in wordlist:
> if W.word == 'of' and W.next.word == 'the' and W.next.next.word == 
> 'United' ...:
>   if W.previous.word != 'president':
> ... oooh, unexpected preceeding word! ...
> 
> You can see that you could also write methods like "is_preceeded_by":
> 
>   def is_preceed_by(self, word2):
> return self.previous.word == word2
> 
> and test "W.is_preceeded_by('president')".
> 
> In short, write out what you would like to express. Then write methods that 
> implement the smaller parts of what you just wrote.
> 
> Cheers,
> Cameron Simpson https://mail.python.org/mailman/listinfo/python-list


Re: Splitting up large python module impact on performance?

2018-06-12 Thread Rick Johnson
On Tuesday, June 12, 2018 at 10:35:47 PM UTC-5, Chris Angelico wrote:
[...]
> A few thousand lines in a file is only a problem if you're
> using an editor that lacks a Find feature. Or if you use
> bad function/class names that you can't search for.

I'm unaware of any text editor that doesn't have a find
feature. But, in a any event, the real problem is not a lack
of features, no, it's a matter of reducing the mental load.
The smaller the file, the less "off screen" data the
programmer must consider at any one time during the editing
process.

Say for instance, you want to add a new symbol, and the
symbol is going in the module namespace. Okay. Seems simple
enough, right? But if your file contains thousands of lines
of code, you can't determine with any degree of certainly
(unless you have a photographic memory!), if the name is
already assigned.

Sure, it only takes a few seconds to (1) bring up the find
feature, (2) type in the symbol, and (3) do the search. But
as programmers we are constantly inventing and assigning
names. And if your modules are so big that you have to bring
up a search tool everytime a new name needs to be assigned,
well, then, i cannot image that workflow being conducive to
any professional environment.

But knowing Chris, we can only assume that he has a custom
MUD solution. Who knows!

> > When in doubt, and when it comes to style issues, there is
> > one universal rule you should always strive to follow, and
> > that rule is to be _consistent_. PEP8 underscores the
> > importance of consistency, and you may want to read it.
> 
> Yep! It does. Let me see...
> 
> [snip link]
> 
> """However, know when to be inconsistent -- sometimes style
> guide recommendations just aren't applicable."""

Hey. Don't blame me. Blame Monty.

> > I may exaggerate on this a bit more if you're interested.
> 
> Isn't it normal for you to exaggerate everything?

Nothing about me is "normal", Chris. 

Haven't you noticed?

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


Re: Splitting up large python module impact on performance?

2018-06-12 Thread Chris Angelico
On Wed, Jun 13, 2018 at 2:15 PM, Rick Johnson
 wrote:
> On Tuesday, June 12, 2018 at 10:35:47 PM UTC-5, Chris Angelico wrote:
> [...]
>> A few thousand lines in a file is only a problem if you're
>> using an editor that lacks a Find feature. Or if you use
>> bad function/class names that you can't search for.
>
> I'm unaware of any text editor that doesn't have a find
> feature. But, in a any event, the real problem is not a lack
> of features, no, it's a matter of reducing the mental load.
> The smaller the file, the less "off screen" data the
> programmer must consider at any one time during the editing
> process.
>
> Say for instance, you want to add a new symbol, and the
> symbol is going in the module namespace. Okay. Seems simple
> enough, right? But if your file contains thousands of lines
> of code, you can't determine with any degree of certainly
> (unless you have a photographic memory!), if the name is
> already assigned.
>
> Sure, it only takes a few seconds to (1) bring up the find
> feature, (2) type in the symbol, and (3) do the search. But
> as programmers we are constantly inventing and assigning
> names. And if your modules are so big that you have to bring
> up a search tool everytime a new name needs to be assigned,
> well, then, i cannot image that workflow being conducive to
> any professional environment.

If your names are at all sane, the mere fact that the feature doesn't
exist is proof that the name doesn't exist.

Oh wait, your code isn't anything remotely sane. But for the rest of
us, large files aren't a problem.

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


Re: Posting warning message

2018-06-12 Thread Tamara Berger
On Tue, Jun 12, 2018 at 7:57 PM Cameron Simpson  wrote:
>
> On 12Jun2018 07:14, Tamara Berger  wrote:

> >Just one more thing, Cameron. I was looking at an Apple support page, and it 
> >says "When you're logged in to your Mac using an administrator account, you 
> >can use the sudo command in the Terminal app to execute commands as a 
> >different user, such as the root user." 
> >(https://support.apple.com/en-us/HT202035). I am logged in as administrator. 
> >So why isn't sudo working for me?
>
> >P.S. How would I make the link I provided live?
>
> What link? This is why we trim quoted text and reply below the relevant bit 
> directly: I don't know what link you provided or even whether it is there, 
> just buried in the huge quoted text. Just cite it again, eg:
>
>   How would I make this link (link here) live?

The link is above, in the first paragraph, beginning with the words
"Just one more thing, Cameron."

> And then, of course, tell us what "live" means :-)

Live means live. It is not a word I created. It means that the link
has been activated, so clicking on it will take you to the associated
page. Here is a definition from www.yourdictionary.com/live-link.
"Live Link - Computer Definition: An active text or graphic link on a
Web page. Clicking the link redirects the user to another Web page or
a document or image." The link to the definition I just copied into
this paragraph is not live because clicking on it will not do
anything.

This question became moot when I posted my message, because that
action activated the link. That is why I asked in my next post how one
can edit one's own messages, because  at that point I would have
deleted this post.

Thanks,

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


Re: pep8 Re: Posting warning message

2018-06-12 Thread Cameron Simpson

On 13Jun2018 00:05, Tamara Berger  wrote:

Thanks for the in-depth answer. I'm going to have to read it
carefully, with the help of a Python glossary. Some of the terms you
use are new to me.


No worries. Just ask if you don't find definitions.

BTW, a "lint" program, or "linter" is a program for reporting on style trivia, 
trivial logic errors like variable used before defined (or never defined, which 
is often a typing error misspelling a variable or function name), and things 
that look like they might be bugs (a common mistake of mine is constructing 
exceptions like logging calls, and one of my linters has found dozens of these 
for me.)



or am I supposed to root around for my module and make the edits one by one?


I was trying to be amusing and didn't get my point across.


Ah, ok then. Easy for stuff like that to fall flat in email.


Finally, no you don't normally root around and change an installed module.
Instead, modify your original copy and reinstall the newer version!


What I meant was, do I have to open the file, search for, e.g., colons
and insert space after them? These were the sorts of picayune errors
picked up by PEP8 on my program. I deliberately omit such spaces when
I code because I like to do as little unnecessary work as possible.
There is enough repetitive coding as it is. I know some IDEs have word
completion suggestion for variables, etc, that the user creates. But
I'm practicing in barebones IDLE and that means a lot of extra work.


Regrettably, yes, unless you're using an editor that has autoformatting 
support. Learn typing habits which minimise stuff like that, it saves going 
back later.


I don't use IDEs on the whole, and I don't use an autoformatter for Python. My 
environment tends to be an editor window and a shell to run things from (thus: 
2 terminals, one running vim and one running a shell).


Training your fingers to do the trivia reflexively helps. And leaving the 
linting until _after_ you've got your code working correctly helps, because you 
aren't changing tasks midstream and you are linting code you've deleted or 
changed :-)


An editor with syntax support can help. I use vi or vim, and its syntax support 
is fairly crude. Two things its does have which I use a lot is autoindent (as 
simple as starting the next line at the same indent as the one I just 
completed) and syntax highlighting, which colours keywords and identifiers and 
strings differently. When you make trivial mistakes like not closing a quote or 
misspelling a keyword or leaving off a colon there is often a visual cue.


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


Re: Posting warning message

2018-06-12 Thread Tamara Berger
On Tue, Jun 12, 2018 at 7:50 PM Cameron Simpson  wrote:
>
> On 12Jun2018 07:48, Tamara Berger  wrote:
> >
> >> On Wed, Jun 13, 2018 at 12:17 AM, T Berger  wrote:
> >> > Sorry, to bother you again. But is there some way to edit a message once
> >> > its posted? Or do I have to delete it and rewrite it?
> >>
> >> Nope. And you can't delete it either.
> >
> >I deleted them a number of time, then got a bar across the page indicating
> >that a post had been deleted.
>
> As has been mentioned, any "delete" you do on Google Groups is pretty limited,
> possibly only to Google's copy. The message has already gone planetwide.
>
> Google's delete _may_ propagate to the rest of usenet, and _may_ be obeyed in
> some of those places. But it certainly doesn't propagate to the mailing list,
> and even if it did, those of use who pull the list down to our personal mail
> folders would ignore such a thing.
>
> >It's nuts that you can't edit your own post.
>
> No, it is actually good:
>
> - there's not one copy of your post that google can modify: it gets copied
>   planet wide, to thousands or millions of independent places
>
> - how do people discover that you've modified a post, to review your change?
>   how do their replies before your modification make any kind of sense if the
>   preceeding message is no longer what they replied to?

I  just meant edit within the moment or two after you've posted a
message. I think a good feature in this forum would allow posters to
edit their messages in just that way. I have such a feature enabled in
gmail. I can "undo" my action for 30 seconds after I've clicked on
"send."

> The correct way to correct a post is to follow up to it (reply to it) with a
> correction or clarification. That way everyone sees the change/fix as a new
> messge. And it works even though the messages get copied everywhere, because
> all that has to happen is to copy your own new message.

Got it.

Thanks,

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


Re: Posting warning message

2018-06-12 Thread Chris Angelico
On Wed, Jun 13, 2018 at 2:41 PM, Tamara Berger  wrote:
> I  just meant edit within the moment or two after you've posted a
> message. I think a good feature in this forum would allow posters to
> edit their messages in just that way. I have such a feature enabled in
> gmail. I can "undo" my action for 30 seconds after I've clicked on
> "send."

The way that works is that Gmail waits 30 seconds after you click
"send" before it actually sends it. You could potentially have that
anywhere, but it'll be implemented the same way: that all sending is
delayed until you're happy to let it go through.

It isn't a feature of "the forum"; it's a feature of the way you post
to the newsgroup/mailing list. I, for instance, post directly to the
mailing list via email; if you do that through Gmail, you'd get the
exact same "undo send" feature.

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


Re: Posting warning message

2018-06-12 Thread Cameron Simpson

On 13Jun2018 00:41, Tamara Berger  wrote:

I  just meant edit within the moment or two after you've posted a
message. I think a good feature in this forum would allow posters to
edit their messages in just that way. I have such a feature enabled in
gmail. I can "undo" my action for 30 seconds after I've clicked on
"send."


Ah. Well that's reasonable. Now you just need to petition Google for such a 
feature :-) Hmm, I wonder if there are browser extensions for that kind of 
thing.


Alternatively you could move outside the forum web page and use other tools.  
Many of us interact with this via email, using whatever email reader we prefer. 
I am minded of a post to alt.peeves from long ago:


 I suppose the solution would be to close the composition window and let
 my article sit for half an hour or so once I've finished with it, and
 then go back and proofread it once more.  But that would be a pain in
 the proverbial bifurcated derriere.  Part of the experience of flaming is
 to load a searing missive into the conceptual breech of my SPARCcannon
 and pull the imaginary lanyard whilst flushed with the adrenaline of mortal
 combat.
 - Geoff Miller, 

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


Re: What is the "Unpacking Arguments List" rule?

2018-06-12 Thread dieter
Jach Fong  writes:
> ...
> 4.7.4. Unpacking Argument Lists
> The reverse situation occurs when the arguments are already in a list or
> tuple but need to be unpacked for a function call requiring separate
> positional arguments.
> ...
 args = [3, 6]
 list(range(*args))
> """
>
> I can't understand why line 19 works?

Not sure what "line 19" is - but if it refers to the example above:

  "range" accepts (among others) 2 integer arguments.
  The "*args" above means: unpack the sequence in "args" into
  individual arguments.
  This means (with the values of the example above),
  that "range(*args)" is equivalent to "range(3, 6)".

> Didn't it violate the rule of
> "# non-keyword argument after a keyword argument"?

No keyword arguments at all in the above example.

> and why a more
> reasonable look syntax gets an error?
>
> action(*args, progress)
>  ^
> SyntaxError: only named arguments may follow *expression  File
> "test.py", line 19

This is (in my view) a somewhat arbitrary restriction -- maybe
introduced for symmetry with the function definition syntax.

The message is quite clear, however: after the "*arg",
you must pass keyword arguments only, i.e. they must have
the form "param=value".

> The only reason I can guess is that it checks with the rule in 4.7.3
> which is really unrelated. The "*any" notation used in different places
> with different meaning, such as defining arbitrary argument, unpacking
> argument or even in an assignment(a,*b=any). Maybe it will be better to
> stop this syntax checking and lets both statements below valid:-)

The "*args" and "**kw" are very helpfull. I hope (and expect)
they will remain.

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


Re: Posting warning message

2018-06-12 Thread Cameron Simpson

On 13Jun2018 00:29, Tamara Berger  wrote:

On Tue, Jun 12, 2018 at 7:57 PM Cameron Simpson  wrote:

On 12Jun2018 07:14, Tamara Berger  wrote:



>Just one more thing, Cameron. I was looking at an Apple support page, and it says 
"When you're logged in to your Mac using an administrator account, you can use the sudo 
command in the Terminal app to execute commands as a different user, such as the root 
user." (https://support.apple.com/en-us/HT202035). I am logged in as administrator. So 
why isn't sudo working for me?

>P.S. How would I make the link I provided live?

What link? This is why we trim quoted text and reply below the relevant bit 
directly: I don't know what link you provided or even whether it is there, just 
buried in the huge quoted text. Just cite it again, eg:

  How would I make this link (link here) live?


The link is above, in the first paragraph, beginning with the words
"Just one more thing, Cameron."


And then, of course, tell us what "live" means :-)


Live means live. It is not a word I created. It means that the link
has been activated, so clicking on it will take you to the associated
page. Here is a definition from www.yourdictionary.com/live-link.
"Live Link - Computer Definition: An active text or graphic link on a
Web page. Clicking the link redirects the user to another Web page or
a document or image." The link to the definition I just copied into
this paragraph is not live because clicking on it will not do
anything.


Aha. Well, clicking on it worked for me! But then I'm using email in a terminal 
window where the terminal window has some support for recognising links and 
making them clickable. I'm surprised GMail doesn't do that as well.



This question became moot when I posted my message, because that
action activated the link. [...]


It may be that the "post" action didn't do it, but Google Groups' message 
rendering did it. You don't need to make some things "live", your user 
interface will do it for you.


To elaborate, I see your messages as plain text. But my reading tool (in this 
case the terminal emulator enclosing my mail reader) saw the link and made it a 
clickable thing for me.


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


Re: Index of entity in List with a Condition

2018-06-12 Thread Cameron Simpson

On 12Jun2018 21:06, Subhabrata Banerjee  wrote:

Dear Sir,
Thank you for your kind reply. I am trying in few days time and getting back. 
I made a small fix of my own and I would discuss it, too. Thank you for your 
kind words, but I ignore unnecessary remarks. So please do not worry. 
Meanwhile, please see as you are posting your mail id is coming here, it may 
be misused. If possible, please omit it as you post next time.


I have long considered my email id to be impossible to conceal, so I usually 
don't try. Please don't worry if it is misused by others, that is a risk I have 
accepted.


Of course, as consideration to others, I try to avoid reciting someone else's 
contact info unless it is already publicly in play where I am.


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


Re: Splitting up large python module impact on performance?

2018-06-12 Thread dieter
Bill Deegan  writes:
> I'm doing some refactoring on a fairly large python codebase.
> Some of the files are > 4000 lines long and contain many classes.

I am typically working with systems consisting of hundreds of
modules (Zope/Plone). Such large systems have a significant
impact on startup time (caused by extensive file system operation
during startup). For one application, I had to significantly
optimize to get an acceptable startup time: I have put most
of the application modules into zip archives).

> Should I expect any performance hit from splitting some of the classes out
> to other files?

Important is the number of resulting modules (and how fast
your file system is): for each module, Python accesses the file system
potentially many times (up to 4 times, when my memory is right)
and this may significantly slow down startup (if a large number
of modules must be imported).

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


Re: Splitting up large python module impact on performance?

2018-06-12 Thread Gregory Ewing

Chris Angelico wrote:

A few thousand lines in a file is only a problem if you're using an
editor that lacks a Find feature.


My editor has a find feature, but I still find it a nuisance
to have to use it every single time I want to find something.

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


Re: Posting warning message

2018-06-12 Thread Gregory Ewing

Tamara Berger wrote:

Live means live. It is not a word I created. It means that the link
has been activated, so clicking on it will take you to the associated
page.


Okay, I think "clickable" is a better word to describe this.

Most mail reading software these days automatically recognises
things that look like URLs and makes them clickable, so you
usually don't need to do anything special. (And if you're
sending plain text email, there's nothing special you
*can* do.)

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


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

2018-06-12 Thread Peter J. Holzer
On 2018-06-11 12:24:54 +, Steven D'Aprano wrote:
> On Mon, 11 Jun 2018 12:31:09 +0200, Peter J. Holzer wrote:
> > On 2018-06-11 01:06:37 +, Steven D'Aprano wrote:
> >> On Sun, 10 Jun 2018 23:57:35 +0200, Peter J. Holzer wrote:
> > 
> > [Note: I was talking about os.stat here, not os.path.exists. I agree
> > that os.path.exists (and the other boolean functions) should simply
> > return false]
> 
> o_O
> 
> Well... I don't know what to say. In a thread about os.path.exists, 
> you're talking about os.stat. I see. I don't understand why,

Easy to explain. Marko wrote:

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

And to this I replied:

| I'm not a Python god, but I don't think os.stat() should be changed.
[and then explained why]

I do take some care to quote only what is necessary for context and
phrase my replies in a way which make it clear what I'm replying to.
Apparently I wasn't successful in this case (even though the message is
relatively short). If you have suggestions on how I might have been
clearer, I'm all ears.


> but if you want to derail the thread to discuss something else,

I wasn't derailing the thread, I was replying to a specific suggestion.

> okay, I'll play along.
> 
> 
> [...]
> > We are talking about platform-specific code here.
> 
> Are we? I thought we were talking about Python and the os module. The 
> very first paragraph of the documentation for os says:
> 
> This module provides a portable way of using operating
> system dependent functionality.

Note the magic words "system dependent functionality". The way you call
os.stat() is the same on all systems, but what it actually does and what
it returns depends on the OS. For example, the description of class
os.stat_result says:

|  st_ino
|
|Platform dependent, but if non-zero, uniquely identifies the file
|for a given value of st_dev.
[...]
| On some Unix systems (such as Linux), the following attributes may also
| be available:
[...]
| On other Unix systems (such as FreeBSD), the following attributes may be
| available (but may be only filled out if root tries to use them):
[...]
| On Mac OS systems, the following attributes may also be available:
[...]
| On Windows systems, the following attribute is also available:

So, quite some variation dependent on the system type.

> It also clearly states:
> 
> All functions in this module raise OSError in the case of
> invalid or inaccessible file names and paths, or other
> arguments that have the correct type, but are not accepted
> by the operating system. 
> 
> You know... like strings with NUL in them.

Ok. I missed that. So either the documentation or the implementation
should be fixed. 

In any case, if the implementation is changed, I still think that
OSError(ENOENT) is wrong. It would have to be OSError(None, "embedded
null byte"), or, if that is not possible (I haven't checked)
OSError(EINVAL, "embedded null byte"), although that is slightly
misleading (it implies that the OS returned EINVAL, which it didn't).

The same check for NUL is also in other functions (e.g. open()), so
those would have to be changed as well.


> > On POSIX systems, there IS NO WAY to pass a filename with an
> > embedded NUL byte to the OS.
> 
> Mac OS X is certified as POSIX-compliant. As I pointed out in a previous 
> email, OS X also provides APIs that are perfectly capable of dealing with 
> NULs in file names.

I wasn't entirely clear here. What I meant is that POSIX systems, as a
group, provide no such way. Some specific systems may have such an API,
but it isn't in POSIX and it not even likely to be the same on different
systems, so it cannot be used portably across POSIX systems or even the
subset of systems which allow NUL in filenames (unless that subset
happens to contain only one OS).


> POSIX specifies a *minimum* set of functionality, not a maximum.

But when writing an application for POSIX systems you are interested in
that minimum set of functionality. Plus maybe some common extensions.

Oh, and from the test results Gregory Ewing posted, it looks like Python
does use the POSIX API (and not the Carbon API) on MacOS. So you won't
ever see a filename containing NUL in a Python program on MacOS and you
won't be able to create one.

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: Splitting up large python module impact on performance?

2018-06-12 Thread Cameron Simpson

On 13Jun2018 17:53, Greg Ewing  wrote:

Chris Angelico wrote:

A few thousand lines in a file is only a problem if you're using an
editor that lacks a Find feature.


My editor has a find feature, but I still find it a nuisance
to have to use it every single time I want to find something.


Tags files. A mapping from names to their definition lines. Tres handy.

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