Re: how to make return(self.res) not to output the content of list ?

2014-09-24 Thread Peter Otten
luofeiyu wrote: > `sys.displayhook = lambda obj: None ` will block everything to be > displayed on the interactive python console . > > i rewrite my code as the following : > > import sqlite3,os,jinja2 > db = r'data.sqlite' > con = sqlite3.connect(db) > cur = con.cursor() > > class status(): >

Re: ThreadPoolExecutor - callback guaranteed to run in same thread as the submitted function?

2014-09-24 Thread Ian Kelly
On Wed, Sep 24, 2014 at 8:44 AM, Praveen Gollakota wrote: > However, it seemed to fail when I removed the `time.sleep(random.random())` > statements, i.e. at least a few `func` functions and `callbacks` **did not** > run in the same thread. > > For a project that I am working on, the callback mu

Re: Which module I'm missing?

2014-09-24 Thread dieter
Igor Korot writes: > I got a suggestion to install eric for my developmental needs. > Unfortunately, it looks like my Linux distribution have a bug as > running eric throws an exception. > > [code] > igor@IgorDellGentoo ~/plaso-build/liblnk-20140905 $ eric5 > An unhandled exception occurred. Pleas

Re: ThreadPoolExecutor - callback guaranteed to run in same thread as the submitted function?

2014-09-24 Thread dieter
Praveen Gollakota writes: > In the ThreadPoolExecutor (TPE), is the callback always guaranteed to run in > the same thread as the submitted function? To answer question of this type (yourself), you may look at the relevant source code. I am quite sure that the "submitted function" will be execu

Automatic Crash Reporting

2014-09-24 Thread Timothy W. Grove
Can anyone recommend a good automatic crash reporting module that would work nicely with a python3/pyqt4 application? Thanks. Tim -- https://mail.python.org/mailman/listinfo/python-list

Which module I'm missing?

2014-09-24 Thread Igor Korot
Hi, ALL, I got a suggestion to install eric for my developmental needs. Unfortunately, it looks like my Linux distribution have a bug as running eric throws an exception. [code] igor@IgorDellGentoo ~/plaso-build/liblnk-20140905 $ eric5 An unhandled exception occurred. Please report the problem usi

Re: Flask and Python 3

2014-09-24 Thread Chris Angelico
On Thu, Sep 25, 2014 at 5:39 AM, Juan Christian wrote: > That's the way I always learned everything. I watch some video courses, read > a book and read the official documentation altogether. > > My way can't work for you, but for me it's excellent. And you don't even > know which video/course I'm

Re: String representations of numbers and approximate equality

2014-09-24 Thread Chris Angelico
On Thu, Sep 25, 2014 at 5:56 AM, Dave Angel wrote: > Your definition is not nearly as concrete as you think. Is the > first number considered to be exact, and we'll only check the > second? Will the factor always be an int, and thus > exact? Apologies: the definition is concrete, just under-sp

Re: how to make return(self.res) not to output the content of list ?

2014-09-24 Thread Cameron Simpson
On 25Sep2014 08:15, luofeiyu wrote: You could write a separate method that just calls self.grow() and does not return the result, and call that method instead from the interactive interpreter. luofeiyu: please take care to include the attribution line. The text above is from Ian Kelly, but yo

Re: cannot run a ruby script from a python script.

2014-09-24 Thread Cameron Simpson
On 24Sep2014 16:57, Shawn Bright wrote: i have a linux computer that i use to run a GUI (wxGTK) program. In this program, there is a call to run an external ruby script. command = "ruby run_my_command.rb &" os.system(command) however, when it runs, i get this in the terminal sh: 1: ruby: not

Re: how to make return(self.res) not to output the content of list ?

2014-09-24 Thread luofeiyu
You could write a separate method that just calls self.grow() and does not return the result, and call that method instead from the interactive interpreter. how can i change your meaning into python code? There is my code structure. class status(): def grow(self): self.res= a

Re: how to make return(self.res) not to output the content of list ?

2014-09-24 Thread luofeiyu
`sys.displayhook = lambda obj: None ` will block everything to be displayed on the interactive python console . i rewrite my code as the following : import sqlite3,os,jinja2 db = r'data.sqlite' con = sqlite3.connect(db) cur = con.cursor() class status(): def __init__(): import sy

cannot run a ruby script from a python script.

2014-09-24 Thread Shawn Bright
hello all. i have a linux computer that i use to run a GUI (wxGTK) program. In this program, there is a call to run an external ruby script. command = "ruby run_my_command.rb &" os.system(command) however, when it runs, i get this in the terminal sh: 1: ruby: not found i had considered that

Re: String representations of numbers and approximate equality

2014-09-24 Thread Dan Stromberg
On Wed, Sep 24, 2014 at 9:54 AM, Chris Angelico wrote: > Yes, it's another "how can I see if two numbers are approximately > equal" thread, but this time I have a concrete definition of > "approximately equal"... and they're Decimals, not floats. > > I have a number of files (this is an ongoing th

Re: GCD in Fractions

2014-09-24 Thread Robert E. Beaudoin
On 09/24/14 09:25, blindanagram wrote: On 24/09/2014 12:44, Steven D'Aprano wrote: blindanagram wrote: [snip] - Mathworld says that GCD of two negative numbers is a negative number; - but Mathematica says that GCD of two negative numbers is a positive; - Wikipedia agrees with Mathematica an

Re: Syntax error in python unittest script

2014-09-24 Thread Terry Reedy
On 9/24/2014 3:33 PM, Milson Munakami wrote: I am learning to use unittest with python [way too long example] File "TestTest.py", line 44 def cleanup(self, success): ^ SyntaxError: invalid syntax A common recommendation is to find the *minimal* example that exhibits the proble

Re: Receiving large files with @tornado.web.stream_request_body

2014-09-24 Thread Nagy László Zsolt
2014.09.24. 16:31 keltezéssel, Nagy László Zsolt írta: @tornado.web.stream_request_body class PostFilesHandler(tornado.web.RequestHandler): def post(self): for postfile in self.request.files: print("File info:",postfile) # There is no postfile["body"] here!!!

Re: Syntax error in python unittest script

2014-09-24 Thread Mark Lawrence
On 24/09/2014 21:06, Milson Munakami wrote: [snipped all the usual garbage] Would you please access this list via https://mail.python.org/mailman/listinfo/python-list or read and action this https://wiki.python.org/moin/GoogleGroupsPython to prevent us seeing double line spacing and single li

Re: Syntax error in python unittest script

2014-09-24 Thread Milson Munakami
On Wednesday, September 24, 2014 1:33:35 PM UTC-6, Milson Munakami wrote: > Hi, > > > > I am learning to use unittest with python and walkthrough with this example > > http://agiletesting.blogspot.com/2005/01/python-unit-testing-part-1-unittest.html > > > Thanks > so my test script is like th

Re:String representations of numbers and approximate equality

2014-09-24 Thread Dave Angel
Chris Angelico Wrote in message: > Yes, it's another "how can I see if two numbers are approximately > equal" thread, but this time I have a concrete definition of > "approximately equal"... and they're Decimals, not floats. > > I have a number of files (this is an ongoing thing) in which there a

Re: Syntax error in python unittest script

2014-09-24 Thread Peter Otten
Milson Munakami wrote: > if self.reportStatus_: > self.log.info("=== Test %s completed normally (%d > sec)", self.name_, duration The info() call is missing the closing parenthesis > def cleanup(self, success): > sys.excepthook =

Re: Syntax error in python unittest script

2014-09-24 Thread Emile van Sebille
On 9/24/2014 12:33 PM, Milson Munakami wrote: def tearDown(self): if self.failed: return duration = time.time() - self.startTime_ self.cleanup(True) if self.reportStatus_: self.

Re: Flask and Python 3

2014-09-24 Thread Juan Christian
On Wednesday, September 24, 2014, Chris “Kwpolska” Warrick < kwpol...@gmail.com> wrote: > Learning from videos is the worst thing you can do. Use the official > flask documentation at http://flask.pocoo.org/docs/0.10/quickstart/ — > it’s much friendlier than a video. > > Also, there is nothing to

Syntax error in python unittest script

2014-09-24 Thread Milson Munakami
Hi, I am learning to use unittest with python and walkthrough with this example http://agiletesting.blogspot.com/2005/01/python-unit-testing-part-1-unittest.html so my test script is like this: import json import urllib #import time #from util import * import httplib #import sys #from scapy.all i

Re: GCD in Fractions

2014-09-24 Thread Johann Hibschman
Steven D'Aprano writes: > blindanagram wrote: > >> Seccondly (as others here have pointed out), the mathematical properties >> of the greatest common divisor are well defined for both positive and >> negative integers. > > You keep saying that, but it simply is not true. Different people use > di

Re: GCD in Fractions

2014-09-24 Thread Terry Reedy
On 9/24/2014 7:44 AM, Steven D'Aprano wrote: blindanagram wrote: Seccondly (as others here have pointed out), the mathematical properties of the greatest common divisor are well defined for both positive and negative integers. You keep saying that, but it simply is not true. Different people

Re: GCD in Fractions

2014-09-24 Thread blindanagram
On 24/09/2014 17:34, Mark Lawrence wrote: > On 24/09/2014 12:14, Mark Dickinson wrote: >> Mark Lawrence yahoo.co.uk> writes: >>> Somebody got there first http://bugs.python.org/issue22477 >> >> I think there's good reason to suspect that Brian Gladman and >> blindanagram are one and the same. :-)

Re: GCD in Fractions

2014-09-24 Thread blindanagram
On 24/09/2014 17:13, Stefan Behnel wrote: > blindanagram schrieb am 24.09.2014 um 15:25: >> On 24/09/2014 12:44, Steven D'Aprano wrote: [snip] > We have an open tracker ticket now on changing *something* about the > current situation. Let's just add some new functionality somewhere if > people re

String representations of numbers and approximate equality

2014-09-24 Thread Chris Angelico
Yes, it's another "how can I see if two numbers are approximately equal" thread, but this time I have a concrete definition of "approximately equal"... and they're Decimals, not floats. I have a number of files (this is an ongoing thing) in which there are two columns of numbers. One of them shoul

Re: GCD in Fractions

2014-09-24 Thread random832
On Wed, Sep 24, 2014, at 10:26, Ian Kelly wrote: > This depends entirely on your implementation of the modulo operation, > which is an issue of computing since the operator is not used in > mathematics. Wikipedia suggests that "remainders from Euclidean division" should be used. In Euclidean divis

Re: why can't open the file with browser?

2014-09-24 Thread Mark Lawrence
On 24/09/2014 13:22, Chris Angelico wrote: On Wed, Sep 24, 2014 at 7:32 PM, luofeiyu wrote: import webbrowser webbrowser.open('f:\\test.html') why the file f:\\test.html is opened by notepad ,not by my firefox or chrome? It looks to me as if your default association is set to Notepad rather t

Re: GCD in Fractions

2014-09-24 Thread Mark Lawrence
On 24/09/2014 12:14, Mark Dickinson wrote: Mark Lawrence yahoo.co.uk> writes: Somebody got there first http://bugs.python.org/issue22477 I think there's good reason to suspect that Brian Gladman and blindanagram are one and the same. :-) sorted("BrianGladman".lower()) == sorted("blindanagra

Re: how to make return(self.res) not to output the content of list ?

2014-09-24 Thread Peter Otten
luofeiyu wrote: > There is a file named analyse.py in the D:\Python34\Lib\site-packages. > > > import sqlite3,os,jinja2 > db = r'F:\workspace\china\data\china.sqlite' > con = sqlite3.connect(db) > cur = con.cursor() > > class status(): > def grow(self): > self.res=cur.execute('sel

Re: GCD in Fractions

2014-09-24 Thread Stefan Behnel
blindanagram schrieb am 24.09.2014 um 15:25: > On 24/09/2014 12:44, Steven D'Aprano wrote: > >> blindanagram wrote: > [snip] >> - Mathworld says that GCD of two negative numbers is a negative number; >> >> - but Mathematica says that GCD of two negative numbers is a positive; >> >> - Wikipedia agr

Re: how to make return(self.res) not to output the content of list ?

2014-09-24 Thread Ian Kelly
On Wed, Sep 24, 2014 at 7:55 AM, luofeiyu wrote: > > now what i want to do is : > 1.keep return(self.res) in grow method. > 2.it is my target that when run the code: > > import analyse > x=analyse.status() > x.grow() > > there is nothing output in my console , to make return(self.res) not to o

Re: "Fuzzy" Counter?

2014-09-24 Thread Ian Kelly
On Tue, Sep 23, 2014 at 11:01 PM, Miki Tebeka wrote: > On Tuesday, September 23, 2014 7:33:06 PM UTC+3, Rob Gaddi wrote: > >> While you're at it, think >> long and hard about that definition of fuzziness. If you can make it >> closer to the concept of histogram "bins" you'll get much better >> pe

RE: Python as Windows Service

2014-09-24 Thread Arulnambi Nandagoban
De : Gmail [mailto:mrje...@gmail.com] Envoyé : Wednesday, September 24, 2014 2:41 PM À : Arulnambi Nandagoban Objet : Re: Python as Windows Service Also, this may work for you NSSM installs an existing app as a service. /Jean

ThreadPoolExecutor - callback guaranteed to run in same thread as the submitted function?

2014-09-24 Thread Praveen Gollakota
Hello, In the ThreadPoolExecutor (TPE), is the callback always guaranteed to run in the same thread as the submitted function? For example, I tested this with the following code. I ran it many times and it seemed like `func` and `callback` always ran in the same thread. import concurrent.

Re: Receiving large files with @tornado.web.stream_request_body

2014-09-24 Thread Nagy László Zsolt
@tornado.web.stream_request_body class PostFilesHandler(tornado.web.RequestHandler): def post(self): for postfile in self.request.files: print("File info:",postfile) # There is no postfile["body"] here!!! def prepare(self): self.temp_file = tempfile.Name

Re: GCD in Fractions

2014-09-24 Thread Ian Kelly
On Wed, Sep 24, 2014 at 5:44 AM, Steven D'Aprano wrote: > The Collins Dictionary of Mathematics (second edition, 2002) says: > > highest common factor, greatest common factor, or greatest > common divisor (abbrev hcf, gcf, gcd) > > n, an integer d that exactly divides (sense 2) two giv

Re: Flask and Python 3

2014-09-24 Thread Chris “Kwpolska” Warrick
On Wed, Sep 24, 2014 at 3:23 AM, Juan Christian wrote: > I didn't learn debug with Flask yet. Only in the next videos. Learning from videos is the worst thing you can do. Use the official flask documentation at http://flask.pocoo.org/docs/0.10/quickstart/ — it’s much friendlier than a video. Al

Re: import reloading

2014-09-24 Thread Dave Angel
Robin Becker Wrote in message: > On 24/09/2014 12:54, Dave Angel wrote: >> Robin Becker Wrote in message: >>... >>> Is a loader supposed to reset all the reused module's attributes and reset >>> the >>> __dict__ or does it just run the code from the module in hte __dict__? >>> >> >> Noth

how to make return(self.res) not to output the content of list ?

2014-09-24 Thread luofeiyu
There is a file named analyse.py in the D:\Python34\Lib\site-packages. import sqlite3,os,jinja2 db = r'F:\workspace\china\data\china.sqlite' con = sqlite3.connect(db) cur = con.cursor() class status(): def grow(self): self.res=cur.execute('select 代码,所属行业,注册资本,雇员人数,管 理人员人数 from prof

Re: brackets at the end of a method name

2014-09-24 Thread ast
"Andrea D'Amore" a écrit dans le message de news:lvuhdu$c6q$1...@virtdiesel.mng.cu.mi.it... On 2014-09-24 13:30:55 +, ast said: we have some methods associated with file f […] f.close() f.name print(type(f.close)) print(type(f.name)) Spot the difference. -- Andrea f.name is an att

Re: brackets at the end of a method name

2014-09-24 Thread Andrea D'Amore
On 2014-09-24 13:30:55 +, ast said: we have some methods associated with file f […] f.close() f.name print(type(f.close)) print(type(f.name)) Spot the difference. -- Andrea -- https://mail.python.org/mailman/listinfo/python-list

brackets at the end of a method name

2014-09-24 Thread ast
Hi Once a file is opened with: f=open("foo.txt", "r") we have some methods associated with file f f.read() f.readline() .. f.close() f.name f.mode I dont understand why sometimes there are brackets () at the end of the method name (ie close())and sometimes no (ie name) I thought that maybe m

Re: import reloading

2014-09-24 Thread Robin Becker
On 24/09/2014 12:54, Dave Angel wrote: Robin Becker Wrote in message: ... Is a loader supposed to reset all the reused module's attributes and reset the __dict__ or does it just run the code from the module in hte __dict__? Nothing gets reset or run. It simply reuses the existing mod

Re: GCD in Fractions

2014-09-24 Thread blindanagram
On 24/09/2014 12:44, Steven D'Aprano wrote: > blindanagram wrote: [snip] > - Mathworld says that GCD of two negative numbers is a negative number; > > - but Mathematica says that GCD of two negative numbers is a positive; > > - Wikipedia agrees with Mathematica and disagrees with Mathworld; Aft

Re: Best way to deal with different data types in a list comprehension

2014-09-24 Thread Steven D'Aprano
Larry Martell wrote: > I have some code that I inherited: > > ' '.join([self.get_abbrev()] + >[str(f['value') > for f in self.filters > if f.has_key('value')]).strip() > > > This broke today when it encountered some non-ascii data. It's already broken. It gi

Receiving large files with @tornado.web.stream_request_body

2014-09-24 Thread Nagy László Zsolt
I was using tornado 3 before. I see that file streaming was included in version 4. This is something I need for posting large files. I have a problem receiving multiple files with a single POST request. Client side could be something like this: First file: Second file: Third file:

Re: why can't open the file with browser?

2014-09-24 Thread Chris Angelico
On Wed, Sep 24, 2014 at 7:32 PM, luofeiyu wrote: > import webbrowser webbrowser.open('f:\\test.html') why the file > f:\\test.html is opened by notepad ,not by my firefox or chrome? It looks to me as if your default association is set to Notepad rather than a web browser. Try opening one of the b

RE: why can't open the file with browser?

2014-09-24 Thread DaveA
> import webbrowser > webbrowser.open('f:\\test.html') > why the file f:\\test.html is opened by notepad  > ,not by my firefox or chrome? The default protocol in a browser is http. If you're not running a server on your local machine,  you need to specify a different protocol.  Try file:///f:/

Re:import reloading

2014-09-24 Thread Dave Angel
Robin Becker Wrote in message: > I'm tryng to bring some outdated ihooks code into the modern world. > > I notice that module loaders are supposed to re-use an existing module if it > is > already in sys.modules. > No, the loader is required to reuse the existing module. > Is a loader supp

Re: GCD in Fractions

2014-09-24 Thread Steven D'Aprano
blindanagram wrote: > Seccondly (as others here have pointed out), the mathematical properties > of the greatest common divisor are well defined for both positive and > negative integers. You keep saying that, but it simply is not true. Different people use different definitions. Some refuse to a

Re: why can't open the file with browser?

2014-09-24 Thread Skip Montanaro
Maybe it's supposed to be file://localhost/test.html ? Just a guess, as I don't use Windows. Skip On Wed, Sep 24, 2014 at 4:32 AM, luofeiyu wrote: > > import webbrowser > webbrowser.open('f:\\test.html') > > why the file f:\\test.html is opened by notepad ,not by my firefox or chrome? > > >

Re: GCD in Fractions

2014-09-24 Thread Mark Dickinson
Mark Lawrence yahoo.co.uk> writes: > Somebody got there first http://bugs.python.org/issue22477 I think there's good reason to suspect that Brian Gladman and blindanagram are one and the same. :-) >>> sorted("BrianGladman".lower()) == sorted("blindanagram") True -- https://mail.python.o

Re: GCD in Fractions

2014-09-24 Thread Mark Lawrence
On 23/09/2014 23:52, Mark Lawrence wrote: On 23/09/2014 22:48, blindanagram wrote: On 23/09/2014 20:30, Mark Lawrence wrote: On 23/09/2014 18:43, blindanagram wrote: All you need do is raise an issue on the bug tracker, provide a patch to code, test and docs and the job is done. Thank you for

import reloading

2014-09-24 Thread Robin Becker
I'm tryng to bring some outdated ihooks code into the modern world. I notice that module loaders are supposed to re-use an existing module if it is already in sys.modules. Is a loader supposed to reset all the reused module's attributes and reset the __dict__ or does it just run the code from

why can't open the file with browser?

2014-09-24 Thread luofeiyu
| import webbrowser webbrowser.open('f:\\test.html') why the file f:\\test.html is opened by notepad ,not by my firefox or chrome? | -- https://mail.python.org/mailman/listinfo/python-list

Re: how to write a html to automatically display the dictionary?

2014-09-24 Thread Jean-Michel Pichavant
- Original Message - > From: "luofeiyu" > To: "Joel Goldstick" , python-list@python.org > Sent: Wednesday, 24 September, 2014 1:06:25 AM > Subject: Re: how to write a html to automatically display the dictionary? > > > how can i create the proper html file with Jinjia 2 or other temple?

Re: Dynamically swapping between two algorithms

2014-09-24 Thread dieter
Steven D'Aprano writes: > ... > *If* Python was a different language, I would spawn two threads, one using > SHORT and the other using LARGE, then which ever completes first, I'd just > kill the other. Alas, this won't work because (1) the GIL The GIL does not prevent this scenario. The two threa

how to display the result in table with jinkoa2 temple?

2014-09-24 Thread luofeiyu
import sqlite3 db=r'F:\workspace\china\data\china.sqlite' con=sqlite3.connect(db) cur=con.cursor() res=cur.execute('select 代码,所属行业,注册资本,雇员人数,管理人员人数 from profile limit 20').fetchall() the result is a list. >>> for row in res: ... print(row) ... ('60', '银行', '187亿', 39340.0, 30.0) ('6000