Re: Python script output in file

2015-03-18 Thread Robert Clove
On Wed, Mar 18, 2015 at 7:10 PM, Rustom Mody wrote: > On Thursday, March 19, 2015 at 1:58:29 AM UTC+5:30, Albert-Jan Roskam > wrote: > > > > On Wed, Mar 18, 2015 7:06 PM CET Rustom Mody wrote: > > > > >On Wednesday, March 18, 2015 at 8:12:12 PM UTC+5:30, Robert Clove

ANN: SciPy (Scientific Python) 2015 Call for Proposals & Registration Open - tutorial & talk submissions due April 1st

2015-03-18 Thread Courtenay Godshall
**SciPy 2015 Conference (Scientific Computing with Python) Call for Proposals: Submit Your Tutorial and Talk Ideas by April 1, 2015 at http://scipy2015.scipy.org.** SciPy 2015, the fourteenth annual Scientific Computing with Python conference, will be held July 6-12, 2015 in Austin, Texas. Sc

Re: how should i add extension and unzip again?

2015-03-18 Thread PK Khatri
On Wednesday, March 18, 2015 at 4:58:34 PM UTC-7, MRAB wrote: > On 2015-03-18 23:22, PK Khatri wrote: > > This script untars .gz file to file without extension > > > > import gzip > > import glob > > import os.path > > import tarfile > > > > source_dir = "C:\\TEST" > > dest_dir = "C:\\TEST

Re: Python script output in file

2015-03-18 Thread Rustom Mody
On Thursday, March 19, 2015 at 1:58:29 AM UTC+5:30, Albert-Jan Roskam wrote: > > On Wed, Mar 18, 2015 7:06 PM CET Rustom Mody wrote: > > >On Wednesday, March 18, 2015 at 8:12:12 PM UTC+5:30, Robert Clove wrote: > >> ./my_eth_script.pl eth0 M > a.txt > >> > >> How can

Re: A simple single line, triple-quoted comment is giving syntax error. Why?

2015-03-18 Thread Denis McMahon
On Wed, 18 Mar 2015 10:46:20 -0700, Aditya Raj Bhatt wrote: > I always do single line comments with # but just for the sake of it I > tried it with ''' ''' and it gives me a syntax error. > ... > So can someone tell me why a triple-quoted string gives a syntax error > if only in one line? A tri

Re: A simple single line, triple-quoted comment is giving syntax error. Why?

2015-03-18 Thread Ben Finney
Aditya Raj Bhatt writes: > I always do single line comments with # but just for the sake of it I > tried it with ''' ''' and it gives me a syntax error. The only comment syntax in Python code is the line-end ‘# …’ syntax. > In both the interpreter, and the source code text file, doing - > > a =

Re: how should i add extension and unzip again?

2015-03-18 Thread MRAB
On 2015-03-18 23:22, PK Khatri wrote: This script untars .gz file to file without extension import gzip import glob import os.path import tarfile source_dir = "C:\\TEST" dest_dir = "C:\\TEST" for src_name in glob.glob(os.path.join(source_dir, '*.gz')): base = os.path.basename(src_n

how should i add extension and unzip again?

2015-03-18 Thread PK Khatri
This script untars .gz file to file without extension import gzip import glob import os.path import tarfile source_dir = "C:\\TEST" dest_dir = "C:\\TEST" for src_name in glob.glob(os.path.join(source_dir, '*.gz')): base = os.path.basename(src_name) dest_name = os.path.join(dest_di

Re: Python script output in file

2015-03-18 Thread Steven D'Aprano
On Thu, 19 Mar 2015 07:22 am, Albert-Jan Roskam wrote: > > > On Wed, Mar 18, 2015 7:06 PM CET Rustom Mody wrote: > >>On Wednesday, March 18, 2015 at 8:12:12 PM UTC+5:30, Robert Clove wrote: >>> ./my_eth_script.pl eth0 M > a.txt >>> >>> How can i run this command wit

Re: A simple single line, triple-quoted comment is giving syntax error. Why?

2015-03-18 Thread Chris Angelico
On Thu, Mar 19, 2015 at 9:58 AM, Steven D'Aprano wrote: > But let's also remember that sometimes you cannot be bothered with *best* > practice, and "good enough for now" practice is fine. > > Need to comment out a large block of code in a hurry while using a basic > editor that doesn't offer a "Co

Re: A simple single line, triple-quoted comment is giving syntax error. Why?

2015-03-18 Thread Steven D'Aprano
On Thu, 19 Mar 2015 06:53 am, Thomas 'PointedEars' Lahn wrote: > I must strongly object and recommend against getting accustomed to the > suggested use of multi-line string literals. I agree in general with Thomas' comments about using arbitrary strings as comments. If you want to write code acco

Re: Python script output in file

2015-03-18 Thread Chris Angelico
On Thu, Mar 19, 2015 at 7:22 AM, Albert-Jan Roskam wrote: > On Wed, Mar 18, 2015 7:06 PM CET Rustom Mody wrote: > >>On Wednesday, March 18, 2015 at 8:12:12 PM UTC+5:30, Robert Clove wrote: >>> ./my_eth_script.pl eth0 M > a.txt >>> >>> How can i run this command with subprocess.popen >> >>Something

Re: UnboundLocalError in TKinter, SQLAlchemy script.

2015-03-18 Thread Steven D'Aprano
On Thu, 19 Mar 2015 06:42 am, Chris Kavanagh wrote: > While I appreciate the help greatly I thought I had put the entire > traceback of the error. I was posting here and on StackOverflow, and > suppose I got confused. We all make mistakes. I got distracted and forgot to link you to http://sscce

Re: UnboundLocalError in TKinter, SQLAlchemy script.

2015-03-18 Thread Mark Lawrence
On 18/03/2015 19:42, Chris Kavanagh wrote: 2nd, you say you "don't want to play guessing games", yet complain about "300 lines of irrelevant code", lol. Which way is it? Do you want the code, or not? How do I know what's relevant or irrelevant when I'm clearly confused? On Stack, if you don'

Re: A simple single line, triple-quoted comment is giving syntax error. Why?

2015-03-18 Thread Terry Reedy
On 3/18/2015 3:53 PM, Thomas 'PointedEars' Lahn wrote: I must strongly object and recommend against getting accustomed to the suggested use of multi-line string literals. I agree. If you want to comment your code, then by all means do so using docstrings and *real* comments. IDEs like PyDev

Re: UnboundLocalError in TKinter, SQLAlchemy script.

2015-03-18 Thread Terry Reedy
On 3/18/2015 3:42 PM, Chris Kavanagh wrote: 2nd, you say you "don't want to play guessing games", yet complain about "300 lines of irrelevant code", lol. Which way is it? Do you want the code, or not? How do I know what's relevant or irrelevant when I'm clearly confused? You comment out appare

Re: A simple single line, triple-quoted comment is giving syntax error. Why?

2015-03-18 Thread Tim Chase
On 2015-03-18 10:46, Aditya Raj Bhatt wrote: > a = 5 '''a comment''' > > results in a syntax error That's to be expected, and happens with any string, not just triple-quoted: >>> a = 5 "hello" > there are no 'true' multiline comments in python and that all those > 'block' comments are actuall

Re: Python script output in file

2015-03-18 Thread Albert-Jan Roskam
On Wed, Mar 18, 2015 7:06 PM CET Rustom Mody wrote: >On Wednesday, March 18, 2015 at 8:12:12 PM UTC+5:30, Robert Clove wrote: >> ./my_eth_script.pl eth0 M > a.txt >> >> How can i run this command with subprocess.popen > >Something like this I guess? > >>> proc = Pope

Re: A simple single line, triple-quoted comment is giving syntax error. Why?

2015-03-18 Thread Thomas 'PointedEars' Lahn
Aditya Raj Bhatt wrote: > I always do single line comments with # but just for the sake of it I > tried it with ''' ''' and it gives me a syntax error. > > In both the interpreter, and the source code text file, doing - > > a = 5 '''a comment''' > > results in a syntax error, with the very last

Re: A simple single line, triple-quoted comment is giving syntax error. Why?

2015-03-18 Thread Thomas 'PointedEars' Lahn
Thomas 'PointedEars' Lahn wrote: > […] standalone multi-line string literals in Python code serve a specific > purpose when at the beginning of a function, method or class clock: they ^ block¹ > constitute *docstrings”, setting _

Re: A simple single line, triple-quoted comment is giving syntax error. Why?

2015-03-18 Thread Thomas 'PointedEars' Lahn
Laurent Pointal wrote: > Laurent Pointal wrote: >> Take care of indent: >> >> def f(x): >> a = 5 >> """an correctly indented expression to be >> inside the function""" >> return a * x > > Here only the first indent of """ at beginning of the string to be aligned > to function blo

Re: UnboundLocalError in TKinter, SQLAlchemy script.

2015-03-18 Thread Chris Kavanagh
On Wednesday, March 18, 2015 at 8:02:14 AM UTC-4, Steven D'Aprano wrote: > On Wed, 18 Mar 2015 01:41 pm, Chris Kavanagh wrote: > > > I have a simple script that takes user input (for an Employee) such as > > name, age, etc then puts in an sqlite3 database. The script worked fine > > until I realiz

Re: A simple single line, triple-quoted comment is giving syntax error. Why?

2015-03-18 Thread Laurent Pointal
Aditya Raj Bhatt wrote: > On Wednesday, March 18, 2015 at 1:04:39 PM UTC-5, Laurent Pointal wrote: >> > Can someone also provide a sort of a 'guide' to triple-quoted > comments >> > in general? >> >> A triple ' or " string is a Python string, allowing line-return in > string. > > What do you mea

Re: A simple single line, triple-quoted comment is giving syntax error. Why?

2015-03-18 Thread Igor Korot
Hi, On Wed, Mar 18, 2015 at 2:23 PM, Aditya Raj Bhatt wrote: > On Wednesday, March 18, 2015 at 1:04:39 PM UTC-5, Laurent Pointal wrote: >> > Can someone also provide a sort of a 'guide' to triple-quoted > comments >> > in general? >> >> A triple ' or " string is a Python string, allowing line-re

Re: A simple single line, triple-quoted comment is giving syntax error. Why?

2015-03-18 Thread Aditya Raj Bhatt
On Wednesday, March 18, 2015 at 1:04:39 PM UTC-5, Laurent Pointal wrote: > > Can someone also provide a sort of a 'guide' to triple-quoted comments > > in general? > > A triple ' or " string is a Python string, allowing line-return in string. What do you mean by line-return in string? Is it newli

Re: Python script output in file

2015-03-18 Thread Rustom Mody
On Wednesday, March 18, 2015 at 11:36:39 PM UTC+5:30, Rustom Mody wrote: > On Wednesday, March 18, 2015 at 8:12:12 PM UTC+5:30, Robert Clove wrote: > > ./my_eth_script.pl eth0 M >> a.txt > > > > How can i run this command with subprocess.popen > > Something like this I guess? > > >>> proc = Pope

Re: A simple single line, triple-quoted comment is giving syntax error. Why?

2015-03-18 Thread Laurent Pointal
Laurent Pointal wrote: (oups) > Take care of indent: > > def f(x): > a = 5 > """an correctly indented expression to be > inside the function""" > return a * x Here only the first indent of """ at beginning of the string to be aligned to function bloc is important, remaining cont

Re: Python script output in file

2015-03-18 Thread Rustom Mody
On Wednesday, March 18, 2015 at 8:12:12 PM UTC+5:30, Robert Clove wrote: > ./my_eth_script.pl eth0 M >> a.txt > > How can i run this command with subprocess.popen Something like this I guess? >>> proc = Popen("cat", shell=True, stdout=open(inname, "w"), >>> stdin=open(outname,"r")) inname and

Re: A simple single line, triple-quoted comment is giving syntax error. Why?

2015-03-18 Thread Laurent Pointal
Aditya Raj Bhatt wrote: > I always do single line comments with # but just for the sake of it I > tried it with ''' ''' and it gives me a syntax error. > > In both the interpreter, and the source code text file, doing - > > a = 5 '''a comment''' > > results in a syntax error, with the very last

A simple single line, triple-quoted comment is giving syntax error. Why?

2015-03-18 Thread Aditya Raj Bhatt
I always do single line comments with # but just for the sake of it I tried it with ''' ''' and it gives me a syntax error. In both the interpreter, and the source code text file, doing - a = 5 '''a comment''' results in a syntax error, with the very last quote at the end of the line highlighted

Re: Python 2 to 3 conversion - embrace the pain

2015-03-18 Thread Paul Rubin
Steven D'Aprano writes: > The two weeks we lost upgrading from Python 2.6 to 2.7 is just the > normal upgrade pains you always have to expect from any major project, Wait, what happened between 2.6 and 2.7 that took you two weeks of upgrading? -- https://mail.python.org/mailman/listinfo/python-l

Re: Brilliant or insane code?

2015-03-18 Thread Robin Becker
On 18/03/2015 00:35, Mark Lawrence wrote: I've just come across this http://www.stavros.io/posts/brilliant-or-insane-code/ as a result of this http://bugs.python.org/issue23695 Any and all opinions welcomed, I'm chickening out and sitting firmly on the fence. There was a long thread on an in

Re: Brilliant or insane code?

2015-03-18 Thread Mark Lawrence
On 18/03/2015 14:59, Ian Kelly wrote: On Tue, Mar 17, 2015 at 7:14 PM, Dan Sommers wrote: On Wed, 18 Mar 2015 00:35:42 +, Mark Lawrence wrote: I've just come across this http://www.stavros.io/posts/brilliant-or-insane-code/ as a result of this http://bugs.python.org/issue23695 Any and al

Re: Brilliant or insane code?

2015-03-18 Thread Ian Kelly
On Tue, Mar 17, 2015 at 7:14 PM, Dan Sommers wrote: > On Wed, 18 Mar 2015 00:35:42 +, Mark Lawrence wrote: > >> I've just come across this >> http://www.stavros.io/posts/brilliant-or-insane-code/ as a result of >> this http://bugs.python.org/issue23695 >> >> Any and all opinions welcomed, I'm

EuroPython 2015: Sponsor brochure available

2015-03-18 Thread M.-A. Lemburg
EuroPython would not be possible and as affordable as it is without the help of our sponsors. Reach out to 1200+ attendees in Europe -- If your company is using Python, sells a product or service in the Python space or looking to hire excellent Python programm

Re: Python script output in file

2015-03-18 Thread Robert Clove
./my_eth_script.pl eth0 M >> a.txt How can i run this command with subprocess.popen On Wed, Mar 18, 2015 at 3:49 AM, Rustom Mody wrote: > On Wednesday, March 18, 2015 at 4:06:05 PM UTC+5:30, Robert Clove wrote: > > Hi, > > > > I have a perl script named "my_eth-traffic.pl" which calculates the

Re: Brilliant or insane code?

2015-03-18 Thread Jason Swails
On Wed, 2015-03-18 at 00:35 +, Mark Lawrence wrote: > I've just come across this > http://www.stavros.io/posts/brilliant-or-insane-code/ as a result of > this http://bugs.python.org/issue23695 > > Any and all opinions welcomed, I'm chickening out and sitting firmly on > the fence. I'll go

Re: Python 2 to 3 conversion - embrace the pain

2015-03-18 Thread Rustom Mody
On Wednesday, March 18, 2015 at 4:23:37 PM UTC+5:30, Steven D'Aprano wrote: > On Wed, 18 Mar 2015 08:11 pm, Ned Deily wrote: > > > In any case, of the two problems noted with Python itself, there is only > > one that appears to be Python 3 related.  That's still not good but I > > think it would b

Re: UnboundLocalError in TKinter, SQLAlchemy script.

2015-03-18 Thread Steven D'Aprano
On Wed, 18 Mar 2015 01:41 pm, Chris Kavanagh wrote: > I have a simple script that takes user input (for an Employee) such as > name, age, etc then puts in an sqlite3 database. The script worked fine > until I realized one problem. The age input field is defined in SQLAlchemy > as an Integer, so if

Re: Python 2 to 3 conversion - embrace the pain

2015-03-18 Thread Steven D'Aprano
On Wed, 18 Mar 2015 08:11 pm, Ned Deily wrote: > In any case, of the two problems noted with Python itself, there is only > one that appears to be Python 3 related.  That's still not good but I > think it would be fairer to ascribe a good chunk of the pain you've > experienced to the more common p

Re: Python script output in file

2015-03-18 Thread Rustom Mody
On Wednesday, March 18, 2015 at 4:06:05 PM UTC+5:30, Robert Clove wrote: > Hi, > > I have a perl script named "my_eth-traffic.pl" which calculates the tx and rx > speed of the Ethernet interface in Mb. > > I want to run this script from another script and want the output in other > file. > So i

Python script output in file

2015-03-18 Thread Robert Clove
Hi, I have a perl script named "my_eth-traffic.pl" which calculates the tx and rx speed of the Ethernet interface in Mb. I want to run this script from another script and want the output in other file. So i wrote the following script but not getting the output. #!/usr/bin/python import sys impo

Re: UnboundLocalError in TKinter, SQLAlchemy script.

2015-03-18 Thread ckava3
On Wednesday, March 18, 2015 at 12:00:54 AM UTC-4, MRAB wrote: > On 2015-03-18 02:41, Chris Kavanagh wrote: > > I have a simple script that takes user input (for an Employee) such as > > name, age, etc then puts in an sqlite3 database. The script worked fine > > until I realized one problem. The ag

Re: Python 2 to 3 conversion - embrace the pain

2015-03-18 Thread Ned Deily
In article , John Nagle wrote: >If only that were true. Look what I'm reporting bugs on: > > ssl - a core Python module. I assume you're referring to http://bugs.python.org/issue23476. It seems to me that the issue there was not in Python but due to a shortcoming in OpenSSL itself.

Re: Python 2 to 3 conversion - embrace the pain

2015-03-18 Thread Mark Lawrence
On 18/03/2015 06:37, John Nagle wrote: On 3/15/2015 4:43 PM, Roy Smith wrote: In article , Mario Figueiredo wrote: What makes you think your anecdotal bugs constitute any sort of evidence this programming language isn't ready to be used by the public? There's several levels of "ready". I

Re: Dict comprehensions - improvement to docs?

2015-03-18 Thread Ian Kelly
On Wed, Mar 18, 2015 at 2:01 AM, Frank Millman wrote: > > "Ian Kelly" wrote in message > news:CALwzidmNDcSvER7S6inEaVZA=DHUrDX1KzL-WRVwhd=o3_l...@mail.gmail.com... >> On Tue, Mar 17, 2015 at 12:44 AM, Frank Millman >> wrote: >>> Thanks for the explanation. I'll try not to make that mistake again

Re: Dict comprehensions - improvement to docs?

2015-03-18 Thread Frank Millman
"Ian Kelly" wrote in message news:CALwzidmNDcSvER7S6inEaVZA=DHUrDX1KzL-WRVwhd=o3_l...@mail.gmail.com... > On Tue, Mar 17, 2015 at 12:44 AM, Frank Millman > wrote: >> Thanks for the explanation. I'll try not to make that mistake again. >> >> However, to go back to the original example, we want