Re: [Tutor] Python isn't working with Apache (Windows)

2017-08-01 Thread Peter Otten
Christopher McGrath wrote: > I am trying to run a simple python web script in a browser with apache. I > have apache installed and running perfectly. I installed Ruby and Perl > I had Python 3.6 installed before and tried to test with these > I also tried with #!Q:\LifeForce\Python36-32\python.e

[Tutor] How sum() works in python

2017-08-01 Thread ramakrishna reddy
Hi All, I know > sum([1,2,3]) returns 6. But sum with [] 'empty list' as second parameter returns as below. > sum([[1,2,3], [3,4,5]], []) returns [1, 2, 3, 3, 4, 5] Can any one please explain this logic ? I searched in google but could not find the suitable answer. Thanks in advance. Thanks,

Re: [Tutor] How sum() works in python

2017-08-01 Thread Alan Gauld via Tutor
On 01/08/17 07:06, ramakrishna reddy wrote: >> sum([1,2,3]) returns 6. > > But sum with [] 'empty list' as second parameter returns as below. > >> sum([[1,2,3], [3,4,5]], []) returns [1, 2, 3, 3, 4, 5] An interesting question, I wasn't aware that you could add lists with sum. However, the resu

Re: [Tutor] How sum() works in python

2017-08-01 Thread Peter Otten
ramakrishna reddy wrote: > Hi All, > > I know > >> sum([1,2,3]) returns 6. > > But sum with [] 'empty list' as second parameter returns as below. > >> sum([[1,2,3], [3,4,5]], []) returns [1, 2, 3, 3, 4, 5] > Can any one please explain this logic ? I searched in google but could not > find the

[Tutor] Error with sqlalchemy

2017-08-01 Thread rakesh sharma
Hi All I am getting an error in python. Its a flask app that I am doing I am getting the error TypeError: utf_8_decode() argument 1 must be string or buffer, not long at this point in the code ship_schedules = ShipSchedule.query.all() The schema definition is like that I gave below, there is

Re: [Tutor] Error with sqlalchemy

2017-08-01 Thread Mats Wichmann
On 08/01/2017 05:13 AM, rakesh sharma wrote: > Hi All > > > I am getting an error in python. Its a flask app that I am doing > > I am getting the error > > TypeError: utf_8_decode() argument 1 must be string or buffer, not long > > at this point in the code > > ship_schedules = ShipSchedule.q

Re: [Tutor] Recommended Python Compiler

2017-08-01 Thread Abdur-Rahmaan Janhangeer
Yes indeed geany is a nice editor. I used it when i was beginning and even wrote a post about it, Feel free to check it ! https://abdurrahmaanjanhangeer.wordpress.com/2016/11/02/python-getting-rid-of-identation-errors-quickly-checking-for-errors-and-the-use-of-editors/ On Tue, Aug 1, 2017 at 9:43

Re: [Tutor] How sum() works in python

2017-08-01 Thread ramakrishna reddy
nice explanation .. thanks this cleared my doubt >>> k = [20] >>> for i in [[1,2,3],[3,4,5]]: ... k += i ... >>> k [20, 1, 2, 3, 3, 4, 5] On Tue, Aug 1, 2017 at 1:35 AM, Alan Gauld via Tutor wrote: > On 01/08/17 07:06, ramakrishna reddy wrote: > > >> sum([1,2,3]) returns 6. > > > > But sum

Re: [Tutor] How sum() works in python

2017-08-01 Thread Abdur-Rahmaan Janhangeer
i guess it adds / sort of concatenates the list On Tue, Aug 1, 2017 at 10:06 AM, ramakrishna reddy wrote: > Hi All, > > I know > > > sum([1,2,3]) returns 6. > > But sum with [] 'empty list' as second parameter returns as below. > > > sum([[1,2,3], [3,4,5]], []) returns [1, 2, 3, 3, 4, 5] > Can a

Re: [Tutor] Error with sqlalchemy

2017-08-01 Thread Alan Gauld via Tutor
On 01/08/17 12:13, rakesh sharma wrote: > I am getting the error > > TypeError: utf_8_decode() argument 1 must be string or buffer, not long That's not too helpful out of context, can you show us more of the error trace? Can you show us the method that generates it? Do you have any indication ab

[Tutor] if __name__=='main' vs entry points: What to teach new comers?

2017-08-01 Thread Thomas Güttler
I have a friend who is a talented shell script writer. He is a linux guru since several years. He asked me if "if __name__=='main':" is state of the art if you want to translate a shell script to python. I started to stutter and did not know how to reply. I use Python since several years and I

Re: [Tutor] if __name__=='main' vs entry points: What to teach new comers?

2017-08-01 Thread Zachary Ware
On Tue, Aug 1, 2017 at 9:54 AM, Thomas Güttler wrote: > I have a friend who is a talented shell script writer. He is a linux guru > since > several years. > > He asked me if "if __name__=='main':" is state of the art if you want > to translate a shell script to python. > > I started to stutter and

Re: [Tutor] if __name__=='main' vs entry points: What to teach new comers?

2017-08-01 Thread Chris Warrick
On 1 August 2017 at 16:54, Thomas Güttler wrote: > I have a friend who is a talented shell script writer. He is a linux guru > since > several years. > > He asked me if "if __name__=='main':" is state of the art if you want > to translate a shell script to python. > > I started to stutter and did

Re: [Tutor] if __name__=='main' vs entry points: What to teach new comers?

2017-08-01 Thread Alan Gauld via Tutor
On 01/08/17 15:54, Thomas Güttler wrote: > He asked me if "if __name__=='main':" is state of the art if you want > to translate a shell script to python. It all depends what you plan to do with the script. If you literally just want to translate a shell script such that it will always be executed

[Tutor] Python Daemons

2017-08-01 Thread Daniel Bosah
I'm following an online tutorial about threading. This is the code I've used so far: import socket import threading from queue import Queue print_lock = threading.Lock() target = 'pythonprogramming.net' def portscan(port): s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) try:

Re: [Tutor] Python Daemons

2017-08-01 Thread Steven D'Aprano
Hi Daniel, My responses below. On Tue, Aug 01, 2017 at 02:48:19PM -0400, Daniel Bosah wrote: > I'm following an online tutorial about threading. This is the code I've > used so far: Can you give us a link to the tutorial? [...] > def portscan(port): > s = socket.socket(socket.AF_INET, socke

Re: [Tutor] How sum() works in python

2017-08-01 Thread Steven D'Aprano
On Mon, Jul 31, 2017 at 11:06:18PM -0700, ramakrishna reddy wrote: > > sum([[1,2,3], [3,4,5]], []) returns [1, 2, 3, 3, 4, 5] [] + [1,2,3] + [3,4,5] returns [1, 2, 3, 3, 4, 5]. -- Steve ___ Tutor maillist - Tutor@python.org To unsubscribe or chang

Re: [Tutor] Python Daemons

2017-08-01 Thread Ben Finney
Daniel Bosah writes: > I'm following an online tutorial about threading. Can you point to it so we can understand your specific situation? > I don't know what a Daemon is The package ‘python-daemon’ is a library to build your program as a daemon https://pypi.org/project/python-daemon/>. The r

[Tutor] What is meaning of "/" in "pow(x, y, z=None, /)"?

2017-08-01 Thread boB Stepp
I had typed help(pow) in the interpreter and got: py3: help(pow) Help on built-in function pow in module builtins: pow(x, y, z=None, /) Equivalent to x**y (with two arguments) or x**y % z (with three arguments) Some types, such as ints, are able to use a more efficient algorithm when

Re: [Tutor] if __name__=='main' vs entry points: What to teach new comers?

2017-08-01 Thread Steven D'Aprano
On Tue, Aug 01, 2017 at 04:54:40PM +0200, Thomas Güttler wrote: [...] > I use Python since several years and I use console_script in entry_points > of setup.py. What's console_script in entry_points of setup.py? In particular, what does that have to do with writing an executable script? setup

Re: [Tutor] What is meaning of "/" in "pow(x, y, z=None, /)"?

2017-08-01 Thread Ben Finney
boB Stepp writes: > A quick scan of some of my Python books does not turn up the use of > "/" as a function argument. The appearance of this in Python's documentation and dfunction signature descriptions, without a clear description of what it means, is troubling. The best I can find is this in

Re: [Tutor] What is meaning of "/" in "pow(x, y, z=None, /)"?

2017-08-01 Thread Steven D'Aprano
On Tue, Aug 01, 2017 at 08:06:58PM -0500, boB Stepp wrote: > pow(x, y, z=None, /) > Equivalent to x**y (with two arguments) or x**y % z (with three arguments) It means that the arguments are positional-only, the names "x", "y" and "z" are for documentation purposes only. You cannot write: p

Re: [Tutor] if __name__=='main' vs entry points: What to teach new comers?

2017-08-01 Thread Ben Finney
Steven D'Aprano writes: > On Tue, Aug 01, 2017 at 04:54:40PM +0200, Thomas Güttler wrote: > > [...] > > I use Python since several years and I use console_script in > > entry_points of setup.py. > > What's console_script in entry_points of setup.py? It is an advanced feature in Setuptools, that

Re: [Tutor] What is meaning of "/" in "pow(x, y, z=None, /)"?

2017-08-01 Thread Ben Finney
Steven D'Aprano writes: > Its quite new. Up until recently, the documentation didn't distinguish > between function parameters which can take optional keywords and those > that can't. Where does the documentation describe this distinction? How is the reader, coming across a link to documentation

Re: [Tutor] What is meaning of "/" in "pow(x, y, z=None, /)"?

2017-08-01 Thread boB Stepp
On Tue, Aug 1, 2017 at 8:25 PM, Ben Finney wrote: > Steven D'Aprano writes: > >> Its quite new. Up until recently, the documentation didn't distinguish >> between function parameters which can take optional keywords and those >> that can't. > > Where does the documentation describe this distincti

Re: [Tutor] What is meaning of "/" in "pow(x, y, z=None, /)"?

2017-08-01 Thread Steven D'Aprano
On Wed, Aug 02, 2017 at 11:25:34AM +1000, Ben Finney wrote: > Steven D'Aprano writes: > > > Its quite new. Up until recently, the documentation didn't distinguish > > between function parameters which can take optional keywords and those > > that can't. > > Where does the documentation describe

Re: [Tutor] if __name__=='main' vs entry points: What to teach new comers?

2017-08-01 Thread Steven D'Aprano
On Wed, Aug 02, 2017 at 11:22:00AM +1000, Ben Finney wrote: > Steven D'Aprano writes: > > > On Tue, Aug 01, 2017 at 04:54:40PM +0200, Thomas Güttler wrote: > > > > [...] > > > I use Python since several years and I use console_script in > > > entry_points of setup.py. > > > > What's console_scrip

Re: [Tutor] Python Daemons

2017-08-01 Thread Steven D'Aprano
On Tue, Aug 01, 2017 at 09:05:02PM -0400, dbosah wrote: > Also here's the link to the tutorial > https://youtu.be/WrtebUkUssc That is clearly marked as "Python 3 Programming Tutorial". Why are you using Python 2? When you have a problem, you won't know if the problem is with your code, or a diff

Re: [Tutor] Python Daemons

2017-08-01 Thread Steven D'Aprano
On Tue, Aug 01, 2017 at 09:03:30PM -0400, dbosah wrote: > It usually says that it's an error. Sorry, my crystal ball is at the shop being repaired and I don't know what "an error" means or how to fix it. Please COPY AND PASTE the full text of the error, starting with the line "Traceback" and e

Re: [Tutor] Python Daemons

2017-08-01 Thread Ben Finney
Steven D'Aprano writes: > On Tue, Aug 01, 2017 at 09:03:30PM -0400, dbosah wrote: (I am not seeing your replies in this forum, dbosah. Please address your replies to the mailing list – not to an individual – if you want the discussion to continue.) > > And I'm still confused by the definition o