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

2019-02-25 Thread Alan Gauld via Tutor
On 24/02/2019 23:25, boB Stepp wrote: >> Secondarily, resizeterm() does not make a change to the terminal itself. > > I realized this before I sent my original post. I really think the > name chosen, resizeterm, is a very misleading name! Only in a world of GUIs. Remember that curses is pre GUI

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

2019-02-24 Thread boB Stepp
On Sun, Feb 24, 2019 at 4:40 PM Cameron Simpson wrote: > I've modified your script. Please try the script appended below. The > short answer is that resizeterm() is _not_ normally useful to you, the > programmer; it will only be useful if curses does not get to notice > terminal size changes - _t

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

2019-02-24 Thread Mats Wichmann
All is is_term_resized, resizeterm and the "internal" resize_term functions are recent additions :-) From "man 3 resizeterm":  This extension of ncurses was introduced in mid-1995.  It  was  adopted in NetBSD curses (2001) and PDCurses (2003). For some definition of "recent" :) I have an

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

2019-02-24 Thread Cameron Simpson
On 24Feb2019 17:48, boB Stepp wrote: On Sun, Feb 24, 2019 at 2:52 PM Mats Wichmann wrote: If it's snippets you want, I always look at programcreek. These are always part of something bigger so they may not fit your request to have them be something you can run. https://www.programcreek.com/p

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

2019-02-24 Thread boB Stepp
On Sun, Feb 24, 2019 at 2:52 PM Mats Wichmann wrote: > > On 2/24/19 1:30 PM, boB Stepp wrote: > > > So what am I misunderstanding? Can someone show me a code snippet > > that I can run which will demonstrate the usefulness and usage of > > curses.resizeterm()? > > > > TIA! > > > > If it's snippet

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

2019-02-24 Thread boB Stepp
On Sun, Feb 24, 2019 at 4:40 PM Cameron Simpson wrote: > > On 24Feb2019 14:30, boB Stepp wrote: > >What you say makes sense and supports much of what I had concluded > >from my coding experiments. However, I still cannot get the function > >call, curses.resizeterm(), to do anything meaningful,

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

2019-02-24 Thread Cameron Simpson
On 24Feb2019 22:51, Mark Lawrence wrote: As I know squat about the curses module is this a time when a bug report could be put into the docs to clarify things, or do you have to know something about curses before you try using the Python wrapper? Well, both. The Python curses module is mostl

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

2019-02-24 Thread Mark Lawrence
On 24/02/2019 22:39, Cameron Simpson wrote: On 24Feb2019 14:30, boB Stepp wrote: On Sun, Feb 24, 2019 at 1:39 AM Cameron Simpson wrote: It looks like the resizeterm() function updates the curses _internal_ records of what it believes the physcial terminal size to be.  When you physically resi

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

2019-02-24 Thread Cameron Simpson
On 24Feb2019 14:30, boB Stepp wrote: On Sun, Feb 24, 2019 at 1:39 AM Cameron Simpson wrote: 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

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

2019-02-24 Thread Mats Wichmann
On 2/24/19 1:30 PM, boB Stepp wrote: So what am I misunderstanding? Can someone show me a code snippet that I can run which will demonstrate the usefulness and usage of curses.resizeterm()? TIA! If it's snippets you want, I always look at programcreek. These are always part of something b

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

2019-02-24 Thread boB Stepp
On Sun, Feb 24, 2019 at 1:39 AM Cameron Simpson wrote: > 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 wh

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

2019-02-24 Thread Alan Gauld via Tutor
On 24/02/2019 05:00, boB Stepp wrote: > 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). > > > Afte

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

[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 an

Re: [Tutor] How to use subprocess module to get current logged in user?

2017-08-26 Thread boB Stepp
Thanks Alan (and Mats)! It appears there are many ways to skin this cat! On Sat, Aug 26, 2017 at 2:21 AM, Alan Gauld via Tutor wrote: > >> My objective: Determine who the currently logged in user is and >> determine if that user is in my list of users that I have authorized >> to use my program

Re: [Tutor] How to use subprocess module to get current logged in user?

2017-08-26 Thread Alan Gauld via Tutor
> My objective: Determine who the currently logged in user is and > determine if that user is in my list of users that I have authorized > to use my programs. In addition to Steve and Mats answers: import os os.getlogin() #-> 'alan' os.getuid() #-> 1001 import pwd pwd.getpwuid(os.getuid()) #

Re: [Tutor] How to use subprocess module to get current logged in user?

2017-08-25 Thread boB Stepp
On Fri, Aug 25, 2017 at 8:33 PM, Steven D'Aprano wrote: > On Fri, Aug 25, 2017 at 07:13:12PM -0500, boB Stepp wrote: > >> My objective: Determine who the currently logged in user is > > py> import os > py> os.getlogin() > 'steve' Sweet! Much better. I did not scan the os modules closely enough

Re: [Tutor] How to use subprocess module to get current logged in user?

2017-08-25 Thread Mats Wichmann
import getpass getpass.getuser () depending on how fussy you want to be... On August 25, 2017 6:13:12 PM MDT, boB Stepp wrote: >SunOS 5.10, Python 2.4/2.6 > >I ask forgiveness in advance as I cannot copy and paste into an email >what I am doing on this system. So I will have to manually type >

Re: [Tutor] How to use subprocess module to get current logged in user?

2017-08-25 Thread Steven D'Aprano
On Fri, Aug 25, 2017 at 07:13:12PM -0500, boB Stepp wrote: > My objective: Determine who the currently logged in user is py> import os py> os.getlogin() 'steve' > and > determine if that user is in my list of users that I have authorized > to use my programs. That's probably best handled at t

[Tutor] How to use subprocess module to get current logged in user?

2017-08-25 Thread boB Stepp
SunOS 5.10, Python 2.4/2.6 I ask forgiveness in advance as I cannot copy and paste into an email what I am doing on this system. So I will have to manually type things, introducing the usual possibility of typos. My objective: Determine who the currently logged in user is and determine if that

Re: [Tutor] How to use function with default values ?

2016-08-07 Thread cs
On 07Aug2016 09:19, Alan Gauld wrote: On 07/08/16 04:22, rishabh mittal wrote: I am new to python and come from C language background. I couldn't able to understand this >>> def f(a, L=[]): ... L.append(a) ... return L print(f(1)) [1] print(f(2)) [1, 2] [...] In the first example

Re: [Tutor] How to use function with default values ?

2016-08-07 Thread Alan Gauld via Tutor
On 07/08/16 04:22, rishabh mittal wrote: > I am new to python and come from C language background. I couldn't able to > understand this > > >>> def f(a, L=[]): > ... L.append(a) > ... return L > ... > print(f(1)) > [1] > print(f(2)) > [1, 2] def f(a, L=10): > ... L=

[Tutor] How to use function with default values ?

2016-08-07 Thread rishabh mittal
Hi I am new to python and come from C language background. I couldn't able to understand this >>> def f(a, L=[]): ... L.append(a) ... return L ... >>> print(f(1)) [1] >>> print(f(2)) [1, 2] >>> print(f(3)) [1, 2, 3] >>> def f(a, L=10): ... L=10+a ... return L ... >

Re: [Tutor] How to use setUpmodule() variables in tests?

2016-05-07 Thread Steven D'Aprano
On Fri, May 06, 2016 at 09:41:18PM -0700, ramakrishna reddy wrote: > Dear All, > > In unittesting in python, how can I use variables of setUpModule() in tests? > > example: > > import unittest > > def setUpModule(): > b = 20 #> how can I use this variable in testa print b here is a lo

[Tutor] How to use setUpmodule() variables in tests?

2016-05-07 Thread ramakrishna reddy
Dear All, In unittesting in python, how can I use variables of setUpModule() in tests? example: import unittest def setUpModule(): b = 20 #> how can I use this variable in testa print class A(unittest.TestCase): def testa(self): a = 10 print(a + b) if __name__ ==

Re: [Tutor] ​How to use the returned telnet object after creating the telnet session.

2015-09-13 Thread Danny Yoo
On Sun, Sep 13, 2015 at 12:29 AM, Manju M wrote: > > Assume that I will pass IP and port information from a function to open the > telnet session. have opened the telnet session and after opening the telnet > session I returned telnet object to calling function. Hi Manju, I apologize for potent

Re: [Tutor] ​How to use the returned telnet object after creating the telnet session.

2015-09-13 Thread Alan Gauld
On 13/09/15 08:29, Manju M wrote: Assume that I will pass IP and port information from a function to open the telnet session. have opened the telnet session and after opening the telnet session I returned telnet object to calling function. That makes sense so far. Unfortunately its hard to rea

[Tutor] ​How to use the returned telnet object after creating the telnet session.

2015-09-13 Thread Manju M
Hello all, First I would like thank you for creating such good platform for discussing python..!!! Assume that I will pass IP and port information from a function to open the telnet session. have opened the telnet session and after opening the telnet session I returned telnet object to calling fu

Re: [Tutor] How to use tkinter with a touch screen device?

2015-07-17 Thread Laura Creighton
In a message of Fri, 17 Jul 2015 22:49:16 -0500, boB Stepp writes: >> ... On the other hand, kivy >> ought to work for you. http://kivy.org/#home I've yet to try it on >> a windows tablet, though. > >I think it was you who mentioned this GUI framework on the main python >list fairly recently. In

Re: [Tutor] How to use tkinter with a touch screen device?

2015-07-17 Thread boB Stepp
On Fri, Jul 17, 2015 at 10:13 PM, Laura Creighton wrote: > The place to ask this question is > https://mail.python.org/mailman/listinfo/tkinter-discuss but I think you are > out of luck... This would explain why I am having trouble finding much information. I *think* I could get things to work

Re: [Tutor] How to use tkinter with a touch screen device?

2015-07-17 Thread Laura Creighton
The place to ask this question is https://mail.python.org/mailman/listinfo/tkinter-discuss but I think you are out of luck. On the other hand, kivy ought to work for you. http://kivy.org/#home I've yet to try it on a windows tablet, though. Laura __

Re: [Tutor] How to use tkinter with a touch screen device?

2015-07-17 Thread Alan Gauld
On 17/07/15 23:04, boB Stepp wrote: that complex gestures are not supported by tkinter. But will tkinter see: 1) Short presses as a left mouse click? 2) Long presses as a right mouse click? 3) Virtual keyboard events the same as physical keyboard events? 4) Etc. ? I'd go to the Tk and Tkint

Re: [Tutor] How to use tkinter with a touch screen device?

2015-07-17 Thread boB Stepp
On Fri, Jul 17, 2015 at 5:32 PM, Mark Lawrence wrote: > A possible starter > http://sumerulabs.in/blog/2015/02/21/touch-screen-for-the-new-raspberry-pi-2-available-in-india-sumerulabs/ > ??? I had briefly glanced at that, but other than a short snippet of code, it seemed to be more an advertisem

Re: [Tutor] How to use tkinter with a touch screen device?

2015-07-17 Thread Mark Lawrence
On 17/07/2015 23:04, boB Stepp wrote: Apparently I will be finding myself having to write some programs to run on a Samsung Slate tablet, manufactured circa 2011. It has Windows 7 home edition 64-bit as its OS. Hopefully Python 3 will be easily installed, and I will be able to run Python 3 prog

[Tutor] How to use tkinter with a touch screen device?

2015-07-17 Thread boB Stepp
Apparently I will be finding myself having to write some programs to run on a Samsung Slate tablet, manufactured circa 2011. It has Windows 7 home edition 64-bit as its OS. Hopefully Python 3 will be easily installed, and I will be able to run Python 3 programs on it. Operating under this assumpt

Re: [Tutor] How to use Git from Windows PC for files on Solaris machine where Git cannot be installed?

2015-04-30 Thread boB Stepp
On Wed, Apr 29, 2015 at 11:38 PM, Dave Angel wrote: > On 04/30/2015 12:28 AM, boB Stepp wrote: >> >> The main danger as I see it is that if I am not careful, then the code >> on the dev environment could diverge from the state of code on my >> Windows PC, i.e., I forgot to do the scp part. But whe

Re: [Tutor] How to use Git from Windows PC for files on Solaris machine where Git cannot be installed?

2015-04-30 Thread Alan Gauld
On 30/04/15 05:28, boB Stepp wrote: That is what I have implemented as of today. I installed Git on my Windows PC where I have been doing my actual coding This is off topic but due to your peculiar restrictions might be useful so I thought I'd bring it up. Do you have Cygwin installed on your

Re: [Tutor] How to use Git from Windows PC for files on Solaris machine where Git cannot be installed?

2015-04-30 Thread Laura Creighton
In a message of Wed, 29 Apr 2015 23:28:59 -0500, boB Stepp writes: >The main danger as I see it is that if I am not careful, then the code >on the dev environment could diverge from the state of code on my >Windows PC, i.e., I forgot to do the scp part. But when I am actively >working on a section

Re: [Tutor] How to use Git from Windows PC for files on Solaris machine where Git cannot be installed?

2015-04-29 Thread Dave Angel
On 04/30/2015 12:28 AM, boB Stepp wrote: The main danger as I see it is that if I am not careful, then the code on the dev environment could diverge from the state of code on my Windows PC, i.e., I forgot to do the scp part. But when I am actively working on a section of code I always insert a fe

Re: [Tutor] How to use Git from Windows PC for files on Solaris machine where Git cannot be installed?

2015-04-29 Thread boB Stepp
On Wed, Apr 29, 2015 at 10:39 PM, Cameron Simpson wrote: > On 29Apr2015 22:10, boB Stepp wrote: >> On the smart enterprise where we (now) do our clinical planning they >> are very strict: no installing any external software; no accessing the >> Internet; no email; etc. Not all centers adhere to

Re: [Tutor] How to use Git from Windows PC for files on Solaris machine where Git cannot be installed?

2015-04-29 Thread Cameron Simpson
On 29Apr2015 22:10, boB Stepp wrote: On Wed, Apr 29, 2015 at 9:40 PM, Cameron Simpson wrote: On 29Apr2015 12:12, boB Stepp wrote: ... (3) install git if needed ... It seems Git is needed, but I am not allowed to install it on the Solaris workstation. So is there a way around this? What d

Re: [Tutor] How to use Git from Windows PC for files on Solaris machine where Git cannot be installed?

2015-04-29 Thread boB Stepp
On Wed, Apr 29, 2015 at 9:40 PM, Cameron Simpson wrote: > On 29Apr2015 12:12, boB Stepp wrote: >>> >>> ... (3) install git if needed ... >> >> >> It seems Git is needed, but I am not allowed to install it on the >> Solaris workstation. So is there a way around this? > > > What do you mean by "ins

Re: [Tutor] How to use Git from Windows PC for files on Solaris machine where Git cannot be installed?

2015-04-29 Thread Cameron Simpson
On 29Apr2015 12:12, boB Stepp wrote: ... (3) install git if needed ... It seems Git is needed, but I am not allowed to install it on the Solaris workstation. So is there a way around this? What do you mean by "install"? Bear in mind that while you may be forbidden from installing git in the

Re: [Tutor] How to use Git from Windows PC for files on Solaris machine where Git cannot be installed?

2015-04-29 Thread Albert-Jan Roskam
- Original Message - > From: boB Stepp > To: tutor > Cc: > Sent: Wednesday, April 29, 2015 7:12 PM > Subject: Re: [Tutor] How to use Git from Windows PC for files on Solaris > machine where Git cannot be installed? > > On Wed, Apr 29, 2015 at 12:04 PM, Alb

Re: [Tutor] How to use Git from Windows PC for files on Solaris machine where Git cannot be installed?

2015-04-29 Thread Laura Creighton
Glad things are going better. Next step. Can you get git running on your solaris machines? Easiest is if it is already installed or if the powers that be will install it for you. But if not, you ought to be able to build your own git from source and run it on your Solaris machines. This li

Re: [Tutor] How to use Git from Windows PC for files on Solaris machine where Git cannot be installed?

2015-04-29 Thread Alan Gauld
On 29/04/15 18:12, boB Stepp wrote: But uhhm, this is not Python at all ;-) I was hoping for clemency on this point due to the earlier thread(s) I started (Which included Python's unittest module.). I've been blurring the lines on this one because version control is something everyone should

Re: [Tutor] How to use Git from Windows PC for files on Solaris machine where Git cannot be installed?

2015-04-29 Thread boB Stepp
On Wed, Apr 29, 2015 at 12:04 PM, Albert-Jan Roskam wrote: > > -- > On Wed, Apr 29, 2015 4:21 PM CEST boB Stepp wrote: > >>I now have Git installed on my Windows 7 PC at work. The files that I >>wish to put under Git version control exist on a Solaris 10 >>workstation.

Re: [Tutor] How to use Git from Windows PC for files on Solaris machine where Git cannot be installed?

2015-04-29 Thread Albert-Jan Roskam
-- On Wed, Apr 29, 2015 4:21 PM CEST boB Stepp wrote: >I now have Git installed on my Windows 7 PC at work. The files that I >wish to put under Git version control exist on a Solaris 10 >workstation. In the Git bash provided, I can ssh into the Solaris 10 >machine. I a

[Tutor] How to use Git from Windows PC for files on Solaris machine where Git cannot be installed?

2015-04-29 Thread boB Stepp
I now have Git installed on my Windows 7 PC at work. The files that I wish to put under Git version control exist on a Solaris 10 workstation. In the Git bash provided, I can ssh into the Solaris 10 machine. I also can the CuteFTP program on my Windows PC to move/copy/etc. files between the two mac

Re: [Tutor] How to use a function

2015-01-19 Thread Albert-Jan Roskam
On Mon, Jan 19, 2015 3:32 PM CET jarod...@libero.it wrote: >Dear All, >I would like to understand how work this funcion: > >def parse_illumina_readset_file(illumina_readset_file): >readsets = [] >samples = [] > >log.info("Parse readset " + illumina_readset

Re: [Tutor] How to use a function

2015-01-19 Thread Peter Otten
jarod...@libero.it wrote: > Dear All, > I would like to understand how work this funcion: > > def parse_illumina_readset_file(illumina_readset_file): [snip code by someone who has yet to learn how to use dicts;)] > return readsets > > > parser_illumina_readset_file("~/Desktop/file.csv")

Re: [Tutor] How to use a function

2015-01-19 Thread Dominik George
Hi, > parser_illumina_readset_file("~/Desktop/file.csv") > > dir() > > I can't found the readsets list. Someone could please help me? > thanks so much! Maybe: readsets = parser_illumina_readset_file("~/Desktop/file.csv") In your call, you discard the result, which, obviously, discards it. -

[Tutor] How to use a function

2015-01-19 Thread jarod...@libero.it
Dear All, I would like to understand how work this funcion: def parse_illumina_readset_file(illumina_readset_file): readsets = [] samples = [] log.info("Parse readset " + illumina_readset_file + " ...") readset_csv = csv.DictReader(open(illumina_readset_file, 'rb'), delimiter='\t

Re: [Tutor] How to use custom protocol with requests?

2014-10-12 Thread Juan Christian
On Sun, Oct 12, 2014 at 12:17 AM, Danny Yoo wrote: > Huh. Wow. That actually worked? > > :P > > --- > > Frankly speaking though, this sounds like a horrible XSRF-style attack > in waiting, if I understand what has just happened. > (http://en.wikipedia.org/wiki/Cross-site_request_forgery) > > Us

Re: [Tutor] How to use custom protocol with requests?

2014-10-11 Thread Danny Yoo
>> I need to call this URL: steam://friends/add/ >> >> If I put it in my browser and press enter it works as expected, now I need >> to do this on my code, I don't need to retrieve anything, I just need it to >> be "executed", is there a way to do that in Python with requests or any >> other lib?

Re: [Tutor] How to use custom protocol with requests?

2014-10-11 Thread Danny Yoo
On Sat, Oct 11, 2014 at 7:58 PM, Juan Christian wrote: > Sorry for triple post, but yes, webbrowser worked 100%. Exactly what I > needed! Huh. Wow. That actually worked? :P --- Frankly speaking though, this sounds like a horrible XSRF-style attack in waiting, if I understand what has just h

Re: [Tutor] How to use custom protocol with requests?

2014-10-11 Thread Juan Christian
On Sat, Oct 11, 2014 at 11:47 PM, Danny Yoo wrote: > This may be more difficult to do; it's unclear whether or not this is > exposed in the web API that Valve provides. > > Unlike the other methods described in: > > https://developer.valvesoftware.com/wiki/Steam_Web_API > > which are all quer

Re: [Tutor] How to use custom protocol with requests?

2014-10-11 Thread Juan Christian
Sorry for triple post, but yes, webbrowser worked 100%. Exactly what I needed! Thanks! ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] How to use custom protocol with requests?

2014-10-11 Thread Juan Christian
On Sat, Oct 11, 2014 at 11:53 PM, Danny Yoo wrote: > >> I need to call this URL: steam://friends/add/ > >> > >> If I put it in my browser and press enter it works as expected, now I > need > >> to do this on my code, I don't need to retrieve anything, I just need > it to > >> be "executed", is th

Re: [Tutor] How to use custom protocol with requests?

2014-10-11 Thread Danny Yoo
On Sat, Oct 11, 2014 at 7:29 PM, Juan Christian wrote: > I need to call this URL: steam://friends/add/ > > If I put it in my browser and press enter it works as expected, now I need > to do this on my code, I don't need to retrieve anything, I just need it to > be "executed", is there a way to do

[Tutor] How to use custom protocol with requests?

2014-10-11 Thread Juan Christian
I need to call this URL: steam://friends/add/ If I put it in my browser and press enter it works as expected, now I need to do this on my code, I don't need to retrieve anything, I just need it to be "executed", is there a way to do that in Python with requests or any other lib? Python 3.4.1

Re: [Tutor] how to use 2to3

2014-01-13 Thread Mark Lawrence
On 13/01/2014 17:30, S Tareq wrote: can you please help me how to use 2to3 on 3.3. i went to the web site follow instraction and it did not work. Providing a sizeable wedge of code and stating "it did not work" is pretty useless. But I'd guess that you've run the code *WITHOUT* the -w flag.

Re: [Tutor] how to use 2to3

2014-01-13 Thread Danny Yoo
On Mon, Jan 13, 2014 at 9:30 AM, S Tareq wrote: > can you please help me how to use 2to3 on 3.3. i went to the web site follow > instraction and it did not work. When asking for debugging help, it is usually a very good idea to provide as much detail about what you exactly did as you can. Specifi

[Tutor] how to use 2to3

2014-01-13 Thread S Tareq
can you please help me how to use 2to3 on 3.3. i went to the web site follow instraction and it did not work.  # Import statements import random import datetime #Arrays to store the definitions and keywords read from the file keywords=[]; definition=[]; correctAnswer=[]; #Counter for the wrong A

Re: [Tutor] How to use introspection to discover parameters?

2012-07-26 Thread David
On 27/07/2012, Jerry Hill wrote: ... inspect.getargspec(logging.log) > ArgSpec(args=['level', 'msg'], varargs='args', keywords='kwargs', > defaults=None) ... > Also, the help object itself is written in python. You can look at > the source in pydoc.py On 27/07/2012, Steven D'Aprano wrote:

Re: [Tutor] How to use introspection to discover parameters?

2012-07-26 Thread Steven D'Aprano
David wrote: Please help me understand the following (I have python 2.6.2) ... Because I want to write nice docstrings, I read PEP257 where it says: "The one-line docstring should NOT be a "signature" reiterating the function/method parameters (which can be obtained by introspection)." As a ge

Re: [Tutor] How to use introspection to discover parameters?

2012-07-26 Thread Jerry Hill
On Thu, Jul 26, 2012 at 9:48 AM, David wrote: > A related question: > help() seems to do the introspection for me. Does python allow me to do it in > my own code? Specifically, how might I write my own function to mimic line 3 > of > help(), appearing like so: > my_function(logging.log) > "l

[Tutor] How to use introspection to discover parameters?

2012-07-26 Thread David
Please help me understand the following (I have python 2.6.2) ... Because I want to write nice docstrings, I read PEP257 where it says: "The one-line docstring should NOT be a "signature" reiterating the function/method parameters (which can be obtained by introspection)." I am understanding this

Re: [Tutor] How to use g_timeout_add () function?

2012-04-06 Thread Mark Lawrence
Please don't top post and please reply to the list Top posting fixed. - Forwarded Message - From: Lion Chen To: Mark Lawrence Cc: Sent: Friday, 6 April 2012, 16:43 Subject: Re: [Tutor] How to use g_timeout_add () function? fixed top posting > On 06/04/2012 15:17, Lion Ch

Re: [Tutor] How to use g_timeout_add () function?

2012-04-06 Thread Mark Lawrence
On 06/04/2012 15:17, Lion Chen wrote: Hello all, i have a question: when i check gtk_time_out in the gtk+2 reference, it said " |gtk_timeout_add|has been deprecated since version 2.4 and should not be used in newly-written code. Use |g_timeout_add()|instead." but i don't know how tu use the g_t

Re: [Tutor] How to use g_timeout_add () function?

2012-04-06 Thread Evert Rol
> Hello all, i have a question: > > when i check gtk_time_out in the gtk+2 reference, it said " gtk_timeout_add > has been deprecated since version 2.4 and should not be used in newly-written > code. Use g_timeout_add() instead." > > but i don't know how tu use the g_timout_add() function: > m

[Tutor] How to use g_timeout_add () function?

2012-04-06 Thread Lion Chen
Hello all, i have a question: when i check gtk_time_out in the gtk+2 reference, it said " |gtk_timeout_add|has been deprecated since version 2.4 and should not be used in newly-written code. Use |g_timeout_add()|instead." but i don't know how tu use the g_timout_add() function: my_id = g_timeout_

Re: [Tutor] how to use int and split() simultaneously

2011-12-08 Thread Steven D'Aprano
शंतनू wrote: Using re module: === import re strNum = raw_input("enter numbers, separated by space: ") if re.search('[^\d ]', strNum): print('Invalid input') else: data = [int(x) for x in strNum.split()] print(data) This is not Perl, where everything is a nail that needs to be ham

Re: [Tutor] how to use int and split() simultaneously

2011-12-08 Thread शंतनू
On 08-Dec-2011, at 7:13 PM, Dario Lopez-Kästen wrote: > oh, yes, no top posting. See below. > > On Thu, Dec 8, 2011 at 1:33 PM, surya k wrote: > > This is something I am trying to do.. > Say, we are entering a string "1 2 3 4 5".so, I want to assign the numbers > directly as numbers. how can

Re: [Tutor] how to use int and split() simultaneously

2011-12-08 Thread Wayne Werner
On Thu, Dec 8, 2011 at 7:43 AM, Dario Lopez-Kästen wrote: > > > In that case a for loop with a try-except would better: > > strNum = raw_input("enter numbers, separated by space: ").split() > num_list = [] > > for token in strNum: > try: > num_list.append(int(token)) > except Valu

Re: [Tutor] how to use int and split() simultaneously

2011-12-08 Thread Dario Lopez-Kästen
oh, yes, no top posting. See below. On Thu, Dec 8, 2011 at 1:33 PM, surya k wrote: > > This is something I am trying to do.. > Say, we are entering a string "1 2 3 4 5".so, I want to assign the numbers > directly as numbers. how can I do it? > I could put that numbers as string but not as numbe

[Tutor] how to use int and split() simultaneously

2011-12-08 Thread surya k
This is something I am trying to do.. Say, we are entering a string "1 2 3 4 5".so, I want to assign the numbers directly as numbers. how can I do it? I could put that numbers as string but not as number.. strNum = raw_input('enter:').split() I can convert the list into numbers by doing this... f

Re: [Tutor] How to use try and except in this case?

2011-11-29 Thread Steven D'Aprano
Mic wrote: Say that I want to try and open 10 files. If none of these exists, I want an error message to appear. But only if NONE of these files exists. I know how to handle this with one file. But I don't know how to do that with more than one. So the program should try and open all 10 files

Re: [Tutor] How to use try and except in this case?

2011-11-27 Thread Andreas Perstinger
On 2011-11-27 17:58, Mic wrote: Say that I want to try and open 10 files. If none of these exists, I want an error message to appear. But only if NONE of these files exists. I know how to handle this with one file. But I don't know how to do that with more than one. So the program should try and

Re: [Tutor] How to use try and except in this case?

2011-11-27 Thread Mic
Mic wrote: class SeatButton(tk.Button): def __init__(self, master, index): text = str(index+1) super(SeatButton, self).__init__(master, text=text, bg=FREE, command=self.clicked) s

Re: [Tutor] How to use __iter__

2011-08-08 Thread Peter Otten
Jia-Yu Aw wrote: > How to use __iter__ > Von: > Jia-Yu Aw > Antwortadresse: > Jia-Yu Aw > Datum: > Dienstag, 9. August 2011 03:48:20 > An: > tutor@python.org > Gruppen: > gmane.comp.python.tutor > Hi all > > I've been learning Classes and have read the documentation on __iter__ but st

[Tutor] How to use __iter__

2011-08-08 Thread Jia-Yu Aw
Hi all I've been learning Classes and have read the documentation on __iter__ but still don't understand how it works. I have two pieces of code: the first is def __iter__, the second is using __iter__. Instead of being an iterator, I'm just using this is a function, which I think is incorrect.

Re: [Tutor] How to use a module when only import package

2011-04-08 Thread Karim
On 04/08/2011 11:13 AM, leechau wrote: Steven wrote: leechau wrote: I wrote module1 in package1, and want to use a method named 'method1' in module1, the caller(test.py) is like this: import package1 package1.module1.method1() [...] When i run test.py, the output is: AttributeError: 'module

Re: [Tutor] How to use a module when only import package

2011-04-08 Thread leechau
Steven wrote: leechau wrote: I wrote module1 in package1, and want to use a method named 'method1' in module1, the caller(test.py) is like this: import package1 package1.module1.method1() [...] When i run test.py, the output is: AttributeError: 'module' object has no attribute 'module1' File

Re: [Tutor] How to use a module when only import package

2011-04-07 Thread Steven D'Aprano
leechau wrote: > I wrote module1 in package1, and want to use a method named 'method1' in > module1, the caller(test.py) is like this: > > import package1 > package1.module1.method1() [...] > When i run test.py, the output is: > AttributeError: 'module' object has no attribute 'module1' > File "e:

[Tutor] How to use a module when only import package

2011-04-07 Thread leechau
I wrote module1 in package1, and want to use a method named 'method1' in module1, the caller(test.py) is like this: import package1 package1.module1.method1() module1.py is like this: def method1(): print 'method1 run!' The filesystem structure is: test.py package1 |__ __init__.py |__ m

Re: [Tutor] How to use a str object, to find the class in exact name?

2011-03-15 Thread Japhy Bartlett
I hate to jump on this one a little late, but even getattr() is kind of ghetto (though exec/eval is worse ;). For setting up shell scripts or CLIs, the usual route is the optparse module. - Japhy 2011/3/15 Yaşar Arabacı : > Thanks for excellent explanations. I almost got this working. I just hav

Re: [Tutor] How to use a str object, to find the class in exact name?

2011-03-15 Thread Yaşar Arabacı
Thanks for excellent explanations. I almost got this working. I just have one more problem, that is: When user enter incorrect number of arguments for a method, I naturally get a type error. I could probably fix that with try and catch, but that is not very explanatory to the user. Is there a

Re: [Tutor] How to use a str object, to find the class in exact name?

2011-03-14 Thread bob gailer
On 3/14/2011 8:49 PM, Yaşar Arabacı wrote: As I try to implement things with getattr, I am getting a really strange error. This is my file: Various interspersed comments: #!/usr/bin/env python # -*- encoding:utf-8 -*- class global_variables: It is customary to start class names with an uppe

Re: [Tutor] How to use a str object, to find the class in exact name?

2011-03-14 Thread Yaşar Arabacı
As I try to implement things with getattr, I am getting a really strange error. This is my file: #!/usr/bin/env python # -*- encoding:utf-8 -*- class global_variables: "Holds class attributes, so that other classes can share them" products = 0 best_bundle = [] class dispa

Re: [Tutor] How to use a str object, to find the class in exact name?

2011-03-14 Thread Steven D'Aprano
Yaşar Arabacı wrote: And What I want to do is a small economy application. It will work this way: user add a product name, rate how much it like it over 10, and enter its price. [repeated as many times as wanted] user will enter h(is|er) budget. user will use "calcute bundle" to show much

Re: [Tutor] How to use a str object, to find the class in exact name?

2011-03-14 Thread Yaşar Arabacı
Before being able to see 3rd answer, I did something like this and it worked for me: #!/usr/bin/env python # -*- encoding:utf-8 -*- def command_dispatcher(): "Takes comman line arguments and executes regardin method" command = raw_input(">>>") args = command.split(" ")

Re: [Tutor] How to use a str object, to find the class in exact name?

2011-03-14 Thread Steven D'Aprano
Prasad, Ramit wrote: Take a look at: http://stackoverflow.com/questions/701802/how-do-i-execute-a-string-containing-python-code-in-python And then please don't do it. eval and exec should be treated as the last resort, and then only if you really know what you are doing. They are slow, and da

Re: [Tutor] How to use a str object, to find the class in exact name?

2011-03-14 Thread Steven D'Aprano
Yaşar Arabacı wrote: Hi I am trying to do something like this: If you are trying to write a mini-language, the ``cmd`` and ``shlex`` modules in the standard library may be useful to you. #!/usr/bin/env python def command_dispatcher(): "Takes comman line arguments and executes regardi

Re: [Tutor] How to use a str object, to find the class in exact name?

2011-03-14 Thread Prasad, Ramit
: tutor-bounces+ramit.prasad=jpmchase@python.org [mailto:tutor-bounces+ramit.prasad=jpmchase@python.org] On Behalf Of Yasar Arabaci Sent: Monday, March 14, 2011 4:16 PM To: tutor@python.org Subject: [Tutor] How to use a str object, to find the class in exact name? Hi I am trying to do

[Tutor] How to use a str object, to find the class in exact name?

2011-03-14 Thread Yaşar Arabacı
Hi I am trying to do something like this: #!/usr/bin/env python def command_dispatcher(): "Takes comman line arguments and executes regardin method" command = raw_input(">>>") args = command.split(" ") args[0].args[1] class calculate: def bundle(self):

Re: [Tutor] How to use pydoc

2010-02-27 Thread Lie Ryan
On 02/27/10 00:31, Ricardo Aráoz wrote: > Checked the manuals on pydoc and wanted to try it. Must certainly be > doing something wrong but I can't figure what. Here's my session : The pydoc command works from your system shell (e.g. bash), not python shell; if you want to get help inside python's

Re: [Tutor] How to use pydoc

2010-02-26 Thread David Hutto
--- On Fri, 2/26/10, Ricardo Aráoz wrote: From: Ricardo Aráoz Subject: [Tutor] How to use pydoc To: tutor@python.org Date: Friday, February 26, 2010, 8:31 AM Checked the manuals on pydoc and wanted to try it. Must certainly be doing something wrong but I can't figure what. Here's

[Tutor] How to use pydoc

2010-02-26 Thread Ricardo Aráoz
Checked the manuals on pydoc and wanted to try it. Must certainly be doing something wrong but I can't figure what. Here's my session : Python 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> p

Re: [Tutor] how to use lxml and win32com?

2009-10-26 Thread elca
Alan Gauld wrote: > > > "elca" wrote > i want to use IE.navigate function with beautifulsoup or lxml.. if anyone know about this or sample. >>> Why do you want to use navigate()? What are you trying to do? >>> There is likely to be another way to do it from Python. > >> so why i

  1   2   >