Re: gmail api

2017-02-09 Thread Kelvid Pang
On Tuesday, 7 February 2017 14:22:32 UTC+8, Kelvid Pang wrote: > hi, > > I am trying to gmail api with reference to this URL: > https://developers.google.com/gmail/api/quickstart/python > > But I couldn't find the 'gmail-python-quickstart.json' file. Any one can > help? thanks. First of all,

Re: int vs. float

2017-02-09 Thread Chris Angelico
On Fri, Feb 10, 2017 at 1:33 PM, wrote: > I understand that because I am starting out by assigning my > number_purchases_str to be an int, when the user enters a float that is a > conflict and will crash. > > My professor apparently believes there is a way to accomplish this. Any help > or ad

int vs. float

2017-02-09 Thread adam14711993
Hello, My computer programming professor challenged me to figure out a way to manipulate my program to display one error message if the user input is a zero or a negative number, and a separate error message if the user input is a decimal number. My program starts out: number_purchases_str =

Re: subprocess problem

2017-02-09 Thread Cameron Simpson
On 10Feb2017 00:03, eryk sun wrote: On Thu, Feb 9, 2017 at 10:50 PM, Cameron Simpson wrote: This is why I suggested the check_returncode() method, which examines the error code. You must be thinking of the returncode attribute, which isn't a method. check_returncode() is a method of the Comp

Re: subprocess problem

2017-02-09 Thread eryk sun
On Fri, Feb 10, 2017 at 12:05 AM, Wildman via Python-list wrote: > > Corrected code: > > def which(target) > for p in pathlist: > fullpath = p + "/" + target > if os.path.isfile(fullpath) and os.access(fullpath, os.X_OK): > return fullpath, True > return None, F

Re: subprocess problem

2017-02-09 Thread MRAB
On 2017-02-10 00:05, Wildman via Python-list wrote: On Fri, 10 Feb 2017 09:53:32 +1100, Cameron Simpson wrote: On 09Feb2017 11:59, Wildman wrote: Here is a method I frequently use to replace the which command. (air code) import os pathlist = os.environ["PATH"].split(":") def which(target)

Re: subprocess problem

2017-02-09 Thread Wildman via Python-list
On Fri, 10 Feb 2017 09:53:32 +1100, Cameron Simpson wrote: > On 09Feb2017 11:59, Wildman wrote: >>Here is a method I frequently use to replace the which >>command. (air code) >> >>import os >>pathlist = os.environ["PATH"].split(":") >> >>def which(target) >>for p in pathlist: >>fullpa

Re: subprocess problem

2017-02-09 Thread eryk sun
On Thu, Feb 9, 2017 at 10:50 PM, Cameron Simpson wrote: > This is why I suggested the check_returncode() method, which examines the > error code. You must be thinking of the returncode attribute, which isn't a method. check_returncode() is a method of the CompletedProcess object that's returned b

The Dominion

2017-02-09 Thread Terry Reedy
A video ad for Anaconda from its maker (satirizing a well know data-related film). I found it amusing, in a good way. https://www.youtube.com/watch?v=0XDqc5wTve0 PS. I don't use Anaconda and I am not posting this to promote it, nor do I necessarily agree with everything said, but I do apprecia

Re: Decorator

2017-02-09 Thread Chris Angelico
On Fri, Feb 10, 2017 at 10:18 AM, Terry Reedy wrote: > Perhaps "There are also cases in which evaluating 'fi(arg)' before rather > than after the def statement makes a difference." should be added. Perhaps not. The word "roughly" covers the odd edge cases, and Python has a general principle of ev

Re: Decorator

2017-02-09 Thread Terry Reedy
On 2/9/2017 2:03 AM, ast wrote: Hi In python courses I read, it is explained that @decor def f(): pass is equivalent to: def f(): pass f = decor(f) But that's not always true. See this code Which is why the official docs now say 'roughly equivalent' ''' For example, the following co

Re: subprocess problem

2017-02-09 Thread Cameron Simpson
On 09Feb2017 11:59, Wildman wrote: Here is a method I frequently use to replace the which command. (air code) import os pathlist = os.environ["PATH"].split(":") def which(target) for p in pathlist: fullpath = p + "/" + target if os.path.isfile(fullpath): return full

Re: subprocess problem

2017-02-09 Thread Cameron Simpson
On 09Feb2017 11:16, Andreas Paeffgen wrote: I guess which does not return an error code. If it does not find anything, the return is just blank. If it finds something, the path is returned. So the change of code did not help, because there is just no error message. Could there be a $path prob

Re: subprocess problem

2017-02-09 Thread Günther Dietrich
Am 09.02.17 um 18:16 schrieb Andreas Paeffgen: > I guess which does not return an error code. In fact, id does return a return code. Here an example: | honk:~ gdie$ which bash; echo $? | /bin/bash | 0 | honk:~ gdie$ which wzlbrmpf; echo $? | 1 It is 0 on success, 1 for a failure. Exactly the res

Re: subprocess problem

2017-02-09 Thread Wildman via Python-list
On Thu, 09 Feb 2017 11:16:18 -0600, Andreas Paeffgen wrote: > I guess which does not return an error code. If it does not find > anything, the return is just blank. If it finds something, the path is > returned. > > So the change of code did not help, because there is just no error message. > C

Re: subprocess problem

2017-02-09 Thread Andreas Paeffgen
I guess which does not return an error code. If it does not find anything, the return is just blank. If it finds something, the path is returned. So the change of code did not help, because there is just no error message. Could there be a $path problem in the subprocess started inside the binar

Re: subprocess problem

2017-02-09 Thread Andreas Paeffgen
Maybe i could use another trick to circumvent the problems in the frozen app? The frozen apps can be downloaded here: https://sourceforge.net/projects/panconvert/files/Newest/ @Cameron: 1. I use PyQT5 for a creating a gui app. To run the app on other systems, where no QT5 and PyQT5 is install

Re: Rename file without overwriting existing files

2017-02-09 Thread eryk sun
On Thu, Feb 9, 2017 at 11:46 AM, Steve D'Aprano wrote: > > So to summarise, os.rename(source, destination): > > - is atomic on POSIX systems, if source and destination are both on the > same file system; > - may not be atomic on Windows? > - may over-write an existing destination on POSIX system

Re: Rename file without overwriting existing files

2017-02-09 Thread Jussi Piitulainen
Steve D'Aprano writes: > On Mon, 30 Jan 2017 09:39 pm, Peter Otten wrote: > > def rename(source, dest): >> ... os.link(source, dest) >> ... os.unlink(source) >> ... > rename("foo", "baz") > os.listdir() >> ['bar', 'baz'] > rename("bar", "baz") >> Traceback (most recent call

Re: Rename file without overwriting existing files

2017-02-09 Thread Steve D'Aprano
On Tue, 31 Jan 2017 11:17 am, Ben Finney wrote: > Peter Otten <__pete...@web.de> writes: > >> http://stackoverflow.com/questions/3222341/how-to-rename-without-race-conditions >> >> and from a quick test it appears to work on Linux: > > By “works on Linux”, I assume you mean “works on filesystems

Re: Rename file without overwriting existing files

2017-02-09 Thread Steve D'Aprano
On Mon, 30 Jan 2017 09:39 pm, Peter Otten wrote: def rename(source, dest): > ... os.link(source, dest) > ... os.unlink(source) > ... rename("foo", "baz") os.listdir() > ['bar', 'baz'] rename("bar", "baz") > Traceback (most recent call last): > File "", line 1, in >

Re: Decorator

2017-02-09 Thread ast
"Steven D'Aprano" a écrit dans le message de news:589c2cdc$0$1584$c3e8da3$54964...@news.astraweb.com... On Thu, 09 Feb 2017 08:03:32 +0100, ast wrote: Congratulations, you've found a microscopic corner of the language where the two different ways of applying decorators are different. Are y

Re: How to store properties

2017-02-09 Thread Chris Angelico
On Thu, Feb 9, 2017 at 7:43 PM, dieter wrote: > "pickle", too, has a potential security risk -- if you allow > unpickling from untrusted source. Usually, however, configuration > comes from trusted sources. Pickle's other downside is that it's an opaque binary file, unlike ConfigParser, JSON, and

Re: How to store properties

2017-02-09 Thread Cecil Westerhof
On Wednesday 8 Feb 2017 12:26 CET, Cecil Westerhof wrote: > In Java you (can) use a properties file store configuration. What is > the best way to do something like that in Python? > I saw ConfigParser, but have the feeling that it is not really used. > Would a JSON file be a good idea? Thanks f

Re: Decorator

2017-02-09 Thread Steven D'Aprano
On Thu, 09 Feb 2017 08:03:32 +0100, ast wrote: > Hi > > In python courses I read, it is explained that > > @decor > def f(): > pass > > is equivalent to: > > def f(): > pass > > f = decor(f) > > But that's not always true. See this code [...] > any comment ? Congratulations, you've

Re: How to store properties

2017-02-09 Thread dieter
Cecil Westerhof writes: > ... >> If you only want to read the configuration, just use an ordinary >> file you import. For example config.py contains the lines: >> username=myuser >> server=myserver >> password=secret >> >> In your script: >> >> import config >> >> Now you can referenc all the var

Re: subprocess problem

2017-02-09 Thread Wolfgang Maier
On 09.02.2017 01:56, Andreas Paeffgen wrote: The Problem with the subprocess code is: Using the sourcecode functioning as normal. The frozen app with cx_freeze on every platform just returns an empty result Here is the code in short: def get_path_pandoc(): settings = QSettings('Pandoc', '

Re: subprocess problem

2017-02-09 Thread Wolfgang Maier
On 09.02.2017 01:56, Andreas Paeffgen wrote: The Problem with the subprocess code is: Using the sourcecode functioning as normal. The frozen app with cx_freeze on every platform just returns an empty result Here is the code in short: def get_path_pandoc(): settings = QSettings('Pandoc', '