Re: Formal Question to Steering Council (re recent PEP8 changes)

2020-07-03 Thread Bev In TX

> On Jul 3, 2020, at 10:23 AM, o1bigtenor  wrote:
> 
> I decry the present hypersensitivity to any hint of culture that was
> present some 200 years ago especially when such sensitivity is used
> to block a wider group from participating. IMO such hypersensitive
> individuals might be better served by finding some other soap box
> to scream from if that is to be their primary input into a particular
> conversation.

I have worked In harmony with multinational teams from all over the world.  We 
never needed a writing standard for code changes.  Are current Python code 
changes documented in such a poor way that they are not understandable?  That 
would be the only reason to promote a standard, which would not have to be as 
stringent as Strunk and White.

I don’t like the use of the word “racism” in connection with writing standards, 
which is blatantly not true.  Do the current leaders of Python promote 
political agendas?  That’s what this sounds like.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Formal Question to Steering Council (re recent PEP8 changes)

2020-07-02 Thread Bev In TX

> On Jul 2, 2020, at 5:48 PM, Random832  wrote:
> 
> but the point is that the *whole idea* of "standard English" is tied to white 
> supremacy

Bunkum.  It is racist to claim that standards are against people, when their 
purpose to to make the written word understood by all who read it, as opposed 
to having to understand all dialects.  There are numerous “white” dialects 
whose words and grammars are not included in those standards.

Bev in TX

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


Re: Python Curses Programming HowTo -reviewers?

2020-06-16 Thread Bev In TX


> On Jun 16, 2020, at 11:12 AM, Alan Gauld via Python-list 
>  wrote:
> 
> If anyone feels keen please reply and I'll forward a copy.
> Eventually I'm aiming to put the finished document on my website.

I am interested.
Thanks,
Bev in TX
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: SaveAs on macOS Catalina.

2020-05-08 Thread Bev In TX

> On May 8, 2020, at 8:29 PM, Terry Reedy  wrote:
> 
> https://bugs.python.org/issue40553
> 
> At least a couple of people have had problems using SaveAs from IDLE when 
> running on macOS Catalina.  But Ned Deily cannot reproduce the issue.  I 
> cannot because I have refused the buggy 'upgrade'.  We could use more data.  
> What do other Catalina Python users experience?
> 
> If not an IDLE user, the experiment is easy.
> 
> In terminal:
> $ python3 -m idlelib
> 
> In IDLE:
> File => New
> File => SaveAs
> 
> In the macOS saveas dialog:
> Enter a minimal name that does not match an existing .py name in Documents.  
> Hit [Save] button.  Does the dialog save and close, or does it clear the 
> Document content list and freeze?
> 
> The three Apple apps I looked at, Safari, Maps, and Keynote do not display 
> folder contents.  This might be the problem.  What do other Mac apps do?
That is not the problem.

On macOS The default Save/Save as dialogs are short, only displaying a few 
major folders along with Favorites and Recents.  That dialog doesn’t display 
folder contents.  However, you can get an expanded dialog by clicking on the 
little arrow to the right of the Where box.  Using that dialog allows one to 
select any folder and displays folder contents.  

I tried using both Save and Save as, and was unable to duplicate the problem 
with either the short or the long dialog.

Python 3.8.2
macOS Catalina 10.15.4

Bev in TX
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Regarding Python

2020-04-17 Thread Bev In TX


Bev

> On Apr 16, 2020, at 5:36 PM, Muneer Malla  wrote:
> ... potion snipped ...
> I need to install python 3.7 or above version, however the previously 
> installed version is python2.7
> I tried many commands 
> sudo apt-get install python3.8
> after running the command it fails 
What failed?  Did the apt-get command fail, or were you unable to run Python 
3.8?

> I removed pthon 2.7 
> but again when I run the command 
> Python --version 
> it again shows python 2.7
If it were me, I would not remove Python 2.7, as on some older Linux versions, 
it may still be used by the system.  Perhaps that’s why you were unable to get 
rid of it.

> please suggest the commands 
> I have my python version 3.8 downloaded in the download folder

Python 2 and Python 3 can happily coexist on the same Linux system.  If both 
are installed, running “python” will invoke version 2.x, while running 
“python3” will invoke version 3.x (without the quotes).  

If for some reason you must run Python 3 with the “python” command on systems 
with both Python 2 and 3, then set up a virtual environment and source into it 
before running Python 3.
https://docs.python.org/3/tutorial/venv.html
https://docs.python.org/3/library/venv.html?highlight=venv

Bev in TX


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


Re: python

2020-02-22 Thread Bev In TX


> On Feb 22, 2020, at 2:42 PM, MRAB  wrote:
> 
>> On 2020-02-22 18:18, lberia...@gmail.com wrote:
>> hi guys can you help me.how to find maximum and minimum in list using while 
>> loop python
> You don't need to use a loop. Use the 'max' and 'min' functions.
Unless it was a homework question, in which case a loop might have been 
required.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python3 - How do I import a class from another file

2019-12-11 Thread Bev In TX

> On Dec 11, 2019, at 6:09 AM, R.Wieser  wrote:
> 
> Paul,
> 
>> You do understand that the reference counting garbage collector is an
>> implementation detail of the CPython implementation *only*, don't you?
> 
> No, I don't.   But do tell how that matters to me.
> 
>> there can be an indefinite delay between the last reference to
>> a value being lost and the object being collected (which is
>> when __del__ gets called).
> 
> Nope.
> 
> As I've posted a number of messages back, I've created a test program which 
> disables that periodically-called garbage collector and than created and 
> destroyed a class instance.  The print command I had put into its __del__ 
> method was called regardless.Which, according to your above claim, 
> should not have happened.
> 
> I (currently) do not care much for how other implementations do it, but feel 
> free to find one which actually does it the way you claim it happens.   But 
> if-and-when you find one be sure to also post how they deal with the, also 
> mentioned before, inherent race conditions. :-)
> 
>> If all you are interested is the semantics of the current CPython
>> release, then your statements are true.
> 
> Thank you !
> 
> Thats, for the moment, /all/ I needed to know.  (no Dennis, I have not 
> forgotten you said the same :-) ).
> 
> I hope you do realize you are now contradicting Greg, who started all of 
> this by his blunt claim that "it was only working by accident" as well as 
> Chris who agreed with him ?
> 
>> But why would anyone here know that you were looking at the
>> situation from such a limited perspective?
> 
> Look at the subject line and my initial question.  It pretty-much /screams/ 
> that I'm a new to the language (and specifies which version).  Do you think 
> that I care much, if anything, about how /other/ implementations work before 
> I have got a handle on this one ?
> 
> But do tell: How many Python 3 (CPython?  is that the same?) implementations 
> are there, and how many do actually lazily call the __del__ method (when its 
> trying to free up some memory) ?
> 
>> And your attitude seems to be confrontational and aggressive.
> 
> I take it you mean "has become".  Yep, that happens when I ask a simple 
> question and everyone just keeps posting "your have to take our word for 
> it!" posts, while refusing to even address my "but this is what happens!" 
> examples.
> 
> Besides, I'm Dutch, I'm supposed to be rude. :-)
> 
> Regards,
> Rudy 

I agree with others who responded to you.  You acknowledge that you are new to 
Python, yet you claimed to know better than Python experts.  You claim you want 
an answer and yet you purposefully ignored their response because it didn’t 
match what you wanted to hear.  You have time to repeatedly vilify everyone 
connected with Python, but you have no time to read the well written 
documentation. 

I have no more time to spend on such a ungrateful person.  I’m blocking all 
messages from you.

Bev in TX
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Vim settings for Python (was: tab replace to space 4)

2019-12-07 Thread Bev In TX

> On Dec 7, 2019, at 4:16 AM, Peter J. Holzer  wrote:
> 
> As an aside, to prevent vim from inserting tabs in the first place, set
>expandtab
>sw=4
> and maybe also
>ts=4
> (The latter is very much a matter of taste. I don't unless I have to
> edit code which already contains tabs intended to be at a certain width.)

I’m not the OP, but I do appreciate this info.  Thanks!
Bev in TX
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to convert the following IDL program lines to equivalent Python program lines?

2019-11-28 Thread Bev In TX


> On Nov 28, 2019, at 9:35 AM, Dennis Lee Bieber  wrote:
> 
> Channeling ancient FORTRAN, I'd interpret it as
> 
> 1XSkip one space
> A7Seven character alpha
> I3Three digit integer
> A2727 character alpha
> 
> and it is rather painful when the arguments are literals of those sizes.
> Makes more sense if the arguments are strings of various widths yet column
> alignment is required.
> 
>Since I still favor string interpolation for formatting, I'd probably
> just end up with
> 
> print(" Column %3d of product matrix A*AINV:")
> 
> {Odd that the original uses a 1X format, when the literals have white space
> at the adjoining ends... Why not " Column " with A8 format?}

Still channeling Fortran, 1X ensured a blank in column 1, which was used 
strictly for carriage control on a line printer.  A8 may, or may not leave a 
blank in column 1, which could have caused erroneous carriage controls.

Bev in TX
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: nonlocal fails ?

2019-11-15 Thread Bev In TX


> On Nov 15, 2019, at 11:11 AM, Python  wrote:
> 
> Richard Damon wrote:
> ...
>> then elsewhere you could do
>> foo(j)
>> and after that j is 2
>> you also could do
>> foo(1)
>> and after that if you did
>> j = 1
>> then now j might have the value 2 as the constant 1 was changed to the
>> value 2 (this can cause great confusion)
> 
> Wow! So fubar that such a feature should definitely makes its
> way into PHP!

I remember fixing a bug caused by this.
Bev in TX
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to delay until a next increment of time occurs ?

2019-11-15 Thread Bev In TX


> On Nov 14, 2019, at 8:42 PM, MRAB  wrote:
> 
> Objective-C++?
> 
> I knew that Objective-C is C with objects.
> 
> I knew that C++ is C with objects.
> 
> But C with both?

Per Wikipedia...
Objective-C++ is a language variant accepted by the front-end to the GNU 
Compiler Collection and Clang, which can compile source files that use a 
combination of C++ and Objective-C syntax. Objective-C++ adds to C++ the 
extensions that Objective-C adds to C. As nothing is done to unify the 
semantics behind the various language features, certain restrictions apply:

Bev in TX
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: (New to Python) Shopping List Code

2019-10-28 Thread Bev In TX

> On Oct 28, 2019, at 8:42 AM, ferzan saglam  wrote:
> 
> How can I stop this code when -1 is typed or at a maximum item count of ten.
> At the moment the code seems to be in a infinite loop meaning it keeps on 
> asking for an entry until -1 is typed 
> 
> 
> total = 0
> while True:
>
>  print('Cost of item')
>
>  item = input()
>
>  if item != -1:
>total = total + item
>  if item == -1:
>
>  break
>
> print(total)
> -- 
Sorry about the blank post— I attempted to scroll down, but instead of doing 
that,it sent the message.

From the documentation (emphasis is mine):
“input([prompt])
If the prompt argument is present, it is written to standard output without a 
trailing newline. The function then reads a line from input, converts it to a 
string (stripping a trailing newline), and returns that. When EOF is read, 
EOFError is raised.

So you don’t have a number; you have a string.  Presuming that the string 
contains an integer, You can convert that string to an integer number with the 
built in int() function.

Bev in TX
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: (New to Python) Shopping List Code

2019-10-28 Thread Bev In TX



Bev

> On Oct 28, 2019, at 8:42 AM, ferzan saglam  wrote:
> 
> How can I stop this code when -1 is typed or at a maximum item count of ten.
> At the moment the code seems to be in a infinite loop meaning it keeps on 
> asking for an entry until -1 is typed 
> 
> 
> total = 0
> while True:
>
>  print('Cost of item')
>
>  item = input()
>
>  if item != -1:
>total = total + item
>  if item == -1:
>
>  break
>
> print(total)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: exec and globals and locals ...

2019-09-19 Thread Bev In TX
I’m not the OP, but I want to thank you for that clarification.  I had 
previously not understood the ramifications of the following in section “7. 
Simple statements” in “The Python Language Reference”:

“An augmented assignment expression like x += 1 can be rewritten as x = x + 1 
to achieve a similar, but not exactly equal effect. In the augmented version, x 
is only evaluated once. Also, when possible, the actual operation is performed 
in-place, meaning that rather than creating a new object and assigning that to 
the target, the old object is modified instead.”

Thanks again.

Bev

> On Sep 19, 2019, at 5:45 AM, Richard Damon  wrote:
> 
> I think the issue is that x += 1 isn't exactly like x = x + 1, and this
> is one case that shows it. x = x + 1 is an assignment to the symbol x,
> which makes x a local, and thus the read becomes an undefined symbol. x
> += 1 is different, it isn't a plain assignment so doesn't create the
> local. The read of x is inherently tied to the writing of x so x stays
> referring to the global.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Which editor is suited for view a python package's source?

2019-08-20 Thread Bev In TX
Sorry, I meant to trim the older portion :-(

Bev in TX

> On Aug 20, 2019, at 4:53 AM, Bev In TX  wrote:
> 
> Search for “Choose” (without the quote marks) on the following webpage to see 
> the differences between the community and commercial versions:
> https://www.jetbrains.com/pycharm/features/
> 
> From the following webpage, “Microsoft Windows 7 SP1 or later”
> https://www.jetbrains.com/help/pycharm/installation-guide.html?_ga=2.186403823.798151923.1566294266-889030968.1566294266
> 
> Bev
> 
>> 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Which editor is suited for view a python package's source?

2019-08-20 Thread Bev In TX
Search for “Choose” (without the quote marks) on the following webpage to see 
the differences between the community and commercial versions:
https://www.jetbrains.com/pycharm/features/

From the following webpage, “Microsoft Windows 7 SP1 or later”
https://www.jetbrains.com/help/pycharm/installation-guide.html?_ga=2.186403823.798151923.1566294266-889030968.1566294266

Bev

> On Aug 19, 2019, at 9:24 PM, jf...@ms4.hinet.net wrote:
> 
> Nick Sarbicki於 2019年8月19日星期一 UTC+8下午5時33分27秒寫道:
>> PyCharm takes you to the source code within the editor for any
>> variables/functions/classes/modules if you ctrl+click on what you want to
>> see. It allows you to browse the relevant bits of code quickly, as well as
>> let you change them in your local environment if need be.
>> 
>> That way you don't have to download the source separately, you can just use
>> it as a normal dependency.
>> 
>> But if you want to view the source of a project in isolation I imagine any
>> common editor will suffice. Personally I'll tend to look where the source
>> is hosted (GitHub, GitLab etc) instead of downloading it. But I can
>> understand why some may not trust this.
>> 
>>> On Mon, 19 Aug 2019, 10:17 ,  wrote:
>>> 
>>> I like to download one package's source and study it in an editor. It
>>> allows me to open the whole package as a project and let me jump from a
>>> reference in one file to its definition in another file back and forth. It
>>> will be even better if it can handle the import modules too. (Maybe this is
>>> too much:-)
>>> 
>>> Can anyone recommend such a tool?
>>> 
>>> --Jach
>>> --
>>> https://mail.python.org/mailman/listinfo/python-list
>>> 
> 
> There is a free community version of PyCharm. Will it support the 
> cross-reference of viewing different files in different subdirectory? and 
> what Windows versions it requires? 
> 
> --Jach
> -- 
> https://mail.python.org/mailman/listinfo/python-list
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Syntax for one-line "nonymous" functions in "declaration style"

2019-03-27 Thread Bev in TX


> On Mar 27, 2019, at 10:41 AM, Antoon Pardon  wrote:
> 
> I don't know. Something like the following is already legal:
> 
> f(x)[n] = x * n
> 
> And it does something completly different.

Where would I find information on what this does in the documentation?
Bev in TX




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


Re: IDLE Default Working Directory

2018-11-14 Thread Bev in TX
Thanks for taking the time to respond, but I’m not certain that we are on the 
same page.

 Every time you start Idle, its File -> Open dialog points to the same default 
location (on MacOS that is ~/Documents).  When you open a project’s file from 
another location, Idle remembers that new folder the next time that you use 
File -> Open.  However, it only does so during the current Idle session.  The 
next time you start Idle, you again have to traverse to your project’s folder.  
The question is how to change Idle’s default File -> Open folder, so that one 
doesn’t have to traverse to the project’s folder every time one starts Idle. 

The OP is teaching a class on Windows.  A possible solution of modifying Idle’s 
startup folder in a shortcut was pointed out to the OP --  that was Windows 
specific.  Given my own little experiments, I’m not sure that Idle even pays 
attention to its startup folder, but that may work differently on Windows, so I 
can’t say for certain.

I only use macOS, so I wondered how to make Idle do the something similar on 
macOS (hence one reply to me mentioning using command-O, rather than ctrl-O, as 
would probably be used on Windows).

On macOS, I suggested adding the project folder to the side bar so that it is 
easier to access it in theIdle -> File -> Open dialog.  One could alternatively 
add an alias to the project folder in ~/Documents.  That would cut folder 
traversal down to one easily accessed level.  I suppose a similar thing could 
be done on Windows by adding a shortcut to the project folder in whatever the 
default File -> Open folder is on that platform. 

> On Nov 14, 2018, at 2:43 AM, Brian Oney  wrote:
> ...
> The idea is to put that script in the project folder.
> 
> You could begin your lecture with an introduction to the import system and 
> command line. The script needs to reside in the desired directory. Once that 
> is the case you would import it:

> 
> import path.to.script.sans.py.ending
> 

AFAIK, one cannot specify a path on the import statement?  The following 
discussion indicates it’s not so straight forward...
https://stackoverflow.com/questions/67631/how-to-import-a-module-given-the-full-path

I’m also not sure as to how this affects Idle’s File -> Open dialog?  

> It may be to much to ask of students. It's easiest to put that script in the 
> project folder. You know have everthing in the same place, where students can 
> copy that directory, take it whereever there is python installed, run that 
> script, and pick up where they left off.
> 
> If you want to control where the directory changes to do this:
> 
> #!/usr/bin/env python3
> 
> import os
> os.chdir('path/to/project/directory')
> 

Again, doing this has no affect in Idle -> File -> Open

> That is brittle though. What if the student don't all have access to that 
> directory? What if they fail to put the project directory in the right place? 
> What if the network drives are down and you end up working locally?
> 
> You could send them a zip-file of everything including my first suggestion 
> and it would just work.


Bev in TX




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


Re: IDLE Default Working Directory

2018-11-13 Thread Bev in TX


> On Nov 12, 2018, at 10:07 AM, Brian Oney  wrote:
> 
> On Mon, 2018-11-12 at 09:35 -0600, Bev in TX wrote:
>> I am not the OP and I’m on macOS — no shortcuts.  How would one do the same 
>> thing on other platforms?
>> Bev in TX
> Hello there,
> 
> I am not an IDLE user. You may try a startup script from python, as per the 
> following.
> 
> oney@oney <mailto:oney@oney>:~$ cat pyhelp/change_to_current_dir.py 
> #!/usr/bin/env python3
> 
> import os
> import sys
> 
> os.chdir(os.path.dirname(os.path.abspath(__file__)))
> 
Thanks so much for taking the time and effort to provide that script.  I 
experimented with it, but it does not work as desired in Idle.  I tried:
* Changed to project directory and then opened Idle
 Idle -> File-> Open still opens ~/Documents — not the project folder.
* Placed the change folder script in ~/Documents, opened it in Idle and ran it 
 Idle did not change to the project folder — it stayed in whichever folder 
the change folder script resided.

Unless someone can come up with a better option for macOS, the best that I can 
think of is to add the project folder to the side bar so that it is easier to 
access it in Idle -> File -> Open.
 
Bev in TX




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


Re: IDLE Default Working Directory

2018-11-13 Thread Bev in TX


> On Nov 12, 2018, at 5:50 PM, Terry Reedy  wrote:
> 
> For me, open (command-O) opens 'Documents'.  I presume it should be easy 
> enough to move into a 'py' subfolder.

The whole point is for Idle -> File -> Open (or command-O) to automatically 
open to a specific folder.  

Bev in TX




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


Re: IDLE Default Working Directory

2018-11-12 Thread Bev in TX
On Nov 12, 2018, at 9:16 AM, eryk sun  wrote:
> 
> On 11/12/18, Christman, Roger Graydon mailto:d...@psu.edu>> 
> wrote:
>> 
>> I looked in IDLE's own configuration menu, and didn't see anything there --
>> and I fear that I might have to fight some Windows settings somewhere else
>> instead.   I think this is Windows 10.
> 
> Modify the "Start in" field of the IDLE shortcut. You can use
> environment variables, e.g. "%UserProfile%\Documents".

I am not the OP and I’m on macOS — no shortcuts.  How would one do the same 
thing on other platforms?
Bev in TX




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


Re: Python indentation (3 spaces)

2018-10-07 Thread Bev in TX

> On Oct 7, 2018, at 4:30 PM, Gene Heskett  wrote:
> 
>> Free for Linux, Macs and Windows ...
>> https://code.visualstudio.com/Download 
>> <https://code.visualstudio.com/Download>
>> <https://code.visualstudio.com/Download 
>> <https://code.visualstudio.com/Download>>
>> 
>> Bev in TX
> 
> Thank you for the url. Downloaded, but not installed on the target 
> machine yet.
Don’t forget to read the license agreement — the link is at the bottom of that 
webpage. 
Bev in TX




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


Re: Python indentation (3 spaces)

2018-10-07 Thread Bev in TX


> On Oct 7, 2018, at 1:19 PM, Gene Heskett  wrote:
> 
>>> 
>>> That 
>>> said, there is an easy fix for tab misuse: in Visual Studio Code,
>>> you can replace all Tabs with Spaces by highlighting the entire code
>>> block, hitting Tab once and Shift-Tab after.
> 
> But that automatically assumes one is running in a windows environment. I 
> don't allow it on the premises if I own the machine. Are there good, 
> alternatives that run on linux?
> 

Free for Linux, Macs and Windows ...
https://code.visualstudio.com/Download <https://code.visualstudio.com/Download>

Bev in TX




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


Re: New books by O’Reilly

2018-08-20 Thread Bev in TX
Thanks for mentioning this — it’s hilarious!  I’ve seen all of them through the 
years.

> 
>> On Sun, 19 Aug 2018, 09:00 Larry Martell, > <mailto:larry.mart...@gmail.com>> wrote:
>>> 
>>> https://imgur.com/gallery/tW1lwEl <https://imgur.com/gallery/tW1lwEl>
>>> --

Bev in TX




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


Re: Is there a nice way to switch between 2 different packages providing the same APIs?

2018-07-06 Thread Bev in TX



> On Jul 6, 2018, at 3:14 AM, Mark via Python-list  
> wrote:
> 
> In the end I changed to a completely different approach.
> 
> I now have two parallel directories, one with PySide-based code and the other 
> with auto-generated PyQt-based code. And I created a tiny script to copy the 
> PySide code to the PyQt directory & do the necessary changes. (I can post the 
> script if anyone's interested.)

I am interested.
> 
> This means that there are no import hacks and no (manual) duplication, while 
> still being easy to test using either binding library.
> -- 
> https://mail.python.org/mailman/listinfo/python-list

Bev in TX




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


Re: logging module

2018-07-01 Thread Bev in TX



> On Jul 1, 2018, at 8:05 AM, Sharan Basappa  wrote:
> 
> Folks,
> 
> I am trying to use logging module and somehow I cannot make it work.

Saying that something does not work does not provide enough information for 
anyone to assist you.  You need to provide both the exact code that did not 
work, what you expected and what happened, and the error message that you 
received, if any.  Details, details and more details.

> 
> A simple code that I am trying is below. The commented code line 5,6 are 
> other options I have tried but don't work
> 
> #importing module
> import logging
> 
> #Create and configure logger
> #logging.basicConfig(filename="D:/Projects/Initiatives/machine 
> learning/programs/newfile.log",
> #logging.basicConfig(filename="newfile.log",
> logging.basicConfig(format='%(asctime)s %(message)s')
> 
> #Creating an object
> logger=logging.getLogger()
> 
> #Setting the threshold of logger to DEBUG
> logger.setLevel(logging.DEBUG)
> 
> #Test messages
> logger.debug("Harmless debug Message")
> logger.info("Just an information")
> logger.warning("Its a Warning")
> logger.error("Did you try to divide by zero")
> logger.critical("Internet is down")
> 
> PS: I am running this under Enthought Canopy
> 
> The following is the output
> %run "D:/Projects/Initiatives/machine learning/programs/debug_4.py"
> -- 
> https://mail.python.org/mailman/listinfo/python-list

Bev in TX




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


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

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

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

Bev in TX




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


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

2018-06-10 Thread Bev in TX


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

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

>  * One with an embedded / in the file name

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Bev in TX



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


Re: help on "from deen import *" vs. "import deen"

2016-11-20 Thread Bev in TX

Thanks to ChrisA and Ned for that clarification.

Bev in TX

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


Re: help on "from deen import *" vs. "import deen"

2016-11-20 Thread Bev in TX

From the Python 3.5.2 docs:

6.15. Evaluation order
Python evaluates expressions from left to right. Notice that while 
evaluating an assignment, the right-hand side is evaluated before the 
left-hand side.


Thus, spam = eggs = cheese = obj is equivalent to:

spam = (eggs = (cheese = obj))

which is also equivalent to:

cheese = obj
eggs = cheese
spam = eggs

These all are now references to obj.

In both of your examples, everything also ends up as references to obj. 
The only difference is the order of evaluation.


Bev in TX

On 11/19/16 12:58 AM, Chris Angelico wrote:

On Sat, Nov 19, 2016 at 3:34 PM, Steve D'Aprano
<steve+pyt...@pearwood.info> wrote:

What happens if you do this?

spam = eggs = cheese = obj

Is that different from:

spam = obj
eggs = obj
cheese = obj


or from this?

spam = obj
eggs = spam
cheese = eggs
...
These aren't silly questions.


Indeed, they are not silly. It surprised me (as a C programmer) that
the assignments happen left-to-right, rather than right-to-left (in C,
cheese would be set first, then eggs, then spam). These are questions
filled with subtleties.

ChrisA


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


Re: How to handle errors?

2016-11-09 Thread Bev in TX
On UNIX type systems, the Python installer creates multiple links to the 
actual Python executable.  For example in Python 3.5:


python - link to python3.5
python3 - link to python3.5
python3.5 - actual executable

Unless your script specifically requires version 3.5, then it is better 
to use the "python3" link, rather than "python3.5".  That way your 
script would continue to run when you later upgrade to a new version of 
Python 3, such as 3.6.


#!/usr/bin/env python3

Bev in TX

On 10/20/16 10:13 PM, D'Arcy Cain wrote:

Which would fail on my system because that's Python 3.5.


For Python 3:  #!/usr/bin/env python3

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


Re: locale and for loop on same line

2016-01-23 Thread Bev in TX
According to the documentation, "...simple statements may occur on a 
single line separated by semicolons."


The "for" statement is a compound, not simple, statement.

Would it be possible to place your statements in a function and then you 
would just need to invoke the function?


Bev in TX

On 1/23/16 4:08 AM, Ramo wrote:

Can someone tell me why this doesn't work?

import locale; locale.setlocale(locale.LC_ALL, ""); for i in range(1,20,4): 
print(locale.format("%2f", i, 1))

It gives an error: SyntaxError: invalid syntax (highlighting the word 'for')

I need this code on one and the same line.
However when I separate them it works fine:

import locale
locale.setlocale(locale.LC_ALL, "")
for i in range(1,20,4):
print(locale.format("%2f", i, 1))


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


Re: logging SMTPhandler Error

2009-08-23 Thread Bev in TX
On Aug 23, 12:48 am, a...@pythoncraft.com (Aahz) wrote:
 It's also not too difficult to do the moral equivalent with dnspython and
 find the MX host for the domain you're trying to send e-mail to; that
 usually does not require an encrypted connection.
 --
 Aahz (a...@pythoncraft.com)           *        http://www.pythoncraft.com/

 I support family values -- Addams family values --www.nancybuttons.com

Thanks :-).  I'm not sure that I understand exactly what needs to be
done, but I'll read the documentation and see what I can come up with.

Bev in TX
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: logging SMTPhandler Error

2009-08-22 Thread Bev in TX
On Aug 21, 8:34 am, Bev in TX countryon...@yahoo.com wrote:
 Hi,

 I've done some Python programming, but I still consider myself a
 Python newbie.  I have a Mac Pro OS X 10.5.8 system and I installed
 Python 2.6.2 (the latest package available for the Mac) yesterday.

 I was working through Matt Wilson's article on using the logging
 module:http://blog.tplus1.com/index.php/2007/09/28/the-python-logging-module...
 (If that does not work, then try:http://tinyurl.com/5v2lcy)

 Everything worked great until his last example.  My ISP does not
 provide e-mail, so I tried using gmail in the line that sets h2.  I
 substituted mailid for my actual e-mail address in the following
 examples; in my test I used my actual e-mail ID.  Also, I used the
 full path to the newly installed Python 2.6.2; otherwise it picked up
 the older Python 2.5:
 #!/Library/Frameworks/Python.framework/Versions/2.6/bin/python

 First attempt:
 h2 = logging.handlers.SMTPHandler('smtp.gmail.com', 'mai...@gmail.com',
 ['mai...@gmail.com'],'ERROR log')
 However, that caused the following error to be issued:

 Traceback (most recent call last):
   File /Library/Frameworks/Python.framework/Versions/2.6/lib/
 python2.6/logging/handlers.py, line 868, in emit
     smtp.sendmail(self.fromaddr, self.toaddrs, msg)
   File /Library/Frameworks/Python.framework/Versions/2.6/lib/
 python2.6/smtplib.py, line 698, in sendmail
     raise SMTPSenderRefused(code, resp, from_addr)
 SMTPSenderRefused: (530, '5.7.0 Must issue a STARTTLS command first.
 7sm3867994qwf.47', 'mai...@gmail.com')

 I also tried providing my gmail userid/password, I tried adding a 5th,
 credential, argument, which is a tupple, (username,password) (new in
 2.6).

 Second attempt:
 h2 = logging.handlers.SMTPHandler('smtp.gmail.com', 'mai...@gmail.com',
 ['mai...@gmail.com'],'ERROR log',('mai...@gmail.com','gmail-
 password'))
 However, that caused the following error message:

 Traceback (most recent call last):
   File /Library/Frameworks/Python.framework/Versions/2.6/lib/
 python2.6/logging/handlers.py, line 867, in emit
     smtp.login(self.username, self.password)
   File /Library/Frameworks/Python.framework/Versions/2.6/lib/
 python2.6/smtplib.py, line 552, in login
     raise SMTPException(SMTP AUTH extension not supported by
 server.)
 SMTPException: SMTP AUTH extension not supported by server.

 I am able access gmail via Mac's Mail, in which it says that outgoing
 mail is going to:
       smtp.gmail.com:mailid
 I tried using that as the server in the Python script, but it could
 not find that server.

 Is this possible?  If I am doing something incorrectly, would someone
 please indicate what it is?

 Thanks,
 Bev in TX

Today I tried this with both Python 2.6.2 and 3.1.1 on an XP system,
with the same error.  For the 3.1.1 test, I had to change the syntax
of the exception from except exc, var to except exc as var.  Here
is the modified script, with my email ID changed to mailid:

import logging
import logging.handlers

#Make a global logging object
x = logging.getLogger(logfun)
x.setLevel(logging.DEBUG)

#This handler writes out everything to stdout
h1 = logging.StreamHandler()
f = logging.Formatter(%(levelname)s %(asctime)s %(funcName)s %(lineno)
d %(message)s)
h1.setFormatter(f)
h1.setLevel(logging.DEBUG)
x.addHandler(h1)

#This handler emails me anything that is an error or worse
h2 = logging.handlers.SMTPHandler('smtp.gmail.com', 'mai...@gmail.com',
['mai...@gmail.com'],'ERROR log')
f = logging.Formatter(%(levelname)s %(asctime)s %(funcName)s %(lineno)
d %(message)s)
h2.setLevel(logging.ERROR)
h2.setFormatter(f)
x.addHandler(h2)

def g():
  1 / 0

def f():
  logfun = logging.getLogger(logfun)
  logfun.debug(inside f!)
  try:
g()
  except Exception as ex:
logfun.exception(Something awful happened!)
  logfun.debug(Finishing f!)

if __name__ == __main__:
  f()

Thanks,
Bev in TX
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: logging SMTPhandler Error

2009-08-22 Thread Bev in TX
On Aug 22, 7:07 pm, Ned Deily n...@acm.org wrote:

 The problem here is that gmail, like most modern mail services, requires
 the use of an encrypted (SSL or TLS) connection for mail relaying so
 that the required user name and password are not sent in the clear.  The
 logging SMTP handler uses the smtplib module from the standard module to
 send mail and, when built properly, smtplib does support TLS.  However,
 the caller of smtplib does need to do some extra work in that case, i.e.
 it needs to call the server object's starttls method at the right point
 in the protocol handshaking. It's currently not done automatically in
 smtplib and, unfortunately, there is no code in the logging smtp handler
 to detect the need for and to call starttls (in response to a
 250-STARTTLS response to an EHLO).

 To make this work, either the logging module or, perhaps better, the
 smptlib module needs to be smarter about this case.  I didn't see an
 open issue on the Python bug tracker about this; you might want to open
 one.  In the meantime, some options would be to find an SMTP mail host
 that doesn't require TLS.  Or write a custom logger.  Or on OS X it's
 not *too* difficult to set up a local host mailer using the
 Apple-supplied prefix that would accept mail locally and forward it to a
 more sophisticated remote mailer.

 --
  Ned Deily,
  n...@acm.org- Hide quoted text -

 - Show quoted text -

Thanks for the excellent and informative response :-).  I'll
investigate further, as you suggested, now that I understand what is
happening.

Bev in TX
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Missing sqlite3.h Error when Building Debug Python -- Windows Vista

2008-07-21 Thread Bev in TX
Thanks for letting me know about this.  I installed Subversion and
tried to make the build work like that, but it fails.

1) I am building 64-bit on Vista, so I used build-amd64.bat instead of
build.bat.

2) build-amd64.bat was setup to use MSVS 9.0, while I am using MSVS
8.0.  Also, some of the BATCH programs incorrectly added a backslash
after the %VS90COMNTOOLS% environment variable.  I corrected those to
use %VS80COMNTOOLS%, without the backslash.

3) It then complained about incompatible solution/project files, so I
modified build-amd64.bat to use the solution/project files in pc\vs8.0
instead of pcbuild.

4) It now has errors/warnings like:
C:\Program Files (x86)\Microsoft Visual Studio 8\VC\PlatformSDK\include
\prsht.h(531) : error C2016: C requires that a struct or union has at
least one member
...
c1 : fatal error C1083: Cannot open source file: '..\..\..
\db-4.4.20\common\zerofill.c': No such file or directory
xa_map.c
...
4..\..\Python\getargs.c(319) : warning C4244: 'function' : conversion
from 'Py_ssize_t' to 'int', possible loss of data

So I don't see how the amd64-bit builds are working out of the box on
MS Windows Vista, and I may have made some error when changing the
build files.

I'd appreciate any other thoughts ...

Bev in TX

On Jul 20, 10:36 am, Tim Golden [EMAIL PROTECTED] wrote:
 I'll leave others to comment on whether or not
 it's expected to build with VS2005, but the easiest
 way to get a debug build is to pretend to be a buildbot.

 1) Check out the python source into, say, c:\dev\python

 svn cohttp://svn.python.org/projects/python/trunkc:\dev\python

 2) Switch to that directory

 cd \dev\python

 3) Pretend to be a buildbot

 tools\buildbot\build

 This will checkout all the necessary sources into, in my
 example, c:\dev. It will then run all the build steps
 necessary to get a debug build which will then be in

 c:\dev\python\pcbuild\python_d.exe

 TJG

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


Missing sqlite3.h Error when Building Debug Python -- Windows Vista

2008-07-19 Thread Bev in TX
I am a complete newbie at building Python.  I am trying to build it
under MS Windows Vista (64-bit AMD) with MS VS2005.  I'm doing that
because I need debug libraries, which I did not see in the standard
distribution.

I downloaded the source and found the MSVS8 solution/project files.
However, when I tried to build it I got the following error:

...\python-2.5.2\modules\_sqlite\connection.h(33) : fatal error C1083:
Cannot open include file: 'sqlite3.h': No such file or directory

I searched on the web, and at one place it said I would just need to
download sqlite3.h from sqlite.org.  I looked around there, but I
could not find the source for sqlite 3.3.4.  I went back and reread
the PCbuild8\readme.txt file, and it mentions using the following
command to download the sqlite:

svn export http://svn.python.org/projects/external/sqlite-source-3.3.4

Do I really need to get the whole thing, or will just sqlite3.h
resolve the build problem.  As far as I know, I don't really need
sqlite.  If I do need to execute that svn command, how do I execute
that under MS Windows?

Or is there some other way in which to circumvent this error?

Thanks,
Bev in TX
--
http://mail.python.org/mailman/listinfo/python-list