Re: [Tutor] How to use "curses.resizeterm(nlines, ncols)"

2019-02-23 Thread Cameron Simpson

On 23Feb2019 23:00, boB Stepp  wrote:

I am trying to understand the functionality that the Python module,
curses, provides.  But I am stuck on how to use the command,
curses.resizeterm(nlines, ncols).  At
https://docs.python.org/3/library/curses.html#curses.resizeterm it says:


curses.resizeterm(nlines, ncols)¶

Resize the standard and current windows to the specified dimensions,
and adjusts other bookkeeping data used by the curses library that
record the window dimensions (in particular the SIGWINCH handler).


After much experimentation -- to no good effect -- I have concluded
that "resizeterm" does *not* mean resize the terminal window that the
curses program is running within.  Can someone give me a working
example of how to use this command?


I think you might misunderstand the purpose of the function; I have to 
say the doco doesn't help you much here.


It looks like the resizeterm() function updates the curses _internal_ 
records of what it believes the physcial terminal size to be.  When you 
physically resize a terminal the processes within it receive a SIGWINCH 
signal, and those which pay attention to that signal should then consult 
the terminal to find out its new size.


The curses library notices this signal, and calls resizeterm() to update 
its own internal idea of the terminal size so that it knows how to draw 
correctly on the screen. It does _not_ change the terminal; it changes 
curses' beliefs _about_ the terminal.


If you call resizeterm() yourself you will cause curses to act from then 
on as though the physcial terminal has the size you supplied. That may 
make for bad rendering if that size does not match reality (consider 
cursor motions "from the right edge" or "from the bottom edge" - their 
sizes are computed from where curses thinks those edges are).


Test the function curses.is_term_resized(nlines,ncols), whose doco says:

 Return True if resize_term() would modify the window structure, False 
 otherwise.


The is_term_resized() function looks up the current physical size and 
reports False if that matches curses current beliefs, and True if it 
does not match, meaning that the physical size has changed since curses 
last set up its beliefs (for example, in some environment where the 
resize _doesn't_ propagate a SIGWINCH to the process using curses, so it 
hasn't noticed).


Does this clarify things for you?

Cheers,
Cameron Simpson 
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] How to use "curses.resizeterm(nlines, ncols)"

2019-02-23 Thread boB Stepp
I am trying to understand the functionality that the Python module,
curses, provides.  But I am stuck on how to use the command,
curses.resizeterm(nlines, ncols).  At
https://docs.python.org/3/library/curses.html#curses.resizeterm it says:


curses.resizeterm(nlines, ncols)¶

Resize the standard and current windows to the specified dimensions,
and adjusts other bookkeeping data used by the curses library that
record the window dimensions (in particular the SIGWINCH handler).


After much experimentation -- to no good effect -- I have concluded
that "resizeterm" does *not* mean resize the terminal window that the
curses program is running within.  Can someone give me a working
example of how to use this command?

TIA!

-- 
boB
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Visual studio Code -Python

2019-02-23 Thread Mark Lawrence

On 23/02/2019 12:23, Asad wrote:

Please don't top post, it is so irritating when trying to read threads, TIA.


Hi All ,

  I am using : pdb.set_trace()

   can you all share some good tricks i using n ,s , l . The tedious
part which I see is  if it is a loop like for loop then I need to do next
till the length for the data is completed

for x in string :
  if re.search(x,line)

len(string)
 = 2500

therefore I need to press n 2500 time so that the loop completes and goes
to another line of code . Any suggestions? how can run the for loop without
doing n for 2500 times ?



Set a breakpoint on the first line after the loop, please see 
https://code.visualstudio.com/docs/python/debugging#_invoking-a-breakpoint-in-code


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

Mark Lawrence

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Visual studio Code -Python

2019-02-23 Thread Asad
Hi All ,

 I am using : pdb.set_trace()

  can you all share some good tricks i using n ,s , l . The tedious
part which I see is  if it is a loop like for loop then I need to do next
till the length for the data is completed

for x in string :
 if re.search(x,line)

len(string)
= 2500

therefore I need to press n 2500 time so that the loop completes and goes
to another line of code . Any suggestions? how can run the for loop without
doing n for 2500 times ?

Thanks,

On Sun, Feb 17, 2019 at 8:58 PM Mats Wichmann  wrote:

> On 2/17/19 1:50 AM, Asad wrote:
> > Hi All ,
> >
> > I am using Visual Studio Code for Python . However I was
> using
> > the debug option F5 i see it list the variables in my program neatly ,I
> set
> > breakpoints it stops there  but I am unable  to preview each line of the
> > execution of the code .
> >
> > Thanks,
>
> You'll need to go to the source for that... the Python extension should
> have limited instructions, and a bunch of pointers for where to go find
> out more, and some animations that intend to show how things work.
>
> Best of luck!
>
>
>

-- 
Asad Hasan
+91 9582111698
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Visual studio Code -Python

2019-02-23 Thread Mats Wichmann

On 2/23/19 5:23 AM, Asad wrote:

Hi All ,

          I am using : pdb.set_trace()
           can you all share some good tricks i using n ,s , l . The 
tedious part which I see is  if it is a loop like for loop then I need 
to do next till the length for the data is completed


for x in string :
      if re.search(x,line)

len(string)
     = 2500

therefore I need to press n 2500 time so that the loop completes and 
goes to another line of code . Any suggestions? how can run the for loop 
without doing n for 2500 times ?


pdb has an "until" command you can use to get it to run until the line 
after the loop, if that's what you are looking for.  sorry, it's a 
little hard to tell what you *are* looking for.



___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] import failure

2019-02-23 Thread Mark Lawrence

On 22/02/2019 16:55, Alex Kleider wrote:


I'm trying to programmatically manipulate my google contacts using
a library (https://github.com/google/gdata-python-client) which I've
cloned.  The documentation suggests running a test to start with
which I did (OS: Ubuntu 18.4, running in a python2.7 venv 'p2')
with the following rather puzzling results (explanation below):

(p2) alex@one:$ pwd
/home/alex/Proj/G/gdata-python-client
(p2) alex@one:$ ls
build    INSTALL.txt  pydocs samples src
contacts_example.py  Makefile README.txt set_python_path.sh 
tests
__init__.py  MANIFEST.in  RELEASE_NOTES.txt  setup.py 
upload-diffs.py

(p2) alex@one:$ ./tests/run_data_tests.py
Traceback (most recent call last):
   File "./tests/run_data_tests.py", line 19, in 
     import gdata_tests.auth_test
   File 
"/home/alex/Proj/G/gdata-python-client/tests/gdata_tests/auth_test.py", 
line 24, in 

     import gdata.auth
   File "/home/alex/Proj/G/gdata-python-client/src/gdata/auth.py", line 
29, in 

     import gdata.oauth.rsa as oauth_rsa
   File "/home/alex/Proj/G/gdata-python-client/src/gdata/oauth/rsa.py", 
line 10, in 

     from tlslite.utils import keyfactory
ImportError: No module named tlslite.utils
(p2) alex@one:$ pip install tlslite
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 
2020. Please upgrade your Python as Python 2.7 won't be maintained after 
that date. A future version of pip will drop support for Python 2.7.

Collecting tlslite
   Downloading 
https://files.pythonhosted.org/packages/92/2b/7904cf913d9bf150b3e408a92c9cb5ce0b97a9ec19f998af48bf4c607f0e/tlslite-0.4.9.tar.gz 
(105kB)

     100% |   | 112kB 174kB/s
     100% |   | 112kB 174kB/s
Building wheels for collected packages: tlslite
   Building wheel for tlslite (setup.py) ... done
   Stored in directory: 
/home/alex/.cache/pip/wheels/f8/de/72/213ac7112be37bc832e971c092757ae92aa5ae4b433e214ba9 


Successfully built tlslite
Installing collected packages: tlslite
Successfully installed tlslite-0.4.9
(p2) alex@one:$ ./tests/run_data_tests.py
Traceback (most recent call last):
   File "./tests/run_data_tests.py", line 19, in 
     import gdata_tests.auth_test
   File 
"/home/alex/Proj/G/gdata-python-client/tests/gdata_tests/auth_test.py", 
line 24, in 

     import gdata.auth
   File "/home/alex/Proj/G/gdata-python-client/src/gdata/auth.py", line 
29, in 

     import gdata.oauth.rsa as oauth_rsa
   File "/home/alex/Proj/G/gdata-python-client/src/gdata/oauth/rsa.py", 
line 10, in 

     from tlslite.utils import keyfactory
ImportError: No module named tlslite.utils
(p2) alex@one:$ python
Python 2.7.15rc1 (default, Nov 12 2018, 14:31:15)
[GCC 7.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.

import tlslite
exit()

(p2) alex@one:$ vim src/gdata/oauth/rsa.py
(p2) alex@one:$ cat src/gdata/oauth/rsa.py | tail -n 4
if __name__ == "__main__":
     print("key_factory = " + repr(keyfactory))
(p2) alex@one:$ python src/gdata/oauth/rsa.py
key_factory = '/home/alex/.virtualenvs/p2/local/lib/python2.7/site-packages/tlslite/utils/keyfactory.pyc'> 


(p2) alex@one:$ python
Python 2.7.15rc1 (default, Nov 12 2018, 14:31:15)
[GCC 7.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.

from tlslite.utils import keyfactory



Details: The initial run failed because of unavailability of a module.
A little reading led to the discovery that it could be easily installed
using pip but after doing so: Still the same failure.
Running the interpreter proves that the module is now available but the
test still fails.
Adding a bit of code to the bottom of the failing module shows that it
in fact can import the module in question.
Ran the interpreter again just to be sure that the function is available
and indeed it is.
I don't understand how this could be possible.

Any suggestions as to what the problem might be or how to investigate
further would be very much appreciated.

Cheers,
Alex



Just to follow up there are some useful tips in this 
https://mail.python.org/pipermail/python-list/2019-February/739643.html 
as to how to debug these type of problems.


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

Mark Lawrence

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] import failure

2019-02-23 Thread Alex Kleider

On 2019-02-22 09:48, Mats Wichmann wrote:






pip installs are specific to the interpreter, you're probably getting
a mismatch there.

Rule one: install this way:

python -m pip install sheepdip

that way you're sure the pip matches the python and things go in the
expected place.

Rule 2:
you can do some inspection by printing the values of sys.executable
and sys.path both in your interactive environment where it works and
in your script where it doesn't work.

My guess is you'll find a mismatch... but this is only surmise,
something to try out, we can't see your precise environment.


Thanks again for the input.
As I mentioned in response to Peter's response, a mismatch was 
definitely the problem.

The program I was trying to run had as its first line:
#!/usr/bin/python
I wrongly reported that the 'shebang' was
#!/usr/bin/env python
When changed to the latter, the program runs as I expected.

Thanks to both of you for your guidance.
Alex
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor