Re: How to handle errors?

2016-10-20 Thread Steve D'Aprano
On Fri, 21 Oct 2016 11:03 am, Wildman wrote: > On Thu, 20 Oct 2016 12:48:28 -0700, SS wrote: > >> The following script works fine: >> >> #!/bin/python > > I meant to include this with my other post but I forgot it. > > Using a direct path to the Python interpreter can cause problems > on some

Re: List of modules available for import inside Python?

2016-10-20 Thread sorimdongja
On Thursday, August 28, 2008 at 1:12:04 AM UTC-5, Michele Simionato wrote: > On Aug 28, 6:21 am, ssecorp wrote: > > Is there a way to view all the modules I have available for import > > from within Python? > > Like writing in the interpreter: > > Try: > > >>> help() > help> modules > Please wai

Re: How to handle errors?

2016-10-20 Thread D'Arcy Cain
On 2016-10-20 08:03 PM, Wildman via Python-list wrote: Using a direct path to the Python interpreter can cause problems on some systems because it is not always installed to the same directory. On my Debian-based system Python is installed in /usr/bin. So your code as written will not run on my

Re: How to handle errors?

2016-10-20 Thread Wildman via Python-list
On Thu, 20 Oct 2016 12:48:28 -0700, SS wrote: > The following script works fine: > > #!/bin/python I meant to include this with my other post but I forgot it. Using a direct path to the Python interpreter can cause problems on some systems because it is not always installed to the same director

Re: How to handle errors?

2016-10-20 Thread Wildman via Python-list
On Thu, 20 Oct 2016 12:48:28 -0700, SS wrote: > The following script works fine: > > #!/bin/python > > import socket > > str = raw_input("Enter a domain name: "); > print "Your domain is ", str > print socket.gethostbyname(str) > > You provide it a hostname, it provides an IP. That works fine

Re: How to handle errors?

2016-10-20 Thread Steve D'Aprano
On Fri, 21 Oct 2016 06:48 am, SS wrote: > The following script works fine: > > #!/bin/python > > import socket > > str = raw_input("Enter a domain name: "); > print "Your domain is ", str > print socket.gethostbyname(str) > > You provide it a hostname, it provides an IP. That works fine. But

Re: Quick way to calculate lines of code/comments in a collection of Python scripts?

2016-10-20 Thread John Strick
On Wednesday, October 5, 2016 at 12:57:14 PM UTC-5, Malcolm Greene wrote: > Looking for a quick way to calculate lines of code/comments in a > collection of Python scripts. This isn't a LOC per day per developer > type analysis - I'm looking for a metric to quickly judge the complexity > of a set o

RE: How to handle errors?

2016-10-20 Thread Joaquin Alzola
> [root@bart /]# ./dataman.py >Enter a domain name: aslfhafja >Your domain is aslfhafja >Traceback (most recent call last): > File "./dataman.py", line 7, in > print socket.gethostbyname(str) >socket.gaierror: [Errno -2] Name or service not known >[root@bart /]# >I would like to be able to h

Re: HTML templating tools

2016-10-20 Thread Adrian Petrescu
On Thu, 20 Oct 2016 11:34:36 +0200, Tony van der Hoff wrote: > Can anyone recommend a suitable replacement (preferably > compatible with htmltmpl)? I don't think anything is going to be compatible with htmltmpl, but Jinja2 is a very widely-used, well-supported and easy-to-learn templating engine

Re: Quick way to calculate lines of code/comments in a collection of Python scripts?

2016-10-20 Thread Brandon McCaig
(Sorry for the late reply) On Wed, Oct 05, 2016 at 01:56:59PM -0400, Malcolm Greene wrote: > Looking for a quick way to calculate lines of code/comments in a > collection of Python scripts. This isn't a LOC per day per developer > type analysis - I'm looking for a metric to quickly judge the compl

Re: How to handle errors?

2016-10-20 Thread John Gordon
In <8500044a-c8d1-43ad-91d9-e836d52bd...@googlegroups.com> SS writes: > I would like to be able to handle that error a bit better. Any ideas? Wrap the socket.gethostbyname() call in a try/except block. -- John Gordon A is for Amy, who fell down the stairs gor...@panix.com

How to handle errors?

2016-10-20 Thread SS
The following script works fine: #!/bin/python import socket str = raw_input("Enter a domain name: "); print "Your domain is ", str print socket.gethostbyname(str) You provide it a hostname, it provides an IP. That works fine. But I need a way to handle errors. For example: [root@bart /]#

Re: function call questions

2016-10-20 Thread Frank Millman
wrote in message news:01cfd810-0561-40b1-a834-95a73dad6...@googlegroups.com... 在 2016年10月20日星期四 UTC+8下午1:32:18,Frank Millman写道: wrote in message news:5506e4d8-bd1d-4e56-8d1b-f71fa8293...@googlegroups.com... > Let's see if I can explain. I am using 't' and 'r' instead of 'tree' and > 'root', bu

Re: function call questions

2016-10-20 Thread chenyong20000
在 2016年10月20日星期四 UTC+8下午1:32:18,Frank Millman写道: > wrote in message > news:5506e4d8-bd1d-4e56-8d1b-f71fa8293...@googlegroups.com... > > 在 2016年10月19日星期三 UTC+8下午3:17:18,Peter Otten写道: > > chenyong20...@gmail.com wrote: > > > > > 在 2016年10月19日星期三 UTC+8上午11:46:28,MRAB写道: > > >> On 2016-10-19 03:15,

Re: Python-based monads essay part 2

2016-10-20 Thread Marko Rauhamaa
Gregory Ewing : > Marko Rauhamaa wrote: > >> def main(): >> try: >> guard_it() >> except ValueError: >> # I'm having none of it! >> resume "CarryOn!" >> >> The problem is, how can the file f unclose itself when work resumes? > > The same thin

ANN: Python Meeting Düsseldorf - 26.10.2016

2016-10-20 Thread eGenix Team: M.-A. Lemburg
[This announcement is in German since it targets a local user group meeting in Düsseldorf, Germany] ANKÜNDIGUNG Python Meeting Düsseldorf http://pyddf.de/ Ein Tref

Re: Python-based monads essay part 2

2016-10-20 Thread Gregory Ewing
Marko Rauhamaa wrote: def main(): try: guard_it() except ValueError: # I'm having none of it! resume "CarryOn!" The problem is, how can the file f unclose itself when work resumes? The same thing could happen in Scheme, though. Re-enteri

Re: Python-based monads essay part 2

2016-10-20 Thread Gregory Ewing
Chris Angelico wrote: Okay. Now let's suppose that, instead of "73" in the first step, you have "ask the user for an integer". Are you allowed to eliminate this prompt, since the result of it cannot possibly affect anything? That's an excellent question. The answer is no, you're not allowed to

Re: HTML templating tools

2016-10-20 Thread Ben Finney
Tony van der Hoff writes: > However, htmltmpl is not available for python3, and doesn't look as if > it ever will be. Can anyone recommend a suitable replacement (preferably > compatible with htmltmpl)? I don't know about compatibility with that tool (I've never heard of it). There are many goo

HTML templating tools

2016-10-20 Thread Tony van der Hoff
For a long time, under Python 2.7, I have been using htmltmpl to generate htmjl pages programmatically from Python. However, htmltmpl is not available for python3, and doesn't look as if it ever will be. Can anyone recommend a suitable replacement (preferably compatible with htmltmpl)? Cheers, To

Re: Meta classes - real example

2016-10-20 Thread Mr. Wrobel
W dniu 18.10.2016 o 16:42, Ethan Furman pisze: On 10/17/2016 11:44 PM, Mr. Wrobel wrote: Ok,so in general, we could say that using Metclasses is ok for manipulating __new__ but not that what is setting by __init__. Am I right? No and yes. In this code (python 2 syntax): #untested class Wond

Re: Converting the keys of a dictionary from numeric to string

2016-10-20 Thread Peter Otten
Peter Otten wrote: > Paul Rubin wrote: > >> Peter Otten <__pete...@web.de> writes: >>> assert len(keydict) == len(mydict) >> >> assert set(keydict) == set(mydict) > > The weaker check is O(1), and, combined with the succeeding for loop, > implies the above. Sorry, I have to take that back: Py

Re: Converting the keys of a dictionary from numeric to string

2016-10-20 Thread Peter Otten
Paul Rubin wrote: > Peter Otten <__pete...@web.de> writes: >> assert len(keydict) == len(mydict) > > assert set(keydict) == set(mydict) The weaker check is O(1), and, combined with the succeeding for loop, implies the above. -- https://mail.python.org/mailman/listinfo/python-list

Re: Converting the keys of a dictionary from numeric to string

2016-10-20 Thread Paul Rubin
Peter Otten <__pete...@web.de> writes: > assert len(keydict) == len(mydict) assert set(keydict) == set(mydict) -- https://mail.python.org/mailman/listinfo/python-list

Re: Converting the keys of a dictionary from numeric to string

2016-10-20 Thread Peter Otten
pozz wrote: > I have a dictionary where the keys are numbers: > > mydict = { 1: 1000, 2: 1500, 3: 100 } > > I would like to convert keys from number to string representation: > > mydict = { "apples": 1000, "nuts": 1500, "tables": 100 } > > Of course, somewhere I have the association between ke

Re: Python-based monads essay part 2

2016-10-20 Thread Steven D'Aprano
On Thursday 20 October 2016 04:57, Chris Angelico wrote: > Short-circuiting depends only on what's known *prior* to that > evaluation. Dead code elimination removes the notion of time: Surely not. I understand "dead code" to mean the same as *unreachable* code: code which cannot be reached by an

Re: [FAQ] "Best" GUI toolkit for python

2016-10-20 Thread Mark Summerfield
On Wednesday, October 19, 2016 at 7:18:28 PM UTC+1, Demosthenes Koptsis wrote: > I thought PyQt was supported by Qt company... > > There is also an official book by Prentice Hall: > > Rapid GUI Programming with Python and Qt (Prentice Hall Open Source > Software Development) > > https://www.ama

Re: [FAQ] "Best" GUI toolkit for python

2016-10-20 Thread Terry Reedy
On 10/20/2016 2:02 AM, Paul Rubin wrote: pozz writes: What can I do and what *can't* I do with Tkinter? I look at the very carefully tuned and sometimes animated UI's in fancy desktop applications like Gimp and don't see a way to do similar things in Tkinter. Since I have not seen Gimp, I