Re: Reading mail getting [, ...

2019-12-14 Thread dieter
Abdur-Rahmaan Janhangeer  writes:

> Can you please indicate where is the header in my code above? Thanks.

Python is an object oriented language. As a consequence,
Python functions often return complex objects and not only
elementary objects. Use the documentation of the complex object's class
to find out how to work with them.

In general, Python has two functions to get a readable
description for an object: "repr" and "str".
"" is a typical
return value for "repr". Apply "str" to this message object
to get a representation which likely fits better your expectations.

Read the documentation for "email.message.Message" to learn how
to work with those "Message" objects on a more granular level.

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


Re: 3rd party mail package

2019-12-14 Thread Barry
I guess the 2nd party is the user.

Barry

> On 13 Dec 2019, at 21:13, Abdur-Rahmaan Janhangeer  
> wrote:
> 
> Wonder where the 2nd party went to. Thanks will look into it!
> -- 
> https://mail.python.org/mailman/listinfo/python-list
> 

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


Setting Pythonpath programmatic

2019-12-14 Thread Prasad Rajassekaran
0


Aim:-

I would want to set python path programmatic in my project. So that, all other 
directories files can be imported without any issues.

Problem statement:-

I used to add all the folders & sub-folders in environment variables under 
PYTHONPATH but this has two constrains.

1, Any new folders created need to be added in environment variables all the 
times. After certain limit, environment variables will not be accepted new path 
reference due to characters limitaion.

- Error: This environment variable is too large. This dialog allows setting 
values up to 2047 characters long.

2, Secondly, all the team members in my team need to perform the same activity 
manually all the times.

Tried self solution:-

Created a sample folder and added the below code before main import files and 
ran from command prompt which worked perfectly fine.

**FilePath: foo/Python/Learning&Development/Pratice/Directory1/File1.py**

class File1():

def parent(self):
return "I am from File1"

**FilePath: foo/Python/Learning&Development/Pratice/Directory2/File2.py**

import sys
try:
sys.path.index('foo/Python/Learning&Development')
sys.path.index('foo/Python/Learning&Development/Pratice')
sys.path.index('foo/Python/Learning&Development/Pratice/Directory1')
sys.path.index('foo/Python/Learning&Development/Pratice/Directory2')
except ValueError:
sys.path.append('foo/Python/Learning&Development')
sys.path.append('foo/Python/Learning&Development/Pratice')
sys.path.append('foo/Python/Learning&Development/Pratice/Directory1')
sys.path.append('foo/Python/Learning&Development/Pratice/Directory2')

from Pratice.Directory1.File1 import File1 as f


class File2():

def child(self):
return f.parent(self)
Results:

I am from File1

Now I wish to convert the sys.path as a single method and call automatically 
before running any .py file in the project folder.

So, on trail basis, I created 'init.py' file added the same piece (sys.path) of 
code, commented the same code in File2.py and run it but ended up with file 
import error.

**FilePath: foo/Python/Learning&Development/Pratice/Directory2/__init__.py**

import sys
try:
sys.path.index('foo/Automation/Python/Learning&Development')
sys.path.index('foo/Automation/Python/Learning&Development/Pratice')

sys.path.index('foo/Automation/Python/Learning&Development/Pratice/Directory1')

sys.path.index('foo/Automation/Python/Learning&Development/Pratice/Directory2')
except ValueError:
sys.path.append('foo/Automation/Python/Learning&Development')
sys.path.append('foo/Automation/Python/Learning&Development/Pratice')
sys.path.append('foo/Automation/Python/Learning&Development/Pratice/Directory1')
 
sys.path.append('foo/Automation/Python/Learning&Development/Pratice/Directory2')

**FilePath: foo/Python/Learning&Development/Pratice/Directory1/File1.py**

class File1():

def parent(self):
return "I am from File1"

**FilePath: foo/Python/Learning&Development/Pratice/Directory2/File2.py**

# import sys
# try:
# sys.path.index('foo/Python/Learning&Development')
# sys.path.index('foo/Python/Learning&Development/Pratice')
# sys.path.index('foo/Python/Learning&Development/Pratice/Directory1')
# sys.path.index('foo/Python/Learning&Development/Pratice/Directory2')
# except ValueError:
# sys.path.append('foo/Python/Learning&Development')
# sys.path.append('foo/Python/Learning&Development/Pratice')
# sys.path.append('foo/Python/Learning&Development/Pratice/Directory1')
# sys.path.append('foo/Python/Learning&Development/Pratice/Directory2')

from Pratice.Directory1.File1 import File1 as f


class File2():

def child(self):
return f.parent(self)
Results:

Traceback (most recent call last):
  File "File2.py", line 13, in 
from Pratice.Directory1.File1 import File1 as f
ModuleNotFoundError: No module named 'Pratice

Could someone help me on this problem? I would want the same piece of code to 
be executed before running any of the .py file in my project folder. So that, 
import error would not come into picture.

Expected: Python path should be set automatically by default and import error 
should not occur while running any python file in the project.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: help with tkinter

2019-12-14 Thread Terry Reedy

On 8/9/2019 3:40 AM, Ahmad Adam Kabbara wrote:


  when I write**from
  tkinter import*


Please put statements on one line.

from tkinter import *



  t=Tk()
  tkinter.colorchooser.askcolor()
  I get this error message
  Traceback (most recent call last):
  ** File "C:\Users\kabba\Desktop\color and coordinates.py", line 3, in
  
  ** tkinter.colorchooser.askcolor()
  NameError: name 'tkinter' is not defined


Please reread the sections of the tutorial and reference that explain 
imports and their effect on the names available in the *importing* module.



  I also tried another way**
  from tkinter.colorchooser import*
  colorchooser.askcolor()
  and I also got an error message
  Traceback (most recent call last):
  ** File "", line 1, in 
  ** colorchooser.askcolor()
  NameError: name 'colorchooser' is not defined


Same issue, which has nothing to do with tkinter as such.  The title 
should be 'Help with imports'.



  the only time it worked is when I typed**
  from tkinter import colorchooser
  colorchooser.askcolor()


When you import the name 'colorchooser', it is defined and usable.  When 
you do not, it is not.  Keep doing experiments until you see the pattern 
and principle.  Learning experiments are really easy with python.


--
Terry Jan Reedy

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


Re: Difference between os.path.isdir and Path.is_dir

2019-12-14 Thread Terry Reedy

On 7/26/2019 3:12 AM, Kirill Balunov wrote:

чт, 25 июл. 2019 г. в 20:28, eryk sun :


On 7/25/19, Kirill Balunov  wrote:



import os
from pathlib import Path
dummy = " "   # or "" or " "
os.path.isdir(dummy)

False

Path(dummy).is_dir()

True


I can't reproduce the above result in either Linux or Windows. The
results should only be different for an empty path string, since
Path('') is the same as Path('.'). The results should be the same for
Path(" "), depending on whether a directory named " " exists (normally
not allowed in Windows, but Linux allows it).



I need to confirm that it was my fault and for non-empty strings (`" "` or `"
"`), both `os.path.isdir(...)` and `Path(...).is_dir()` produce the same
results.So sorry for the noise.

Concerning the case with empty path string, I will open a ticket at the bug
tracker (but for some reason it is blocked in my country :(
https://isitblockedinrussia.com/?host=https%3A%2F%2Fbugs.python.org%2F).


For me, this now returns 'No, https://bugs.python.org is probably not 
blocked in Russia. Yet.'.



Obviously
these are not equivalent forms, so either this should be noted in the
documentation or corrected in the code.


--
Terry Jan Reedy


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


Fwd: Problem installing pygame

2019-12-14 Thread Eric Gonzalez



Get Outlook for Android

From: Eric Gonzalez
Sent: Thursday, December 12, 2019 9:35:40 PM
To: [email protected] 
Subject: Problem installing pygame

Hello, with the above mentioned i am having some serious problems with the 
installation of "Pygame" on my laptop.
I have tried using the "pip" method and it tells me that ''pip' is not 
recognized as an internal or external command, operable program or batch file 
', i researched but honestly i don't know what to do. I  installed the python 
program the proper way, but for some reason the 'pip' method doesn't work for 
me,  I also tried the method whereby you go and find which pygame SDL package 
that is compatible with my 32 bit windows 10 and it didn't work either. Oh...  
i tried using the pip method in pycharm but it was unsuccessful as well.

Am a rookie 1 with python, really love the language its very efficient and easy 
to learn hence the reason i love it and am focusing on only learning this 
language for its the BEST
Please help me i would really appreciate it a lot.

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


Re: Difference between os.path.isdir and Path.is_dir

2019-12-14 Thread Kirill Balunov
Yeah it is True, for the last two weeks or so I can access bugs.python.org
in normal way. But I totally agree with the site that the best description
of this situation is "Yet".

with kind regards,
-gdg

сб, 14 дек. 2019 г. в 19:46, Terry Reedy :

> On 7/26/2019 3:12 AM, Kirill Balunov wrote:
> > чт, 25 июл. 2019 г. в 20:28, eryk sun :
> >
> >> On 7/25/19, Kirill Balunov  wrote:
> >>>
> >> import os
> >> from pathlib import Path
> >> dummy = " "   # or "" or " "
> >> os.path.isdir(dummy)
> >>> False
> >> Path(dummy).is_dir()
> >>> True
> >>
> >> I can't reproduce the above result in either Linux or Windows. The
> >> results should only be different for an empty path string, since
> >> Path('') is the same as Path('.'). The results should be the same for
> >> Path(" "), depending on whether a directory named " " exists (normally
> >> not allowed in Windows, but Linux allows it).
> >>
> >>
> > I need to confirm that it was my fault and for non-empty strings (`" "`
> or `"
> > "`), both `os.path.isdir(...)` and `Path(...).is_dir()` produce the same
> > results.So sorry for the noise.
> >
> > Concerning the case with empty path string, I will open a ticket at the
> bug
> > tracker (but for some reason it is blocked in my country :(
> > https://isitblockedinrussia.com/?host=https%3A%2F%2Fbugs.python.org%2F).
>
> For me, this now returns 'No, https://bugs.python.org is probably not
> blocked in Russia. Yet.'.
>
> > Obviously
> > these are not equivalent forms, so either this should be noted in the
> > documentation or corrected in the code.
>
> --
> Terry Jan Reedy
>
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Fwd: Problem installing pygame

2019-12-14 Thread MRAB

On 2019-12-14 02:12, Eric Gonzalez wrote:



Get Outlook for Android

From: Eric Gonzalez
Sent: Thursday, December 12, 2019 9:35:40 PM
To: [email protected] 
Subject: Problem installing pygame

Hello, with the above mentioned i am having some serious problems with the installation 
of "Pygame" on my laptop.
I have tried using the "pip" method and it tells me that ''pip' is not 
recognized as an internal or external command, operable program or batch file ', i 
researched but honestly i don't know what to do. I  installed the python program the 
proper way, but for some reason the 'pip' method doesn't work for me,  I also tried the 
method whereby you go and find which pygame SDL package that is compatible with my 32 bit 
windows 10 and it didn't work either. Oh...  i tried using the pip method in pycharm but 
it was unsuccessful as well.

Am a rookie 1 with python, really love the language its very efficient and easy 
to learn hence the reason i love it and am focusing on only learning this 
language for its the BEST
Please help me i would really appreciate it a lot.


Try running pip via the Python launcher.

Instead of:

pip install XXX

try:

py -m pip install XXX
--
https://mail.python.org/mailman/listinfo/python-list