Re: Is there a way to display source code for Python function?

2014-10-02 Thread Viet Nguyen
On Thursday, October 2, 2014 10:47:28 PM UTC-7, Ian wrote: > On Thu, Oct 2, 2014 at 11:34 PM, Viet Nguyen > > wrote: > > > Hi, > > > > > > When I am debug mode, is there some command which will help display the > > source code for a Python function of interest? Much like you'd use "info > >

Re: Is there a way to display source code for Python function?

2014-10-02 Thread Viet Nguyen
On Thursday, October 2, 2014 10:34:15 PM UTC-7, Viet Nguyen wrote: > Hi, > > > > When I am debug mode, is there some command which will help display the > source code for a Python function of interest? Much like you'd use "info > proc" to display contents of Tcl proc. > > > > Thanks, > >

Re: Is there a way to display source code for Python function?

2014-10-02 Thread Ian Kelly
On Thu, Oct 2, 2014 at 11:34 PM, Viet Nguyen wrote: > Hi, > > When I am debug mode, is there some command which will help display the > source code for a Python function of interest? Much like you'd use "info > proc" to display contents of Tcl proc. > > Thanks, > Viet You can use inspect.getso

Is there a way to display source code for Python function?

2014-10-02 Thread Viet Nguyen
Hi, When I am debug mode, is there some command which will help display the source code for a Python function of interest? Much like you'd use "info proc" to display contents of Tcl proc. Thanks, Viet -- https://mail.python.org/mailman/listinfo/python-list

Re: Clearing globals in CPython

2014-10-02 Thread Stefan Behnel
Chris Angelico schrieb am 02.10.2014 um 16:12: > On Fri, Oct 3, 2014 at 12:07 AM, Grant Edwards wrote: >> On 2014-10-01, Steven D'Aprano wrote: >> >>> Obviously the easiest way to recover is to exit the current session and >>> restart it, but as a challenge, can we recover from this state? >> >> Py

Re: Error from pandas.io.data import DataReader

2014-10-02 Thread Miki Tebeka
Greetings, > I am trying to run this snippet of code. > > from pandas.io.data import DataReader > ... > > I keep getting this error. > > Traceback (most recent call last): > > File "C:\Python27\download_dow.py", line 1, in > > from pandas.io.data import DataReader > > ImportError: No

Re: How to show a dictionary sorted on a value within its data?

2014-10-02 Thread Chris Angelico
On Fri, Oct 3, 2014 at 9:16 AM, Steven D'Aprano wrote: >> Anyway, pylint doesn't complain about a bare use of lambda, but it >> does complain about a map applied to a lambda or a filter applied to a >> lambda. Pylint says they could be replaced by a list comprehension, >> with the warning "deprec

Re: Function passed as an argument returns none

2014-10-02 Thread Chris Angelico
On Fri, Oct 3, 2014 at 11:49 AM, Rustom Mody wrote: > Ok so there is no conventional attribution line because it was > cut-pasted from elsewhere in the thread but there is a clear > and unequivocal prefix of "OP subject as well as post". When I respond to this part... > Why/how should there be a

Re: Function passed as an argument returns none

2014-10-02 Thread Rustom Mody
On Friday, October 3, 2014 5:41:12 AM UTC+5:30, Steven D'Aprano wrote: > [Rustom] > > Right and the OP subject as well as post are essentially that conflation: > [allegedly Steven] > >> Any idea why 'None' is getting passed even though calling the donuts(4) > >> alone returns the expected value?

Re: Function passed as an argument returns none

2014-10-02 Thread Steven D'Aprano
Rustom Mody wrote: > On Thursday, October 2, 2014 1:30:03 PM UTC+5:30, Steven D'Aprano wrote: >> Chris Angelico wrote: > Restoring the attribution line you removed: On Thu, Oct 2, 2014 at 12:29 PM, Rustom Mody wrote: >> >> So by now you know there are 2 kinds of return: >> >> So the morals in s

Re: How to show a dictionary sorted on a value within its data?

2014-10-02 Thread Steven D'Aprano
Dan Stromberg wrote: > On Thu, Oct 2, 2014 at 12:15 PM, Ian Kelly wrote: >> On Thu, Oct 2, 2014 at 10:33 AM, wrote: >>> Ah, so at least there is a reason for it, I'm far from being a >>> mathematician though so it's not particularly obvious (for me anyway). >> >> You're not alone; a lot of peop

Re: Python 3.4.1 installer on Mac links Python to old Tcl/Tk

2014-10-02 Thread Ned Deily
In article , "Peter Tomcsanyi" wrote: > "Ned Deily" wrote in message > news:nad-40cb03.10344701102...@news.gmane.org... > > The python.org 3.4.x series of installers will likely never change from > > linking with Tk 8.5 by default. That would break a number of important > > third-party Python

Re: How to show a dictionary sorted on a value within its data?

2014-10-02 Thread Chris Angelico
On Fri, Oct 3, 2014 at 6:06 AM, Dan Stromberg wrote: > Anyway, pylint doesn't complain about a bare use of lambda, but it > does complain about a map applied to a lambda or a filter applied to a > lambda. Pylint says they could be replaced by a list comprehension, > with the warning "deprecated-l

Re: How to show a dictionary sorted on a value within its data?

2014-10-02 Thread Dan Stromberg
On Thu, Oct 2, 2014 at 12:15 PM, Ian Kelly wrote: > On Thu, Oct 2, 2014 at 10:33 AM, wrote: >> Ah, so at least there is a reason for it, I'm far from being a >> mathematician though so it's not particularly obvious (for me anyway). > > You're not alone; a lot of people find the terminology not i

Re: Programming for Everybody (Python)

2014-10-02 Thread Juan Christian
I recommend to everyone. Already took one of his courses on Coursera and he's amazing as a teacher. On Thu, Oct 2, 2014 at 4:24 PM, Seymore4Head wrote: > Starts in 3 days > Coursera.org > > About the Course > This course is specifically designed to be a first programming course > using the popul

Re: How to show a dictionary sorted on a value within its data?

2014-10-02 Thread Grant Edwards
On 2014-10-02, c...@isbd.net wrote: > Grant Edwards wrote: >> On 2014-10-02, c...@isbd.net wrote: >> >> > It throws me because 'lambda' simply has no meaning whatsoever for me, >> > i.e. it's just a greek letter. >> > >> > So from my point of view it's like seeing 'epsilon' stuck in the >> > mid

Programming for Everybody (Python)

2014-10-02 Thread Seymore4Head
Starts in 3 days Coursera.org About the Course This course is specifically designed to be a first programming course using the popular Python programming language. The pace of the course is designed to lead to mastery of each of the topics in the class. We will use simple data analysis as the pr

Re: How to show a dictionary sorted on a value within its data?

2014-10-02 Thread Ian Kelly
On Thu, Oct 2, 2014 at 10:33 AM, wrote: > Ah, so at least there is a reason for it, I'm far from being a > mathematician though so it's not particularly obvious (for me anyway). You're not alone; a lot of people find the terminology not intuitive. Even GvR has publicly lamented the choice of key

Re: Keepin constants, configuration values, etc. in Python - dedicated module or what?

2014-10-02 Thread Dave Angel
On 09/30/2014 10:55 AM, c...@isbd.net wrote: Dave Angel wrote: >> name. And presumably you never remove an old name from the config. The only things really likely to change (and may change regularly) are the conversion factors, drifting voltage references etc. will inevitably requ

Re: How to show a dictionary sorted on a value within its data?

2014-10-02 Thread Rustom Mody
On Thursday, October 2, 2014 4:47:50 PM UTC+5:30, Marko Rauhamaa wrote: > > It's not as if I'm new to programming either, I've been writing > > software professionally since the early 1970s, now retired. I have no > > formal computer training, there wasn't much in the way of university > > courses

Re: Reticulated Python

2014-10-02 Thread Ethan Furman
On 10/02/2014 10:01 AM, Mark Lawrence wrote: My apologies if this has been discussed before but I thought it may be of interest wphomes.soic.indiana.edu/jsiek/files/2014/08/retic-python-v3.pdf Looks interesting, thanks for the link! -- ~Ethan~ -- https://mail.python.org/mailman/listinfo/pyth

Re: Recommended hosting

2014-10-02 Thread Chris Angelico
On Fri, Oct 3, 2014 at 3:33 AM, David Hutto wrote: > You can go over to Zenfinite. I just so happen to know the owner; so if you > see a nice plan you like, and it's a little pricey, I can see if the price > can be dropped. Or maybe you not so much *know* the owner as *are* the owner... given tha

Re: Recommended hosting

2014-10-02 Thread David Hutto
You can go over to Zenfinite. I just so happen to know the owner; so if you see a nice plan you like, and it's a little pricey, I can see if the price can be dropped. On Thu, Oct 2, 2014 at 12:33 PM, Tim wrote: > On Thursday, October 2, 2014 9:30:38 AM UTC-4, writeson wrote: > > Hi all, > > I'd

Reticulated Python

2014-10-02 Thread Mark Lawrence
My apologies if this has been discussed before but I thought it may be of interest wphomes.soic.indiana.edu/jsiek/files/2014/08/retic-python-v3.pdf -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence -- https://mail.python.org

Re: How to show a dictionary sorted on a value within its data?

2014-10-02 Thread cl
Grant Edwards wrote: > On 2014-10-02, c...@isbd.net wrote: > > Travis Griggs wrote: > >> > >> > >> Sent from my iPhone > >> > >> > On Oct 1, 2014, at 04:12, Peter Otten <__pete...@web.de> wrote: > >> > > >> > `lambda` is just a fancy way to define a function inline > >> > >> Not sure "fancy

Re: Recommended hosting

2014-10-02 Thread Tim
On Thursday, October 2, 2014 9:30:38 AM UTC-4, writeson wrote: > Hi all, > I'd like to build a web site for myself, essentially a "vanity" web site > web applications written with Python and Flask, running as uwsgi > applications. These would support dynamic HTML where needed, but mostly it >

Re: Assignment Operators?

2014-10-02 Thread Ian Kelly
On Thu, Oct 2, 2014 at 7:24 AM, Didymus wrote: >The '|=' operator, I read should be like a = a | b, but this appears to > add the two numbers as long as it's more than the previous: Note that: a = a or b and: a = a | b are different operations. It sounds like you're probably look

Re: Python unittesting method call issue

2014-10-02 Thread Milson Munakami
On Saturday, September 27, 2014 5:26:00 PM UTC-6, Milson Munakami wrote: > I am trying to set the precondition for the test first prior to test other > test cases. But as you can see in my code the precondition print command is > not fired! Can you explain the cause and solution how to fire the c

Re: How to set the global variable so that it can be accessed and released inside other methods

2014-10-02 Thread Chris Angelico
On Fri, Oct 3, 2014 at 1:29 AM, Milson Munakami wrote: > #I am trying to set net variable to global > global net > > def CreateNet(self): > "Create an empty network and add nodes to it." > net = Mininet( controller=RemoteController ) You're

How to set the global variable so that it can be accessed and released inside other methods

2014-10-02 Thread Milson Munakami
Hi, I am newbie to Python, I am trying to use unittest and python. My python script is like this: #! /usr/bin/env python __author__ = 'Milson Munakami' __revision__ = '0.0.2' import json import urllib import httplib from scapy.all import * import unittest import os, sys, socket, struct, selec

Re: Recommended hosting

2014-10-02 Thread Tim Golden
On 02/10/2014 14:30, writeson wrote: > Hi all, > > I'd like to build a web site for myself, essentially a "vanity" web > site to show off whatever web development skills I have, and perhaps > do some blogging. I'm a Python developer, so I'd like to develop the > site with the following stack: > >

Re: Assignment Operators?

2014-10-02 Thread Grant Edwards
On 2014-10-02, Chris Angelico wrote: > On Thu, Oct 2, 2014 at 11:24 PM, Didymus wrote: > errors = False > errors |= 3 > errors >> 3 > errors |= 4 > errors >> 7 [...] > When you use False there, it's equivalent to zero. Why is that, you ask? [Or should, anyway] The fact th

Re: Clearing globals in CPython

2014-10-02 Thread Chris Angelico
On Fri, Oct 3, 2014 at 12:07 AM, Grant Edwards wrote: > On 2014-10-01, Steven D'Aprano wrote: > >> Obviously the easiest way to recover is to exit the current session and >> restart it, but as a challenge, can we recover from this state? > > Python apparently _does_ need a "restart command". App

Re: Clearing globals in CPython

2014-10-02 Thread Grant Edwards
On 2014-10-01, Steven D'Aprano wrote: > Obviously the easiest way to recover is to exit the current session and > restart it, but as a challenge, can we recover from this state? Python apparently _does_ need a "restart command". -- Grant Edwards grant.b.edwardsYow! The PI

Re: How to show a dictionary sorted on a value within its data?

2014-10-02 Thread Grant Edwards
On 2014-10-02, c...@isbd.net wrote: > Travis Griggs wrote: >> >> >> Sent from my iPhone >> >> > On Oct 1, 2014, at 04:12, Peter Otten <__pete...@web.de> wrote: >> > >> > `lambda` is just a fancy way to define a function inline >> >> Not sure "fancy" is the correct adjective; more like syntac

Re: Thoughts on python classes to represent an ebook reader

2014-10-02 Thread math math
Thanks a lot. It is quite helpful to follow the thought process here. Another person gave the example of 'Calibre', but I've found it overwhelming and I couldn't find any UML diagram there (maybe not searched hard enough). Regards, Felix -- https://mail.python.org/mailman/listinfo/python-list

Re: Clearing globals in CPython

2014-10-02 Thread Marco Buttu
On 01/10/2014 18:00, Steven D'Aprano wrote: Out of curiosity, I ran: globals().clear() in the interactive interpreter. It broke much more than I expected! Built-ins were no longer available, and import stopped working. Interesting... :D Obviously the easiest way to recover is to exit the c

Recommended hosting

2014-10-02 Thread writeson
Hi all, I'd like to build a web site for myself, essentially a "vanity" web site to show off whatever web development skills I have, and perhaps do some blogging. I'm a Python developer, so I'd like to develop the site with the following stack: web applications written with Python and Flask, r

Re: Assignment Operators?

2014-10-02 Thread Chris Angelico
On Thu, Oct 2, 2014 at 11:24 PM, Didymus wrote: errors = False errors |= 3 errors > 3 errors |= 4 errors > 7 > >The '|=' operator, I read should be like a = a | b, but this appears to > add the two numbers as long as it's more than the previous: > errors |= 5 >>>

Assignment Operators?

2014-10-02 Thread Didymus
Hi All, I was wondering if someone could explain an assignment operator that I'm seeing in some code. As an example: >>> errors = False >>> errors |= 3 >>> errors 3 >>> errors |= 4 >>> errors 7 The '|=' operator, I read should be like a = a | b, but this appears to add the two numbers a

Re: pyqt problem

2014-10-02 Thread Sachin Tiwari
On Thursday, October 2, 2014 3:19:22 PM UTC+5:30, Sachin Tiwari wrote: > Hi > > I am learning pyqt, can any one help me to make instances of pushbutton > wherever cursor will be clicked on canvas,like a circuit simulator where we > add components on canvas just by left or right click. > > >

Re: Function passed as an argument returns none

2014-10-02 Thread Rustom Mody
On Thursday, October 2, 2014 1:30:03 PM UTC+5:30, Steven D'Aprano wrote: > Chris Angelico wrote: > > wrote: > >> So by now you know there are 2 kinds of return: > >> So the morals in short: > >> 1. Stick to the return that works -- python's return statement -- > >> and avoid the return that seems

Re: Function passed as an argument returns none

2014-10-02 Thread Rustom Mody
On Thursday, October 2, 2014 3:18:22 PM UTC+5:30, wrote: > Steven D'Aprano wrote: > > between printing output to the screen and returning values from a function, > > and under what circumstances Python will automatically print said returned > > values as a convenience. Conflating the two as "2 kin

Re: Python 3.4.1 installer on Mac links Python to old Tcl/Tk

2014-10-02 Thread Peter Tomcsanyi
Thanks again for quick and informative reply. "Ned Deily" wrote in message news:nad-40cb03.10344701102...@news.gmane.org... The python.org 3.4.x series of installers will likely never change from linking with Tk 8.5 by default. That would break a number of important third-party Python package

Re: How to show a dictionary sorted on a value within its data?

2014-10-02 Thread Marko Rauhamaa
c...@isbd.net: > It's not as if I'm new to programming either, I've been writing > software professionally since the early 1970s, now retired. I have no > formal computer training, there wasn't much in the way of university > courses on computing in the 1960s, I have a degree in Electrical > Engin

Re: pyqt problem

2014-10-02 Thread Mark Lawrence
On 02/10/2014 10:49, sachin.tiwar...@gmail.com wrote: Hi I am learning pyqt, can any one help me to make instances of pushbutton wherever cursor will be clicked on canvas,like a circuit simulator where we add components on canvas just by left or right click. Thanks & Regards, Sachin Please

pyqt problem

2014-10-02 Thread sachin . tiwari50
Hi I am learning pyqt, can any one help me to make instances of pushbutton wherever cursor will be clicked on canvas,like a circuit simulator where we add components on canvas just by left or right click. Thanks & Regards, Sachin -- https://mail.python.org/mailman/listinfo/python-list

Re: How to show a dictionary sorted on a value within its data?

2014-10-02 Thread cl
Travis Griggs wrote: > > > Sent from my iPhone > > > On Oct 1, 2014, at 04:12, Peter Otten <__pete...@web.de> wrote: > > > > `lambda` is just a fancy way to define a function inline > > Not sure "fancy" is the correct adjective; more like syntactic tartness > (a less sweet version of syntact

Re: Function passed as an argument returns none

2014-10-02 Thread cl
Steven D'Aprano wrote: > between printing output to the screen and returning values from a function, > and under what circumstances Python will automatically print said returned > values as a convenience. Conflating the two as "2 kinds of return" is an To me automically printing something is a mi

Re: Function passed as an argument returns none

2014-10-02 Thread Chris Angelico
On Thu, Oct 2, 2014 at 6:46 PM, Shiva wrote: > Hi All, > > Thank you everyone. This is fantastic - I post a query and go to sleep and > by the time I get up there is already a nice little thread of discussion > going on. Yeah, that's what python-list is like! Busy list, lots of opinionated pe

Re: Function passed as an argument returns none

2014-10-02 Thread Shiva
Hi All, Thank you everyone. This is fantastic - I post a query and go to sleep and by the time I get up there is already a nice little thread of discussion going on. By the way, I sorted it with all your suggestions. def donuts(count): if count <= 9: #This had to be 9 instead of 5 as p

Re: Obscuring Python source from end users

2014-10-02 Thread Chris Angelico
On Thu, Oct 2, 2014 at 5:50 PM, Johannes Bauer wrote: > On 29.09.2014 16:53, Sturla Molden wrote: >> Chris Angelico wrote: >> I have a project that involves distributing Python code to users in an organisation. Users do not interact directly with the Python code; they only know thi

Re: Clearing globals in CPython

2014-10-02 Thread Mark Lawrence
On 02/10/2014 09:11, Steven D'Aprano wrote: Peter Otten wrote: Steven D'Aprano wrote: Obviously the easiest way to recover is to exit the current session and restart it, but as a challenge, can we recover from this state? $ python3 Python 3.4.0 (default, Apr 11 2014, 13:05:11) [GCC 4.8.2]

Re: Clearing globals in CPython

2014-10-02 Thread Steven D'Aprano
Peter Otten wrote: > Steven D'Aprano wrote: >> Obviously the easiest way to recover is to exit the current session and >> restart it, but as a challenge, can we recover from this state? > > $ python3 > Python 3.4.0 (default, Apr 11 2014, 13:05:11) > [GCC 4.8.2] on linux > Type "help", "copyright

Re: Function passed as an argument returns none

2014-10-02 Thread Steven D'Aprano
Chris Angelico wrote: > On Thu, Oct 2, 2014 at 12:29 PM, Rustom Mody > wrote: >> So by now you know there are 2 kinds of return: >> >> So the morals in short: >> >> 1. Stick to the return that works -- python's return statement -- >> and avoid the return that seems to work -- the print statement

Re: Obscuring Python source from end users

2014-10-02 Thread Johannes Bauer
On 29.09.2014 16:53, Sturla Molden wrote: > Chris Angelico wrote: > >>> I have a project that involves distributing Python code to users in an >>> organisation. Users do not interact directly with the Python code; they >>> only know this project as an Excel add-in. >>> >>> Now, internal audit tak

Re: Obscuring Python source from end users

2014-10-02 Thread Steven D'Aprano
Marko Rauhamaa wrote: > Dan Stromberg : > >> On Mon, Sep 29, 2014 at 4:47 AM, Steven D'Aprano >>> Yes. Distribute the pyc files only. >> >> Yes, this is the way it's usually done. > > Has the .pyc file format stabilized? A decade ago, my employer shipped > an application as .pyc files but had to

Re: Obscuring Python source from end users

2014-10-02 Thread Terry Reedy
On 10/2/2014 1:17 AM, Marko Rauhamaa wrote: Dan Stromberg : On Mon, Sep 29, 2014 at 4:47 AM, Steven D'Aprano Yes. Distribute the pyc files only. Yes, this is the way it's usually done. Has the .pyc file format stabilized? No. The cache files are binary specific and are so labelled. x.py