Re: When I need classes?

2016-01-10 Thread Ulli Horlacher
Cameron Simpson wrote: > I always structure this aspect as: > > ... at or near top of script ... > > def main(argv): >... do main logic here ... > > ... at bottom ... > if __name__ == '__main__': >sys.exit(main(sys.argv)) I, as a Python beginner, came to the same solution! It seem

Re: When I need classes?

2016-01-10 Thread Cameron Simpson
On 10Jan2016 22:45, Arshpreet Singh wrote: On Sunday, 10 January 2016 20:33:20 UTC+5:30, Michael Torrie wrote: This way I can import functions defined in this script into another script later if I want. If I find I need to share state between functions, and if I find that I might need to have

Re: When I need classes?

2016-01-10 Thread Arshpreet Singh
On Sunday, 10 January 2016 20:33:20 UTC+5:30, Michael Torrie wrote: > This way I can import functions defined in this script into another > script later if I want. > > If I find I need to share state between functions, and if I find that I > might need to have multiple situations of shared state

Re: When I need classes?

2016-01-10 Thread Arshpreet Singh
On Sunday, 10 January 2016 21:09:52 UTC+5:30, Steven D'Aprano wrote: > There are *no* problems that are impossible to solve without classes, but > sometimes classes will make problems easier to solve. And sometimes classes > make problems harder to solve. It depends on the problem. Is there any

Re: When I need classes?

2016-01-10 Thread Arshpreet Singh
On Sunday, 10 January 2016 23:20:02 UTC+5:30, Bernardo Sulzbach wrote: > Essentially, classes (as modules) are used mainly for organizational purposes. > > Although you can solve any problem you would solve using classes > without classes, solutions to some big problems may be cheaper and > more

Re: Question on pytest example code

2016-01-10 Thread Terry Reedy
On 1/10/2016 2:38 PM, Robert wrote: Hi, Below is a code snippet from pytest package. It passes pytest, i.e. there is no failure report. # content of test_sysexit.py import pytest def f(): raise SystemExit(1) def test_mytest(): with pytest.raises(SystemExit): f() I se

Re: Which Python editor has this feature?

2016-01-10 Thread Rustom Mody
On Monday, January 11, 2016 at 7:30:10 AM UTC+5:30, jf...@ms4.hinet.net wrote: > It lets you jump between the current cursor position and the line the upper > level indentation start, something like the bracket matching in C editor. > Because of Python use indentation as its code block mark, It m

Re: Confusing on bool data object or class function?

2016-01-10 Thread Steven D'Aprano
On Mon, 11 Jan 2016 12:57 pm, Robert wrote: > Hi, > > When I use an on line code snippet, see below please, I find that > 'converged' in class ConvergenceMonitor is seen as a data. That is because converged is a property. That makes it be seen as data. > @property > def converged(self):

Re: When I need classes?

2016-01-10 Thread Chris Angelico
On Mon, Jan 11, 2016 at 1:57 PM, Cameron Simpson wrote: > I always structure this aspect as: > > ... at or near top of script ... > > def main(argv): >... do main logic here ... > > ... at bottom ... > if __name__ == '__main__': >sys.exit(main(sys.argv)) > > This has the benefits of (a

Re: Which Python editor has this feature?

2016-01-10 Thread Tim Chase
On 2016-01-10 17:59, jf...@ms4.hinet.net wrote: > It lets you jump between the current cursor position and the line > the upper level indentation start, something like the bracket > matching in C editor. Because of Python use indentation as its code > block mark, It might be helpful if we can jump

Re: When I need classes?

2016-01-10 Thread Cameron Simpson
On 10Jan2016 08:02, Michael Torrie wrote: I can't speak to Flask or any other web development. But for simple scripts, I'll start out with no classes. Just functions as needed, and some main logic. I always use the idiom: if __name__ == '__main__': # do main logic here This way I can imp

Re: Which Python editor has this feature?

2016-01-10 Thread Chris Angelico
On Mon, Jan 11, 2016 at 12:59 PM, wrote: > It lets you jump between the current cursor position and the line the upper > level indentation start, something like the bracket matching in C editor. > Because of Python use indentation as its code block mark, It might be helpful > if we can jump be

Which Python editor has this feature?

2016-01-10 Thread jfong
It lets you jump between the current cursor position and the line the upper level indentation start, something like the bracket matching in C editor. Because of Python use indentation as its code block mark, It might be helpful if we can jump between different level of it:-) --Jach Fong -- ht

Confusing on bool data object or class function?

2016-01-10 Thread Robert
Hi, When I use an on line code snippet, see below please, I find that 'converged' in class ConvergenceMonitor is seen as a data. - class ConvergenceMonitor(object): """Monitors and reports convergence to :data:`sys.stderr`. Parameters -- tol : double

Improving code written in order to reduce verbosity and perhaps use a decorator?

2016-01-10 Thread kbtyo
Hello everyone: A member on the Stack Overflow community advised me to post my question on this forum: http://codereview.stackexchange.com/questions/116395/opening-the-same-csv-file-in-two-different-ways-in-order-to-transform-data-in-on I appreciate your feedback immensely. Sincerely, Saran -

Re: Python launcher options

2016-01-10 Thread Edward Diener
On 1/10/2016 6:38 AM, Tim Golden wrote: On 10/01/2016 05:18, Edward Diener wrote: On 1/9/2016 11:03 AM, Tim Golden wrote: On 06/01/2016 00:48, Edward Diener wrote: The Python launcher in Windows is a neat tool for running multiple versions of Python 2 and Python 3 at different times. It allo

Re: Python launcher options

2016-01-10 Thread Edward Diener
On 1/10/2016 6:38 AM, Tim Golden wrote: On 10/01/2016 05:18, Edward Diener wrote: On 1/9/2016 11:03 AM, Tim Golden wrote: On 06/01/2016 00:48, Edward Diener wrote: The Python launcher in Windows is a neat tool for running multiple versions of Python 2 and Python 3 at different times. It allo

Re: licenses

2016-01-10 Thread Bernardo Sulzbach
Cody wrote a good and correct answer. Everyone is going with "lawyers, lawyers, lawyers...". It is not any lawyer. Most big companies and consulting firms will have lawyers that are experienced with open source licenses, some that have even fought against GPL and whatnot. So look for the correct t

Re: licenses

2016-01-10 Thread Cody Piersall
On Fri, Jan 8, 2016 at 1:41 PM, Martinez, Jorge Alberto (GE Aviation) < jorgealberto.marti...@ge.com> wrote: > > Hello > We develop applications here with Python and I want to know if there's issues by using. > We use NumPy, PyDaqMx, Py Visa > > How can we cover this licensing? I am not a lawyer,

Question on pytest example code

2016-01-10 Thread Robert
Hi, Below is a code snippet from pytest package. It passes pytest, i.e. there is no failure report. # content of test_sysexit.py import pytest def f(): raise SystemExit(1) def test_mytest(): with pytest.raises(SystemExit): f() I see that f() will generate 'SystemExit(1)'.

Re: How to remove item from heap efficiently?

2016-01-10 Thread Sven R. Kunze
On 09.01.2016 19:32, Paul Rubin wrote: "Sven R. Kunze" writes: Basically a task scheduler where tasks can be thrown away once they are too long in the queue. I don't think there's a real nice way to do this with heapq. The computer-sciencey way would involve separate balanced tree structures

Re: How to remove item from heap efficiently?

2016-01-10 Thread Sven R. Kunze
Wow. That's an impressive reply. On 08.01.2016 20:26, srinivas devaki wrote: So you need a task scheduler with expiration and priority on each task. Interesting Problem.. as peter said about marking the task in heapB to be deleted. but this needs searching everytime you pop off an old item [com

Re: What use of these _ prefix members?

2016-01-10 Thread Peter Otten
Robert wrote: > When I read a sample file from hmm learn package, which is on top of > scikit-learn package, I see there are many member functions (prefix with > '_') have no caller. That is, I don't see anything uses those functions. > Below is a sample part from class GMMHMM(_BaseHMM): I bet t

Re: What use of these _ prefix members?

2016-01-10 Thread Steven D'Aprano
On Mon, 11 Jan 2016 04:55 am, Robert wrote: > Some online tutorials tell me '_' prefix is a kind of convention of > private members. Correct. Not just private members, but private *anything*. Any time you see anything starting with a single underscore, whether it is a module, class, method, att

What use of these _ prefix members?

2016-01-10 Thread Robert
Hi, When I read a sample file from hmm learn package, which is on top of scikit-learn package, I see there are many member functions (prefix with '_') have no caller. That is, I don't see anything uses those functions. Below is a sample part from class GMMHMM(_BaseHMM): // def _

Re: Understanding " 'xml.etree.ElementTree.Element' does not support the buffer interface"

2016-01-10 Thread Saran Ahluwalia
Hi Steven: The previous code was a stand along under the " if __name__ == '__main__': ". The full function suite that I have made (and indeed includes a try and except block): import os.path import sys import csv from io import StringIO import xml.etree.cElementTree as ElementTree from xml.etree.

Re: When I need classes?

2016-01-10 Thread Bernardo Sulzbach
Essentially, classes (as modules) are used mainly for organizational purposes. Although you can solve any problem you would solve using classes without classes, solutions to some big problems may be cheaper and more feasible using classes. If Python is your everyday scripting tool, you will usual

Re: Understanding " 'xml.etree.ElementTree.Element' does not support the buffer interface"

2016-01-10 Thread Steven D'Aprano
On Mon, 11 Jan 2016 02:04 am, kbtyo wrote: > Hello Everyone: > > I am curious to know why I receive the aforementioned message. I am using > Python 3.4.3 and Windows 7. I am running the following script from Windows > Powershell: I created a file "data" containing the input data you said: > The

Re: Understanding " 'xml.etree.ElementTree.Element' does not support the buffer interface"

2016-01-10 Thread Saran Ahluwalia
Hi Steven: That is the only message (*xml.etree.ElementTree.Element' does not support the buffer interface"*). There is no traceback. My apologies for not clarifying previously. On Sun, Jan 10, 2016 at 10:19 AM, Steven D'Aprano wrote: > On Mon, 11 Jan 2016 02:04 am, kbtyo wrote: > > > Hello Eve

Re: When I need classes?

2016-01-10 Thread Steven D'Aprano
On Sun, 10 Jan 2016 06:29 pm, Arshpreet Singh wrote: > Hello Friends, I am quite new to OOP(object oriented Programming), I did > some projects with python which includes Data-Analysis, Flask Web > Development and some simple scripts. > > I have only one question which is bothering me most of the

Re: Understanding " 'xml.etree.ElementTree.Element' does not support the buffer interface"

2016-01-10 Thread Steven D'Aprano
On Mon, 11 Jan 2016 02:04 am, kbtyo wrote: > Hello Everyone: > > I am curious to know why I receive the aforementioned message. It is impossible to be sure from the information you have given us, since we do not know which line of code caused the error. Please copy and paste the ENTIRE traceb

Understanding " 'xml.etree.ElementTree.Element' does not support the buffer interface"

2016-01-10 Thread kbtyo
Hello Everyone: I am curious to know why I receive the aforementioned message. I am using Python 3.4.3 and Windows 7. I am running the following script from Windows Powershell: Response = 's.csv' with open(Response, 'rU', encoding='utf-8') as data: separated = data.

Re: When I need classes?

2016-01-10 Thread Michael Torrie
On 01/10/2016 12:29 AM, Arshpreet Singh wrote: > Hello Friends, I am quite new to OOP(object oriented Programming), I > did some projects with python which includes Data-Analysis, Flask Web > Development and some simple scripts. > > I have only one question which is bothering me most of the time,

Fwd: python unit test framework sample code

2016-01-10 Thread Ganesh Pal
Apologies, looks like I did a reply instead of reply-all. So forwarding this email , please provide guidance on the same -- Forwarded message -- From: Ganesh Pal Date: Thu, Jan 7, 2016 at 12:26 PM Subject: Re: python unit test framework sample code To: Terry Reedy > Unless you

Re: Python launcher options

2016-01-10 Thread Tim Golden
On 10/01/2016 05:18, Edward Diener wrote: On 1/9/2016 11:03 AM, Tim Golden wrote: On 06/01/2016 00:48, Edward Diener wrote: The Python launcher in Windows is a neat tool for running multiple versions of Python 2 and Python 3 at different times. It allows as options the ability to specify the

Re: licenses

2016-01-10 Thread Thomas 'PointedEars' Lahn
Ben Finney wrote: > "Martinez, Jorge Alberto (GE Aviation)" […] writes: >> We develop applications here with Python and I want to know if there's >> issues by using. We use NumPy, PyDaqMx, Py Visa > > Those are all free software: meaning, every recipient has freedom to > execute, modify, and/or r