PythonPath / sys.path

2023-05-14 Thread Grizzy Adams via Python-list
Hi All

My first post (repeated)

I am having a problem with PythonPath / sys.path

I have a dir where I keep all my current work, but I can't seem to add it to 
PythonPath / sys.path

When I try to import one of my modules I see

>>>import My_Working_File
Traceback (most recent call last):
  File "", line 1, in 
import My_Working_File
ImportError: No module named 'My_Working_File'

I have tried adding my dir in registry to the existing PythonPath 

[HKEY_CURRENT_USER\Software\Python\PythonCore\3.4\PythonPath]
@="D:\\Shades\\Tools\\Python\\Lib;D:\\Shades\\Tools\\Python\\DLLs"

that did not help, 

I tried adding PYTHONPATH as an enviramental variable, that also had no effect

(I did re-boot after these two tests)

If I go to the editor window and run (F5) any of my modules then I can 

>>>  RESTART 
>>> 
>>> import My_Working_File
>>> 

without error

I can also (from a fresh start) 

>>> import sys
>>> sys.path.append(r'D:\Shades\Tools\Python\MyWork')
>>> print(sys.path)
['', 'D:\\Shades\\Tools\\Python\\Lib\\idlelib', 
'D:\\Shades\\Tools\\Python\\python34.zip', 'D:\\Shades\\Tools\\Python\\DLLs', 
'D:\\Shades\\Tools\\Python\\lib', 'D:\\Shades\\Tools\\Python', 
'D:\\Shades\\Tools\\Python\\lib\\site-packages', 
'D:\\Shades\\Tools\\Python\\MyWork']
>>> import My_Working_File
>>>

I don't really want to go this route every time I start work, and more to the 
point I will need (to learn how) to add dir's to the path at times

I did search the net for an answer but only got what I had already tried

any pointers what I'm doing wrong (other than using windows '->) 

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


Re: PythonPath / sys.path

2023-05-14 Thread Grizzy Adams via Python-list
Sunday, May 14, 2023  at 11:11, Mats Wichmann wrote:
Re: PythonPath / sys.path (at least in part)

>On 5/14/23 10:43, Barry wrote:

>> I take it you have business reasons to use an obsolete version python.
>> Where did you get your version of python from?

>In fact, a *nine* year old version of Python that reached end-of-life 
>four years ago.

>Just sayin'

>Python version shouldn't have anything to do with the sys.path, though.

I must have slept a while

Python 3.4.10 (default, Jul 14 2019, 14:41:03) [MSC v.1600 32 bit (Intel)] on 
win32

Actually I did have 3..4.3 when I asked the question (first time) because I 
could only find 3.4.10 as src and did not feel I was able to compile it with 
any certainty ;->)

I have since moved up (a little) so only ~4 years old, I then updated pip from 
9.x to 19.1

reason its an old version is it's an old PC (XpPro), if I start to get passable 

at this I will try it on my Ubuntu box which is running 22.04 (latest LTS) and 
23.04, (23.10 daily builds soon) I took a look and it seems I "may" have to 
play a little to get IDLE on (if it's not in the normal repo's)

I seem to have managed to sort "PythonPath / sys.path" the environment variable 

is working, so I can now import my_work without any other hassle, which is 
good, now I find that some of the files which worked a treat from GUI, Editor 
(F5) or terminal but don't do the same once saved and imported later, I'm sure 
it's me, I have come from VB/VBA, Delphi and a (very) little C++, and am still 
working through the python tutorial, trying not to skip ahead (ok I did skip 
"Hello World" :->) so I may end up asking some (senior moment) newbie 
questions, I will try hard to work it out myself first

Thanks to all who got me thus far

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


Re: What to use instead of nntplib?

2023-05-16 Thread Grizzy Adams via Python-list
Tuesday, May 16, 2023  at 9:26, Alan Gauld wrote:
Re: What to use instead of nntplib? (at least in part)

>On 15/05/2023 22:11, Grant Edwards wrote:
>> I got a nice warning today from the inews utility I use daily:
>> 
>> DeprecationWarning: 'nntplib' is deprecated and slated for removal in 
>> Python 3.13
>> 
>> What should I use in place of nntplib?

>I'm curious as to why nntplib is deprecated? Surely there are still a
>lot of nntp servers around

there must be this list is mirrored on one, and AFAICS some pythoners use that 
way to post (over the list)
-- 
https://mail.python.org/mailman/listinfo/python-list


Silly (maybe) question re imported module(s)

2023-05-18 Thread Grizzy Adams via Python-list
Morning All

I'm working through the tutorial and running / saving work that I wish to keep 
and build on, most times I can save and (re)import later with no difference to 
when typed in console or editor and run with F5 (which saves before it can run) 


But sometimes saved work (albeit small) when imported does not work any longer

I assume I have missed something, any pointers to what/how/why please




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


Re: Silly (maybe) question re imported module(s)

2023-05-19 Thread Grizzy Adams via Python-list
Friday, May 19, 2023  at 12:25, Barry Scott wrote:
Re: Silly (maybe) question re impor (at least in part)

>
>
>> On 19 May 2023, at 07:44, Grizzy Adams via Python-list 
>>  wrote:
>> 
>> Morning All
>> 
>> I'm working through the tutorial and running / saving work that I wish to 
>> keep 
>> and build on, most times I can save and (re)import later with no difference 
>> to 
>> when typed in console or editor and run with F5 (which saves before it can 
>> run) 
>> 
>> But sometimes saved work (albeit small) when imported does not work any 
>> longer
 
>> I assume I have missed something, any pointers to what/how/why please

>reimport is not 100% reliable, in simple cases it will work, but as your
>code gets more complex it can break.

at the moment my code is very minimal, one saved piece is a nice one-liner that 
I kept because I wanted to remember syntax and how easy/elegant "some" things 
are in python, but if I import it it fails

>I rarely use reimport. Usually just exit python and start again.

I may have confused this I use import to get my saved work, the "re" was to 
shoe it had been saved by the editor

>If you are working on scripts then just run them from the Terminal
>will work well with any need to use reimport.

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


Re: Checking if email is valid

2023-11-02 Thread Grizzy Adams via Python-list
Thursday, November 02, 2023  at 6:46, Simon Connah via Python-list wrote:
Re: Checking if email is valid (at least in part)

>My goal is to make a simple mailing list platform. I guess I could just send
>email to an address and if it bounces then I can remove it from the database.

That function is "built in" with many email clients, I use a modified version 
to move probably dead addresses to a "bounced" folder, from there I can build a 
Dlist with one click and test again later, even later I add these addresss to a 
larger Dlist to filter for mail from known bad/dead addresses
-- 
https://mail.python.org/mailman/listinfo/python-list


Newline (NuBe Question)

2023-11-14 Thread Grizzy Adams via Python-list
Hi & thanks for patience with what could be simple to you

Have this (from an online "classes" tutorial) 

--- Start Code Snippit  ---

students = []
grades = []
for s in geographyClass:
students.append(geographyStudent(s))
for s in students:
grades.append(s.school)
grades.append(s.name)
grades.append(s.finalGrade())
if s.finalGrade()>82:
grades.append("Pass")
else:
grades.append("Fail")
print(grades)

--- End Code Snippit  ---

I have extended (from tutorial) it a bit, I would really like to have a newline 

at end of each record, I have searched (and tested) but cant get "\n" to give a 

newline, I get "Mydata\n"

Do I need to replace "append" with "print", or is there a way to get the 
newline in as I append to list?

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


Re: Newline (NuBe Question)

2023-11-15 Thread Grizzy Adams via Python-list
Wednesday, November 15, 2023  at 9:50, Alan Gauld via Python-list wrote:
Re: Newline (NuBe Question) (at least in part)

>On 15/11/2023 07:25, Grizzy Adams via Python-list wrote:

>> for s in students:
>> grades.append(s.school)
>> grades.append(s.name)
>> grades.append(s.finalGrade())
>> if s.finalGrade()>82:
>> grades.append("Pass")
>> else:
>> grades.append("Fail")
>> print(grades)
>> 
>> --- End Code Snippit  ---

>> Do I need to replace "append" with "print", or is there a way to get the 
>> newline in as I append to list?

>Firstly, it is usually a bad idea to mix formatting features(like
>newline) with the data. You will need to remove them again if you want
>to work with the data itself.

True, I onlt went that way when my (vain) attempts to add a newline any other 
way, my usual language is VB/VBA, Delphi or C++ at a push, so I'm really a nube 
here

>So, better to print the raw data and add the formatting during printing.

>There are a couple of options here (well more than a couple actually!)
>The simplest is to create another for loop and print each field with a
>newline automatically added by print()

>Another is to simply join everything in grades together separated by
>newlines. Python has a method to do that called join():

>print('\n'.join(grades))

>Unfortunately it seems your data has a mix of strings and numbers so
>that won't work without some tweaks:

>print('\n'.join(str(f) for f in grades))

that gets closer (sort of) my old code gave on long (only 5 records so far) 
list,

['Example High', 'Mary', 89.6, 'Pass', 'Example High', 'Matthew', 76.5, 'Fail', 
'Example High', 'Marie', 80.4, 'Fail', 'Example High', 'Manuel', 79.6, 'Fail', 
'Example High', 'Malala', 98.9, 'Pass']

your code gives one tall column, 

Example High
Mary
89.6
Pass
Example High
Matthew
76.5
Fail
Example High
Marie
80.4
Fail
Example High
Manuel
79.6
Fail
Example High
Malala
98.9
Pass

my ideal one row for each student (this I have edited manually)

Example High, Mary, 89.6, Pass
Example High, Matthew, 76.5, Fail
Example High, Marie, 80.4, Fail
Example High, Manuel, 79.6, Fail
Example High, Malala, 98.9, Pass

>However, I wonder if this really what you want? You have created grades as a
>long list containing all of the attributes of all of the students plus their
>Pass/Fail status. But you have no (easy)way to access the Pass/Fail value for
>each student. Do you really want to store the Pass/Fail in the student? And
>then print the students? Like so: 

I do want to keep the data in tact, incase it gets reused later in the 
tutorial(s)

>Just a thought...

>PS. There are neater ways to do this but you may not have covered
>those yet so I'll stick to basics.

I already jumped forward a bit (to python Classes)

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


Re: Newline (NuBe Question)

2023-11-15 Thread Grizzy Adams via Python-list
Wednesday, November 15, 2023  at 9:45, Thomas Passin via Python-list wrote:
Re: Newline (NuBe Question) (at least in part)

>On 11/15/2023 2:25 AM, Grizzy Adams via Python-list wrote:
>> Hi & thanks for patience with what could be simple to you

>You may see responses that suggest various code alternatives.  But you 
>haven't shown us an example of what you want the output to look like,

Offered code got closer (sort of) my old code gave on long (only 5 records so 
far) list,

['Example High', 'Mary', 89.6, 'Pass', 'Example High', 'Matthew', 76.5, 'Fail', 
'Example High', 'Marie', 80.4, 'Fail', 'Example High', 'Manuel', 79.6, 'Fail', 
'Example High', 'Malala', 98.9, 'Pass']

offered code gave one tall column,

Example High
Mary
89.6
Pass
Example High
Matthew
76.5
Fail
Example High
Marie
80.4
Fail
Example High
Manuel
79.6
Fail
Example High
Malala
98.9
Pass

my ideal is one row for each student (I had edited manually to show this)

Example High, Mary, 89.6, Pass
Example High, Matthew, 76.5, Fail
Example High, Marie, 80.4, Fail
Example High, Manuel, 79.6, Fail
Example High, Malala, 98.9, Pass
 
>and you haven't said what else you plan to use the list for.  So anyone 
>who responds has to fly blind, without knowing key information.

I'll keep list for a while in case it gets used or reused later, for now it's 
just a test bed along with a few others, I can work thru as I learn 

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


Re: Newline (NuBe Question)

2023-11-15 Thread Grizzy Adams via Python-list
Wednesday, November 15, 2023  at 12:19, Pierre Fortin wrote:
Re: Newline (NuBe Question) (at least in part)

>On Wed, 15 Nov 2023 16:51:09 -0000 Grizzy Adams via Python-list wrote:
>
>I don't give solutions; just a nudge...  you appear not to fully grok
>"list"; your list is ONE list with no delineation between students. You
>want a "list of lists"...

>>['Example High', 'Mary', 89.6, 'Pass', 'Example High', 'Matthew', 76.5, 
>>'Fail', 'Example High', 'Marie', 80.4, 'Fail', 'Example High', 'Manuel', 
>>79.6, 'Fail', 'Example High', 'Malala', 98.9, 'Pass']

>Like this:

>students = [
>['Example High', 'Mary', 89.6, 'Pass'],
>['Example High','Matthew', 76.5, 'Fail'],
>['Example High', 'Marie', 80.4, 'Fail'],
>['Example High', 'Manuel', 79.6, 'Fail'],
>['Example High', 'Malala', 98.9, 'Pass']
>]

for now I made a copt of code and altered to 

students = []
grades = []
for s in geographyClass:
students.append(geographyStudent(s))

for s in students:
 if s.finalGrade()>82: Result=("Pass")
   else: Result=("Fail")
   print(s.school, s.name, s.finalGrade(),Result)

>This may help get you headed in the right direction:

>for s in students:
>print( s )

>Hint: look forward to learning about f-strings...

I will look forward to them, may even go search ahead, 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Newline (NuBe Question)

2023-11-15 Thread Grizzy Adams via Python-list
Wednesday, November 15, 2023  at 15:54, Thomas Passin via Python-list wrote:
Re: Newline (NuBe Question) (at least in part)

>On 11/15/2023 2:04 PM, Grizzy Adams via Python-list wrote:
>> Wednesday, November 15, 2023  at 12:19, Pierre Fortin wrote:
>> Re: Newline (NuBe Question) (at least in part)
 
>>> On Wed, 15 Nov 2023 16:51:09 - Grizzy Adams via Python-list wrote:

>>> I don't give solutions; just a nudge...  you appear not to fully grok
>>> "list"; your list is ONE list with no delineation between students. You
>>> want a "list of lists"...
 
>>>> ['Example High', 'Mary', 89.6, 'Pass', 'Example High', 'Matthew', 76.5, 
>>>> 'Fail', 'Example High', 'Marie', 80.4, 'Fail', 'Example High', 'Manuel', 
>>>> 79.6, 'Fail', 'Example High', 'Malala', 98.9, 'Pass']

>>> Like this:
 
>>> students = [
>>> ['Example High', 'Mary', 89.6, 'Pass'],
>>> ['Example High','Matthew', 76.5, 'Fail'],
>>> ['Example High', 'Marie', 80.4, 'Fail'],
>>> ['Example High', 'Manuel', 79.6, 'Fail'],
>>> ['Example High', 'Malala', 98.9, 'Pass']
>>> ]
 
>> for now I made a copt of code and altered to
>> 
>> students = []
>> grades = []

># In this design there is no point in the extra loop.
># also, the indentation is wrong.  Perhaps you inserted
># tabs?  Use only spaces in these posts.

I copy-pasted the code direct from IDLE, (to avoid any other typo's) 

># Also you don't need the students list
>> for student in geographyClass:
>>  # students.append(geographyStudent(s))
> s = geographyStudent(student)
>> 
>  # for s in students:
>>   if s.finalGrade()>82: Result=("Pass")
>>   else: Result=("Fail")
>>   print(s.school, s.name, s.finalGrade(),Result)

I'll hive this a try (as a learning point)

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


Re: Newline (NuBe Question)

2023-11-16 Thread Grizzy Adams via Python-list
Thursday, November 16, 2023  at 7:47, Thomas Passin via Python-list wrote:
Re: Newline (NuBe Question) (at least in part)

>I wrote that you don't need the "students" list, which is correct.  But 
>there could be a use for a list.  It would let you change the order in 
>which students appear in the printed output.  Knowing how to do that is 
>a useful skill.  But that should be left for a later lesson, not mixed 
>in here.

I have a vague memory of seeing sorted list somewhere ;->)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Extract lines from file, add to new files

2024-01-11 Thread Grizzy Adams via Python-list
Thursday, January 11, 2024  at 10:44, Rich Shepard via Python-list wrote:
Re: Extract lines from file, add to (at least in part)

>On Thu, 11 Jan 2024, MRAB via Python-list wrote:

>> From the look of it:
>> 1. If the line is empty, ignore it.
>> 2. If the line contains "@", it's an email address.
>> 3. Otherwise, it's a name.

If that is it all? a simple Grep would do (and save on the blank line)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: test-ignore

2024-02-16 Thread Grizzy Adams via Python-list
Thursday, February 15, 2024  at 16:02, Tony Oliver via Python-list wrote:
Re: test-ignore (at least in part)

>On Thursday 15 February 2024 at 21:16:22 UTC, E.D.G. wrote:
>> Test - ignore February 15, 2024 
>> 
>> Test post to see if my Newsgroup post program is working.
>
>Aim your test messages at alt.test, please.

or alt.test.ignore
-- 
https://mail.python.org/mailman/listinfo/python-list