Re: Neither pdb or print() displays the bug

2021-06-02 Thread Peter Otten

On 01/06/2021 23:32, Rich Shepard wrote:

On Tue, 1 Jun 2021, Ethan Furman wrote:


Well, you only had two logging statements in that code -- logging is like
print: if you want to see it, you have to call it:


Ethan,

Got it, thanks.

I believe


Do you have unit tests? Those are an excellent tool to ensure that the 
components of an application work as expected and that those components 
have well-defined interfaces. Debugging a failing unittest is usually 
easier than to debug a complex application.
While I don't know if there is a convenient way to test the GUI 
everything else should run reliably *before* connecting it with the GUI.


my problem is with the datasource module. I'm focused on 
making it

work (using logging to confirm that it is doing so). Will report results
when they're available.

Regards,

Rich



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


Re: Neither pdb or print() displays the bug

2021-06-02 Thread Rich Shepard

On Wed, 2 Jun 2021, Peter Otten wrote:


Do you have unit tests? Those are an excellent tool to ensure that the
components of an application work as expected and that those components
have well-defined interfaces. Debugging a failing unittest is usually
easier than to debug a complex application. While I don't know if there is
a convenient way to test the GUI everything else should run reliably
*before* connecting it with the GUI.


Peter,

I believe there is a way to apply unit tests to PyQt and I'll certainly
learn to take this testing-while-developing approach.

Thanks,

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


fabric: fab command

2021-06-02 Thread jayshankar nair via Python-list
Hi,
I am unable to find the package for the below module. The error shows when i 
run the command fab(fabric).

import tools.fab.dev_utils as dev_utilsImportError: No module named 
tools.fab.dev_utils
Please let me know which package i have to install.
Thanks,Jayshankar
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Definition of "property"

2021-06-02 Thread George Fischhof
Greg Ewing  ezt írta (időpont: 2021. jún. 2.,
Sze, 4:01):

> On 1/06/21 7:01 am, Alan Gauld wrote:
> > That was the point, the OP said it was a book about OOP.
> > Not a book about "OOP in Python".
>
> In that case it would be best to avoid the word, or give
> a definition of the way he's using it, making it clear
> that it's not a universal definition. Python's definition
> is somewhat unusual, and so would not be appropriate.
>
> --
> Greg
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>


Hi,

I think in OOP point of view one can write that property is the python
implementation of the OOP concepts:
Encapsulation and Information hiding

Some explanation for beginners on these paradigms:
https://stackify.com/oop-concept-for-beginners-what-is-encapsulation/

BR,
George
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: fabric: fab command

2021-06-02 Thread Alan Gauld via Python-list
On 02/06/2021 14:35, jayshankar nair via Python-list wrote:

> import tools.fab.dev_utils as dev_utilsImportError: No module named 
> tools.fab.dev_utils
> Please let me know which package i have to install.

Work backwards.
Can you import tools.fab?
Can you import tools?

Once you know what you do have you can figure out
what you don't and why.

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


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


Interpreter Bug

2021-06-02 Thread Alice Braim
   Good morning-



   I am having some very serious issues with Python, and I was hoping you
   could help?

   I downloaded both Python and PyCharm, and the 2 do not seem to be working.
   Every time I select Python as an interpreter, the whole thing crashes.
   Obviously, I went onto repairs, but even then it told me there was a
   `fatal error'. I tried uninstalling and restarting multiple times, and
   nothing improved. I've tried redownloading loads of times, no improvement.
   I have the latest version (3.9.5) and there definitely seems to be
   something going on at your end.

   Any ideas?



   ~Alexa


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


Re: Embedding Python

2021-06-02 Thread Faraaz Mohammed
On Tuesday, 1 July 2008 at 21:37:49 UTC+5:30, mk wrote:
> Carsten Haese wrote:
> > python_code is a C string containing the raw bytes from your pyc file. 
> > Casting that to a PyObject pointer will not magically transform it into 
> > a Python code object.
>  well yeah, I kind of didn't think that through..
> A pyc file contains the following:
> > 
> > 1) An 8 byte header containing a magic number.
> > 2) A "marshal" serialization of the code object.
> > 
> > So, in order to transform those contents into a code object, you need to 
> > skip the 8 byte header and an unmarshal the rest. Basically, replace the 
> > line above with something like this:
> > 
> > codeobj = PyMarshal_ReadObjectFromString(python_code+8, size-8);
> > mainobj = PyImport_ExecCodeModule("multiply", codeobj);
> > 
> > where codeobj is of type (PyObject *).
> > 
> > Once that works, add magic number checking and exception handling to taste.
> Thanks. That's exactly what I was looking for.


I tried exactly the same thing. but I am still hitting segmentation fault at 
PyImport_ExecCodeModule(). python version is 2.7.17
-- 
https://mail.python.org/mailman/listinfo/python-list


3.7.6 struggles a bit

2021-06-02 Thread Luke
   When i wrote a program, i tried to open it but it struggles to open.


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


Re: Embedding Python

2021-06-02 Thread Chris Angelico
On Thu, Jun 3, 2021 at 4:05 AM Faraaz Mohammed  wrote:
>
> On Tuesday, 1 July 2008 at 21:37:49 UTC+5:30, mk wrote:
> > Carsten Haese wrote:
> > > python_code is a C string containing the raw bytes from your pyc file.
> > > Casting that to a PyObject pointer will not magically transform it into
> > > a Python code object.
> >  well yeah, I kind of didn't think that through..
> > A pyc file contains the following:
> > >
> > > 1) An 8 byte header containing a magic number.
> > > 2) A "marshal" serialization of the code object.
> > >
> > > So, in order to transform those contents into a code object, you need to
> > > skip the 8 byte header and an unmarshal the rest. Basically, replace the
> > > line above with something like this:
> > >
> > > codeobj = PyMarshal_ReadObjectFromString(python_code+8, size-8);
> > > mainobj = PyImport_ExecCodeModule("multiply", codeobj);
> > >
> > > where codeobj is of type (PyObject *).
> > >
> > > Once that works, add magic number checking and exception handling to 
> > > taste.
> > Thanks. That's exactly what I was looking for.
>
>
> I tried exactly the same thing. but I am still hitting segmentation fault at 
> PyImport_ExecCodeModule(). python version is 2.7.17

You're replying to something from *thirteen years ago*. A lot has
changed in that time. I'd recommend starting over, figuring out what's
going on, and preferably, using Python 3.

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


Re: 3.7.6 struggles a bit

2021-06-02 Thread Barry Scott



> On 2 Jun 2021, at 18:18, Luke  wrote:
> 
>   When i wrote a program, i tried to open it but it struggles to open.

I'm guessing you are a Windows user.

Does this help? https://docs.python.org/3/faq/windows.html 


Barry

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


Re: Interpreter Bug

2021-06-02 Thread Barry Scott



> On 2 Jun 2021, at 10:34, Alice Braim  wrote:
> 
>   Good morning-
> 
> 
> 
>   I am having some very serious issues with Python, and I was hoping you
>   could help?
> 
>   I downloaded both Python and PyCharm, and the 2 do not seem to be working.
>   Every time I select Python as an interpreter, the whole thing crashes.
>   Obviously, I went onto repairs, but even then it told me there was a
>   `fatal error'. I tried uninstalling and restarting multiple times, and
>   nothing improved. I've tried redownloading loads of times, no improvement.
>   I have the latest version (3.9.5) and there definitely seems to be
>   something going on at your end.

Details please: Which OS which version of Python etc.

What does crashes mean exactly?

Was it PyCharm that crashes or python that crashes?

Barry


> 
>   Any ideas?
> 
> 
> 
>   ~Alexa
> 
> 
> -- 
> https://mail.python.org/mailman/listinfo/python-list
> 

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


RE: How to debug python + curses? [was: RE: Applying winpdb_reborn]

2021-06-02 Thread pjfarley3
> -Original Message-
> From: Grant Edwards 
> Sent: Monday, May 31, 2021 11:18 AM
> To: python-list@python.org
> Subject: Re: How to debug python + curses? [was: RE: Applying
winpdb_reborn]
> 
> On 2021-05-31, Dennis Lee Bieber  wrote:
> > On Mon, 31 May 2021 08:07:21 +1000, Cameron Simpson 
> > declaimed the following:
> >
> >
> >>Open another terminal, note its terminal device with the "tty" command.
> >>Start your programme like this:
> >>
> >>python .. 2>/dev/tty-of-the-other-termina
> >
> > The OP specified Win10, so the above is dead from the start.
> 
> Perhaps Windows isn't an appropriate OS under which to develop curses
> applicatoins?

Perhaps, but why isn't it?


Why are Windows users, even knowledgeable ones, so often considered second-
or even third-class netizens?

I do know some of the answers that will come back for that question, but the
attitude is not professional.


Peter

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


RE: How to debug python + curses? [was: RE: Applying winpdb_reborn]

2021-06-02 Thread pjfarley3
> -Original Message-
> From: Dennis Lee Bieber 
> Sent: Monday, May 31, 2021 7:11 PM
> To: python-list@python.org
> Subject: Re: How to debug python + curses? [was: RE: Applying winpdb_reborn]
> 
> On Tue, 1 Jun 2021 08:04:54 +1000, Cameron Simpson 
> declaimed the following:
> 
> >On 30May2021 20:36, Dennis Lee Bieber  wrote:
> >>On Mon, 31 May 2021 08:07:21 +1000, Cameron Simpson 
> >>declaimed the following:
> >>>Open another terminal, note its terminal device with the "tty"
> >>>command.
> >>>Start your programme like this:
> >>>python .. 2>/dev/tty-of-the-other-termina
> >>>
> >>The OP specified Win10, so the above is dead from the start.
> >
> >Good point; I wasn't aware that curses worked in Windows.
> 
> https://docs.python.org/3/howto/curses.html
> "The Windows version of Python doesn’t include the curses module. A ported
> version called UniCurses is available."
> 
>   Appears the easiest is to PIP "windows-curses" then track down
> piecemeal installs (it is unclear if UniCurses includes PDCurses, or needs 
> that as a
> separate install).

Indeed, that is likely the one most commonly used because it is easy to install 
and mostly "just works".  Unicurses has not been worked on since 2010 and gets 
no responses to issues raised, plus these days it requires compiling your own 
binary of the PDCurses libraries (which isn’t actually very hard, but . . .).  
Also, PDCurses no longer distributes binary downloads for recent python 
versions.  The last version available as a binary download is for python 3.4.

Peter 

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


RE: How to debug python + curses? [was: RE: Applying winpdb_reborn]

2021-06-02 Thread pjfarley3
> -Original Message-
> From: Grant Edwards 
> Sent: Monday, May 31, 2021 11:17 AM
> To: python-list@python.org
> Subject: Re: How to debug python + curses? [was: RE: Applying
winpdb_reborn]
> 
> On 2021-05-30, Alan Gauld via Python-list  wrote:
> > On 30/05/2021 18:26, pjfarl...@earthlink.net wrote:
> >> I tried winpdb-reborn some time last year on my Win10 system (python
> >> 3.8.3 at that time), but could not figure out how to use it to debug
> >> a python script that uses the curses module.
> >
> > You are not alone. debugging curses is one of the biggest obstacles to
> > its use.
> 
> Can't you just run the debugger in a different window and attach to the
process
> you want to debug? That's how one uses a debugger with curses apps written
in
> C/C++. Or I add debugging printf calls which write to stderr and redirect
stderr to
> a file.

"Attach to another (console) process you want to debug" isn't, AFAIK, a
command-line capability from a Windows command prompt as it is in *ix
terminal windows.

> > My approach is to define a status line at the bottom of my program and
> > write print statements into that window. Something like:
> 
> Why not just use the standard python logging facility and log to a file or
another
> terminal window?

As I said in an earlier reply, I have done that, and it works, but it is
somewhat slower and certainly not interactive.

Peter

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


RE: How to debug python + curses? [was: RE: Applying winpdb_reborn]

2021-06-02 Thread pjfarley3
> -Original Message-
> From: jak 
> Sent: Tuesday, June 1, 2021 3:34 AM
> To: python-list@python.org
> Subject: Re: How to debug python + curses? [was: RE: Applying
winpdb_reborn]
> 
> Il 31/05/2021 02:36, Dennis Lee Bieber ha scritto:
> > On Mon, 31 May 2021 08:07:21 +1000, Cameron Simpson 
> > declaimed the following:
> >
> >
> >> Open another terminal, note its terminal device with the "tty" command.
> >> Start your programme like this:
> >>
> >> python .. 2>/dev/tty-of-the-other-termina
> >>
> >
> > The OP specified Win10, so the above is dead from the start.
> >
> >
> 
> OP can try this way on win10: write the debug information in a log file
and, from
> another console, open the same log file with an editor that knows how to
check
> the active status of the file (eg: notepad++), which can automatically
update the
> changes (you can remove the notification for this action from the tab
> preferences).

For this kind of debugging (write a log and review it later) a live view of
what is happening in the log isn't always that helpful.

Peter

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


RE: How to debug python + curses? [was: RE: Applying winpdb_reborn]

2021-06-02 Thread pjfarley3
> -Original Message-
> From: Cameron Simpson 
> Sent: Tuesday, June 1, 2021 7:32 PM
> To: python-list@python.org
> Subject: Re: How to debug python + curses? [was: RE: Applying
winpdb_reborn]
> 
> On 01Jun2021 19:48, Alan Gauld  wrote:
> >On 31/05/2021 16:16, Grant Edwards wrote:
> >> On 2021-05-30, Alan Gauld via Python-list 
wrote:
> >>> You are not alone. debugging curses is one of the biggest obstacles
> >>> to its use.
> >>
> >> Can't you just run the debugger in a different window and attach to
> >> the process you want to debug? That's how one uses a debugger with
> >> curses apps written in C/C++.
> >
> >That's how we did it when I used curses on VMS/Unix using C.
> 
> That's ok for C-level things - they're close to the metal. But this is
Python, so
> such tools may well be poorly adapted.
> 
> >But I confess I didn't think you could attach any python debugger to
> >another python session?
> 
> Dennis Lee Bieber wrote earlier in this thread:
 
> So it sounds like someone's done the hard work here. I can imagine it
embeds a
> Python proxy in the app which can be remote controlled from the debugger
> client, but I'm just guessing wildly.

If winpdb_reborn worked, that would be true.  The original thread did also
discuss how often it did not work.

Peter

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


RE: How to debug python + curses? [was: RE: Applying winpdb_reborn]

2021-06-02 Thread pjfarley3
> -Original Message-
> From: Jach Feng 
> Sent: Tuesday, June 1, 2021 9:19 PM
> To: python-list@python.org
> Subject: Re: How to debug python + curses? [was: RE: Applying winpdb_reborn]
> 
> pjfa...@earthlink.net 在 2021年5月31日 星期一上午1:42:43 [UTC+8] 的信中寫
> 道:
> > I tried winpdb-reborn some time last year on my Win10 system (python
> > 3.8.3 at that time), but could not figure out how to use it to debug a
> > python script that uses the curses module.
> >
> > Does anyone here know if winpdb-reborn or any other debugger can
> > support 2-window debugging for a python script that uses the curses
> > module? It seems to me that a 2-window debugging session is necessary
> > for a python script that uses the curses module because using curses
> > takes over the screen from which the script is started, so debugging
> > output and script output need to be in separate windows.
> >
> > I've been forced to use a logger to trace critical values and program
> > flow for errors in such a script. It works, but it is annoyingly slow
> > to debug that way.
> >
> > TIA for any advice or RTFM you can provide.
> >
> > Peter
> > --
> I have no problem on using rpdb2 to debug a script which is based on curses.
> 
> My environment are:
> Windows Vista, Python 3.4.4, rpdb2 of winpdb-1.4.8, curses-2.2-cp34-cp34m-
> win32.whl, snake.py
> 
> Everything are old, but it works:-)

Indeed, I can believe that.  My problem is that my system has much more recent 
versions that I do need to use.

I may, as I said previously, try winpdb_reborn again and see how it works with 
fresh eyes and some accumulated experience.

Peter
--

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


RE: How to debug python + curses? [was: RE: Applying winpdb_reborn]

2021-06-02 Thread pjfarley3
> -Original Message-
> From: boB Stepp 
> Sent: Wednesday, June 2, 2021 12:21 AM
> To: python-list@python.org
> Subject: Re: How to debug python + curses? [was: RE: Applying winpdb_reborn]
 
> windows-curses 2.2.0 has been working well for me so far on Win10:
> https://pypi.org/project/windows-curses/
> 
> "Adds support for the standard Python curses module on Windows. Based on
> these wheels. Uses the PDCurses curses implementation."

Agreed.  Mostly it "just works".

Peter
--

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


Re: How to debug python + curses? [was: RE: Applying winpdb_reborn]

2021-06-02 Thread Grant Edwards
On 2021-06-03,   wrote:
>> -Original Message-
>> From: Grant Edwards 
>> Sent: Monday, May 31, 2021 11:18 AM
>> To: python-list@python.org
>> Subject: Re: How to debug python + curses? [was: RE: Applying
> winpdb_reborn]
>> 
>> On 2021-05-31, Dennis Lee Bieber  wrote:
>> > On Mon, 31 May 2021 08:07:21 +1000, Cameron Simpson 
>> > declaimed the following:
>> >
>> >
>> >>Open another terminal, note its terminal device with the "tty" command.
>> >>Start your programme like this:
>> >>
>> >>python .. 2>/dev/tty-of-the-other-termina
>> >
>> >The OP specified Win10, so the above is dead from the start.
>> 
>> Perhaps Windows isn't an appropriate OS under which to develop curses
>> applicatoins?
>
> Perhaps, but why isn't it?

1. Because it's (apparently) so difficult to debug Windows Python
   console programs from another window.

2. Because curses applications are very rare on Windows, yet are still
   quite common on Unix.

--
Grant

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


Re: How to debug python + curses? [was: RE: Applying winpdb_reborn]

2021-06-02 Thread Cameron Simpson
On 02Jun2021 21:24, pjfarl...@earthlink.net  wrote:
>> -Original Message-
>> From: Grant Edwards 
>> Perhaps Windows isn't an appropriate OS under which to develop curses
>> applicatoins?
>
>Perhaps, but why isn't it?

I don't think it isn't. (Um, so many negatives in that sentence - I mean 
I don't consider Windows inappropriate.)

The only salient negative I've seen in this thread is that it isn't 
trivial to "open another terminal and direct messages there". Otherwise, 
if there's a decent remote debugger I don't see a technical reason to 
diss Windows.

That said, I am not a Windows person and probably never will be; 
Microsoft the company have had a long history of gratuitously doing 
things differently for market based reasons rather than technical 
reasons and on a personal basis I find Windows desktops painful to use.  
Some of that is lack of familiarity, doubtless. And my own UNIX side 
desktops are usually spartan by others' standards.

>
>Why are Windows users, even knowledgeable ones, so often considered second-
>or even third-class netizens?
>
>I do know some of the answers that will come back for that question, but the
>attitude is not professional.
>

I agree it is not professional. I know some Windows devs and they're 
broadly just as sane as the UNIXy folks I'm more familiar with.

But a lot of things in Windows do seem... more complex.

The UNIX world has quite a simple underlying basis, and that spills over 
into the simplicity of connecting things together. We _expect_ to just 
glom files and terminals and whatever together with pipes and 
redirections, and the flip side is that many things developed in that 
world are slanted for that to be easy, and when that doesn't translate 
to Windows that looks like a poor environment to an outsider.

The historic difficulties with installing Python on Windows probably 
also spill over into this. There are skilled people inside Microsoft who 
have brought Python installs into the (I gather) first class citizen 
area recently, meaning (again, I gather) that a user can go to the MS 
store and push a button. Most UNIXy platforms come with Python 
preinstalled.

All of these caveats aside, I think Grant's being a bit uncharitable.

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