[ANN] jsonrpclib-pelix 0.1.5

2013-06-24 Thread Thomas Calmant
Hi,

I'm glad to announce the release of jsonrpclib-pelix 0.1.5 !

What is it ?


jsonrpclib-pelix is an implementation of the JSON-RPC specification.
It supports both the original 1.0 specification, as well as
the 2.0 specification, which includes batch submission, keyword arguments,
etc.
The suffix -pelix only indicates that this version works with
Pelix Remote Services, but it is not a Pelix specific implementation.

This version is a fork of Josh Marshal's jsonrpclib.
It cannot be installed with the original version, as it uses the same
package name.

This project is under Apache License 2.0.

It is available on PyPI:
https://pypi.python.org/pypi/jsonrpclib-pelix

The source code is on GitHub:
https://github.com/tcalmant/jsonrpclib


What's new in 0.1.5
---

This is the second release of jsonrpclib-pelix, and the first one to be
announced on this list.
It adds the following features:

* Support of Python 3
* Added support of the dispatch_method agument in SimpleJSONRPCDispatcher
* Removed the support of Unix sockets
* Added features from other forks:

  * Improved JSON-RPC 1.0 support
  * Less strict error response handling
  * New AppError exception raised if a RPC error code is not a pre-defined one
  * Support of custom headers sent in requests


Enjoy,
Thomas
-- 
http://mail.python.org/mailman/listinfo/python-announce-list

Support the Python Software Foundation:
http://www.python.org/psf/donations/


[ANN] MadPUG - A New Python Users' Group in Madison, WI

2013-06-24 Thread Ian Cordasco
Hey all,

I wanted to first announce a python users' group in Madison, WI and
second ask that anyone with a desire to speak at the first meet-up get
in touch. Devin Walters and I are using meetup.com to coordinate the
event and would hope to start holding meet-ups on a regular basis.

If you're interested please join the group here: http://www.meetup.com/MadPUG/

We would also be willing to use madi...@python.org which once hosted
the list for a PUG in Madison (but seems rather inactive) if the
python community would like.

Cheers!
Ian

---
https://github.com/sigmavirus24
https://bitbucket.org/icordasc
-- 
http://mail.python.org/mailman/listinfo/python-announce-list

Support the Python Software Foundation:
http://www.python.org/psf/donations/


ANN: Bubbles 0.1 – Virtual Data Object Framework

2013-06-24 Thread Stefan Urbanek
Hi,

I'm happy to announce new Python data framework: Bubbles

Motto: Focus on the process, not the data technology.

Blog post: http://blog.databrewery.org/posts/bubbles-0-1-released.html

Here is a short presentation of the core concepts:

http://www.slideshare.net/Stiivi/data-brewery-2-data-objects

The concepts are:

* data objects – abstraction of tabular data, one object might have multiple 
representations at once (SQL, iterator, ...)
* data stores – abstraction of dataset collections
* operations (performing on top of representations) and execution context (with 
operation catalog)
* processing pipelines

Priorities of the framework are:

* understandability of the process
* auditability of the data being processed (frequent use of metadata)
* usability
* versatility

Working with data:

* keep data in their original form. For example: represent data by a SQL 
statement and do not touch neither move around data if not necessary.
* use native operations if possible: compose SQL statements, chain python 
iterators, compose APIs
* performance provided by technology: SQL optimizer should know the best
* have options – custom operations are easy to create

Bubbles is performance agnostic at the low level of physical data 
implementation. Performance should be assured by the data technology and proper 
use of operations.

Summary of current operations:

http://www.scribd.com/doc/147247069/Bubbles-Brewery2-Operations

More will come, at least basic Mongo ops are planned for 0.2.

Github: https://github.com/Stiivi/bubbles

If you have any comments, suggestions or questions, let me know.

Cheers,

Stefan
-- 
http://mail.python.org/mailman/listinfo/python-announce-list

Support the Python Software Foundation:
http://www.python.org/psf/donations/


devpi-0.9.2: uploading existing archives files

2013-06-24 Thread holger krekel

devpi, the caching pypi server and its optional upload/test/install helper
tool, just got a devpi-0.9.2 release.  See the full updated docs here:

http://doc.devpi.net

Apart from some streamlining, there is a new upload option::

devpi upload --from-dir path/to/dir [--only-latest]

which uploads existing release files to a devpi index, optionally only
the latest versions.  This is achieved with the help of ``pkginfo``
extracting PKGINFO files and, for the few where it's missing, using the
filename to determine name/version data.  Thanks to Anthon van der Neut 
for his related PRs.

See below for a more detailed changelog.

best,
holger

0.9.2 (compared to 0.9.1)


server:

- fix /USER/INDEXNAME root views to contain only latest in-stage packages

- make +api calls return bases so that devpi use can show them

client:

- introduce devpi upload --fromdir for uploading archives in bulk
  mode, thanks to Anthon van der Neut for helping with this!
  (resolved issue5)

- improve automatic server handling via devpi use

- for devpi server you now need to specify --log to see log lines

- make devpi use also show base indexes by default

- fix issue4: auto-server data stored in non-dot dir
-- 
http://mail.python.org/mailman/listinfo/python-announce-list

Support the Python Software Foundation:
http://www.python.org/psf/donations/


XMLtoPDFBook v1.1 released: Create simple PDF books from XML text content

2013-06-24 Thread vasudevram

XMLtoPDFBook v1.1 released:

XMLtoPDFBook is a program that lets you create simple PDF books from XML text 
content, including support for chapter numbers and names, headers and footers, 
automatic pagination, and page numbers.

Please see this blog post about XMLtoPDFBook:

XMLtoPDFBook now supports chapter numbers and names:
http://jugad2.blogspot.in/2013/06/xmltopdfbook-now-supports-chapter.html

XMLtoPDFBook is not separately released as a stand-alone product; I've added it 
as one of the components of my larger xtopdf project. But you can use it as a 
separate product, once you install the prerequisites, which include 1) v1.21 of 
the open source version of the ReportLab toolkit for PDF creation, and 2) 
xtopdf itself.

The blog post linked above, has links to download xtopdf (and hence, 
XMLtoPDFBook). The same post (which also links to a previous post about 
XMLtoPDFBook), also shows how to use XMLtoPDFBook to generate simple PDF ebooks 
from the text content in XML files that are created in a specific format. The 
format is simple: the top-level element should be a book element, and the 
inner elements should be chapter elements. Chapter elements can have an 
optional attribute like this:

chapter name=chapter_name

Using this attribute will result in the specific chapter name being displayed 
in the header for the pages comprising that chapter (in the PDF output).

Here is a guide to installing and using xtopdf:

http://jugad2.blogspot.in/2012/07/guide-to-installing-and-using-xtopdf.html

Enjoy, and give feedback, if any.
- Vasudev Ram
Dancing Bison Enterprises
Python, Linux and open source training and consulting
http://dancingbison.com
http://jugad2.blogspot.com
https://twitter.com/vasudevram

-- 
http://mail.python.org/mailman/listinfo/python-announce-list

Support the Python Software Foundation:
http://www.python.org/psf/donations/


[ANN] pypiserver 1.1.2 - minimal private pypi server

2013-06-24 Thread Ralf Schmitt
Hi,

I've just uploaded pypiserver 1.1.2 to the python package index.

pypiserver is a minimal PyPI compatible server. It can be used to serve
a set of packages and eggs to easy_install or pip.

pypiserver is easy to install (i.e. just 'pip install pypiserver'). It
doesn't have any external dependencies.

https://pypi.python.org/pypi/pypiserver/ should contain enough
information to easily get you started running your own PyPI server in a
few minutes.

The code is available on github: https://github.com/schmir/pypiserver

Changes in this version
---
- fix pypi-server -U stable/unstable detection, i.e. do not
  accidentally update to unstable packages

-- 
Cheers
Ralf
-- 
http://mail.python.org/mailman/listinfo/python-announce-list

Support the Python Software Foundation:
http://www.python.org/psf/donations/


Re: Python development tools

2013-06-24 Thread rusi
On Monday, June 24, 2013 11:04:48 AM UTC+5:30, cutems93 wrote:
 Alright. Thanks everyone for your responses. I just want to know what tools 
 are GENERALLY used by professional developers. I am helping somebody who 
 wants to know about software that he might use in his project. He does not 
 know what kind of project it will be, but it will be more like scripting in 
 the beginning. I know my question is somewhat vague, but this is all I can 
 give you. Could you help me by sharing your experiences?

There was a thread on editors a few months ago where I made some suggestions:
http://mail.python.org/pipermail/python-list/2013-January/639351.html and 
following

I dont know what you mean my 'scripting'
Anyhow I'll add this: the python docs are exceptionally well-written and a 
pleasure to go through.

Start with http://docs.python.org/2/library/
Heres a suggested order to navigate

5 Subsects 1 to 9 are important
10 File and Directory subsects 1 2 7 3
27.1 sys
13 1 and 2 (csv and config)
Some 3rd party config parsers better than builtin 
15 1 os
One of 15. 4 5 or 6 (command line parsing)
Yes this is a bit of a mess

22 Internationalization (unicode) is increasingly important but I cannot make 
head-or-tail of it. Python 2 and 3 completely inconsistent in this area

On general note about python's object orientation:
If by 'scripting' you mean working within some large App's environment eg 
libreoffice or blender which are scripted with python, then you need to 
carefully understand that app's object model.

If by scripting you mean something like shell-scripting and a few steps beyond, 
just forget about OO
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python development tools

2013-06-24 Thread Ben Finney
rusi rustompm...@gmail.com writes:

 I dont know what you mean my 'scripting'

Any time someone has shown me a “Python script”, I don't see how it's
different from what I'd call a “Python program”. So I just mentally
replace “scripting with “programming”.

-- 
 \  “Dvorak users of the world flgkd!” —Kirsten Chevalier, |
  `\rec.humor.oracle.d |
_o__)  |
Ben Finney

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What is the semantics meaning of 'object'?

2013-06-24 Thread Steven D'Aprano
On Mon, 24 Jun 2013 02:53:06 +0100, Rotwang wrote:

 On 23/06/2013 18:29, Steven D'Aprano wrote:
 On Sat, 22 Jun 2013 23:40:53 -0600, Ian Kelly wrote:
 [...]

 Can you elaborate or provide a link?  I'm curious to know what other
 reason there could be for magic methods to behave differently from
 normal methods in this regard.

 It's an efficiency optimization. I don't quite get the details, but
 when you run something like a + b, Python doesn't search for __add__
 using the normal method lookup procedure. That allows it to skip
 checking the instance __dict__, as well as __getattribute__ and
 __getattr__.
 
 It's not just an efficiency optimisation, it's actually necessary in
 cases where a dunder method gets called on a type. Consider what happens
 when one calls repr(int), for example - if this tried to call
 int.__repr__() by the normal lookup method, it would call the unbound
 __repr__ method of int with no self argument:


I don't know about *necessary*, after all, classic classes manage just 
fine in Python 2.x:

py class OldStyle:
... def __repr__(self):
... return Spam
... 
py repr(OldStyle())
'Spam'
py repr(OldStyle)
'class __main__.OldStyle at 0xb7553e0c'


I daresay that there are good reasons why new-style classes don't do the 
same thing, but the point is that had the Python devs had been 
sufficiently interested in keeping the old behaviour, and willing to pay 
whatever costs that would require, they could have done so.

But your point is well taken. It's not just purely a speed optimization.


 This is explained here:
 
 http://docs.python.org/3.3/reference/datamodel.html#special-lookup


Nice link, thank you.


-- 
Steven
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python development tools

2013-06-24 Thread rusi
On Monday, June 24, 2013 11:50:38 AM UTC+5:30, Ben Finney wrote:
 rusi  writes:
 
  I dont know what you mean my 'scripting'
 
 Any time someone has shown me a “Python script”, I don't see how it's
 different from what I'd call a “Python program”. So I just mentally
 replace “scripting with “programming”.

If you are saying that python spans the scripting to programming spectrum 
exceptionally well, I agree.  I dont however think that the two philosophies 
are the same. See http://www.tcl.tk/doc/scripting.html



-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Making a pass form cgi = webpy framework

2013-06-24 Thread Νίκος

Στις 24/6/2013 7:37 πμ, ο/η Michael Torrie έγραψε:

Why use mako's approach which requires 2 files(an html template and the
actual python script rendering the data) when i can have simple print
statements inside 1 files(my files.py script) ?
After all its only one html table i wish to display.

Sooner or later your needs grow to the point where your single python
CGI file is mixing so much html and python code that it becomes unwieldy.


Yes Michale indeed, my pelatologio.py is filled with print html statemnt 
and actual python code. it lloks like this:


#print all client profiles
print('''
body background=/data/images/bluetiles.jpg
centerh3font color=yellow size=5~ Πελατολόγιο ~br
font color=white size=5
Πελάτες:   font color=red%s   /font
Επισκευές: font color=silver %s   /font
Χρήματα:   font color=violet %s € /fontbrbr
table border=5 cellpadding=5 bgcolor=black
	thfont color=lime size=5 Πελάτης /ththfont color=orange 
size=5 Τηλέφωνο /th
	thfont color=tomato size=5 Επισκευές /ththfont color=cyan 
size=5 Σύνολο /th

''' % (clients, hits, money) )

for row in data:
(name, phone, hits, money) = row

print('''   
tr
			tdcentera 
href=http://superhost.gr/cgi-bin/pelatologio.py/?log=%s; font 
color=lime size=4 %s /a/td

tdcenterfont color=orange size=4 %s /td
tdcenterfont color=tomato size=4 %s /td
tdcenterfont color=cyan   size=4 %s /td
/tr
''' % (name, name, phone, hits, money) )
===

Apart form the fact that i will need to separate the design form the 
code, if i didn't is there an easiest way to  print tables and forms by 
using python's html generation functions and not plain print statements 
that will make the code more clear?



And also in my pelatologio.py and other script i use if statements to 
check if user submitted data or not so to print them on screen and then 
exit, like modularization.


foe example:

if( log ):
name = log
print this and this

if( seek ):
other statements
print this and this

How will i be able to do this if i use an html template
every time an if() runs all the html will run and not a part of it.

Thanks.




--
What is now proved was at first only imagined!
--
http://mail.python.org/mailman/listinfo/python-list


Re: What is the semantics meaning of 'object'?

2013-06-24 Thread Steven D'Aprano
On Sun, 23 Jun 2013 21:38:33 -0400, Roy Smith wrote:

 In article 51c7a087$0$2$c3e8da3$54964...@news.astraweb.com,
  Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote:
 
 On Sun, 23 Jun 2013 15:24:14 -0400, Roy Smith wrote:
 
  In article 51c74373$0$2$c3e8da3$54964...@news.astraweb.com,
   Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote:
  
  What else would you call a function that does lookups on the current
  object's superclasses?
  
  Well, mro_lookup() would have been a better choice.  Super() has an
  obvious meaning, which just happens to be wrong.
 
 This obvious but wrong meaning isn't the least bit obvious to me.
 Care to give me a hint? The only thing I can think of is:
 
 - if you are familiar with single inheritance;
 
 True.
 
 - but unfamiliar with multiple inheritance;
 
 False.  Although, I'm pretty sure that all the times I've used MI (in
 both Python and C++), it was of the mix-in variety.

Mixins are such a limited version of MI that it's often not even counted 
as MI, and even when it is, being familiar with mixins is hardly 
sufficient to count yourself as familiar with MI. That's kind of like me 
saying I'm familiar with life in Italy on the strength of a three-week 
holiday back in 1982 :-)

If you still think of the superclass, then you haven't done enough MI 
to learn better :-)

 
 - then you might assume that super means return the superclass of this
 class (or possibly instance).
 
 That's exactly what I assumed.  And, since you correctly surmised that
 that's what I would assume, I would suggest that it was pretty obvious
 to you too.  Of course, given that assumption, it was not at all clear
 what it would do in a class with multiple ancestors.

That's exactly why it *isn't* obvious. Too many assumptions need to be 
made, and questions left unanswered, for the conclusion to be obvious. 
Just because some people might jump to an unjustified conclusion, doesn't 
mean that the conclusion is obvious. That's like saying that it's 
obvious that the sun goes around the earth, because that's what it 
looks like. What would it look like if it was the other way around?



 I don't think that counts as obvious. Or at least not intuitive :-)
 
 Obvious is in the mind of the observer.

Well that's obvious :-)




-- 
Steven
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ANN: Bubbles 0.1 – Virtual Data Object Framework

2013-06-24 Thread Dariusz Suchojad

On 06/23/2013 07:58 PM, Stefan Urbanek wrote:


If you have any comments, suggestions or questions, let me know.


Hi Stefan,

GH readme links to http://bubbles.databrewery.org/ but this page times 
out, can't connect to it.


cheers,

--
Dariusz Suchojad
--
http://mail.python.org/mailman/listinfo/python-list


Re: Loop Question

2013-06-24 Thread christhecomic
Here is my code...I'm using 2.7.5

username=raw_input(Please enter your username: )
password=raw_input(Please enter your password: )
if username == john doe and password == fopwpo:
 print Login Successful
else:
 print Please try again
-- 
http://mail.python.org/mailman/listinfo/python-list


Looking for a name for a deployment framework...

2013-06-24 Thread jonathan . slenders
Hi all,

Any suggestions for a good name, for a framework that does automatic server 
deployments?

It's like Fabric, but more powerful.
It has some similarities with Puppet, Chef and Saltstack, but is written in 
Python.

Key points are that it uses Python, but is still very declarative and supports 
introspection. It supports parallel deployments, and interactivity. And it has 
a nice commandline shell with autocompletion for traversing the deployment tree.

The repository:
https://github.com/jonathanslenders/python-deployer/tree/refactoring-a-lot-v2


Suggestions welcome :)
Jonathan
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What is the semantics meaning of 'object'?

2013-06-24 Thread Roy Smith
In article 51c7fe14$0$29973$c3e8da3$54964...@news.astraweb.com,
 Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote:

 Mixins are such a limited version of MI that it's often not even counted 
 as MI, and even when it is, being familiar with mixins is hardly 
 sufficient to count yourself as familiar with MI.

OK, fair enough.

  - then you might assume that super means return the superclass of this
  class (or possibly instance).
  
  That's exactly what I assumed.  And, since you correctly surmised that
  that's what I would assume, I would suggest that it was pretty obvious
  to you too.  Of course, given that assumption, it was not at all clear
  what it would do in a class with multiple ancestors.
 
 That's exactly why it *isn't* obvious. Too many assumptions need to be 
 made, and questions left unanswered, for the conclusion to be obvious.

I think we're using different definitions of obvious.  I'm using it to 
mean, What you would conclude from a first look at a problem.  The 
fact that it is proven to be wrong upon closer examination doesn't 
change the fact that it's obvious.

 That's like saying that it's obvious that the sun goes around the 
 earth, because that's what it looks like. What would it look like if 
 it was the other way around?

Well, it is obvious.  It's just wrong, based on our current 
understanding.  Humans have been theorizing about how the heavenly 
bodies work for thousands of years.  It's only in the past 400 that 
they're figured out how the solar system works.

So, to bring this back to Python, the goal of designing 
easy-to-understand things is that the obvious explanation also happens 
to be the correct one.  Giving super() the name that it has failed at 
this.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Looking for a name for a deployment framework...

2013-06-24 Thread Roy Smith
In article 8b0d8931-cf02-4df4-8f17-a47ddd279...@googlegroups.com,
 jonathan.slend...@gmail.com wrote:

 Hi all,
 
 Any suggestions for a good name, for a framework that does automatic server 
 deployments?
 
 It's like Fabric, but more powerful.
 It has some similarities with Puppet, Chef and Saltstack, but is written in 
 Python.
 
 Key points are that it uses Python, but is still very declarative and 
 supports introspection. It supports parallel deployments, and interactivity. 
 And it has a nice commandline shell with autocompletion for traversing the 
 deployment tree.
 
 The repository:
 https://github.com/jonathanslenders/python-deployer/tree/refactoring-a-lot-v2
 
 
 Suggestions welcome :)
 Jonathan

Without forming any opinion on the software itself, the best advice I 
can offer is that naming puns are very popular.  If you're thinking of 
this as a fabric replacement, I would go with cloth, textile, material, 
gabardine, etc.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Don't feed the troll...

2013-06-24 Thread Antoon Pardon
Op 23-06-13 16:29, ru...@yahoo.com schreef:

 On 06/21/2013 01:32 PM, Antoon Pardon wrote:
 Op 19-06-13 23:13, ru...@yahoo.com schreef:
 The troll is outside the volition of the group and so his
 appearance is effectively an act of nature.

 This seems a rather artificial division. Especially because the
 immediate cause that led to this discussion is Nikos. As the
 situation is now I see very little reason to exclude Nikos
 from the group. He has made a substantial number of contribution
 and has received a substantial number of replies. So on what
 grounds would you put Nikos outside the volition of this group?

 made contributions?  I think you mean asked questions.
 He has not (as far as I tell) been a participant here in
 the past, has not tried to help or participated in any other 
 threads, seems to be interested only in getting his own 
 problems solved, and not shown many signs of concern with 
 any form of group consensus(es), not responded to requests.  
 Isn't all that in large part the basis of your objection 
 to him?  Outside the volition of this group seems like 
 a reasonable description to me. 

What do you mean with not a participant in the past? As far
as I can see his first appearance was in dec 2011. That is
over a year ago. It also seems that he always find people
willing to engage with him. Is how the group treats him
not also an aspect in deciding whether he belongs or not?


But if you want to classify Nikos as somehow incorrigible
and hope for better from others, I can understand that.
I just have a harder time understanding why you seem to
make it some kind of priority that people in the group
should still be able to communicate with this person with
only a minimum of hassle.


 Possibly. But I don't consider utiltarism such a good measuring
 stick for these kind of situations. Too easy to neglect the
 concerns of individuals or small groups.

 And your alternative that doesn't neglect concerns of individuals
 or small groups would be what?  Something that neglects the concerns
 of the majority?  I would love to see a proposed solution that 
 satisfies the concerns of every individual and group here.  And
 of course since you maintain above that trolls themselves are 
 legitimate members of the newsgroup, it should also satisfy their
 desires as well.  But sadly, in the real world there are conflicting 
 desires so I don't think your alternative exists. 

Are you trying to have a meaningful conversation or going for debating
points? I didn't claim to have a solution that will satisfy everyone.
But I do think there are better ways in handling this kind of situation
other than one group of people by some kind of introspection coming to
a conclusion of how best to deal with it, simply trying to argue others
into compliance. Especially if this solution puts none of the burden on
their own shoulders but all on others.


 So the question to answer is: how do those different policies
 affect the cost/benefits of the different groups and which one
 leads to the greatest good for the most?

 And I don't think that is the right question. It leads to people
 who are less annoyed by this kind of behaviour to ignore or brush
 of people who are more annoyed and attempts by the former to
 make the latter shoulder the full burden while not bearing any
 costs themselves and even behaving in such a way as to increase
 the annoyance of the latter group.

 Addressed in more detail below.  No brushing off involved, 
 only an attempt at the most reasonable tradeoff for everybody 
 (which means not agreeing to the vigilantes desire to engage 
 in flame wars with people that annoy them.) 

Yes, brushing off. Your attempt seems to consist solely on
some kind of intropspection in which you came to some kind
of conclusion and attempts to argue people into compliance.

As far as I can see you didn't try to understand the view
of others but just tried to convice them of the truth of
your conclusion. That looks like brushing off to me.


 I have said something that can be interpretted as the first.
 But I made it clear because Nikos had allready receiced a
 ton of help like links of which he showed very little interest
 in actually reading. My boycot was meant for until he could
 show some results of him actively trying to solve his problems
 instead of us keeping to spoon feed him.

 What you see as a ton of help like links I submit did 
 not seem that way to Nikos.  Consider the help in one 
 thread:
  | This is all you need to read:
  |  http://docs.python.org/2/reference/expressions.html#boolean-operations 
 Ignoring that the link is to Python2 while Nikos was 
 using Python3 (and clearly did understand enough about the
 differences to assume it was still relevant), the contents
 start with In the context of Boolean operations... when
 Nikos' confusion (IIRC) was due to not understanding even 
 the concept of a boolean context and the distinction 
 between True/False and true/false (which is not even 
 

Re: Looking for a name for a deployment framework...

2013-06-24 Thread MRAB

On 24/06/2013 13:50, Roy Smith wrote:

In article 8b0d8931-cf02-4df4-8f17-a47ddd279...@googlegroups.com,
  jonathan.slend...@gmail.com wrote:


Hi all,

Any suggestions for a good name, for a framework that does automatic server
deployments?

It's like Fabric, but more powerful.
It has some similarities with Puppet, Chef and Saltstack, but is written in
Python.

Key points are that it uses Python, but is still very declarative and
supports introspection. It supports parallel deployments, and interactivity.
And it has a nice commandline shell with autocompletion for traversing the
deployment tree.

The repository:
https://github.com/jonathanslenders/python-deployer/tree/refactoring-a-lot-v2


Suggestions welcome :)
Jonathan


Without forming any opinion on the software itself, the best advice I
can offer is that naming puns are very popular.  If you're thinking of
this as a fabric replacement, I would go with cloth, textile, material,
gabardine, etc.


Snakeskin? Oh, I see that's already taken. :-(
--
http://mail.python.org/mailman/listinfo/python-list


Re: Loop Question

2013-06-24 Thread rusi
On Monday, June 24, 2013 5:42:51 PM UTC+5:30, christ...@gmail.com wrote:
 Here is my code...I'm using 2.7.5
 
 
 username=raw_input(Please enter your username: )
 password=raw_input(Please enter your password: )
 if username == john doe and password == fopwpo:
  print Login Successful
 else:
  print Please try again


Good!

Now take Steven's suggestion loop with a break
and bung your code into Steven's loop.
[Hint: You have to add a break somewhere!]

Or at least try!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Default Value

2013-06-24 Thread Grant Edwards
On 2013-06-22, Ian Kelly ian.g.ke...@gmail.com wrote:
 On Fri, Jun 21, 2013 at 7:15 PM, Steven D'Aprano
steve+comp.lang.pyt...@pearwood.info wrote:
 On Fri, 21 Jun 2013 23:49:51 +0100, MRAB wrote:

 On 21/06/2013 21:44, Rick Johnson wrote:
 [...]
 Which in Python would be the MutableArgumentWarning.

 *school-bell*

 I notice that you've omitted any mention of how you'd know that the
 argument was mutable.

 That's easy. Just call ismutable(arg). The implementation of ismutable is
 just an implementation detail, somebody else can work that out. A
 language designer of the sheer genius of Rick can hardly be expected to
 worry himself about such trivial details.

 While we're at it, I would like to petition for a function
 terminates(f, args) that I can use to determine whether a function
 will terminate before I actually call it.

I think it should be terminate_time() -- so you can also find out how
long it's going to run.  It can return None if it's not going to
terminate...

-- 
Grant Edwards   grant.b.edwardsYow! I'm continually AMAZED
  at   at th'breathtaking effects
  gmail.comof WIND EROSION!!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ANN: Bubbles 0.1 – Virtual Data Object Framework

2013-06-24 Thread Skip Montanaro
When the bubbles URL fails, Chrome suggests simply databrewery.org,
which seems to work, though it has no mention of bubbles.

Skip


On Mon, Jun 24, 2013 at 3:54 AM, Dariusz Suchojad ds...@gefira.pl wrote:
 On 06/23/2013 07:58 PM, Stefan Urbanek wrote:

 If you have any comments, suggestions or questions, let me know.


 Hi Stefan,

 GH readme links to http://bubbles.databrewery.org/ but this page times out,
 can't connect to it.

 cheers,

 --
 Dariusz Suchojad
 --
 http://mail.python.org/mailman/listinfo/python-list
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python development tools

2013-06-24 Thread Grant Edwards
On 2013-06-23, cutems93 ms2...@cornell.edu wrote:

 I am new to python development and I want to know what kinds of tools
 people use for python development.

 1) emacs
 2) Cpython
 3) subversion
 4) http://www.python.org/doc/
 5) comp.lang.python 

99.9% of the programs I write are command-line tools.
 
-- 
Grant Edwards   grant.b.edwardsYow! I'm shaving!!
  at   I'M SHAVING!!
  gmail.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What is the semantics meaning of 'object'?

2013-06-24 Thread Rotwang

On 24/06/2013 07:31, Steven D'Aprano wrote:

On Mon, 24 Jun 2013 02:53:06 +0100, Rotwang wrote:


On 23/06/2013 18:29, Steven D'Aprano wrote:

On Sat, 22 Jun 2013 23:40:53 -0600, Ian Kelly wrote:

[...]

Can you elaborate or provide a link?  I'm curious to know what other
reason there could be for magic methods to behave differently from
normal methods in this regard.


It's an efficiency optimization. I don't quite get the details, but
when you run something like a + b, Python doesn't search for __add__
using the normal method lookup procedure. That allows it to skip
checking the instance __dict__, as well as __getattribute__ and
__getattr__.


It's not just an efficiency optimisation, it's actually necessary in
cases where a dunder method gets called on a type. Consider what happens
when one calls repr(int), for example - if this tried to call
int.__repr__() by the normal lookup method, it would call the unbound
__repr__ method of int with no self argument:



I don't know about *necessary*, after all, classic classes manage just
fine in Python 2.x:

py class OldStyle:
... def __repr__(self):
... return Spam
...
py repr(OldStyle())
'Spam'
py repr(OldStyle)
'class __main__.OldStyle at 0xb7553e0c'


Point taken. It's also possible to override the __repr__ method of an 
old-style instance and have the change recognised by repr, so repr(x) 
isn't simply calling type(x).__repr__(x) in general.




I daresay that there are good reasons why new-style classes don't do the
same thing, but the point is that had the Python devs had been
sufficiently interested in keeping the old behaviour, and willing to pay
whatever costs that would require, they could have done so.


Sure, though the above behaviour was probably easier to achieve with 
old-style classes than it would have been with new-style classes because 
all instances of old-style classes have the same type. But I don't doubt 
that you're correct that they could have done it if they wanted.

--
http://mail.python.org/mailman/listinfo/python-list


Re: [SPAM] Re: Default Value

2013-06-24 Thread MRAB

On 24/06/2013 15:22, Grant Edwards wrote:

On 2013-06-22, Ian Kelly ian.g.ke...@gmail.com wrote:

On Fri, Jun 21, 2013 at 7:15 PM, Steven D'Aprano
steve+comp.lang.pyt...@pearwood.info wrote:

On Fri, 21 Jun 2013 23:49:51 +0100, MRAB wrote:


On 21/06/2013 21:44, Rick Johnson wrote:

[...]

Which in Python would be the MutableArgumentWarning.

*school-bell*


I notice that you've omitted any mention of how you'd know that the
argument was mutable.


That's easy. Just call ismutable(arg). The implementation of ismutable is
just an implementation detail, somebody else can work that out. A
language designer of the sheer genius of Rick can hardly be expected to
worry himself about such trivial details.


While we're at it, I would like to petition for a function
terminates(f, args) that I can use to determine whether a function
will terminate before I actually call it.


I think it should be terminate_time() -- so you can also find out how
long it's going to run.  It can return None if it's not going to
terminate...


Surely that should be float(inf)! Anything else would be ridiculous!
:-)
--
http://mail.python.org/mailman/listinfo/python-list


Re: Making a pass form cgi = webpy framework

2013-06-24 Thread rusi
On Monday, June 24, 2013 1:02:51 PM UTC+5:30, Νίκος wrote:

 And also in my pelatologio.py and other script i use if statements to 
 check if user submitted data or not so to print them on screen and then 
 exit, like modularization.
 
 
 
 foe example:
 
 if( log ):
   name = log
   print this and this
 
 if( seek ):
   other statements
   print this and this
 
 
 How will i be able to do this if i use an html template
 every time an if() runs all the html will run and not a part of it.

Every significant templating system has something for this
eg in mako
http://docs.makotemplates.org/en/latest/syntax.html#control-structures

The main thing to understand is this:
- When you use straight python, by default you are 'inside python' except when 
inside strings (inside prints) then you are 'inside html'

- When using a templating engine, by default you are inside html, except when 
you escape from html into python
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What is the semantics meaning of 'object'?

2013-06-24 Thread Mark Janssen
 Mostly I'm saying that super() is badly named.

 What else would you call a function that does lookups on the current
 object's superclasses?

^.  You make a symbol for it.  ^__init__(foo, bar)

-- 
MarkJ
Tacoma, Washington
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python development tools

2013-06-24 Thread Wolfgang Keller
 Also, I will use GUI interface for Python. What kind of widget
 toolkits do you recommend? I know there are GTK+ and Qt. 

wxPython, PyGUI...

Sincerely,

Wolfgang
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What is the semantics meaning of 'object'?

2013-06-24 Thread Ian Kelly
On Mon, Jun 24, 2013 at 9:00 AM, Rotwang sg...@hotmail.co.uk wrote:
 On 24/06/2013 07:31, Steven D'Aprano wrote:

 I daresay that there are good reasons why new-style classes don't do the
 same thing, but the point is that had the Python devs had been
 sufficiently interested in keeping the old behaviour, and willing to pay
 whatever costs that would require, they could have done so.


 Sure, though the above behaviour was probably easier to achieve with
 old-style classes than it would have been with new-style classes because all
 instances of old-style classes have the same type. But I don't doubt that
 you're correct that they could have done it if they wanted.

It seems to me that the important difference with new-style classes is
that they suddenly have metaclasses and are themselves just ordinary
objects, and so it is important that they consistently resolve calls
in the same way that all other objects do.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What is the semantics meaning of 'object'?

2013-06-24 Thread Ian Kelly
On Mon, Jun 24, 2013 at 9:58 AM, Mark Janssen dreamingforw...@gmail.com wrote:
 Mostly I'm saying that super() is badly named.

 What else would you call a function that does lookups on the current
 object's superclasses?

 ^.  You make a symbol for it.  ^__init__(foo, bar)

On the one hand, eww.

On the other hand, with the changes to super in Python 3 to make it
more magical, it might as well be syntax.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Looking for a name for a deployment framework...

2013-06-24 Thread Neil Cerutti
On 2013-06-24, MRAB pyt...@mrabarnett.plus.com wrote:
 On 24/06/2013 13:50, Roy Smith wrote:
 In article 8b0d8931-cf02-4df4-8f17-a47ddd279...@googlegroups.com,
   jonathan.slend...@gmail.com wrote:

 Hi all,

 Any suggestions for a good name, for a framework that does automatic server
 deployments?

 It's like Fabric, but more powerful.
 It has some similarities with Puppet, Chef and Saltstack, but is written in
 Python.

 Key points are that it uses Python, but is still very declarative and
 supports introspection. It supports parallel deployments, and interactivity.
 And it has a nice commandline shell with autocompletion for traversing the
 deployment tree.

 The repository:
 https://github.com/jonathanslenders/python-deployer/tree/refactoring-a-lot-v2


 Suggestions welcome :)
 Jonathan

 Without forming any opinion on the software itself, the best advice I
 can offer is that naming puns are very popular.  If you're thinking of
 this as a fabric replacement, I would go with cloth, textile, material,
 gabardine, etc.

 Snakeskin? Oh, I see that's already taken. :-(

Most things are taken nowadays.

A short nonsense-word is best. Something like Folaf. Yeah, it
doesn't spark the imagination, but it's easy to find, if not to
remember.

Well, not Folaf. That seems to be an African style restaurant
in L.A.

-- 
Neil Cerutti
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Looking for a name for a deployment framework...

2013-06-24 Thread Cousin Stanley
jonathan.slend...@gmail.com wrote:

 Any suggestions for a good name, 
 for a framework that does 
 automatic server deployments ?

  asdf :  automatic server deployment framework


-- 
Stanley C. Kitching
Human Being
Phoenix, Arizona

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Loop Question

2013-06-24 Thread christhecomic
On Sunday, June 23, 2013 6:18:35 PM UTC-5, christ...@gmail.com wrote:
 How do I bring users back to beginning of user/password question once they
 
 fail it? thx

Can't seem to get this to cooperate...where does the while statement belong?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Loop Question

2013-06-24 Thread John Gordon
In e41ce3a3-c8cb-4cfc-ba86-462f40f32...@googlegroups.com 
christheco...@gmail.com writes:

 On Sunday, June 23, 2013 6:18:35 PM UTC-5, christ...@gmail.com wrote:
  How do I bring users back to beginning of user/password question once they
  
  fail it? thx

 Can't seem to get this to cooperate...where does the while statement belong?

while True:
username = raw_input(Please enter your username: )
password = raw_input(Please enter your password: )

if username == john doe and password == fopwpo:
print Login Successful
break

else:
print Please try again

-- 
John Gordon   A is for Amy, who fell down the stairs
gor...@panix.com  B is for Basil, assaulted by bears
-- Edward Gorey, The Gashlycrumb Tinies

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Loop Question

2013-06-24 Thread Chris “Kwpolska” Warrick
On Mon, Jun 24, 2013 at 8:42 PM, John Gordon gor...@panix.com wrote:
 In e41ce3a3-c8cb-4cfc-ba86-462f40f32...@googlegroups.com 
 christheco...@gmail.com writes:

 On Sunday, June 23, 2013 6:18:35 PM UTC-5, christ...@gmail.com wrote:
  How do I bring users back to beginning of user/password question once they
 
  fail it? thx

 Can't seem to get this to cooperate...where does the while statement belong?

 while True:
 username = raw_input(Please enter your username: )
 password = raw_input(Please enter your password: )

 if username == john doe and password == fopwpo:
 print Login Successful
 break

 else:
 print Please try again

You didn’t test the code, did you?  Because the code you posted is
right.  Remember to always test code before submitting.  And note that
the getpass module is what you should use for that second thing in
real life, for the security of your users.

--
Kwpolska http://kwpolska.tk | GPG KEY: 5EAAEA16
stop html mail| always bottom-post
http://asciiribbon.org| http://caliburn.nl/topposting.html
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Looking for a name for a deployment framework...

2013-06-24 Thread Irmen de Jong
On 24-6-2013 20:13, Cousin Stanley wrote:
 jonathan.slend...@gmail.com wrote:
 
 Any suggestions for a good name, 
 for a framework that does 
 automatic server deployments ?
 
   asdf :  automatic server deployment framework
 
 


:-)


wsad: wonderful serverside automatic deployments

(hm, could use a bit of tweaking, maybe FPS keys don't map easily to names)


Irmen
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Loop Question

2013-06-24 Thread John Gordon
In mailman.3754.1372100014.3114.python-l...@python.org 
=?UTF-8?B?Q2hyaXMg4oCcS3dwb2xza2HigJ0gV2Fycmljaw==?= kwpol...@gmail.com 
writes:

  while True:
  username = raw_input(Please enter your username: )
  password = raw_input(Please enter your password: )
 
  if username == john doe and password == fopwpo:
  print Login Successful
  break
 
  else:
  print Please try again

 You didn't test the code, did you?  Because the code you posted is
 right.

It's right, therefore I did not test it?  I don't understand.

If the code has a bug, please point it out.

 And note that the getpass module is what you should use for that second
 thing in real life, for the security of your users.

I'm sure this is just an exercise for the OP to understand loops.  Security
would be counter-productive.

-- 
John Gordon   A is for Amy, who fell down the stairs
gor...@panix.com  B is for Basil, assaulted by bears
-- Edward Gorey, The Gashlycrumb Tinies

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Looking for a name for a deployment framework...

2013-06-24 Thread Fábio Santos
On 24 Jun 2013 13:39, jonathan.slend...@gmail.com wrote:

 Hi all,

 Any suggestions for a good name, for a framework that does automatic
server deployments?

 It's like Fabric, but more powerful.
 It has some similarities with Puppet, Chef and Saltstack, but is written
in Python.

 Key points are that it uses Python, but is still very declarative and
supports introspection. It supports parallel deployments, and
interactivity. And it has a nice commandline shell with autocompletion for
traversing the deployment tree.

 The repository:

https://github.com/jonathanslenders/python-deployer/tree/refactoring-a-lot-v2


 Suggestions welcome :)
 Jonathan

omglolftwdeploy
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Loop Question

2013-06-24 Thread Dave Angel

On 06/24/2013 03:00 PM, John Gordon wrote:

In mailman.3754.1372100014.3114.python-l...@python.org 
=?UTF-8?B?Q2hyaXMg4oCcS3dwb2xza2HigJ0gV2Fycmljaw==?= kwpol...@gmail.com writes:


while True:
 username = raw_input(Please enter your username: )
 password = raw_input(Please enter your password: )

 if username == john doe and password == fopwpo:
 print Login Successful
 break

 else:
 print Please try again



You didn't test the code, did you?  Because the code you posted is
right.


It's right, therefore I did not test it?  I don't understand.


I expect that Chris simply misinterpreted the quoting in your message, 
thinking that the OP had both typed the

  Can't seem to get this to cooperate...where does t...
and the correct code.  In fact, the OP typed the former, and you typed 
the latter.



--
DaveA
--
http://mail.python.org/mailman/listinfo/python-list


What's wrong with this code? (UnboundLocalError: local variable referenced before assignment)

2013-06-24 Thread pablobarhamalzas
Hi there! I'm quite new to programming, even newer in python (this is actually 
the first thing I try on it), and every other topic I've seen on forums about 
my problem doesn't seem to help. 

So, the following lines are intended to draw a white square (which it does), 
turn it to blue when you click on it, and back to white when you click on it 
again (and so on). Here's what I wrote (python 3 syntax):


from tkinter import *

root = Tk()
root.geometry(500x500)

w = Canvas(root, width=500, height=500)
w.pack()

coords = (x1, y1, x2, y2) = (100, 100, 200, 200)

rect = w.create_rectangle(coords, fill=white)
isWhite = True

def change(event):
if event.x  x1 and event.x  x2 and event.y  y1 and event.y  y2:
if isWhite:
w.itemconfig(rect, fill=blue)
isWhite = False
else:
w.itemconfig(rect, fill=white)   
isWhite = True
  
w.bind(Button-1, change)
  
root.mainloop()  


The problem occurs when clicking on the white square. The following error 
appears:
if isWhite:
UnboundLocalError: local variable 'isWhite' referenced before assignment

However, the isWhite variable is clearly defined at True a few lines before.
Also, if I remove the lines that change isWhite to False if it's True and 
viceversa, the program doesn't throw any error, but obviously doesn't do what I 
want it to do (it only changes the square color once, as isWhite stays set to 
True).

What can the problem be? I'm sure it's something really simple, but I don't get 
it... Thank's!

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What's wrong with this code? (UnboundLocalError: local variable referenced before assignment)

2013-06-24 Thread pablobarhamalzas
Just before anyone says, the reason I bind to the Canvas instead of binding 
directly to the rectangle is because I plan to add more squares in the future.
Cheers.
-- 
http://mail.python.org/mailman/listinfo/python-list


Is this PEP-able? fwhile

2013-06-24 Thread jimjhb

Syntax:


fwhile X in ListY and conditionZ:


The following would actually exactly as:  for X in ListY:


fwhile X in ListY and True:


fwhile would act much like 'for', but would stop if the condition after the 
'and' is no longer True.


The motivation is to be able to make use of all the great aspects of the python 
'for' (no indexing or explict
end condition check, etc.) and at the same time avoiding a 'break' from the 
'for'.  


(NOTE:  Many people are being taught to avoid 'break' and 'continue' at all 
costs, so they instead convert
the clean 'for' into a less-clean 'while'.  Or they just let the 'for' run out. 
 You can argue against this teaching
(at least for Python) but that doesn't mean it's not prevalent and prevailing.)


[People who avoid the 'break' by functionalizing an inner portion of the loop 
are just kidding themselves and making
their own code worse, IMO.]


I'm not super familiar with CPython, but I'm pretty sure I could get this up 
and working without too much effort.
The mandatory 'and' makes sense because 'or' would hold the end value valid 
(weird) and not accomplish much.
The condition itself could of course have multiple parts to it, including 'or's.


It's possible the name 'fwhile' is not optimal, but that shouldn't affect the 
overall merit/non-merit of the concept.


Comments and Questions welcome.


Thanks.  
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What's wrong with this code? (UnboundLocalError: local variable referenced before assignment)

2013-06-24 Thread Peter Otten
pablobarhamal...@gmail.com wrote:

 Hi there! I'm quite new to programming, even newer in python (this is
 actually the first thing I try on it), and every other topic I've seen on
 forums about my problem doesn't seem to help.
 
 So, the following lines are intended to draw a white square (which it
 does), turn it to blue when you click on it, and back to white when you
 click on it again (and so on). Here's what I wrote (python 3 syntax):
 
 
 from tkinter import *
 
 root = Tk()
 root.geometry(500x500)
 
 w = Canvas(root, width=500, height=500)
 w.pack()
 
 coords = (x1, y1, x2, y2) = (100, 100, 200, 200)
 
 rect = w.create_rectangle(coords, fill=white)
 isWhite = True
 
 def change(event):
 if event.x  x1 and event.x  x2 and event.y  y1 and event.y  y2:
 if isWhite:
 w.itemconfig(rect, fill=blue)
 isWhite = False
 else:
 w.itemconfig(rect, fill=white)
 isWhite = True
   
 w.bind(Button-1, change)
   
 root.mainloop()
 
 
 The problem occurs when clicking on the white square. The following error
 appears: if isWhite:
 UnboundLocalError: local variable 'isWhite' referenced before assignment
 
 However, the isWhite variable is clearly defined at True a few lines
 before. Also, if I remove the lines that change isWhite to False if it's
 True and viceversa, the program doesn't throw any error, but obviously
 doesn't do what I want it to do (it only changes the square color once, as
 isWhite stays set to True).
 
 What can the problem be? I'm sure it's something really simple, but I
 don't get it... Thank's!

Python statically determines the scope of a variable -- if you rebind a name 
it assumes that the variable is local:

 def f():
... print is_white
... is_white = 42
... 
 f()
Traceback (most recent call last):
  File stdin, line 1, in module
  File stdin, line 2, in f
UnboundLocalError: local variable 'is_white' referenced before assignment

The fix is to tell Python that you want to access the global variable:

 def f():
... global is_white
... print is_white
... is_white = 42
... 
 is_white = whatever
 f()
whatever
 f()
42


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What's wrong with this code? (UnboundLocalError: local variable referenced before assignment)

2013-06-24 Thread Antoon Pardon

Op 24-06-13 21:47, pablobarhamal...@gmail.com schreef:

Hi there! I'm quite new to programming, even newer in python (this is actually 
the first thing I try on it), and every other topic I've seen on forums about 
my problem doesn't seem to help.

So, the following lines are intended to draw a white square (which it does), 
turn it to blue when you click on it, and back to white when you click on it 
again (and so on). Here's what I wrote (python 3 syntax):


from tkinter import *

root = Tk()
root.geometry(500x500)

w = Canvas(root, width=500, height=500)
w.pack()

coords = (x1, y1, x2, y2) = (100, 100, 200, 200)

rect = w.create_rectangle(coords, fill=white)
isWhite = True

def change(event):
 if event.x  x1 and event.x  x2 and event.y  y1 and event.y  y2:
 if isWhite:
 w.itemconfig(rect, fill=blue)
 isWhite = False
 else:
 w.itemconfig(rect, fill=white)
 isWhite = True

w.bind(Button-1, change)

root.mainloop()


The problem occurs when clicking on the white square. The following error 
appears:
if isWhite:
UnboundLocalError: local variable 'isWhite' referenced before assignment

However, the isWhite variable is clearly defined at True a few lines before.


No it is not.

In Python, when you assign to a variable within a function, that
variable will be treated as a local variable. If you have a global
variable with the same name, that global variable will just for
the duration of the function become inaccessible.

The quick solution in this case is to include a global statement.
Something like

def change(event)
global isWhite
...

--
Antoon Pardon

--
http://mail.python.org/mailman/listinfo/python-list


Re: Is this PEP-able? fwhile

2013-06-24 Thread Ian Kelly
On Mon, Jun 24, 2013 at 1:52 PM,  jim...@aol.com wrote:
 Syntax:

 fwhile X in ListY and conditionZ:

 The following would actually exactly as:  for X in ListY:

 fwhile X in ListY and True:

 fwhile would act much like 'for', but would stop if the condition after the
 'and' is no longer True.

 The motivation is to be able to make use of all the great aspects of the
 python 'for' (no indexing or explict
 end condition check, etc.) and at the same time avoiding a 'break' from the
 'for'.

I would advocate using the break myself.  Another alternative is this:

for X in itertools.takewhile(lambda X: conditionZ, ListY):
...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What's wrong with this code? (UnboundLocalError: local variable referenced before assignment)

2013-06-24 Thread John Gordon
In b3d3518a-f24a-4c32-a41a-b99145753...@googlegroups.com 
pablobarhamal...@gmail.com writes:

 isWhite = True
 
 def change(event):
 if event.x  x1 and event.x  x2 and event.y  y1 and event.y  y2:
 if isWhite:
 w.itemconfig(rect, fill=blue)
 isWhite = False
 else:
 w.itemconfig(rect, fill=white)   
 isWhite = True
   
 w.bind(Button-1, change)
   
 root.mainloop()  

 The problem occurs when clicking on the white square. The following error
 appears:
 if isWhite:
 UnboundLocalError: local variable 'isWhite' referenced before assignment

 However, the isWhite variable is clearly defined at True a few lines
 before.

Since you're new to programming, this might be a bit tricky to explain,
but I'll do my best. :-)

The problem is that change() isn't being executed here; instead it's being
executed from within root.mainloop(), whenever the user presses button-1.

And within root.mainloop(), there is no variable called isWhite.

-- 
John Gordon   A is for Amy, who fell down the stairs
gor...@panix.com  B is for Basil, assaulted by bears
-- Edward Gorey, The Gashlycrumb Tinies

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What's wrong with this code? (UnboundLocalError: local variable referenced before assignment)

2013-06-24 Thread pablobarhamalzas
Thank's to you all! 

Setting isWhite as global worked fine.
I'll probably be back soon with another silly question, see you then :)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is this PEP-able? fwhile

2013-06-24 Thread Ian Kelly
On Mon, Jun 24, 2013 at 1:52 PM,  jim...@aol.com wrote:
 Syntax:

 fwhile X in ListY and conditionZ:

Also, this syntax is ambiguous.  Take for example the statement:

fwhile X in ListA and ListB and ListC and ListD:

At which and does the iterable expression stop and the condition
expression begin?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What's wrong with this code? (UnboundLocalError: local variable referenced before assignment)

2013-06-24 Thread Joshua Landau
Here's a little test to make sure you understand (this is one of the
most confusing parts of Python's closures in my opinion):

foo = I'm foo!

def working():
print(foo)

def broken():
print(foo)

if False: # There's no way this could cause a problem!
foo = This will *never* happen
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What's wrong with this code? (UnboundLocalError: local variable referenced before assignment)

2013-06-24 Thread Joshua Landau
On 24 June 2013 21:12, John Gordon gor...@panix.com wrote:
 Since you're new to programming, this might be a bit tricky to explain,
 but I'll do my best. :-)

 The problem is that change() isn't being executed here; instead it's being
 executed from within root.mainloop(), whenever the user presses button-1.

 And within root.mainloop(), there is no variable called isWhite.

Sorry, but I don't think you're right. Functions carry their
contexts around with them, so that shouldn't matter

(See Peter and Antoon's comments for explanation of what I think it is)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is this PEP-able? fwhile

2013-06-24 Thread Fábio Santos
On Mon, Jun 24, 2013 at 8:52 PM,  jim...@aol.com wrote:
 Syntax:

 fwhile X in ListY and conditionZ:

 The following would actually exactly as:  for X in ListY:

 fwhile X in ListY and True:

 fwhile would act much like 'for', but would stop if the condition after the
 'and' is no longer True.

 The motivation is to be able to make use of all the great aspects of the
 python 'for' (no indexing or explict
 end condition check, etc.) and at the same time avoiding a 'break' from the
 'for'.

 (NOTE:  Many people are being taught to avoid 'break' and 'continue' at all
 costs, so they instead convert
 the clean 'for' into a less-clean 'while'.  Or they just let the 'for' run
 out.  You can argue against this teaching
 (at least for Python) but that doesn't mean it's not prevalent and
 prevailing.)

 [People who avoid the 'break' by functionalizing an inner portion of the
 loop are just kidding themselves and making
 their own code worse, IMO.]

 I'm not super familiar with CPython, but I'm pretty sure I could get this up
 and working without too much effort.
 The mandatory 'and' makes sense because 'or' would hold the end value valid
 (weird) and not accomplish much.
 The condition itself could of course have multiple parts to it, including
 'or's.

 It's possible the name 'fwhile' is not optimal, but that shouldn't affect
 the overall merit/non-merit of the concept.

 Comments and Questions welcome.

 Thanks.


I can see where you are coming from, but this is probably not going to
happen.  The and keyword is also

Also, the (amazing) python devs are concerned with overcomplicating
the language syntax, which is bad for: newbies, other implementations
of the language, and code readability. The syntax doesn't seem too
obvious, and there is a new keyword, fwhile.

This can probably be best achieved by adding to the existing for loop,
so maybe taking advantage of the existing for...if syntax and adding
for...while would be a better idea?

So, maybe:

for x in y while cond:

And for list/set/dict comprehensions and generator expressions:

[x for x in range(123) while cond]

Just maybe.

--
Fábio Santos
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is this PEP-able? fwhile

2013-06-24 Thread Joshua Landau
On 24 June 2013 20:52,  jim...@aol.com wrote:
 Syntax:

 fwhile X in ListY and conditionZ:

 The following would actually exactly as:  for X in ListY:

 fwhile X in ListY and True:

 fwhile would act much like 'for', but would stop if the condition after the
 'and' is no longer True.

 The motivation is to be able to make use of all the great aspects of the
 python 'for' (no indexing or explict
 end condition check, etc.) and at the same time avoiding a 'break' from the
 'for'.

There is one good reason not to use breaks: itertools.
I often prefer a for-over-a-properly-constrained-iterable to a
for-with-a-break, but there's no real reason to ever prefer a while.

That said, why add this to the syntax when there's already
functionality that gives you what you want? Just use
itertools.takewhile as Ian Kelly says.

 (NOTE:  Many people are being taught to avoid 'break' and 'continue' at all
 costs, so they instead convert
 the clean 'for' into a less-clean 'while'.  Or they just let the 'for' run
 out.  You can argue against this teaching
 (at least for Python) but that doesn't mean it's not prevalent and
 prevailing.)

We shouldn't make a language around people are taught the language
badly - let us accommodate for their bad practices!

 [People who avoid the 'break' by functionalizing an inner portion of the
 loop are just kidding themselves and making
 their own code worse, IMO.]

 I'm not super familiar with CPython, but I'm pretty sure I could get this up
 and working without too much effort.
 The mandatory 'and' makes sense because 'or' would hold the end value valid
 (weird) and not accomplish much.
 The condition itself could of course have multiple parts to it, including
 'or's.

 It's possible the name 'fwhile' is not optimal, but that shouldn't affect
 the overall merit/non-merit of the concept.

Possible? It's more than just possible, *wink*.

 Comments and Questions welcome.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What's wrong with this code? (UnboundLocalError: local variable referenced before assignment)

2013-06-24 Thread Joshua Landau
On 24 June 2013 21:19,  pablobarhamal...@gmail.com wrote:
 Thank's to you all!

 Setting isWhite as global worked fine.
 I'll probably be back soon with another silly question, see you then :)

By the way, it's normally bad to use globals like this. When you're
learning it's something you just do, though; it's fine for now.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What's wrong with this code? (UnboundLocalError: local variable referenced before assignment)

2013-06-24 Thread Dave Angel

On 06/24/2013 04:12 PM, John Gordon wrote:

In b3d3518a-f24a-4c32-a41a-b99145753...@googlegroups.com 
pablobarhamal...@gmail.com writes:


isWhite = True

def change(event):
 if event.x  x1 and event.x  x2 and event.y  y1 and event.y  y2:
 if isWhite:
 w.itemconfig(rect, fill=blue)
 isWhite = False
 else:
 w.itemconfig(rect, fill=white)
 isWhite = True

w.bind(Button-1, change)

root.mainloop()



The problem occurs when clicking on the white square. The following error
appears:
if isWhite:
UnboundLocalError: local variable 'isWhite' referenced before assignment



However, the isWhite variable is clearly defined at True a few lines
before.


Since you're new to programming, this might be a bit tricky to explain,
but I'll do my best. :-)

The problem is that change() isn't being executed here; instead it's being
executed from within root.mainloop(), whenever the user presses button-1.

And within root.mainloop(), there is no variable called isWhite.



Actually that's irrelevant.  Whether or not there's one global with the 
same name, or twenty-three object attributes with the same name, the 
fact that there's a binding of the local makes that name a local.  The 
only way to avoid that is not to bind, or to use global or nonlocal 
declarations.



Pablo:  Global variables are generally frowned upon, unless they're 
constant.  If they're constant, use ALLCAPS to indicate that.  Since 
this is not, it would normally be an attribute of some object, in your 
case, possibly the object w.  And of course, w should have been an 
argument to the function as well, since you're operating on it.  But you 
may be stuck with that, because of tkinter's design.  Anyway, you can assign

w.isWhite = True

and access
if w.isWhite

with impunity, since w is not being bound inside the function.


When you need to pass extra arguments that the event model doesn't allow 
for, one approach is to use functools.partial().


And it's also possible that there's a method (in tkinter) on event that 
let's you find the object that it's acting upon, w.  In this case, you 
could avoid needing a global at all, which would be a big improvement. 
Especially when you decide to have multiple such boxes, and want each to 
be able to toggle colors independently.



--
DaveA
--
http://mail.python.org/mailman/listinfo/python-list


Re: Is this PEP-able? fwhile

2013-06-24 Thread jimjhb
I find itertools clumsy and wordy.  You shouldn't have to have a lambda 
expression just to break out of a for!

I agree to not cater to bad practices, but if a clean improvement is possible 
it will practically help code
overall, even if theoretically people shouldn't be adopting a practice (don't 
use breaks) to the wrong
circumstance (the python 'for' is not like other fors in other languages).


-Jim



-Original Message-
From: Joshua Landau joshua.landau...@gmail.com
To: jimjhb jim...@aol.com
Cc: python-list python-list@python.org
Sent: Mon, Jun 24, 2013 4:41 pm
Subject: Re: Is this PEP-able? fwhile


On 24 June 2013 20:52,  jim...@aol.com wrote:
 Syntax:

 fwhile X in ListY and conditionZ:

 The following would actually exactly as:  for X in ListY:

 fwhile X in ListY and True:

 fwhile would act much like 'for', but would stop if the condition after the
 'and' is no longer True.

 The motivation is to be able to make use of all the great aspects of the
 python 'for' (no indexing or explict
 end condition check, etc.) and at the same time avoiding a 'break' from the
 'for'.

There is one good reason not to use breaks: itertools.
I often prefer a for-over-a-properly-constrained-iterable to a
for-with-a-break, but there's no real reason to ever prefer a while.

That said, why add this to the syntax when there's already
functionality that gives you what you want? Just use
itertools.takewhile as Ian Kelly says.

 (NOTE:  Many people are being taught to avoid 'break' and 'continue' at all
 costs, so they instead convert
 the clean 'for' into a less-clean 'while'.  Or they just let the 'for' run
 out.  You can argue against this teaching
 (at least for Python) but that doesn't mean it's not prevalent and
 prevailing.)

We shouldn't make a language around people are taught the language
badly - let us accommodate for their bad practices!

 [People who avoid the 'break' by functionalizing an inner portion of the
 loop are just kidding themselves and making
 their own code worse, IMO.]

 I'm not super familiar with CPython, but I'm pretty sure I could get this up
 and working without too much effort.
 The mandatory 'and' makes sense because 'or' would hold the end value valid
 (weird) and not accomplish much.
 The condition itself could of course have multiple parts to it, including
 'or's.

 It's possible the name 'fwhile' is not optimal, but that shouldn't affect
 the overall merit/non-merit of the concept.

Possible? It's more than just possible, *wink*.

 Comments and Questions welcome.

 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is this PEP-able? fwhile

2013-06-24 Thread jimjhb
Your syntax makes great sense.  Avoiding new keywords is obviously preferable.



-Original Message-
From: Fábio Santos fabiosantos...@gmail.com
To: jimjhb jim...@aol.com
Cc: python-list python-list@python.org
Sent: Mon, Jun 24, 2013 4:34 pm
Subject: Re: Is this PEP-able? fwhile


On Mon, Jun 24, 2013 at 8:52 PM,  jim...@aol.com wrote:
 Syntax:

 fwhile X in ListY and conditionZ:

 The following would actually exactly as:  for X in ListY:

 fwhile X in ListY and True:

 fwhile would act much like 'for', but would stop if the condition after the
 'and' is no longer True.

 The motivation is to be able to make use of all the great aspects of the
 python 'for' (no indexing or explict
 end condition check, etc.) and at the same time avoiding a 'break' from the
 'for'.

 (NOTE:  Many people are being taught to avoid 'break' and 'continue' at all
 costs, so they instead convert
 the clean 'for' into a less-clean 'while'.  Or they just let the 'for' run
 out.  You can argue against this teaching
 (at least for Python) but that doesn't mean it's not prevalent and
 prevailing.)

 [People who avoid the 'break' by functionalizing an inner portion of the
 loop are just kidding themselves and making
 their own code worse, IMO.]

 I'm not super familiar with CPython, but I'm pretty sure I could get this up
 and working without too much effort.
 The mandatory 'and' makes sense because 'or' would hold the end value valid
 (weird) and not accomplish much.
 The condition itself could of course have multiple parts to it, including
 'or's.

 It's possible the name 'fwhile' is not optimal, but that shouldn't affect
 the overall merit/non-merit of the concept.

 Comments and Questions welcome.

 Thanks.


I can see where you are coming from, but this is probably not going to
happen.  The and keyword is also

Also, the (amazing) python devs are concerned with overcomplicating
the language syntax, which is bad for: newbies, other implementations
of the language, and code readability. The syntax doesn't seem too
obvious, and there is a new keyword, fwhile.

This can probably be best achieved by adding to the existing for loop,
so maybe taking advantage of the existing for...if syntax and adding
for...while would be a better idea?

So, maybe:

for x in y while cond:

And for list/set/dict comprehensions and generator expressions:

[x for x in range(123) while cond]

Just maybe.

--
Fábio Santos

 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is this PEP-able? fwhile

2013-06-24 Thread Ian Kelly
On Mon, Jun 24, 2013 at 3:01 PM, Ian Kelly ian.g.ke...@gmail.com wrote:
 On Mon, Jun 24, 2013 at 2:34 PM, Fábio Santos fabiosantos...@gmail.com 
 wrote:
 This can probably be best achieved by adding to the existing for loop,
 so maybe taking advantage of the existing for...if syntax and adding
 for...while would be a better idea?

 The for...if syntax only exists for comprehensions and generators.  If
 we're going to add for...while for loops, then we might as well go
 ahead and add for...if loops there as well.

Which of course brings us to the for...if...while loop.  Or should it
be for...while...if?  Or do we allow both, and if so, are the
semantics the same or different?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is this PEP-able? fwhile

2013-06-24 Thread Ian Kelly
On Mon, Jun 24, 2013 at 2:34 PM, Fábio Santos fabiosantos...@gmail.com wrote:
 This can probably be best achieved by adding to the existing for loop,
 so maybe taking advantage of the existing for...if syntax and adding
 for...while would be a better idea?

The for...if syntax only exists for comprehensions and generators.  If
we're going to add for...while for loops, then we might as well go
ahead and add for...if loops there as well.

That said, I do like this syntax better than fwhile.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Looking for a name for a deployment framework...

2013-06-24 Thread jonathan . slenders
Thanks everyone, I'll think about it.

The main reason is that I'm working on the documentation, and this a a good 
opportunity to think about the naming. python-deploy-framework or 
python-deployer could be too boring.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python development tools

2013-06-24 Thread Cameron Simpson
On 24Jun2013 14:28, Grant Edwards invalid@invalid.invalid wrote:
| On 2013-06-23, cutems93 ms2...@cornell.edu wrote:
|  I am new to python development and I want to know what kinds of tools
|  people use for python development.
| 
|  1) emacs
|  2) Cpython
|  3) subversion
|  4) http://www.python.org/doc/
|  5) comp.lang.python 

1) vi/vim
2) Cpython
3) mercurial
4) local copy of http://www.python.org/doc/ for python 2 and 3
   (lets me work offline and snappier to browse)
5) python-list@python.org

| 99.9% of the programs I write are command-line tools.

99.9% of the programs I write are command-line tools.

Cheers,
-- 
Cameron Simpson c...@zip.com.au

The simple truth is that interstellar distances will not fit into the
human imagination. - Douglas Adams
-- 
http://mail.python.org/mailman/listinfo/python-list


(newbye) exceptions list for python3 classes

2013-06-24 Thread chrem

Hi,

what is the best way to find out all exceptions for a class?
E.g. I want to find out all exceptions related to the zipfile (I'm 
searching for the Bad password exception syntax).


thanks for your help or feedback,
Christophe
--
http://mail.python.org/mailman/listinfo/python-list


Re: What's wrong with this code? (UnboundLocalError: local variable referenced before assignment)

2013-06-24 Thread John Gordon
In mailman.3767.1372106609.3114.python-l...@python.org Dave Angel 
da...@davea.name writes:

  The problem is that change() isn't being executed here; instead it's being
  executed from within root.mainloop(), whenever the user presses button-1.
 
  And within root.mainloop(), there is no variable called isWhite.
 

 Actually that's irrelevant.  Whether or not there's one global with the 
 same name, or twenty-three object attributes with the same name, the 
 fact that there's a binding of the local makes that name a local.  The 
 only way to avoid that is not to bind, or to use global or nonlocal 
 declarations.

Quite right.  I should have verified my answer before posting.  Thanks
for setting me straight.  :-)

-- 
John Gordon   A is for Amy, who fell down the stairs
gor...@panix.com  B is for Basil, assaulted by bears
-- Edward Gorey, The Gashlycrumb Tinies

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is this PEP-able? fwhile

2013-06-24 Thread Chris Angelico
On Tue, Jun 25, 2013 at 5:52 AM,  jim...@aol.com wrote:
 (NOTE:  Many people are being taught to avoid 'break' and 'continue' at all
 costs...

Why? Why on earth should break/continue be avoided? I think that's the
solution: teach people that loops are there to be interrupted and
manipulated. And then it's a small step to jumping into the middle of
a loop, and from there to Duff's Device... hmm, I'm not sure that
strengthens my case, really. But anyway. Python has no issues with
breaking out of loops, and even has syntax specifically to complement
it (the 'else:' clause). Use break/continue when appropriate.

ChrisA
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: (newbye) exceptions list for python3 classes

2013-06-24 Thread chrem

Le 24/06/13 23:35, chrem a écrit :

Hi,

what is the best way to find out all exceptions for a class?
E.g. I want to find out all exceptions related to the zipfile (I'm
searching for the Bad password exception syntax).

thanks for your help or feedback,
Christophe


without exception, it shown:
RuntimeError: ('Bad password for file', zipfile.ZipInfo object at 
0x100756690)


then I tried:
except zipfile.BadPassword:
print(Password does not match)
but it returned:
AttributeError: 'module' object has no attribute 'BadPassword'




--
http://mail.python.org/mailman/listinfo/python-list


Re: Is this PEP-able? fwhile

2013-06-24 Thread Tim Chase
On 2013-06-25 07:38, Chris Angelico wrote:
 Python has no issues with breaking out of loops, and even has
 syntax specifically to complement it (the 'else:' clause). Use
 break/continue when appropriate.

from minor_gripes import breaking_out_of_nested_loops_to_top_level

-tkc


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is this PEP-able? fwhile

2013-06-24 Thread Chris Angelico
On Tue, Jun 25, 2013 at 8:30 AM, Tim Chase
python.l...@tim.thechases.com wrote:
 On 2013-06-25 07:38, Chris Angelico wrote:
 Python has no issues with breaking out of loops, and even has
 syntax specifically to complement it (the 'else:' clause). Use
 break/continue when appropriate.

 from minor_gripes import breaking_out_of_nested_loops_to_top_level

True. There are times I do wish for a 'goto'. But if goto were
implemented, I would also use it for jumping _into_ loops, and I'm not
sure that's going to make the feature popular :)

ChrisA
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is this PEP-able? fwhile

2013-06-24 Thread Ian Kelly
On Mon, Jun 24, 2013 at 4:41 PM, Fábio Santos fabiosantos...@gmail.com wrote:

 On 24 Jun 2013 22:29, Ian Kelly ian.g.ke...@gmail.com wrote:

 On Mon, Jun 24, 2013 at 2:34 PM, Fábio Santos fabiosantos...@gmail.com
 wrote:
  This can probably be best achieved by adding to the existing for loop,
  so maybe taking advantage of the existing for...if syntax and adding
  for...while would be a better idea?

 The for...if syntax only exists for comprehensions and generators.  If
 we're going to add for...while for loops, then we might as well go
 ahead and add for...if loops there as well.

 That said, I do like this syntax better than fwhile.

 Good point. Still, I don't see why for..if doesn't exist in for loops
 anyway. It may be lack of foresight, but I don't understand why at all.

Because it adds more syntax to learn when learning the language, it
introduces more maintenance overhead, and it offers no clear benefit
over simply nesting an if inside a for.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is this PEP-able? fwhile

2013-06-24 Thread Fábio Santos
On 24 Jun 2013 23:35, Tim Chase python.l...@tim.thechases.com wrote:

 On 2013-06-25 07:38, Chris Angelico wrote:
  Python has no issues with breaking out of loops, and even has
  syntax specifically to complement it (the 'else:' clause). Use
  break/continue when appropriate.

 from minor_gripes import breaking_out_of_nested_loops_to_top_level

 -tkc


for x, y in itertools.product(range(width), range(height)):
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is this PEP-able? fwhile

2013-06-24 Thread Fábio Santos
On 24 Jun 2013 22:29, Ian Kelly ian.g.ke...@gmail.com wrote:

 On Mon, Jun 24, 2013 at 2:34 PM, Fábio Santos fabiosantos...@gmail.com
wrote:
  This can probably be best achieved by adding to the existing for loop,
  so maybe taking advantage of the existing for...if syntax and adding
  for...while would be a better idea?

 The for...if syntax only exists for comprehensions and generators.  If
 we're going to add for...while for loops, then we might as well go
 ahead and add for...if loops there as well.

 That said, I do like this syntax better than fwhile.

Good point. Still, I don't see why for..if doesn't exist in for loops
anyway. It may be lack of foresight, but I don't understand why at all.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is this PEP-able? fwhile

2013-06-24 Thread Ian Kelly
On Mon, Jun 24, 2013 at 4:35 PM, Chris Angelico ros...@gmail.com wrote:
 On Tue, Jun 25, 2013 at 8:30 AM, Tim Chase
 python.l...@tim.thechases.com wrote:
 On 2013-06-25 07:38, Chris Angelico wrote:
 Python has no issues with breaking out of loops, and even has
 syntax specifically to complement it (the 'else:' clause). Use
 break/continue when appropriate.

 from minor_gripes import breaking_out_of_nested_loops_to_top_level

 True. There are times I do wish for a 'goto'. But if goto were
 implemented, I would also use it for jumping _into_ loops, and I'm not
 sure that's going to make the feature popular :)

You can have labeled break and continue without going all the way to a
goto statement.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is this PEP-able? fwhile

2013-06-24 Thread MRAB

On 24/06/2013 23:35, Chris Angelico wrote:

On Tue, Jun 25, 2013 at 8:30 AM, Tim Chase
python.l...@tim.thechases.com wrote:

On 2013-06-25 07:38, Chris Angelico wrote:

Python has no issues with breaking out of loops, and even has
syntax specifically to complement it (the 'else:' clause). Use
break/continue when appropriate.


from minor_gripes import breaking_out_of_nested_loops_to_top_level


True. There are times I do wish for a 'goto'. But if goto were
implemented, I would also use it for jumping _into_ loops, and I'm not
sure that's going to make the feature popular :)


I think a better way would be to label the outer loop somehow and then
break out of it by name.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Is this PEP-able? fwhile

2013-06-24 Thread Fábio Santos
On 25 Jun 2013 00:04, MRAB pyt...@mrabarnett.plus.com wrote:

 On 24/06/2013 23:35, Chris Angelico wrote:

 On Tue, Jun 25, 2013 at 8:30 AM, Tim Chase
 python.l...@tim.thechases.com wrote:

 On 2013-06-25 07:38, Chris Angelico wrote:

 Python has no issues with breaking out of loops, and even has
 syntax specifically to complement it (the 'else:' clause). Use
 break/continue when appropriate.


 from minor_gripes import breaking_out_of_nested_loops_to_top_level


 True. There are times I do wish for a 'goto'. But if goto were
 implemented, I would also use it for jumping _into_ loops, and I'm not
 sure that's going to make the feature popular :)

 I think a better way would be to label the outer loop somehow and then
 break out of it by name.

I like how discussions on this list tend to go off topic ;)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is this PEP-able? fwhile

2013-06-24 Thread Mark Lawrence

On 24/06/2013 23:30, Tim Chase wrote:

On 2013-06-25 07:38, Chris Angelico wrote:

Python has no issues with breaking out of loops, and even has
syntax specifically to complement it (the 'else:' clause). Use
break/continue when appropriate.


from minor_gripes import breaking_out_of_nested_loops_to_top_level

-tkc




Doesn't the goto module http://entrian.com/goto/ fix this? :)

--
Steve is going for the pink ball - and for those of you who are 
watching in black and white, the pink is next to the green. Snooker 
commentator 'Whispering' Ted Lowe.


Mark Lawrence

--
http://mail.python.org/mailman/listinfo/python-list


Re: Is this PEP-able? fwhile

2013-06-24 Thread Tim Chase
On 2013-06-24 23:39, Fábio Santos wrote:
 On 24 Jun 2013 23:35, Tim Chase wrote:
  On 2013-06-25 07:38, Chris Angelico wrote:
   Python has no issues with breaking out of loops, and even has
   syntax specifically to complement it (the 'else:' clause). Use
   break/continue when appropriate.
 
  from minor_gripes import breaking_out_of_nested_loops_to_top_level
 
 for x, y in itertools.product(range(width), range(height)):

This works nicely for certain use cases, but if there's additional
processing that needs to be done in the outer loops, it starts to get
hairy.  As Ian Kelly mentions, I could really dig a labeled
break/continue in Python (it's one of the few ideas I like that Java
made pretty popular; though I can't say I particularly care for
Java's implementation).  I'd love to see something like a decorator
where you could do things like the following pseudocode:

  @toplevel
  for i in range(height):
for j in range(width):
  for component in data[i,j]:
if condition:
  continue toplevel
elif other_condition:
  break toplevel
else:
  other processing

I'm not sure such a feature would ever arrive, but it would make it
easier than the current recommendation which is usually to either (1)
make inner loops into functions from which you can return; or (2)
raise a custom exception and then catch it in the outer loop.

-tkc




-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is this PEP-able? fwhile

2013-06-24 Thread Chris Angelico
On Tue, Jun 25, 2013 at 8:43 AM, Ian Kelly ian.g.ke...@gmail.com wrote:
 On Mon, Jun 24, 2013 at 4:41 PM, Fábio Santos fabiosantos...@gmail.com 
 wrote:

 On 24 Jun 2013 22:29, Ian Kelly ian.g.ke...@gmail.com wrote:

 On Mon, Jun 24, 2013 at 2:34 PM, Fábio Santos fabiosantos...@gmail.com
 wrote:
  This can probably be best achieved by adding to the existing for loop,
  so maybe taking advantage of the existing for...if syntax and adding
  for...while would be a better idea?

 The for...if syntax only exists for comprehensions and generators.  If
 we're going to add for...while for loops, then we might as well go
 ahead and add for...if loops there as well.

 That said, I do like this syntax better than fwhile.

 Good point. Still, I don't see why for..if doesn't exist in for loops
 anyway. It may be lack of foresight, but I don't understand why at all.

 Because it adds more syntax to learn when learning the language, it
 introduces more maintenance overhead, and it offers no clear benefit
 over simply nesting an if inside a for.

In more free-form languages, I implement this by simply omitting a line-break:

for (int i=0;inum_whatevers;++i) if (whatever[i].flag)
{
do_stuff;
}

Python could afford to lose a little rigidity here rather than gain
actual new syntax:

for i in range(10): if i%3:
print(i)

And there you are, the for-if filtered iteration model, just by
relaxing one rule.

ChrisA
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is this PEP-able? fwhile

2013-06-24 Thread Fábio Santos
On 25 Jun 2013 00:06, Fábio Santos fabiosantos...@gmail.com wrote:
 I like how discussions on this list tend to go off topic ;)

And now I'm off topic myself :(
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python development tools

2013-06-24 Thread Ben Finney
rusi rustompm...@gmail.com writes:

 On Monday, June 24, 2013 11:50:38 AM UTC+5:30, Ben Finney wrote:
  Any time someone has shown me a “Python script”, I don't see how
  it's different from what I'd call a “Python program”. So I just
  mentally replace “scripting with “programming”.

 If you are saying that python spans the scripting to programming
 spectrum exceptionally well, I agree. 

I'm saying that “scripting” is a complete subset of “programming”, so
it's nonsense to talk about “the scripting-to-programming spectrum”.

Scripting is, always, programming. Scripts are, always, programs. (But
not vice-versa; I do acknowledge there is more to programming than
scripting.) I say this because anything anyone has said to me about the
former is always something included already by the latter.

So I don't see much need for treating scripts as somehow distinct from
programs, or scripting as somehow distinct from programming. Whenever
you're doing the former, you're doing the latter by definition.

 I dont however think that the two philosophies are the same. See
 http://www.tcl.tk/doc/scripting.html

That essay constrasts “scripting” versus “system programming”, a useful
(though terminologically confusing) distinction.

It's a mistake to think that essay contrasts “scripting“ versus
“programming”. But the essay never justifies its aversion to
“programming” as a term for what it's describing, so that mistake is
easy to make.

-- 
 \   “A celebrity is one who is known by many people he is glad he |
  `\  doesn't know.” —Henry L. Mencken |
_o__)  |
Ben Finney

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: (newbye) exceptions list for python3 classes

2013-06-24 Thread alex23

On 25/06/2013 7:43 AM, chrem wrote:

Le 24/06/13 23:35, chrem a écrit :

what is the best way to find out all exceptions for a class?
E.g. I want to find out all exceptions related to the zipfile (I'm
searching for the Bad password exception syntax).


The only way is to look at the source code for the class and look for 
raise statements. However, not this will not show exceptions that may be 
raised by other objects it wraps or utilises, like file IO exceptions.



without exception, it shown:
RuntimeError: ('Bad password for file', zipfile.ZipInfo object at
0x100756690)

then I tried:
 except zipfile.BadPassword:
 print(Password does not match)
but it returned:
AttributeError: 'module' object has no attribute 'BadPassword'


The exception is prefixed to the message, try catching RuntimeError instead:

except RuntimeError as e:
if 'Bad password' in e.message:
print('Password does not match')
else:
raise e

In this example, I've re-raised the exception if it isn't a bad password 
problem, as it's not handled by my code. This is considered good 
practice: deal with the exceptions you can, ignore or re-raise the ones 
you can't.

--
http://mail.python.org/mailman/listinfo/python-list


Re: Is this PEP-able? fwhile

2013-06-24 Thread alex23

On 25/06/2013 6:12 AM, Ian Kelly wrote:

On Mon, Jun 24, 2013 at 1:52 PM,  jim...@aol.com wrote:

Syntax:
fwhile X in ListY and conditionZ:

fwhile would act much like 'for', but would stop if the condition after the
'and' is no longer True.


I would advocate using the break myself.  Another alternative is this:

for X in itertools.takewhile(lambda X: conditionZ, ListY):
 ...


I'd probably just go with a generator expression to feed the for loop:

for X in (i for i in ListY if conditionZ):


--
http://mail.python.org/mailman/listinfo/python-list


Re: (newbye) exceptions list for python3 classes

2013-06-24 Thread Ben Finney
chrem usenetnos...@chr1st0ph9.eu writes:

 Hi,

Howdy, congratulations on finding the Python programming language.

 what is the best way to find out all exceptions for a class?

Python is not Java. Your program doesn't need to know everything that
might happen; you should catch only those exceptions you can actually
deal with usefully, and let any others propagate.

 E.g. I want to find out all exceptions related to the zipfile (I'm
 searching for the Bad password exception syntax).

The documentation will describe the behaviour of the module; many
exceptions are implied by that (e.g. if the module deals with the
filesystem, you can expect OSError to be raised under certain
conditions).

Other exceptions will come from deeper within Python; e.g. if you give
text in a bad encoding you can expect UnicodeDecodeError, or if you give
it an object that can't be handled as expected you might get a TypeError.

But trying to get a complete set of all exceptions that might be raised
is a fool's errand. It would be futile, both because everything in
Python is an object and can therefore raise whatever exceptions are
appropriate, and also because even if you knew a complete set, you can't
usefully do anything consistent with such a huge set of exception types.

So, what is it you want to do one you know a set of exception types that
can be raised by the code?

 thanks for your help or feedback,

Hope that helps, and good fortune to you in learning to code Pythonically!

-- 
 \  “When we talk to God, we're praying. When God talks to us, |
  `\ we're schizophrenic.” —Jane Wagner, via Lily Tomlin, 1985 |
_o__)  |
Ben Finney

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is this PEP-able? fwhile

2013-06-24 Thread Fábio Santos
On 25 Jun 2013 00:31, alex23 wuwe...@gmail.com wrote:

 On 25/06/2013 6:12 AM, Ian Kelly wrote:

 On Mon, Jun 24, 2013 at 1:52 PM,  jim...@aol.com wrote:

 Syntax:
 fwhile X in ListY and conditionZ:

 fwhile would act much like 'for', but would stop if the condition after
the
 'and' is no longer True.


 I would advocate using the break myself.  Another alternative is this:

 for X in itertools.takewhile(lambda X: conditionZ, ListY):
  ...


 I'd probably just go with a generator expression to feed the for loop:

 for X in (i for i in ListY if conditionZ):
 

That is nice but it's not lazy. If the condition or the iterables took too
long to compute, it would be troublesome.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: n00b question on spacing

2013-06-24 Thread alex23

On 23/06/2013 3:43 AM, Mark Janssen wrote:

There was a recent discussion about this (under implicit string
concatenation).  It seems this is a part of the python language
specification that was simply undefined.


It's part of the language reference, not an accidental artifact:
http://docs.python.org/2/reference/lexical_analysis.html#string-literal-concatenation

--
http://mail.python.org/mailman/listinfo/python-list


Re: What is the semantics meaning of 'object'?

2013-06-24 Thread Steven D'Aprano
On Mon, 24 Jun 2013 08:58:23 -0700, Mark Janssen wrote:

 Mostly I'm saying that super() is badly named.

 What else would you call a function that does lookups on the current
 object's superclasses?
 
 ^.  You make a symbol for it.  ^__init__(foo, bar)

If you want Perl, you can find it here:

http://www.perl.org/


Or even more scary:

https://en.wikipedia.org/wiki/APL_syntax_and_symbols



^ won't do the job, because it's already used for bitwise-xor. I suppose 
that *technically* it could be used as either a binary or unary operator, 
like +, -, *, **, but I don't think it could be used as both an operator 
and an identifier.



-- 
Steven
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is this PEP-able? fwhile

2013-06-24 Thread alex23

On 25/06/2013 9:35 AM, Fábio Santos wrote:

  I'd probably just go with a generator expression to feed the for loop:
 
  for X in (i for i in ListY if conditionZ):
  

That is nice but it's not lazy. If the condition or the iterables took
too long to compute, it would be troublesome.


I'm not sure I follow. It's a generator expression, not a list 
comprehension, so the condition will be evaluated per item iterated over 
in the generator, not across all valid items in ListY at once.


--
http://mail.python.org/mailman/listinfo/python-list


Re: n00b question on spacing

2013-06-24 Thread Mark Janssen
On Mon, Jun 24, 2013 at 4:48 PM, alex23 wuwe...@gmail.com wrote:
 On 23/06/2013 3:43 AM, Mark Janssen wrote:

 There was a recent discussion about this (under implicit string
 concatenation).  It seems this is a part of the python language
 specification that was simply undefined.


 It's part of the language reference, not an accidental artifact:
 http://docs.python.org/2/reference/lexical_analysis.html#string-literal-concatenation

When I say specification, I mean specified in the formal notation
(BNF, etc).  whitespace is not defined (otherwise there would be a
line in the token list for linefeed and carriagereturn.

-- 
MarkJ
Tacoma, Washington
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is this PEP-able? fwhile

2013-06-24 Thread Fábio Santos
On 25 Jun 2013 01:08, alex23 wuwe...@gmail.com wrote:

 On 25/06/2013 9:35 AM, Fábio Santos wrote:

   I'd probably just go with a generator expression to feed the for loop:
  
   for X in (i for i in ListY if conditionZ):
   

 That is nice but it's not lazy. If the condition or the iterables took
 too long to compute, it would be troublesome.


 I'm not sure I follow. It's a generator expression, not a list
comprehension, so the condition will be evaluated per item iterated over in
the generator, not across all valid items in ListY at once.


for X in (i for i in open('largefile') if is_part_of_header(i)):

The above code would be wasting time on IO and processing. It would load
another line and calculate the condition for every line of the large file
and I just wanted to loop over the few header lines.

itertools.takewhile and fwhile/for..while actually stops the loop when the
condition is not meant, while your example keeps checking the condition
until the end of file, even though it is a generator expression.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is this PEP-able? fwhile

2013-06-24 Thread wu wei
On Tue, Jun 25, 2013 at 10:19 AM, Fábio Santos fabiosantos...@gmail.com
 wrote:

 for X in (i for i in open('largefile') if is_part_of_header(i)):

 The above code would be wasting time on IO and processing. It would load
 another line and calculate the condition for every line of the large file
 and I just wanted to loop over the few header lines.

 itertools.takewhile and fwhile/for..while actually stops the loop when the
 condition is not meant, while your example keeps checking the condition
 until the end of file, even though it is a generator expression.

Ah yes, of course, my bad.

It's still possible by raising a StopIteration within the condition
function:

def is_part_of_header(x):
if header_condition:
return True
else:
raise StopIteration

But yes, by this point any clarity of the generator expression approach
comes with the cost of more explicit setup of the breaking condition.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Looking for a name for a deployment framework...

2013-06-24 Thread Roy Smith
In article kqa28v$4us$1...@dont-email.me,
 Cousin Stanley cousinstan...@gmail.com wrote:

 jonathan.slend...@gmail.com wrote:
 
  Any suggestions for a good name, 
  for a framework that does 
  automatic server deployments ?
 
   asdf :  automatic server deployment framework

I prefer:

Quite Wonderful Electronic Rollout Tool
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is this PEP-able? fwhile

2013-06-24 Thread rusi
On Tuesday, June 25, 2013 3:08:57 AM UTC+5:30, Chris Angelico wrote:
 On Tue, Jun 25, 2013 at 5:52 AM,   wrote:
 
  (NOTE:  Many people are being taught to avoid 'break' and 'continue' at all
  costs...
 
 Why? Why on earth should break/continue be avoided?

Because breaks and continues are just goto-in-disguise?

[Well so is while and if and function-call and... Who is to say that?]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: (newbye) exceptions list for python3 classes

2013-06-24 Thread Dave Angel

On 06/24/2013 05:43 PM, chrem wrote:

Le 24/06/13 23:35, chrem a écrit :

Hi,

what is the best way to find out all exceptions for a class?
E.g. I want to find out all exceptions related to the zipfile (I'm
searching for the Bad password exception syntax).

thanks for your help or feedback,
Christophe


without exception, it shown:
RuntimeError: ('Bad password for file', zipfile.ZipInfo object at
0x100756690)

then I tried:
 except zipfile.BadPassword:


You cannot just make up a name, and hope that it's a valid exception 
type.  There is no such exception as zipfile.BadPassword.  There is an 
exception, zipfile.BadZipFile,

as mentioned  at
http://docs.python.org/3.3/library/zipfile.html#zipfile.BadZipFile

But of course that's not what you want.  The exception type above is 
RuntimeError, the part before the colon.




 print(Password does not match)
but it returned:
AttributeError: 'module' object has no attribute 'BadPassword'







--
DaveA
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python development tools

2013-06-24 Thread Reed Xia
在 2013年6月24日星期一UTC+8上午4时40分07秒,cutems93写道:
 Hello, 
 
 
 
 I am new to python development and I want to know what kinds of tools people 
 use for python development. I went to Python website and found several tools. 
 
 
 
 1. Automated Refactoring Tools
 
 2. Bug Tracking
 
 3. Configuration And BuildTools
 
 4. Distribution Utilities
 
 5. Documentation Tools
 
 6. Integrated Development Environments
 
 7. Python Debuggers
 
 8. Python Editors
 
 9. Python Shells
 
 10. Test Software
 
 11. Useful Modules
 
 12. Version Control
 
 
 
 What else do I need? Also, which software is used in daily base? I know 
 version control software and bug tracking software are used almost everyday 
 by developers. Which software is used less often? 
 
 
 
 Also, I will use GUI interface for Python. What kind of widget toolkits do 
 you recommend? I know there are GTK+ and Qt. 
 
 
 
 Thank you in advance!
 
 -Min S.-

It's a big question.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python development tools

2013-06-24 Thread rusi
On Tuesday, June 25, 2013 4:41:22 AM UTC+5:30, Ben Finney wrote:
 rusi  writes:
  I dont however think that the two philosophies are the same. See
  http://www.tcl.tk/doc/scripting.html
 
 That essay constrasts “scripting” versus “system programming”, a useful
 (though terminologically confusing) distinction.
 
 It's a mistake to think that essay contrasts “scripting“ versus
 “programming”. But the essay never justifies its aversion to
 “programming” as a term for what it's describing, so that mistake is
 easy to make.

The essay is 15 years old. So a bit dated. Referred to it as it conveys the 
sense/philosophy of scripting.

 
  On Monday, June 24, 2013 11:50:38 AM UTC+5:30, Ben Finney wrote:
   Any time someone has shown me a “Python script”, I don't see how
   it's different from what I'd call a “Python program”. So I just
   mentally replace “scripting with “programming”.
 
  If you are saying that python spans the scripting to programming
  spectrum exceptionally well, I agree. 
 
 I'm saying that “scripting” is a complete subset of “programming”, so
 it's nonsense to talk about “the scripting-to-programming spectrum”.
 
 Scripting is, always, programming. Scripts are, always, programs. (But
 not vice-versa; I do acknowledge there is more to programming than
 scripting.) I say this because anything anyone has said to me about the
 former is always something included already by the latter.
 
 So I don't see much need for treating scripts as somehow distinct from
 programs, or scripting as somehow distinct from programming. Whenever
 you're doing the former, you're doing the latter by definition.
 

My personal associations with the word 'scripting'

- Cavalier attitude towards efficiency
- No interest (and maybe some scorn) towards over-engineering (hence OOP)
- Heavy use of regular expressions, also sophistication of the command-line args
- A sense (maybe vague) of being glue more than computation, eg. a bash script 
is almost certain to invoke something other than builtins alone and is more 
likely to invoke a non-bash script than a bash script.  For a C program that 
likelihood is the other way round.  For python it could be either
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python development tools

2013-06-24 Thread MRAB

On 25/06/2013 03:24, rusi wrote:

On Tuesday, June 25, 2013 4:41:22 AM UTC+5:30, Ben Finney wrote:

rusi  writes:
 I dont however think that the two philosophies are the same. See
 http://www.tcl.tk/doc/scripting.html

That essay constrasts “scripting” versus “system programming”, a useful
(though terminologically confusing) distinction.

It's a mistake to think that essay contrasts “scripting“ versus
“programming”. But the essay never justifies its aversion to
“programming” as a term for what it's describing, so that mistake is
easy to make.


The essay is 15 years old. So a bit dated. Referred to it as it conveys the 
sense/philosophy of scripting.



 On Monday, June 24, 2013 11:50:38 AM UTC+5:30, Ben Finney wrote:
  Any time someone has shown me a “Python script”, I don't see how
  it's different from what I'd call a “Python program”. So I just
  mentally replace “scripting with “programming”.

 If you are saying that python spans the scripting to programming
 spectrum exceptionally well, I agree.

I'm saying that “scripting” is a complete subset of “programming”, so
it's nonsense to talk about “the scripting-to-programming spectrum”.

Scripting is, always, programming. Scripts are, always, programs. (But
not vice-versa; I do acknowledge there is more to programming than
scripting.) I say this because anything anyone has said to me about the
former is always something included already by the latter.

So I don't see much need for treating scripts as somehow distinct from
programs, or scripting as somehow distinct from programming. Whenever
you're doing the former, you're doing the latter by definition.



My personal associations with the word 'scripting'

- Cavalier attitude towards efficiency


And convenience for the programmer.

Manipulating long texts using variable-length strings? Yes, I know 
it's inefficient, but it's still faster than doing it by hand!



- No interest (and maybe some scorn) towards over-engineering (hence OOP)
- Heavy use of regular expressions, also sophistication of the command-line args
- A sense (maybe vague) of being glue more than computation, eg. a bash script 
is almost certain to invoke something other than builtins alone and is more 
likely to invoke a non-bash script than a bash script.  For a C program that 
likelihood is the other way round.  For python it could be either

Automating tasks, e.g. controlling other applications and stringing 
together tasks that you would otherwise be doing by hand.


--
http://mail.python.org/mailman/listinfo/python-list


Re: Python development tools

2013-06-24 Thread rusi
On Tuesday, June 25, 2013 8:09:19 AM UTC+5:30, MRAB wrote:


 And convenience for the programmer.
 
 Manipulating long texts using variable-length strings? Yes, I know 
 it's inefficient, but it's still faster than doing it by hand!

Well... did not say it because it tends to be emotionally charged :-)
C programmers find C convenient.
Haskell programmers find monads convenient
Python programmers are (increasingly) finding OOP convenient

 Automating tasks, e.g. controlling other applications and stringing 
 together tasks that you would otherwise be doing by hand.

Yes scripting is more programmer oriented as against GUIs which are more user 
oriented.
Related: scripting is more FP-ish, whereas GUIs are more OOP-ish.
A shell pipeline is really function composition in different syntax and a 
back-quoted command is close to a higher-order function.
By contrast a windows user clicks on a 'doc' and it just 'opens'
Many of them dont exactly know the diff between a doc and MsWord.
And even a supposed programmer (like yours truly) has a hell of a time finding 
the executable when needed.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is this PEP-able? fwhile

2013-06-24 Thread Chris Angelico
On Tue, Jun 25, 2013 at 12:01 PM, rusi rustompm...@gmail.com wrote:
 On Tuesday, June 25, 2013 3:08:57 AM UTC+5:30, Chris Angelico wrote:
 On Tue, Jun 25, 2013 at 5:52 AM,   wrote:

  (NOTE:  Many people are being taught to avoid 'break' and 'continue' at all
  costs...

 Why? Why on earth should break/continue be avoided?

 Because breaks and continues are just goto-in-disguise?

 [Well so is while and if and function-call and... Who is to say that?]

And that's still not a reason imho. You've just pointed out that
they're all control-flow. :)

ChrisA
-- 
http://mail.python.org/mailman/listinfo/python-list


io module and pdf question

2013-06-24 Thread jyoung79
Would like to get your opinion on this.  Currently to get the metadata out of a 
pdf file, I loop through the guts of the file.  I know it's not the greatest 
idea to do this, but I'm trying to avoid extra modules, etc.

Adobe javascript was used to insert the metadata, so the added data looks 
something like this:

XYZ:colorList=DarkBlue,Yellow

With python 2.7, it successfully loops through the file contents and I'm able 
to find the line that contains XYZ:colorList.

However, when I try to run it with python 3, it errors:

  File 
/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/codecs.py, 
line 300, in decode
(result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe2 in position 10: 
invalid continuation byte

I've done some research on this, and it looks like encoding it to latin-1 
works.  I also found that if I use the io module, it will work on both python 
2.7 and 3.3.  For example:

--
import io
import os

pdfPath = '~/Desktop/test.pdf'

colorlistData = ''

with io.open(os.path.expanduser(pdfPath), 'r', encoding='latin-1') as f:
for i in f:
if 'XYZ:colorList' in i:
colorlistData = i.split('XYZ:colorList')[1]
break

print(colorlistData)
--

As you can tell, I'm clueless in how exactly this works and am hoping someone 
can give me some insight on:
1. Is there another way to get metadata out of a pdf without having to install 
another module?
2. Is it safe to assume pdf files should always be encoded as latin-1 (when 
trying to read it this way)?  Is there a chance they could be something else?
3. Is the io module a good way to pursue this?

Thanks for your help!

Jay
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is this PEP-able? fwhile

2013-06-24 Thread Benjamin Kaplan
On Mon, Jun 24, 2013 at 8:54 PM, Chris Angelico ros...@gmail.com wrote:
 On Tue, Jun 25, 2013 at 12:01 PM, rusi rustompm...@gmail.com wrote:
 On Tuesday, June 25, 2013 3:08:57 AM UTC+5:30, Chris Angelico wrote:
 On Tue, Jun 25, 2013 at 5:52 AM,   wrote:

  (NOTE:  Many people are being taught to avoid 'break' and 'continue' at 
  all
  costs...

 Why? Why on earth should break/continue be avoided?

 Because breaks and continues are just goto-in-disguise?

 [Well so is while and if and function-call and... Who is to say that?]

 And that's still not a reason imho. You've just pointed out that
 they're all control-flow. :)

 ChrisA

The reason I was given (which I promptly ignored, of course) is that
it's best practice to only have one exit point for a block of code.
Only one way of terminating your loop, only one return per function,
never use exceptions, etc. I think it originally came about as a way
to make sure that your clean-up code was called (and to make it easier
for code reviewers to make sure your clean up code was called) and
then started being passed around as a rule among programming teachers
who didn't have any experience outside the classroom.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Looking for a name for a deployment framework...

2013-06-24 Thread Chris Rebert
On Jun 24, 2013 5:36 AM, jonathan.slend...@gmail.com wrote:

 Hi all,

 Any suggestions for a good name, for a framework that does automatic
server deployments?

 It's like Fabric, but more powerful.
 It has some similarities with Puppet, Chef and Saltstack, but is written
in Python.

Er, Salt is likewise written in Python.
(Your statement seemed to imply otherwise.)

Cheers,
Chris
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is this PEP-able? fwhile

2013-06-24 Thread Ian Kelly
On Mon, Jun 24, 2013 at 6:41 PM, wu wei wuwe...@gmail.com wrote:
 It's still possible by raising a StopIteration within the condition
 function:

 def is_part_of_header(x):
 if header_condition:
 return True
 else:
 raise StopIteration

Which is basically just taking the break and moving it to somewhere
else in the code, and meanwhile rendering the is_part_of_header
function non-reusable.
-- 
http://mail.python.org/mailman/listinfo/python-list


[issue18234] Unicodedata module should provide access to codepoint aliases

2013-06-24 Thread Marc-Andre Lemburg

Marc-Andre Lemburg added the comment:

On 23.06.2013 22:43, Alexander Belopolsky wrote:
 
 Alexander Belopolsky added the comment:
 
 unicodedata.name() was discussed in #12353 (msg144739) where MvL argued that 
 misspelled names are better than corrected because they are more likely to 
 appear misspelled in other sources.  I am not sure I buy this argument.  
 Someone googling for 'BYZANTINE MUSICAL SYMBOL FHTORA SKLIRON CHROMA VASIS' 
 will probably just enter BYZANTINE VASIS and find what he or she needs.  A 
 more likely scenario is someone trying to get all FTHORA symbols using a 
 naive code like this: [hex(i) for i in range(1114112) if 'FTHORA' in 
 ud.name(chr(i), '')].
 
 Even more likely scenario is someone seeing a fancy symbol on the web and 
 wanting to use it in a python program.  Such programmer would copy the symbol 
 to python prompt, call unicode.name() and copy the result in the program.  Do 
 we want to encourage people to perpetuate the mistake that Unicode has 
 corrected?
 
 I don't think the issue of control codes names was discussed in #12353.  I 
 see no downside with returning the first alias in case no name is present.

We should stick to the rules. Please leave the function as it
is, i.e. a 1-1 mapping to the official, non-changing Unicode
name reference (including spelling errors, etc). Same with
code points that have no name.

If you want to expose the aliases, you can do so in a new
function, say .aliases() which then returns the list of
aliases of a character (including the original name,
if available).

If we change the return values of .name() to whatever we think
would be more usable, we'd be modifying how Python programmers
see the Unicode database. That's not the purpose of the module.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18234
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



  1   2   3   >