Python Bootcamp - Last week to Register (June 20-24, 2011)

2011-06-14 Thread Chander Ganesan

Just a reminder that there are only 3 weeks remaining to register for
the Open Technology Group's Python Bootcamp, a 5 day hands-on,
intensive, in-depth introduction to Python.  This course is confirmed
and guaranteed to run.

Not up for summer travel?  Attend the hands-on, instructor-led class 
virtually - at a significant cost savings!


Worried about the costs of air and hotel to travel for training?  Don't!
 Our All-Inclusive Packages provide round-trip airfare and 
single-occupancy hotel accommodations (in a nice hotel!) and are 
available for all students attending from the Continental US, parts of 
Canada, and parts of Europe!  Best of all, these packages can be booked 
up to June 17, 2011!


For complete course outline/syllabus, or to enroll, call us at
877-258-8987 or visit our web site at:

http://www.otg-nc.com/python-bootcamp

OTG's Python Bootcamp is a 5 day intensive course that teaches
programmers how to design, develop, and debug applications using the
Python programming language.  Over a 5 day period through a set of
lectures, demonstrations, and hands-on exercises, students will learn 
how to develop powerful applications using Python and integrate their 
new found Python skills in their day-to-day job activities.  Students 
will also learn how to utilize Python's Database API to interface with

relational databases.

This Python course is available for on-site delivery world-wide (we
bring the class to you) for a group as small as 3, for as little as
$8,000 (including instructor travel  per-diem)!

Our course is guaranteed to run, regardless of enrollment, and available
in an all inclusive package that includes round-trip airfare, 5 nights
of hotel accommodation, shuttle services (to/from the airport, to/from
our facility, and to/from local eateries/shopping), and our training.
All-inclusive packages are priced from $2,595 for the 5 day course
(course only is $2,295) - or attend virtually for $1,995.

For more information - or to schedule an on-site course, please contact
us at 877-258-8987 .

The Open Technology Group is the world leader in the development and
delivery of training solutions focused around Open Source technologies.

--
Chander Ganesan
Open Technology Group, Inc.
One Copley Parkway, Suite 210
Morrisville, NC  27560
919-463-0999/877-258-8987
http://www.otg-nc.com






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

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


Leo 4.9 b4 released

2011-06-14 Thread Edward K. Ream
Leo 4.9 b4 is now available at: http://sourceforge.net/projects/leo/files/
If you have trouble downloading, please do try an alternate mirror.

Unless serious problems are reported, expect Leo 4.9 rc1 this Friday,
June 17
and 4.9 final on Tuesday, June 21.

Leo is a text editor, data organizer, project manager and much more.
See: http://webpages.charter.net/edreamleo/intro.html

**The highlights of Leo 4.9:**

- The Qt gui completely replaces the Tk gui--Qt gui now has all
essential
  features of Tk, including plugins.
- Completed Leo's autocompleter.
- The rendering pane can now display movies, html, svg images, etc.
- The scrolledmessage plugin can now use the rendering pane.
- Nodes may contain multiple @language directives.
- Leo highlights URL's everywhere. Ctrl-click URL's opens them in your
web
  browser.
- Leo uses an @file node's extension by default if there is no
@language
  directive in effect.
- Unified extract and import commands.
- Leo can now colorize multiple @language directives in a single node.
- Plain up/down arrow keys in headline-editing mode select a new node.
- New commands to insert, delete, change or print uA's.
- Added namespace directive to .leo files.
- Fixed many bugs, some important, others merely annoying.

Links:
--
Leo:  http://webpages.charter.net/edreamleo/front.html
Forum:http://groups.google.com/group/leo-editor
Download: http://sourceforge.net/projects/leo/files/
Bzr:  http://code.launchpad.net/leo-editor/
Quotes:   http://webpages.charter.net/edreamleo/testimonials.html

Edward K. Ream
June 14, 2011
-- 
http://mail.python.org/mailman/listinfo/python-announce-list

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


Wing IDE 4.0.3 released

2011-06-14 Thread Wingware

Hi,

Wingware has released version 4.0.3 of Wing IDE, an integrated development
environment designed specifically for the Python programming language.

Wing IDE is a cross-platform Python IDE that provides a professional code
editor with vi, emacs, and other key bindings, auto-completion, call tips,
refactoring, a powerful graphical debugger, version control, unit testing,
search, and many other features.

**Changes in Version 4.0.3**

This is a maintenance release with the following changes:

* Added ability to save and load test results
* Added ability to run unittest tests from the command line and save the 
results

  for loading into Wing
* Allow access to the search engine and source analysis from the 
scripting API

* Provide optional reminder when Support+Upgrades is expiring
* Added copy-selection-or-line command
* About 36 bug fixes for source analysis, refactoring, and other features

See the change log for details.

**New Features in Version 4.0**

Version 4.0 adds the following new major features:

* Refactoring -- Rename/move symbols, extract to function/method, and 
introduce variable

* Find Uses -- Find all points of use of a symbol
* Diff/Merge -- Graphical file and repository comparison and merge
* Django Support -- Debug Django templates, run Django unit tests, and more
* matplotlib Support -- Maintains live-updating plots in shell and debugger
* Simplified Licensing -- Includes all OSes and adds Support+Upgrades 
subscriptions


Complete change log:   
http://wingware.com/pub/wingide/4.0.3/CHANGELOG.txt

Details on licensing changes:  http://wingware.com/news/2011-02-16

**About Wing IDE**

Wing IDE is an integrated development environment designed specifically for
the Python programming language.  It provides powerful editing, testing, and
debugging features that help reduce development and debugging time, cut down
on coding errors, and make it easier to understand and navigate Python code.
Wing IDE can be used to develop Python code for web, GUI, and embedded
scripting applications.

Wing IDE is available in three product levels:  Wing IDE Professional is
the full-featured Python IDE, Wing IDE Personal offers a reduced feature
set at a low price, and Wing IDE 101 is a free simplified version designed
for teaching beginning programming courses with Python.

Version 4.0 of Wing IDE Professional includes the following major features:

* Professional quality code editor with vi, emacs, and other keyboard
  personalities
* Code intelligence for Python:  Auto-completion, call tips, find uses,
  goto-definition, error indicators, refactoring, smart indent and 
rewrapping,

  and source navigation
* Advanced multi-threaded debugger with graphical UI, command line 
interaction,

  conditional breakpoints, data value tooltips over code, watch tool, and
  externally launched and remote debugging
* Powerful search and replace options including keyboard driven and 
graphical

  UIs, multi-file, wild card, and regular expression search and replace
* Version control integration for Subversion, CVS, Bazaar, git, 
Mercurial, and

  Perforce
* Integrated unit testing with unittest, nose, and doctest frameworks
* Django support:  Debugs Django templates, provides project setup tools,
  and runs Django unit tests
* Many other features including project manager, bookmarks, code snippets,
  diff/merge tool, OS command integration, indentation manager, PyLint
  integration, and perspectives
* Extremely configurable and may be extended with Python scripts
* Extensive product documentation and How-Tos for Django, matplotlib,
  Plone, wxPython, PyQt, mod_wsgi, Autodesk Maya, and many other frameworks

Please refer to http://wingware.com/wingide/features for a detailed listing
of features by product level.

System requirements are Windows 2000 or later, OS X 10.3.9 or later 
(requires
X11 Server), or a recent Linux system (either 32 or 64 bit).  Wing IDE 
supports

Python versions 2.0.x through 3.2.x and Stackless Python.

For more information, see the http://wingware.com/

**Downloads**

Wing IDE Professional and Wing IDE Personal are commercial software and
require a license to run. A free trial can be obtained directly from the
product when launched.

Wing IDE Pro -- Full-featured product:
http://wingware.com/downloads/wingide/4.0

Wing IDE Personal -- A simplified IDE:
http://wingware.com/downloads/wingide-personal/4.0

Wing IDE 101 -- For teaching with Python:
http://wingware.com/downloads/wingide-101/4.0

**Purchasing and Upgrading**

Wing 4.0 requires an upgrade for Wing IDE 2.x and 3.x users at a cost of
1/2 the full product pricing.

Upgrade a license:   https://wingware.com/store/upgrade
Purchase a new license:  https://wingware.com/store/purchase

Optional Support+Upgrades subscriptions are available for expanded
support coverage and free upgrades to new major releases:

http://wingware.com/support/agreement

Thanks!

--

The Wingware Team
Wingware | Python IDE
Advancing Software 

Re: Binding was Re: Function declarations ?

2011-06-14 Thread Ethan Furman

Patty wrote:
So I am wondering if you learned this 
in Computer Science or Computer Engineering?, on the job?


I learned it on this list.  :)

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


Re: Keyboard Layout: Dvorak vs Colemak: is it Worthwhile to Improve the Dvorak Layout?

2011-06-14 Thread Xah Lee

On Jun 13, 6:45 pm, Gregory Ewing greg.ew...@canterbury.ac.nz wrote:
 Chris Angelico wrote:
  And did any of the studies take into account the fact that a lot of
  computer users - in all but the purest data entry tasks - will use a
  mouse as well as a keyboard?

 What I think's really stupid is designing keyboards with two
 big blocks of keys between the alphabetic keys and the mouse.
 Back when standard-grade keyboards didn't usually have a
 built-in numeric keypad, it was much easier to move one's
 right hand back and forth between the keyboard and mouse.

 Nowadays I find myself perpetually prone to off-by-one errors
 when moving back to the keyboard. :-(

numerical keypad is useful to many. Most people can't touch type. Even
for touch typist, many doesn't do the number keys. So, when they need
to type credit, phone number, etc, they go for the number pad. Also, i
think the number pad esentially have become a calculator for vast
majority of computer users. These days, almost all keyboard from
Microsoft or Logitech has a Calculator button near the number pad to
launch it.

i myself, am a qwerty typist since ~1987, also worked as data entry
clerk for a couple of years. Am a dvorak touch typist since 1994. (and
emacs since 1997) However, i never learned touch type the numbers on
the main section till i think ~2005. Since about 2008, the numerical
keypad is used as extra function keys.

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


Rant on web browsers

2011-06-14 Thread Chris Angelico
Random rant and not very on-topic. Feel free to hit Delete and move on.

I've just spent a day coding in Javascript, and wishing browsers
supported Python instead (or as well). All I needed to do was take two
dates (as strings), figure out the difference in days, add that many
days to both dates, and put the results back into DOM Input objects
(form entry fields). Pretty simple, right? Javascript has a Date
class, it should be fine. But no. First, the date object can't be
outputted as a formatted string. The only way to output a date is Feb
21 2011. So I have to get the three components (oh and the month is
0-11, not 1-12) and emit those. And Javascript doesn't have a simple
format function that would force the numbers to come out with leading
zeroes, so I don't bother with that.

What if I want to accept any delimiter in the date - slash, hyphen, or
dot? Can I just do a simple translate, turn all slashes and dots into
hyphens? Nope. Have to go regular expression if you want to change
more than the first instance of something. There's no nice string
parse function (like sscanf with %d-%d-%d), so I hope every browser
out there has a fast regex engine. When all you have is a half-ton
sledgehammer, everything looks like a really REALLY flat nail...

Plus, Javascript debugging is annoyingly difficult if you don't have
tools handy. I need third-party tools to do anything other than code
blind? Thanks.

Oh, and int i is illegal in Javascript. Whoops. That one is my fault, though.

Javascript's greatest strength is that it exists in everyone's
browser. That is simultaneously it's worst failing, because it becomes
nigh impossible to improve it. If Chrome's V8 starts supporting new
features and everyone else's JS engines don't, we can't use those
features. Even if they're added to the standard, there'll still be old
browsers that don't support things. The only way to add to the
language is to dump stuff into a .js file and include it everywhere.

But if anyone feels like writing an incompatible browser, please can
you add Python scripting?

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


Re: Keyboard Layout: Dvorak vs Colemak: is it Worthwhile to Improve the Dvorak Layout?

2011-06-14 Thread Xah Lee
On Jun 13, 6:19 am, Steven D'Aprano 〔steve
+comp.lang.pyt...@pearwood.info〕 wrote:

│ I don't know if there are any studies that indicate how much of a
│ programmer's work is actual mechanical typing but I'd be surprised
if it
│ were as much as 20% of the work day. The rest of the time being
thinking,
│ planning, debugging, communicating with customers or managers,
reading
│ documentation, testing, committing code, sketching data schemas on
the
│ whiteboard ... to say nothing of the dreaded strategy meetings.

you can find the study on my site. URL in the first post of this
thread.

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


Re: Keyboard Layout: Dvorak vs. Colemak: is it Worthwhile to Improve the Dvorak Layout?

2011-06-14 Thread Xah Lee


Ba Wha 13, 7:23 nz, Ehfgbz Zbql 〔ehfgbzcz...@tznvy.pbz〕 jebgr:
│ Qibenx -- yvxr djregl naq nal bgure xrlobneq ynlbhg -- nffhzrf gur
│ pbzchgre vf n glcrjevgre.
│ Guvf zrnaf va rssrpg ng yrnfg gjb pbafgenvagf, arprffnel sbe gur
│ glcrjevgre ohg abg sbe gur pbzchgre:
│
│ n. Gur glcvfg pna glcr bayl 1 xrl ng n gvzr
│ o. Bar (xrl)fgebxr trarengrf rknpgyl 1 yrggre
│
│ Rkprcgvbaf gb [n] ner Fuvsg (Pgey) rgp ohg pyrneyl va ehaavat hfr
gurl
│ ner gur rkprcgvba abg gur ehyr.
│
│ │ Jurer fcrrq ernyyl vf ivgny, fhpu nf sbe pbheg fgrabtencuref,
fcrpvny zrpunavpny
│ │ fubegunaq znpuvarf fhpu nf fgrabglcrf ner hfrq, pbfgvat gubhfnaqf
bs qbyynef ohg nyybjvat
│ │ gur glcvfg gb ernpu fcrrqf bs bire 300 jcz.
│
│ Lrf, vafgehzragf yvxr fgrabglcrf fcrrq hc glcvat ol hanffhzvat [n]
│ Yvxrjvfr cvnavfgf pna or fnvq (naq frra) gb qb zber ng gur cvnab
guna
│ glcvfgf ng n pbzchgre orpnhfr pubeqf ner cneg bs gur 'nyybjrq
│ ynathntr'.
│
│ Nffhzcgvba [o] yvxrjvfr vf haarprffnevyl erfgevpgvir ba n pbzchgre.
│ Guvax bs nyy gur 'nooeri/favccrg/fubegsbez/grzcyngr' flfgrzf yvxr
│ lnfavccrg, grkgzngr-favccrgf, rznpf/iv nooerif rgp.
│
│ Sbe beqvanel Ratyvfu gurer ner guvatf yvxr 
xrlfpevcguggc://jjj.serrjrof.pbz/pnfflwnarx
│
│ Sbe rknzcyr gur zbfg pbzzba jbeqf (rfgvzngrq gb or nebhaq 40% bs
│ Ratyvfu) ner fubegsbezrq nf:
│ o = ohg
│ p = jvgu
│ q = unq
│ r = guvf
│ s = bs
│ t = gung
│ u = gur
│ w = juvpu
│ a = naq
│ ...rgp rgp hcgb
│ m = jnf
│
│ gura pbzzba cuenfrf
│ noyr gb  = po
│ unq orra = qa
│ qb abg   = qk
│ qvq abg  = rk
│ qbrf abg = qfk
│
│ rgp
│
│ Pyrneyl, sbe cebtenzzref guvf vf hayvxryl gb or zhpu hfr --
│ cebtenzzvat ynathntrf ner abg Ratyvfu.
│
│ Ohg ohg vg vf pregnvayl na bcra dhrfgvba jurgure vs gur ercrngvat
│ cnggreaf va cebtenzzvat ynathntrf ner pncgherq vagb fbzr flfgrz, gur
│ erfhygvat orarsvg jbhyq or n zrer zvpeb-bcgvzvmngvba be fbzrguvat
zber
│ fvtavsvpnag.  V unir frra fbzr tbbq cebtenzzref fjrne ol
│ rznpf-lnfavccrgf, grkgzngr-favccrgf rgp.

gurer'f fcrpvny vachg qrivprf qrfvtarq sbe pubeqvat, pnyyrq pubeqvat
xrlobneq. Gurer'f qngnunaq. Ybbx hc Jvxvcrqvn sbe n yvfg.

gurer'f nyfb xvarfvf naq bguref gung jbexf jvgu sbbg crqnyf. Fb, vg'f
yvxr pubeqvat jvgu lbhe srrg gbb. Rire frra gubfr penml betnavfg jvgu
srrg ohfl ba 30 crqnyf?

unir lbh gevrq ibvpr vachg? Jvaqbjf pbzrf jvgu vg. Cerggl tbbq.
Gubhtu, qbrfa'g jbex fb jryy jvgu nccf vzcyrzragrq bhgfvqr bs ZF'f
senzrjbex, fhpu nf rznpf.

fbzr cebtenzre'f fbyhgvbaf:

〈Pryroevgl Cebtenzref jvgu EFV (Ercrgvgvir Fgenva Vawhel)〉
 uggc://knuyrr.bet/rznpf/rznpf_unaq_cnva_pryroevgl.ugzy

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


Re: I want this to work. [[]] * n

2011-06-14 Thread SherjilOzair
Thanks. This works. :)

Regards,
Sherjil Ozair
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Keyboard Layout: Dvorak vs. Colemak: is it Worthwhile to Improve the Dvorak Layout?

2011-06-14 Thread Xah Lee
for some reason, was unable to post the previous message. (but can
post others) So, the message is rot13'd and it works. Not sure what's
up with Google groups. (this happened a few years back once.
Apparantly, the message content  might have something to do with it
because rot13 clearly works. Yet, the problem doesnt seem to be my
name or embedded url, since it only happens with the previous message)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: working with raw image files

2011-06-14 Thread Martin De Kauwe
what is a .raw file, do you mean a flat binary?
-- 
http://mail.python.org/mailman/listinfo/python-list


ftplib: Software caused connection abort, how I solved it

2011-06-14 Thread Mad Sweeney

My program polls FTP servers at intervals for jobs to process.
Its running as a service on Windows server 2000 or 2003 :-(.
About 13% of times the retrbinary and less often the nlst calls would fail 
with

Software caused connection abort.
I could find no relevant solution on the intertubes.
I added blocksize=2048 to the retrbinary call which lowerd the failures to 
about 2% but that was still unsatisfactory for me.

When I added:
 socket.setdefaulttimeout(60)
to the setup stuff in order to solve a different problem, the connection 
abort errors went away completely.
Even when I restored retrbinary to use the default blocksize it still 
worked.


HTH


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


Re: Rant on web browsers

2011-06-14 Thread Martin P. Hellwig

On 14/06/2011 07:31, Chris Angelico wrote:
cut

But if anyone feels like writing an incompatible browser, please can
you add Python scripting?


You might find that Pyjamas already fill your needs python/javascript 
wise. It is truly great to just write python, translate it, and then 
have it work in the browser.


--
mph

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


Re: Rant on web browsers

2011-06-14 Thread Chris Angelico
On Tue, Jun 14, 2011 at 6:39 PM, Martin P. Hellwig
martin.hell...@gmail.com wrote:
 On 14/06/2011 07:31, Chris Angelico wrote:
 cut

 But if anyone feels like writing an incompatible browser, please can
 you add Python scripting?

 You might find that Pyjamas already fill your needs python/javascript wise.
 It is truly great to just write python, translate it, and then have it work
 in the browser.

I had a (very) quick glance at that; it entails a fairly large library
that has to get loaded. It still comes down to the only way to
improve this is to dish out a huge helping of .js to everyone who
comes, which imho is unideal.

That said, though, my context for this job was tiny thing, just do
the same as you're doing on the back-end. For something larger, I may
well give Pyjamas a whirl.

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


UPnP client

2011-06-14 Thread Nikos Fotoulis
Hi.

Recently i needed some code to be able to listen on the public IP
address outside my modem router. Eventually, i came up with a
minimal UPnP implementation and because it seems to work and i'm
happy about it, i've decided to post it here at clpy in case
anybody else may have a use for it. You never know


# NAT Traversal via UPnP Port Mapping
# Written by Nikos Fotoulis niko...@gmx.com
# This code is public domain.
#
# Tested on Thomsom TG858v7 modem router.
# UPnP is hairy. May not work with other routers
# Feedback is welcome.

import re, thread, socket, traceback as tb, random
from time import sleep
from urlparse import urlparse
from urllib import urlopen
import urllib2

VERBOSE = VVERBOSE = False
DEFAULT_ADDR = UPNPS = None

# regexes
rWANIP = re.compile (rST:[^\n]*(WAN(IP|PPP)Connection:\d+), re.I).search
rLOCATION = re.compile (rLoCaTiON:([^\n]+), re.I).search
def rTAG (t):
return re.compile (%s(.+?)/%s%(t, t), re.I|re.DOTALL)
rSERVICE = rTAG (service).findall

for tag in [controlURL, URLBase, NewExternalIPAddress, 
NewLeaseDuration, NewProtocol,
NewInternalClient, NewExternalPort, NewInternalPort]:
def f (txt, r=rTAG (tag).search):
x = r (txt)
if x:
return x. groups ()[0].strip ()
if tag.startswith (New):
tag = tag [3:]
globals () [r + tag.upper ()] = f

# multicast and discover UPnP gateways
# Returns a dictionary where the keys are our external IP addresses
def DiscoverUPnP ():
global UPNPS, DEFAULTGW, DEFAULTIFACE, DEFAULT_ADDR
S = {}
UPNPS = {}

s = socket.socket (socket.AF_INET, socket.SOCK_DGRAM)
s.setsockopt (socket.IPPROTO_IP, socket.IP_MULTICAST_TTL, 2)
#s.setsockopt (socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
R = M-SEARCH * HTTP/1.1\r\nHOST: 239.255.255.250:1900\r\nMAN: 
ssdp:discover\r\nMX: 10\r\nST: ssdp:all\r\n\r\n
try: s.sendto (R, (239.255.255.250, 1900))
except:
print UPnP gateways unreachable
return

timeout = 5
while 1:
s.settimeout (timeout)
try:
data, addr = s.recvfrom (4096)
except:
break
timeout = max (timeout * 0.5, 0.01)
r = rWANIP (data)
if r:
service = r.groups ()[0]
r = rLOCATION (data)
if r:
location = r.groups () [0].strip ()
if VERBOSE:
print server:, addr, supports, 
service, at, location
S [addr] = service, location
if VVERBOSE: print +

for userver, (service, location) in S.items ():
up = urlparse (location)
netloc = up.netloc
if : in netloc: server, _, port = netloc.partition (:)
else: server, port = netloc, 80
data = urlopen (location).read ()

URLBase = rURLBASE (data) or http://%s:%s%(server, port)
controlURL = None
for x in rSERVICE (data):
if service in x:
controlURL = rCONTROLURL (x)
break
if controlURL:
addr = GetExternalIP (service, URLBase + controlURL)
if addr:
s = socket.socket (socket.AF_INET, 
socket.SOCK_STREAM)
s.connect ((server, int (port)))
thishost = s.getsockname () [0]
s.close ()
UPNPS [server] = addr, service, URLBase + 
controlURL, thishost
if VERBOSE:
print for server:, server, 
controlURL:, controlURL
else:
print No controlURL found for server:, server

# set defaults
if len (UPNPS) == 1:
k = UPNPS.items ()[0]
DEFAULT_ADDR, DEFAULTGW, DEFAULTIFACE = k [1][0], k [0], k 
[1][3]
else:
print Multiple UPnP gateways!

return UPNPS


# generic request POST data
def envelope (request, service, **kw):
return ?xml version=1.0?
s:Envelope xmlns:s=http://schemas.xmlsoap.org/soap/envelope/; 
s:encodingStyle=http://schemas.xmlsoap.org/soap/encoding/;
s:Body
u:%s xmlns:u=urn:schemas-upnp-org:service:%s
%(request, service) + \n.join ([%s%s/%s%(k,v,k) for k, v in kw.items 
()]) +  /u:%s
/s:Body
/s:Envelope%request

def Request (service, URL, request, **kw):
req = urllib2.Request (URL)
req.add_header (content-type,'text/xml; charset=utf-8')
req.add_header (SOAPACTION, 

Python-URL! - weekly Python news and links (Jun 14)

2011-06-14 Thread Cameron Laird
[Originally drafted by Gabriel Genellina.]

QOTW: Well, it's incompatible with the Python compiler I keep in my
head. Have
these developers no consideration for backward-thinking-
compatibility?
   (Ben Finney, 2011-06-10, on certain old but not-so-obvious change)


   Python versions 2.7.2 and 3.1.4 (final) have been released!
   http://www.python.org/news/

   Formatting numbers with dynamic width and padding:
   http://groups.google.com/group/comp.lang.python/t/52810ad96a5e759b/

   How good is security via hashing?
   http://groups.google.com/group/comp.lang.python/t/2bfe26882f3de56f/

   Is it possible to omit the parentheses when writing a decorator
accepting
   optional arguments?
   http://groups.google.com/group/comp.lang.python/t/3adbb4ec23b38b31/

   Inheriting docstrings
   http://groups.google.com/group/comp.lang.python/t/af47222fd9188506/

   virtualenv has extremely powerful capabilities.  How will they
   reach Python?
   http://mail.python.org/pipermail/python-dev/2011-June/111903.html

   The regular expressions culture:
   http://groups.google.com/group/comp.lang.python/t/4df6669917ef2bfd/

   How and when metaclasses are actually used:
   http://groups.google.com/group/comp.lang.python/t/a48f5efafc287c68/

   Unicode handling when stdout is not a tty:
   http://groups.google.com/group/comp.lang.python/t/293dab4db766b68a/
   http://thread.gmane.org/gmane.comp.python.general/692355

   The difference between dot and bracket notation:
   http://groups.google.com/group/comp.lang.python/t/e0ea54b326d14c6e/



Everything Python-related you want is probably one or two clicks away
in
these pages:

   Python.org's Python Language Website is the traditional
   center of Pythonia
   http://www.python.org
   Notice especially the master FAQ
   http://www.python.org/doc/FAQ.html

   Just beginning with Python?  This page is a great place to start:
   http://wiki.python.org/moin/BeginnersGuide/Programmers

   Planet Python:  you want to visit there:
   http://planet.python.org
   But don't confuse it with Planet SciPy:
   http://planet.scipy.org
   And don't confuse *that* with SciPyTip, a high-quality daily (!)
tip
   for the numerically-inclined:
   http://twitter.com/SciPyTip

   Python Insider is the official blog of the Python core development
   team:
   
http://pyfound.blogspot.com/2011/03/python-dev-launches-python-insider-blog.html

   The Python Software Foundation (PSF) has replaced the Python
   Consortium as an independent nexus of activity.  It has official
   responsibility for Python's development and maintenance.
   http://www.python.org/psf/
   Among the ways you can support PSF is with a donation.
   http://www.python.org/psf/donations/
   Keep up with the PSF at Python Software Foundation News:
   http://pyfound.blogspot.com

   The Python Papers aims to publish the efforts of Python
enthusiasts:
   http://pythonpapers.org/

   Doug Hellman's Module of the week is essential reading:
   http://www.doughellmann.com/PyMOTW/

   comp.lang.python.announce announces new Python software.  Be
   sure to scan this newsgroup weekly.
   http://groups.google.com/group/comp.lang.python.announce/topics

   Python411 indexes podcasts ... to help people learn Python ...
   Updates appear more-than-weekly:
   http://www.awaretek.com/python/index.html

   The Python Package Index catalogues packages.
   http://www.python.org/pypi/

   Much of Python's real work takes place on Special-Interest Group
   mailing lists
   http://www.python.org/sigs/

   Python Success Stories--from air-traffic control to on-line
   match-making--can inspire you or decision-makers to whom you're
   subject with a vision of what the language makes practical.
   http://www.pythonology.com/success

   The Summary of Python Tracker Issues is an automatically generated
   report summarizing new bugs, closed ones, and patch submissions.
   
http://search.gmane.org/?author=status%40bugs.python.orggroup=gmane.comp.python.develsort=date

   nullege is an interesting search Web application, with the
intelligence
   to distinguish between Python code and comments.  It provides what
   appear to be relevant results, and demands neither Java nor CSS be
   enabled:
   http://www.nullege.com

   Although unmaintained since 2002, the Cetus collection of Python
   hyperlinks retains a few gems.
   http://www.cetus-links.org/oo_python.html

   The Cookbook is a collaborative effort to capture useful and
   interesting recipes:
   http://code.activestate.com/recipes/langs/python/

   Many Python conferences around the world are in preparation.
   Watch this space for links to them.

   Among several Python-oriented RSS/RDF feeds available, see:
   http://www.python.org/channews.rdf
   For more, see:
   

Dictionaries and incrementing keys

2011-06-14 Thread Steve Crook
Hi all,

I've always done key creation/incrementation using:

if key in dict:
dict[key] += 1
else:
dict[key] = 1

Today I spotted an alternative:

dict[key] = dict.get(key, 0) + 1

Whilst certainly more compact, I'd be interested in views on how
pythonesque this method is.
-- 
http://mail.python.org/mailman/listinfo/python-list


pkg_resources ?

2011-06-14 Thread km
Hi all,

I am trying to  look at the source code of a python  script (run.py). But
it  reads
###code - run.py 
#!/usr/bin/env python
# EASY-INSTALL-SCRIPT: 'pbpy==0.1','run.py'
__requires__ = 'pbpy==0.1'
import pkg_resources
pkg_resources.run_script('pbpy==0.1', 'run.py')
##code #

What are the advantages of using pkg_resources stuff ?

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


Re: Dictionaries and incrementing keys

2011-06-14 Thread Peter Otten
Steve Crook wrote:

 I've always done key creation/incrementation using:
 
 if key in dict:
 dict[key] += 1
 else:
 dict[key] = 1

Your way is usually faster than
 
 dict[key] = dict.get(key, 0) + 1
 
 Whilst certainly more compact, I'd be interested in views on how
 pythonesque this method is.

You may also consider

http://docs.python.org/library/collections.html#collections.defaultdict
http://docs.python.org/library/collections.html#collections.Counter
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Keyboard Layout: Dvorak vs Colemak: is it Worthwhile to Improve the Dvorak Layout?

2011-06-14 Thread Elena
On 13 Giu, 11:22, Chris Angelico ros...@gmail.com wrote:
 On Mon, Jun 13, 2011 at 6:42 PM, Yang Ha Nguyen cmp...@gmail.com wrote:

  Could you show which studies?  Do they do research just about habit or
  other elements (e.g. movement rates, comfortablility, ...) as well?
  Have they ever heard of RSI because of repetitive movements?

 And did any of the studies take into account the fact that a lot of
 computer users - in all but the purest data entry tasks - will use a
 mouse as well as a keyboard? The classic grasp mouse sitting to the
 right of the keyboard mandates either a one-handed typing style (left
 hand on keyboard, right hand on mouse) or constant re-aiming and
 re-grasping. Or you can use a touchpad; what are the consequences of
 that on typing speed? And my personal favorite, the IBM TrackPoint - a
 stick mouse between the G/H/B keys, a design which other manufacturers
 have since copied (although IMHO the IBM/Lenovo type still beats the
 others hands down) - keep your hands where you want them and just
 reach out to grab the mouse with your index finger, or slide your
 fingers one key over (works fine if you're used to it).

 Typing speed depends on a lot more than just your layout, and it's
 going to be nearly impossible to narrow it down viably.

 Chris Angelico

Moreover, I've seen people move the mouse faster than I could achieve
the same task by keyboard.

To me, the advantage of ergonomic layout is not about speed - I'm sure
there will always be people able to type blazingly fast on any random
layout - but about comfort.  Even when typing slowly, I don't want my
fingers and my hands neither moving much more nor contorting much more
than necessary.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Dictionaries and incrementing keys

2011-06-14 Thread AlienBaby
On Jun 14, 12:16 pm, Peter Otten __pete...@web.de wrote:
 Steve Crook wrote:
  I've always done key creation/incrementation using:

  if key in dict:
      dict[key] += 1
  else:
      dict[key] = 1

 Your way is usually faster than

  dict[key] = dict.get(key, 0) + 1

  Whilst certainly more compact, I'd be interested in views on how
  pythonesque this method is.

 You may also consider

 http://docs.python.org/library/collections.html#collections.defaultdicthttp://docs.python.org/library/collections.html#collections.Counter



How do those methods compare to the one I normally use;

try:
 dict[key]+=1
except:
 dict[key]=1

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


Re: Rant on web browsers

2011-06-14 Thread Novocastrian_Nomad
CoffeeScript maybe? http://jashkenas.github.com/coffee-script
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Dictionaries and incrementing keys

2011-06-14 Thread Steve Crook
On Tue, 14 Jun 2011 05:37:45 -0700 (PDT), AlienBaby wrote in
Message-Id: 078c5e9a-8fad-4d4c-b081-f69d0f575...@v11g2000prk.googlegroups.com:

 How do those methods compare to the one I normally use;

 try:
  dict[key]+=1
 except:
  dict[key]=1

This is a lot slower in percentage terms.  You should also qualify the
exception: except KeyError
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Dictionaries and incrementing keys

2011-06-14 Thread Steve Crook
On Tue, 14 Jun 2011 13:16:47 +0200, Peter Otten wrote in
Message-Id: it7fu4$rc5$1...@solani.org:

 Your way is usually faster than
  
 dict[key] = dict.get(key, 0) + 1

Thanks Peter, ran it through Timeit and you're right. It's probably also
easier to read the conditional version, even if it is longer.

 You may also consider

 http://docs.python.org/library/collections.html#collections.defaultdict
 http://docs.python.org/library/collections.html#collections.Counter

Useful functions, thanks again.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Dictionaries and incrementing keys

2011-06-14 Thread Steven D'Aprano
On Tue, 14 Jun 2011 10:57:44 +, Steve Crook wrote:

 Hi all,
 
 I've always done key creation/incrementation using:
 
 if key in dict:
 dict[key] += 1
 else:
 dict[key] = 1
 
 Today I spotted an alternative:
 
 dict[key] = dict.get(key, 0) + 1
 
 Whilst certainly more compact, I'd be interested in views on how
 pythonesque this method is.

Either version is perfectly fine. There's no reason to avoid either other 
than personal preference.

The if key in dict version does up to three item lookups (first to see 
if the key is in the dict, then to fetch the value, then to assign it), 
the version with dict.get only does two.

If the key has an expensive hash function, the version using dict.get 
will be much faster:

 key = (abcdefgh*1, 5**30, frozenset(range(1))) * 30

 from timeit import Timer

 t1 = Timer(if key in d:
... d[key] += 1
... else:
... d[key] = 1
... , from __main__ import key; d = {key: 0})

 t2 = Timer(d[key] = d.get(key, 0) + 1, 
... from __main__ import key; d = {key: 0})

 min(t1.repeat())
8.739075899124146
 min(t2.repeat())
6.425030946731567

but that will rarely be a problem in practice. For normal keys which 
are small strings or ints, the if key in dict version will usually be 
faster. Unless there are lots of missing keys, in which case the version 
using dict.get may be faster.

Either way, the difference is unlikely to be significant except for the 
tightest of tight loops. 


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


Leo 4.9 b4 released

2011-06-14 Thread Edward K. Ream
Leo 4.9 b4 is now available at: http://sourceforge.net/projects/leo/files/
If you have trouble downloading, please do try an alternate mirror.

Unless serious problems are reported, expect Leo 4.9 rc1 this Friday,
June 17
and 4.9 final on Tuesday, June 21.

Leo is a text editor, data organizer, project manager and much more.
See: http://webpages.charter.net/edreamleo/intro.html

**The highlights of Leo 4.9:**

- The Qt gui completely replaces the Tk gui--Qt gui now has all
essential
  features of Tk, including plugins.
- Completed Leo's autocompleter.
- The rendering pane can now display movies, html, svg images, etc.
- The scrolledmessage plugin can now use the rendering pane.
- Nodes may contain multiple @language directives.
- Leo highlights URL's everywhere. Ctrl-click URL's opens them in your
web
  browser.
- Leo uses an @file node's extension by default if there is no
@language
  directive in effect.
- Unified extract and import commands.
- Leo can now colorize multiple @language directives in a single node.
- Plain up/down arrow keys in headline-editing mode select a new node.
- New commands to insert, delete, change or print uA's.
- Added namespace directive to .leo files.
- Fixed many bugs, some important, others merely annoying.

Links:
--
Leo:  http://webpages.charter.net/edreamleo/front.html
Forum:http://groups.google.com/group/leo-editor
Download: http://sourceforge.net/projects/leo/files/
Bzr:  http://code.launchpad.net/leo-editor/
Quotes:   http://webpages.charter.net/edreamleo/testimonials.html

Edward K. Ream
June 14, 2011
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Dictionaries and incrementing keys

2011-06-14 Thread Steven D'Aprano
On Tue, 14 Jun 2011 12:53:11 +, Steve Crook wrote:

 On Tue, 14 Jun 2011 05:37:45 -0700 (PDT), AlienBaby wrote in Message-Id:
 078c5e9a-8fad-4d4c-b081-f69d0f575...@v11g2000prk.googlegroups.com:
 
 How do those methods compare to the one I normally use;

 try:
  dict[key]+=1
 except:
  dict[key]=1
 
 This is a lot slower in percentage terms.  You should also qualify the
 exception: except KeyError

Not necessarily. It depends on how often you have KeyError.

By my measurements, if the key is usually present, it is faster to use 
try...except. Only if the key is frequently missing does it become faster 
to test first.


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


Re: Binding was Re: Function declarations ?

2011-06-14 Thread Patty


- Original Message - 
From: Ethan Furman et...@stoneleaf.us

To: python-list@python.org
Sent: Monday, June 13, 2011 10:55 PM
Subject: Re: Binding was Re: Function declarations ?



Patty wrote:
So I am wondering if you learned this 
in Computer Science or Computer Engineering?, on the job?


I learned it on this list.  :)

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


Smarty - I guess I can say the same thing - I understand it 


or was I supposed to add '+1' ?  I learned that on this list ;)

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


Re: Rant on web browsers

2011-06-14 Thread Patty


- Original Message - 
From: Chris Angelico ros...@gmail.com

To: python-list@python.org
Sent: Monday, June 13, 2011 11:31 PM
Subject: Rant on web browsers



Random rant and not very on-topic. Feel free to hit Delete and move on.

I've just spent a day coding in Javascript, and wishing browsers
supported Python instead (or as well). All I needed to do was take two
dates (as strings), figure out the difference in days, add that many
days to both dates, and put the results back into DOM Input objects
(form entry fields). Pretty simple, right? Javascript has a Date
class, it should be fine. But no. First, the date object can't be
outputted as a formatted string. The only way to output a date is Feb
21 2011. So I have to get the three components (oh and the month is
0-11, not 1-12) and emit those. And Javascript doesn't have a simple
format function that would force the numbers to come out with leading
zeroes, so I don't bother with that.

What if I want to accept any delimiter in the date - slash, hyphen, or
dot? Can I just do a simple translate, turn all slashes and dots into
hyphens? Nope. Have to go regular expression if you want to change
more than the first instance of something. There's no nice string
parse function (like sscanf with %d-%d-%d), so I hope every browser
out there has a fast regex engine. When all you have is a half-ton
sledgehammer, everything looks like a really REALLY flat nail...

Plus, Javascript debugging is annoyingly difficult if you don't have
tools handy. I need third-party tools to do anything other than code
blind? Thanks.

Oh, and int i is illegal in Javascript. Whoops. That one is my fault, 
though.


Javascript's greatest strength is that it exists in everyone's
browser. That is simultaneously it's worst failing, because it becomes
nigh impossible to improve it. If Chrome's V8 starts supporting new
features and everyone else's JS engines don't, we can't use those
features. Even if they're added to the standard, there'll still be old
browsers that don't support things. The only way to add to the
language is to dump stuff into a .js file and include it everywhere.

But if anyone feels like writing an incompatible browser, please can
you add Python scripting?

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




Hi Chris - I am just learning JavaScript and this was helpful to me, not a 
rant.  I am reading JavaScript:  The Good Parts so he is jumping around in 
topic and I can just use this when learning about dates and ints coming up.


Patty 


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


Re: Keyboard Layout: Dvorak vs Colemak: is it Worthwhile to Improve the Dvorak Layout?

2011-06-14 Thread Dotan Cohen
On Mon, Jun 13, 2011 at 10:21, Elena egarr...@gmail.com wrote:
 On 13 Giu, 06:30, Tim Roberts t...@probo.com wrote:
 Studies have shown that even a
 strictly alphabetical layout works perfectly well, once the typist is
 acclimated.

 Once the user is acclimated to move her hands much  more (about 40%
 more for Qwerty versus Dvorak), that is.


And disproportionate usage of fingers. On QWERTY the weakest fingers
(pinkies) do almost 1/4 of the keypresses when modifier keys, enter,
tab, and backspace are taken into account.

I'm developing a QWERTY-based layout that moves the load off the
pinkies and onto the index fingers:
http://dotancohen.com/eng/noah_ergonomic_keyboard_layout.html

There is a Colemak version in the works as well.

-- 
Dotan Cohen

http://gibberish.co.il
http://what-is-what.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Looking for Coders or Testers for an Open Source File Organizer

2011-06-14 Thread Matt Chaput

On 13/06/2011 11:55 PM, zainul franciscus wrote:

Iknow you guys must be thinking Hmm, Miranda, isn't that an IM
application ?; Yep I hear you, I'll change the name once I get a good
name. I am open for any suggestions.


Actually I was thinking isn't that a functional programming language?

My suggestion: Cruftbuster
--
http://mail.python.org/mailman/listinfo/python-list


Python Pickle Problems (Ellipsis + Other Objects)

2011-06-14 Thread Sunjay Varma
See more details in my forum post:

http://www.python-forum.org/pythonforum/viewtopic.php?f=18t=26724


I'm trying to pickle a bunch of functions (mostly built-in) and pickle keeps 
giving me errors. I have no Ellipsis in my data at all, and for some reason, 
pickle seems to think I do.

Here is an error I once received:
Traceback (most recent call last):
  File C:/Sunjay/My Website/projects/sunjay.ca/build/domath, line 132, in 
lt;modulegt;
    main()
  File C:/Sunjay/My Website/projects/sunjay.ca/build/domath, line 127, in main
    actions[action](form)
  File C:/Sunjay/My Website/projects/sunjay.ca/build/domath, line 107, in 
do_math
    print SESSION.output()
  File C:\Python27\lib\site-packages\session.py, line 207, in output
    self.commit()
  File C:\Python27\lib\site-packages\session.py, line 152, in commit
    dump(data, f, HIGHEST_PROTOCOL)
PicklingError: Can't pickle type 'ellipsis': attribute lookup 
__builtin__.ellipsis failed

As well as the data structure which I am pickling:
user_session = {'math_user': {'scope': {'int': type 'int', 'DEGREE': 
'DEGREE', 'atan': built-in function atan, 'pow': built-in function pow, 
'fsum': built-in function fsum, 'cosh': built-in function cosh, 'ldexp': 
built-in function ldexp, 'hypot': built-in function hypot, 'acosh': 
built-in function acosh, 'tan': built-in function tan, 'asin': built-in 
function asin, 'isnan': built-in function isnan, 'log': built-in function 
log, 'fabs': built-in function fabs, 'floor': built-in function floor, 
'atanh': built-in function atanh, 'sqrt': built-in function sqrt, 
'__package__': None, 'frexp': built-in function frexp, 'factorial': built-in 
function factorial, 'abs': built-in function abs, 'degrees': built-in 
function degrees, '_': 123, 'fib': session.FuncData instance at 0x02A6CD50, 
'pi': 3.141592653589793, 'log10': built-in function log10, '__doc__': 'This 
module is always available. It provides access to
 mathematical\nfunctions for complex numbers.', 'mode': session.FuncData 
instance at 0x02A6CD78, 'polar': built-in function polar, 'asinh': built-in 
function asinh, 'float': type 'float', 'fmod': built-in function fmod, 
'CALC_MODE': 'RADIAN', '__builtins__': {}, 'copysign': built-in function 
copysign, 'cos': built-in function cos, 'ceil': built-in function ceil, 
'atan2': built-in function atan2, 'isinf': built-in function isinf, 'sinh': 
built-in function sinh, 'phase': built-in function phase, '__name__': 
'cmath', 'rect': built-in function rect, 'trunc': built-in function trunc, 
'expm1': built-in function expm1, 'e': 2.718281828459045, 'tanh': built-in 
function tanh, 'radians': built-in function radians, 'sin': built-in 
function sin, 'lgamma': built-in function lgamma, 'erf': built-in function 
erf, 'Vector': class 'vector.Vector', 'erfc': built-in function erfc, 
'RADIAN': 'RADIAN', 'modf': built-in function
 modf, 'Ans': 123, 'exp': built-in function exp, 'acos': built-in function 
acos, 'log1p': built-in function log1p, 'round': built-in function round, 
'gamma': built-in function gamma}, 'history': [('123', 123)]}, 
'__date_loaded__': '2011-06-11'}

The above data structure can be simply put as so:
user_session = {
   math_user: {
      scope: {dictionary of all python math functions plus other types and 
functions},
      history: [list of previous commands],
      __date_loaded__: timestamp of today's date
      }
   }

Please help me find out why this code is failing:
 from cPickle import dump, HIGHEST_PROTOCOL
 dump(user_session, open(C:\\Session.dump, wb), HIGHEST_PROTOCOL)
Traceback (most recent call last):
  File pyshell#56, line 1, in module
    dump(SESSION.data, open(C:\\Session.dump, wb), HIGHEST_PROTOCOL)
PicklingError: Can't pickle type 'ellipsis': attribute lookup 
__builtin__.ellipsis failed
 
Thanks for your help,
Sunjay V. - www.sunjay.ca-- 
http://mail.python.org/mailman/listinfo/python-list


What is the Most Efficient Way of Printing A Dict's Contents Out In Columns?

2011-06-14 Thread Zachary Dziura
I have a dict that I would like to print out in a series of columns,
rather than as a bunch of lines. Normally when you do print(dict), the
output will look something like this:

{'Header2': ['2', '5', '8'], 'Header3': ['3', '6', '9'], 'Header1':
['1', '4', '7'], 'Header4': ['10', '11', '12']}

I can then iterate through (in this case) a list of the headers in
order to produce something similar to this:

Header1 = ['1', '4', '7']
Header2 = ['2', '5', '8']
Header3 = ['3', '6', '9']
Header4 = ['10', '11', '12']

What I want to know is how I can print out that information in a
column, where the header is the first line of the column, with the
data following underneath, like so:

Header1Header2Header3Header4
1  2  3   4
5  6  7   8
9  1011 12
-- 
http://mail.python.org/mailman/listinfo/python-list


Wing IDE 4.0.3 released

2011-06-14 Thread Wingware

Hi,

Wingware has released version 4.0.3 of Wing IDE, an integrated development
environment designed specifically for the Python programming language.

Wing IDE is a cross-platform Python IDE that provides a professional code
editor with vi, emacs, and other key bindings, auto-completion, call tips,
refactoring, a powerful graphical debugger, version control, unit testing,
search, and many other features.

**Changes in Version 4.0.3**

This is a maintenance release with the following changes:

* Added ability to save and load test results
* Added ability to run unittest tests from the command line and save the 
results

  for loading into Wing
* Allow access to the search engine and source analysis from the 
scripting API

* Provide optional reminder when Support+Upgrades is expiring
* Added copy-selection-or-line command
* About 36 bug fixes for source analysis, refactoring, and other features

See the change log for details.

**New Features in Version 4.0**

Version 4.0 adds the following new major features:

* Refactoring -- Rename/move symbols, extract to function/method, and 
introduce variable

* Find Uses -- Find all points of use of a symbol
* Diff/Merge -- Graphical file and repository comparison and merge
* Django Support -- Debug Django templates, run Django unit tests, and more
* matplotlib Support -- Maintains live-updating plots in shell and debugger
* Simplified Licensing -- Includes all OSes and adds Support+Upgrades 
subscriptions


Complete change log:   
http://wingware.com/pub/wingide/4.0.3/CHANGELOG.txt

Details on licensing changes:  http://wingware.com/news/2011-02-16

**About Wing IDE**

Wing IDE is an integrated development environment designed specifically for
the Python programming language.  It provides powerful editing, testing, and
debugging features that help reduce development and debugging time, cut down
on coding errors, and make it easier to understand and navigate Python code.
Wing IDE can be used to develop Python code for web, GUI, and embedded
scripting applications.

Wing IDE is available in three product levels:  Wing IDE Professional is
the full-featured Python IDE, Wing IDE Personal offers a reduced feature
set at a low price, and Wing IDE 101 is a free simplified version designed
for teaching beginning programming courses with Python.

Version 4.0 of Wing IDE Professional includes the following major features:

* Professional quality code editor with vi, emacs, and other keyboard
  personalities
* Code intelligence for Python:  Auto-completion, call tips, find uses,
  goto-definition, error indicators, refactoring, smart indent and 
rewrapping,

  and source navigation
* Advanced multi-threaded debugger with graphical UI, command line 
interaction,

  conditional breakpoints, data value tooltips over code, watch tool, and
  externally launched and remote debugging
* Powerful search and replace options including keyboard driven and 
graphical

  UIs, multi-file, wild card, and regular expression search and replace
* Version control integration for Subversion, CVS, Bazaar, git, 
Mercurial, and

  Perforce
* Integrated unit testing with unittest, nose, and doctest frameworks
* Django support:  Debugs Django templates, provides project setup tools,
  and runs Django unit tests
* Many other features including project manager, bookmarks, code snippets,
  diff/merge tool, OS command integration, indentation manager, PyLint
  integration, and perspectives
* Extremely configurable and may be extended with Python scripts
* Extensive product documentation and How-Tos for Django, matplotlib,
  Plone, wxPython, PyQt, mod_wsgi, Autodesk Maya, and many other frameworks

Please refer to http://wingware.com/wingide/features for a detailed listing
of features by product level.

System requirements are Windows 2000 or later, OS X 10.3.9 or later 
(requires
X11 Server), or a recent Linux system (either 32 or 64 bit).  Wing IDE 
supports

Python versions 2.0.x through 3.2.x and Stackless Python.

For more information, see the http://wingware.com/

**Downloads**

Wing IDE Professional and Wing IDE Personal are commercial software and
require a license to run. A free trial can be obtained directly from the
product when launched.

Wing IDE Pro -- Full-featured product:
http://wingware.com/downloads/wingide/4.0

Wing IDE Personal -- A simplified IDE:
http://wingware.com/downloads/wingide-personal/4.0

Wing IDE 101 -- For teaching with Python:
http://wingware.com/downloads/wingide-101/4.0

**Purchasing and Upgrading**

Wing 4.0 requires an upgrade for Wing IDE 2.x and 3.x users at a cost of
1/2 the full product pricing.

Upgrade a license:   https://wingware.com/store/upgrade
Purchase a new license:  https://wingware.com/store/purchase

Optional Support+Upgrades subscriptions are available for expanded
support coverage and free upgrades to new major releases:

http://wingware.com/support/agreement

Thanks!

--

The Wingware Team
Wingware | Python IDE
Advancing Software 

Re: Looking for Coders or Testers for an Open Source File Organizer

2011-06-14 Thread Zachary Dziura
 On Jun 13, 11:55 pm, zainul franciscus zainul.francis...@gmail.com wrote:
 I started an open source file organizer called Miranda.  Miranda is
 inspired by Belvedere written by Adam Pash of Lifehacker (http://
 lifehacker.com/341950/belvedere-automates-your-self+cleaning-pc). I
 know you guys must be thinking Hmm, Miranda, isn't that an IM
 application ?; Yep I hear you, I'll change the name once I get a good
 name. I am open for any suggestions.

 Miranda is written in Python, meant for Ubuntu, but hopefully it can
 be tested for every Linux Flavour. I have nothing much to offer in
 return for the software,but I will acknowledge your contribution in
 the software, and give credit to anyone helping when I feature Miranda
 in How-To Geek :http://www.howtogeek.com/

 I am a beginner in python, so the code may look a bit messy, and I am
 open to rewrite the code if I can get a mentor whom I can pair with
 for coding the application. I do have 7+ years of programming, web
 development, database, desktop, you name it. So I am not totally blind
 of programming, but it will be great to get an experienced python
 programmer who has the passion for coding, and the patience to mentor
 a beginner python.

 The chief geek has given his nod of approval to publish Miranda
 through how-to geek, and I can pitch any of your software to him, and
 write an article about it - provided that the chief geek approve the
 software.

Where is this code hosted? I'd be more than happy to (hopefully) lend
a hand wherever I can. I'm not that savvy (yet) with Python, but I'm
knowledgeable with a lot of computer science algorithms and such for
both sorting and searching, which I assume will help greatly!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What is the Most Efficient Way of Printing A Dict's Contents Out In Columns?

2011-06-14 Thread Terry Reedy

On 6/14/2011 11:29 AM, Zachary Dziura wrote:

I have a dict that I would like to print out in a series of columns,
rather than as a bunch of lines. Normally when you do print(dict), the
output will look something like this:

{'Header2': ['2', '5', '8'], 'Header3': ['3', '6', '9'], 'Header1':
['1', '4', '7'], 'Header4': ['10', '11', '12']}

I can then iterate through (in this case) a list of the headers in
order to produce something similar to this:

Header1 = ['1', '4', '7']
Header2 = ['2', '5', '8']
Header3 = ['3', '6', '9']
Header4 = ['10', '11', '12']

What I want to know is how I can print out that information in a
column, where the header is the first line of the column, with the
data following underneath, like so:

Header1Header2Header3Header4
1  2  3   4
5  6  7   8
9  1011 12


You did not specify how much can be assumed about the dict and built in 
to the program and how much needs to be discovered with code. Assuming 
that this is not homework, here is a start:


d={'Header2': ['2', '5', '8'], 'Header3': ['3', '6', '9'],
   'Header1': ['1', '4', '7'], 'Header4': ['10', '11', '12']}

arr = []
for key,value in d.items():
line = ['{:10s}'.format(key)]
for num in value:
line.append('{:10s}'.format(num))
arr.append(line)

for line in zip(*arr):
for item in line:
print(item, end='')
print() # newline

   Header2   Header3   Header1   Header4
 2 3 110
 5 6 411
 8 9 712

For zip(*arr) to work properly, each line of arr should have the same 
length, which means that either each value of d has the same length or 
that you find the max length and pad lines with blanks up to the max 
length. The code above assumes the first.


If the items in each value of d are not strings, more fiddling is 
needed. The printed field size is also arbitrary. It needs adjusting for 
the actual max length. You might want to adjust it for each key-value 
pair in the dict, which is to say, each column of the resulting table.


--
Terry Jan Reedy

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


Re: working with raw image files

2011-06-14 Thread Terry Reedy

On 6/14/2011 3:49 AM, Martin De Kauwe wrote:

what is a .raw file, do you mean a flat binary?

Perhaps tiff-like.
https://secure.wikimedia.org/wikipedia/en/wiki/Raw_image_format

Providing a detailed and concise description of the content of raw 
files is highly problematic. There is no single raw format; formats can 
be similar or radically different. Different manufacturers use their own 
proprietary and typically undocumented formats, which are collectively 
known as raw format. Often they also change the format from one camera 
model to the next. Several major camera manufacturers, including Nikon, 
Canon and Sony, encrypt portions of the file in an attempt to prevent 
third-party tools from accessing them.[2]


A real mess.

'.raw' is used (among others) by Panasonic and Leica. Not clear if .raw 
is the same for both.


--
Terry Jan Reedy

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


Re: Dictionaries and incrementing keys

2011-06-14 Thread Asen Bozhilov
Steve Crook wrote:

 Whilst certainly more compact, I'd be interested in views on how
 pythonesque this method is.

Instead of calling function you could use:

d = {}

d[key] = (key in d and d[key]) + 1

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


Re: Looking for Coders or Testers for an Open Source File Organizer

2011-06-14 Thread geremy condra
On Tue, Jun 14, 2011 at 7:54 AM, Matt Chaput m...@whoosh.ca wrote:
 On 13/06/2011 11:55 PM, zainul franciscus wrote:

 Iknow you guys must be thinking Hmm, Miranda, isn't that an IM
 application ?; Yep I hear you, I'll change the name once I get a good
 name. I am open for any suggestions.

 Actually I was thinking isn't that a functional programming language?

Same here.

 My suggestion: Cruftbuster

'Phile'

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


Re: What is the Most Efficient Way of Printing A Dict's Contents Out In Columns?

2011-06-14 Thread Zach Dziura
 d={'Header2': ['2', '5', '8'], 'Header3': ['3', '6', '9'],
     'Header1': ['1', '4', '7'], 'Header4': ['10', '11', '12']}

 arr = []
 for key,value in d.items():
      line = ['{:10s}'.format(key)]
      for num in value:
          line.append('{:10s}'.format(num))
      arr.append(line)

 for line in zip(*arr):
      for item in line:
          print(item, end='')
      print() # newline
  
     Header2   Header3   Header1   Header4
           2         3         1        10
           5         6         4        11
           8         9         7        12

 For zip(*arr) to work properly, each line of arr should have the same
 length, which means that either each value of d has the same length or
 that you find the max length and pad lines with blanks up to the max
 length. The code above assumes the first.

 If the items in each value of d are not strings, more fiddling is
 needed. The printed field size is also arbitrary. It needs adjusting for
 the actual max length. You might want to adjust it for each key-value
 pair in the dict, which is to say, each column of the resulting table.

 --
 Terry Jan Reedy

I just have one quick question. On the line where you have zip(*arr),
what is the * for? Is it like the pointer operator, such as with C? Or
is it exactly the pointer operator?

Otherwise, thank you for the example! This isn't homework, but I'm
working on something at work, and I was wondering how to properly
format the output from CSV files into another file. It's all a part of
an analyzer script for database tables, and the table wherein. Thank
you a bunch for the help!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Looking for Coders or Testers for an Open Source File Organizer

2011-06-14 Thread Alister Ware
On Mon, 13 Jun 2011 20:55:54 -0700, zainul franciscus wrote:

 I started an open source file organizer called Miranda.  Miranda is
 inspired by Belvedere written by Adam Pash of Lifehacker (http://
 lifehacker.com/341950/belvedere-automates-your-self+cleaning-pc). I know
 you guys must be thinking Hmm, Miranda, isn't that an IM application
 ?; Yep I hear you, I'll change the name once I get a good name. I am
 open for any suggestions.
 
 Miranda is written in Python, meant for Ubuntu, but hopefully it can be
 tested for every Linux Flavour. I have nothing much to offer in return
 for the software,but I will acknowledge your contribution in the
 software, and give credit to anyone helping when I feature Miranda in
 How-To Geek : http://www.howtogeek.com/
 
 I am a beginner in python, so the code may look a bit messy, and I am
 open to rewrite the code if I can get a mentor whom I can pair with for
 coding the application. I do have 7+ years of programming, web
 development, database, desktop, you name it. So I am not totally blind
 of programming, but it will be great to get an experienced python
 programmer who has the passion for coding, and the patience to mentor a
 beginner python.
 
 The chief geek has given his nod of approval to publish Miranda through
 how-to geek, and I can pitch any of your software to him, and write an
 article about it - provided that the chief geek approve the software.

So where can I get a copy or have i missed something (Fedora user so thats 
one more distro for you)



-- 
Boy, that crayon sure did hurt!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Infinite recursion in __reduce__ when calling original base class reduce, why?

2011-06-14 Thread Irmen de Jong
On 14-6-2011 2:40, Chris Torek wrote:

 
 Nonetheless, there is something at least slightly suspicious here:
[... snip explanations...]

Many thanks Chris, for the extensive reply. There's some useful knowledge in it.

My idea to call the base class reduce as the default fallback causes the 
problems:
return return super(TestClass, self).__reduce__()
If, following your suggestion, I replace that with:
return self.__class__, (self.name,)
it works fine.

By the way, in the meantime I've played around with copyreg.pickle, and that 
code worked
in all Python implementations I've tried it in. This code feels better too, 
because it
is possible to simply use
return self.__reduce__()
as a fallback in it, because we're not touching the object's own __reduce__ in 
any way.

Anyway thanks again

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


Re: What is the Most Efficient Way of Printing A Dict's Contents Out In Columns?

2011-06-14 Thread Karim

On 06/14/2011 05:29 PM, Zachary Dziura wrote:

I have a dict that I would like to print out in a series of columns,
rather than as a bunch of lines. Normally when you do print(dict), the
output will look something like this:

{'Header2': ['2', '5', '8'], 'Header3': ['3', '6', '9'], 'Header1':
['1', '4', '7'], 'Header4': ['10', '11', '12']}

I can then iterate through (in this case) a list of the headers in
order to produce something similar to this:

Header1 = ['1', '4', '7']
Header2 = ['2', '5', '8']
Header3 = ['3', '6', '9']
Header4 = ['10', '11', '12']

What I want to know is how I can print out that information in a
column, where the header is the first line of the column, with the
data following underneath, like so:

Header1Header2Header3Header4
1  2  3   4
5  6  7   8
9  1011 12
Over alternative that only costs 2 lines of code, use pretty print (not 
in columns but crystal clear):


import pprint
pprint.pprint(my_dict)

or in a file:
pprint.pprint(my_dict, open(output.dat, wb))

Cheers
karim


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


Question regarding DNS resolution in urllib2

2011-06-14 Thread saurabh verma
hi ,

I trying to use urllib2 in my script , but the problem is lets say a domains 
resolves to multiple IPs , If the URL is served by plain http , I can add 
“Host: domain” header and check whether all IPs are returning proper responses 
or not , but in case of https , I have to trust on my local machines dns 
resolver and I can’t apply host header in the request . 

Is it possible to override dns resolver in urllib2 or something else ? 

 req = urllib2.Request(url='https://google.com/')
 f = urllib2.urlopen(req)
 print f.read()

I wanted to control the IPs which urllib2 is trying to connect . 


I Hope I am some sense out of my question , 

Thanks in advance. 

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


Re: What is the Most Efficient Way of Printing A Dict's Contents Out In Columns?

2011-06-14 Thread MRAB

On 14/06/2011 18:48, Zach Dziura wrote:
[snip]

I just have one quick question. On the line where you have zip(*arr),
what is the * for? Is it like the pointer operator, such as with C? Or
is it exactly the pointer operator?


[snip]
The * in the argument list of a function call unpacks the following
list as arguments for the call, for example, zip(*[0, 1, 2]) becomes
zip(0, 1, 2), so zip(*arr) becomes zip(arr[0], arr[1], ...).

There's also **, which unpacks a dict as keyword arguments.
--
http://mail.python.org/mailman/listinfo/python-list


Re: working with raw image files

2011-06-14 Thread kafooster
Ok, I solved the problem with matplotlib

fileobj = open(hand.raw, 'rb')
data = numpy.fromfile(fileobj,dtype=np.uint16)
data = numpy.reshape(data,(96,470,352))
imshow(data[:,:,40],cmap='gray')
show()

the error was caused by different order of data, however it still
reads the dataset as half of it size. whatever.

please leave the part about .raw, lets just start thinking of it from
level of numpy array.

I would like to visualize this data with PIL, but PIL works only with
8bit data. How could I resample my array from 16bit to 8bit?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: working with raw image files

2011-06-14 Thread MRAB

On 14/06/2011 21:13, kafooster wrote:

Ok, I solved the problem with matplotlib

fileobj = open(hand.raw, 'rb')
data = numpy.fromfile(fileobj,dtype=np.uint16)
data = numpy.reshape(data,(96,470,352))
imshow(data[:,:,40],cmap='gray')
show()

the error was caused by different order of data, however it still
reads the dataset as half of it size. whatever.

please leave the part about .raw, lets just start thinking of it from
level of numpy array.

I would like to visualize this data with PIL, but PIL works only with
8bit data. How could I resample my array from 16bit to 8bit?


Multiply the numpy array by a scaling factor, which is
float(max_8bit_value) / float(max_16bit_value).
--
http://mail.python.org/mailman/listinfo/python-list


Re: pkg_resources ?

2011-06-14 Thread Ned Deily
In article BANLkTi=-=jjlk_4awqgna3h7kv3aa9y...@mail.gmail.com,
 km srikrishnamo...@gmail.com wrote:
 I am trying to  look at the source code of a python  script (run.py). But
 it  reads
 ###code - run.py 
 #!/usr/bin/env python
 # EASY-INSTALL-SCRIPT: 'pbpy==0.1','run.py'
 __requires__ = 'pbpy==0.1'
 import pkg_resources
 pkg_resources.run_script('pbpy==0.1', 'run.py')
 ##code #
 
 What are the advantages of using pkg_resources stuff ?

What you are seeing is boiler-plate code automatically generated by 
setuptools (or the Distribute clone of setuptools) when a script is 
installed with easy_install.  The main reason for the wrapper is to 
allow multiple versions of a Python package (in the PyPi sense) to be 
installed in one Python instance.  There's more information here: 
http://peak.telecommunity.com/DevCenter/setuptools

-- 
 Ned Deily,
 n...@acm.org

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


Re: working with raw image files

2011-06-14 Thread Dan Stromberg
On Tue, Jun 14, 2011 at 1:26 PM, MRAB pyt...@mrabarnett.plus.com wrote:

 On 14/06/2011 21:13, kafooster wrote:


 I would like to visualize this data with PIL, but PIL works only with
 8bit data. How could I resample my array from 16bit to 8bit?


 Multiply the numpy array by a scaling factor, which is
 float(max_8bit_value) / float(max_16bit_value).


I don't know PIL specifics at all, but often 8 bit graphics formats are
palette-based, and 16 bit graphics are often a compressed form of 24 bit rgb
graphics that take advantage of how much the human eye sees various colors.
IOW, for some formats I'm sure scaling will help, but for others I'm sure it
won't.

The O.P. could try rawtopgm and rawtoppm, after attempting the scaling
thing, assuming scaling doesn't help - and hopefully it will.  I believe PIL
understands these NetPBM formats.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: working with raw image files

2011-06-14 Thread kafooster
On 14 Cze, 22:26, MRAB pyt...@mrabarnett.plus.com wrote:

 Multiply the numpy array by a scaling factor, which is
 float(max_8bit_value) / float(max_16bit_value).

could you please explain it a little? I dont understand it. like
multiplying each element?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Looking for Coders or Testers for an Open Source File Organizer

2011-06-14 Thread Chris Angelico
On Wed, Jun 15, 2011 at 3:33 AM, geremy condra debat...@gmail.com wrote:
 My suggestion: Cruftbuster

 'Phile'

Or 'Philtre'. A philtre is a very useful thing to have around a
house... just ask Aline Sangazure.

I'd like to join this project, as a tester.

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


Re: Rant on web browsers

2011-06-14 Thread Chris Angelico
On Wed, Jun 15, 2011 at 12:11 AM, Patty pa...@cruzio.com wrote:
 Hi Chris - I am just learning JavaScript and this was helpful to me, not a
 rant.  I am reading JavaScript:  The Good Parts so he is jumping around in
 topic and I can just use this when learning about dates and ints coming up.

Hehe. Just that it was helpful doesn't make it not-a-rant, but I'm
glad there was some value in it.

There's probably more value in people's offered suggestions than in my
original moan, though. I'm going to have to start looking into a few
of them; there's probably one that I can sell to my boss as Hey, we
need this.

CoffeeScript looks interesting, but I'm somewhat worried that it's
only going to add its own restrictions on top of Javascript's,
changing syntax without really improving very much. It does look cool,
though. (But I disagree with it (and Python) on points such as
non-declared variables.) Since it's a new language (we don't use Ruby
here yet), I don't think I can justify it to my boss - any new
language would have to be learned by more people than just me. On the
flip side, I might play around with it for my own web site at some
point.

Thanks for the tips, all. This is what makes a good mailing list -
helpful people!

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


Re: working with raw image files

2011-06-14 Thread MRAB

On 14/06/2011 22:20, kafooster wrote:

On 14 Cze, 22:26, MRABpyt...@mrabarnett.plus.com  wrote:


Multiply the numpy array by a scaling factor, which is
float(max_8bit_value) / float(max_16bit_value).


could you please explain it a little? I dont understand it. like
multiplying each element?


Yes. Something like this:

fileobj = open(hand.raw, 'rb')
data = numpy.fromfile(fileobj, dtype=numpy.uint16)
fileobj.close()
data = data * float(0xFF) / float(0x)
data = numpy.array(data, dtype=numpy.uint8)
data = data.reshape((96, 470, 352))
imshow(data[:, :, 40], cmap='gray')
show()
--
http://mail.python.org/mailman/listinfo/python-list


break in a module

2011-06-14 Thread Eric Snow
When you want to stop execution of a statement body early, for flow
control, there is a variety ways you can go, depending on the context.
 Loops have break and continue.  Functions have return.  Generators
have yield (which temporarily stops execution).  Exceptions sort of
work for everything, but have to be caught by a surrounding scope, and
are not necessarily meant for general flow control.

Is there a breaking flow control mechanism for modules?

Regardless of the context, I've found it cleaner to use flow control
statements, like break, continue, and return, to stop execution under
some condition and then leave the rest of my code at the smaller
indentation level.  For example:

  for i in range(5):
  if i % 2:
  print(odd: %s % i)
  continue

  print(even: %s % i)

This could be written with if-else for control flow:

  for i in range(5):
  if i % 2:
  print(odd: %s % i)
  else:
  print(even: %s % i)

Or, for functions:

  def f(arg):
  if not arg:
  return None

  print(found something: %s % arg)
  return arg

vs:

  def f(arg):
  if not arg:
  result = None
  else:
  print(found something: %s % arg)
  result = arg
  return result

The more levels of indentation the harder it becomes to read.
However, with the breaking flow control statements, you can mitigate
the nesting levels somewhat.  One nice thing is that when doing this
you can have your default behavior stay at the smallest indentation
level, so the logic is easier to read.

With modules I sometimes have code at the beginning to do some small
task if a certain condition is met, and otherwise execute the rest of
the module body.  Here's my main use case:

  some module

  import sys
  import importlib
  import util  # some utility module somewhere...

  if __name__ == __main__:
  name = util.get_module_name(sys.modules[__name__])
  module = importlib.import_module(name)
  sys.modules[__name__] = module
  else:
  # do my normal stuff at 1 indentation level

I would rather have something like this:

  some module

  import sys
  import importlib
  import util  # some utility module somewhere...

  if __name__ == __main__:
  name = util.get_module_name(sys.modules[__name__])
  module = importlib.import_module(name)
  sys.modules[__name__] = module
  break

  # do my normal stuff at 0 indentation level

So, any thoughts?  Thanks.

-eric

p.s. I might just handle this with a PEP 302 import hook regardless,
but it would still be nice to know if there is a better solution than
basically indenting my entire module.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Keyboard Layout: Dvorak vs Colemak: is it Worthwhile to Improve the Dvorak Layout?

2011-06-14 Thread Andrew Berg
On 2011.06.13 08:58 PM, Chris Angelico wrote:
 That's one of the reasons I like my laptop keyboard so much.
I find that the terribly tiny keys on a laptop keyboard make them very
evil. I don't see how anyone could type fast on one of them without
making tons of errors. I constantly have to fix typos (the 'o' key is
the worst) when writing with this thing, and I'm not typing fast at all.
I suppose if you have really small hands, the compact layout might be
more comfortable, but I hate my keyboard. Then again, maybe I just have
a tiny keyboard; you might have one that actually fills the space on the
bottom.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Rant on web browsers

2011-06-14 Thread Asen Bozhilov
Chris Angelico wrote:

 I've just spent a day coding in Javascript, and wishing browsers
 supported Python instead (or as well). All I needed to do was take two
 dates (as strings), figure out the difference in days, add that many
 days to both dates, and put the results back into DOM Input objects
 (form entry fields). Pretty simple, right? Javascript has a Date
 class, it should be fine. But no. First, the date object can't be
 outputted as a formatted string. The only way to output a date is Feb
 21 2011. So I have to get the three components (oh and the month is
 0-11, not 1-12) and emit those. And Javascript doesn't have a simple
 format function that would force the numbers to come out with leading
 zeroes, so I don't bother with that.

Actually there is not Date class. There are not any classes in
ECMAScript.

 What if I want to accept any delimiter in the date - slash, hyphen, or
 dot? Can I just do a simple translate, turn all slashes and dots into
 hyphens? Nope. Have to go regular expression if you want to change
 more than the first instance of something. There's no nice string
 parse function (like sscanf with %d-%d-%d), so I hope every browser
 out there has a fast regex engine. When all you have is a half-ton
 sledgehammer, everything looks like a really REALLY flat nail...

function formatDate(date) {
return ('000' + date.getFullYear()).slice(-4) + '-' +
   ('0' + (date.getMonth() + 1)).slice(-2) + '-' +
   ('0' + date.getDate()).slice(-2);
}

formatDate(new Date());

 Plus, Javascript debugging is annoyingly difficult if you don't have
 tools handy. I need third-party tools to do anything other than code
 blind? Thanks.

It depends on the environment. It is good idea to read c.l.js and
JSMentors.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Looking for Coders or Testers for an Open Source File Organizer

2011-06-14 Thread Redcat
 The chief geek has given his nod of approval to publish Miranda through
 how-to geek, and I can pitch any of your software to him, and write an
 article about it - provided that the chief geek approve the software.

I wouldn't mind contributing some time to this project.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: break in a module

2011-06-14 Thread MRAB

On 14/06/2011 23:28, Eric Snow wrote:
[snip]

With modules I sometimes have code at the beginning to do some small
task if a certain condition is met, and otherwise execute the rest of
the module body.  Here's my main use case:

   some module

   import sys
   import importlib
   import util  # some utility module somewhere...

   if __name__ == __main__:
   name = util.get_module_name(sys.modules[__name__])
   module = importlib.import_module(name)
   sys.modules[__name__] = module
   else:
   # do my normal stuff at 1 indentation level

I would rather have something like this:

   some module

   import sys
   import importlib
   import util  # some utility module somewhere...

   if __name__ == __main__:
   name = util.get_module_name(sys.modules[__name__])
   module = importlib.import_module(name)
   sys.modules[__name__] = module
   break

   # do my normal stuff at 0 indentation level

So, any thoughts?  Thanks.


To me, the obvious choice would be return, not break.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Looking for Coders or Testers for an Open Source File Organizer

2011-06-14 Thread zainul franciscus
On Jun 15, 10:43 am, Redcat red...@catfolks.net wrote:
  The chief geek has given his nod of approval to publish Miranda through
  how-to geek, and I can pitch any of your software to him, and write an
  article about it - provided that the chief geek approve the software.

 I wouldn't mind contributing some time to this project.

Thank you all for the replies; I really appreciate it. I should have
mentioned in my original message that I am hosting the code in Google
Code: http://code.google.com/p/mirandafileorganizer/

The home page has a link to a developer/user guide:
http://code.google.com/p/mirandafileorganizer/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Looking for Coders or Testers for an Open Source File Organizer

2011-06-14 Thread zainul franciscus
Hi Chris,

Thank you for the reply. I should have mentioned where I am hosting
the code *doh slap on the wrist.

I am hosting the code in google code: 
http://code.google.com/p/mirandafileorganizer/

There is a link to the user/developer guide on how to get started with
the software:
https://docs.google.com/document/d/1OGvrS5offb27WlkZ5genMJX2El18AqrnfY0VvTOsPQk/edit?hl=en_USauthkey=CJ_q7Dwpli=1

I look forward to hear more from you =)

Best Wishes,
Zainul Franciscus


On Jun 15, 9:48 am, Chris Angelico ros...@gmail.com wrote:
 On Wed, Jun 15, 2011 at 3:33 AM, geremy condra debat...@gmail.com wrote:
  My suggestion: Cruftbuster

  'Phile'

 Or 'Philtre'. A philtre is a very useful thing to have around a
 house... just ask Aline Sangazure.

 I'd like to join this project, as a tester.

 Chris Angelico

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


Re: Looking for Coders or Testers for an Open Source File Organizer

2011-06-14 Thread zainul franciscus
Hi Chris,

Thank you for the reply. I should have mentioned where I am hosting
the code *doh slap on the wrist.

I am hosting the code in google code: 
http://code.google.com/p/mirandafileorganizer/

There is a link to the user/developer guide on how to get started with
the software:
https://docs.google.com/document/d/1OGvrS5offb27WlkZ5genMJX2El18Aqrnf...

I look forward to hear more from you =)

Best Wishes,
Zainul Franciscus

On Jun 15, 9:48 am, Chris Angelico ros...@gmail.com wrote:
 On Wed, Jun 15, 2011 at 3:33 AM, geremy condra debat...@gmail.com wrote:
  My suggestion: Cruftbuster

  'Phile'

 Or 'Philtre'. A philtre is a very useful thing to have around a
 house... just ask Aline Sangazure.

 I'd like to join this project, as a tester.

 Chris Angelico

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


Re: break in a module

2011-06-14 Thread Ethan Furman

MRAB wrote:

On 14/06/2011 23:28, Eric Snow wrote:

I would rather have something like this:

   some module

   import sys
   import importlib
   import util  # some utility module somewhere...

   if __name__ == __main__:
   name = util.get_module_name(sys.modules[__name__])
   module = importlib.import_module(name)
   sys.modules[__name__] = module
   break

   # do my normal stuff at 0 indentation level

So, any thoughts?  Thanks.


To me, the obvious choice would be return, not break.


To me, too -- too bad it doesn't work:

c:\temp\python32\python early_abort.py
  File early_abort.py, line 7
return
   ^
SyntaxError: 'return' outside function

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


Re: working with raw image files

2011-06-14 Thread Dave Angel

On 01/-10/-28163 02:59 PM, kafooster wrote:

On 14 Cze, 22:26, MRABpyt...@mrabarnett.plus.com  wrote:


Multiply the numpy array by a scaling factor, which is
float(max_8bit_value) / float(max_16bit_value).


could you please explain it a little? I dont understand it. like
multiplying each element?



You said in an earlier message to ignore the RAW format.  However, if 
your file matches a typical camera's raw file, there are several problems:


1) the data is typically 12 to 14 bits per pixel, only rarely 16 (very 
expensive cameras)
2) the data does not have R, G and B values for each pixel, but only one 
of these.  The others are generated by Bayer interpolation.
3) the data is linear (which is what the hardware produces), and 
traditional image data wants to be in some non-linear color space.  For 
example, most jpegs are sRGB 8*3 bits per pixel.


The first would mean that you'd need to do a lot of shifting and 
masking.  The second would mean a pretty complex interpolation 
algorithm.  And the third would require an exponential function at the 
very least.


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


Re: What is the Most Efficient Way of Printing A Dict's Contents Out In Columns?

2011-06-14 Thread Ben Finney
Zachary Dziura zcdzi...@gmail.com writes:

 What I want to know is how I can print out that information in a
 column, where the header is the first line of the column, with the
 data following underneath, like so:

I'm glad you got some good replies. It probably reflects badly on me
that my first thought was URL:http://bash.org/?5804.

-- 
 \  “In case of fire, do your utmost to alarm the porter.” —hotel, |
  `\Vienna |
_o__)  |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: break in a module

2011-06-14 Thread Erik Max Francis

Eric Snow wrote:

With modules I sometimes have code at the beginning to do some small
task if a certain condition is met, and otherwise execute the rest of
the module body.  Here's my main use case:

  some module

  import sys
  import importlib
  import util  # some utility module somewhere...

  if __name__ == __main__:
  name = util.get_module_name(sys.modules[__name__])
  module = importlib.import_module(name)
  sys.modules[__name__] = module
  else:
  # do my normal stuff at 1 indentation level

I would rather have something like this:

  some module

  import sys
  import importlib
  import util  # some utility module somewhere...

  if __name__ == __main__:
  name = util.get_module_name(sys.modules[__name__])
  module = importlib.import_module(name)
  sys.modules[__name__] = module
  break

  # do my normal stuff at 0 indentation level

So, any thoughts?  Thanks.


The answer would depend on exactly what normal stuff you expect your 
module to do if it's not being run as a script (which is what your 
`__name__ == '__main__'` check tests for).  A typical module will define 
it's appropriate attributes, functions, classes, and so on at module 
scope.  It will then end with a test to see if it's being run as a 
script, and then do the appropriate thing.  This allows modules to be 
imported separately from being executed as scripts.


Your sample code makes it hard to understand the use case, especially 
since if you want this hypothetical module break to stop executing the 
module, then your `__name__ == '__main__'` test basically does nothing 
useful (it fiddles with some modules -- especially since it appears to 
be they very module that is being executed -- and then quits).


At a more general level, the idea of a module break doesn't make much 
sense.  Modules are just collections of things; they can include some 
direct code, but typically consist of mostly definitions.  Modules can 
interact with each other, be called recursively, etc., and so at an 
arbitrary point saying, break out of this module doesn't have a great 
deal of meaning.


--
Erik Max Francis  m...@alcyone.com  http://www.alcyone.com/max/
 San Jose, CA, USA  37 18 N 121 57 W  AIM/Y!M/Skype erikmaxfrancis
  There is _never_ no hope left. Remember.
   -- Louis Wu
--
http://mail.python.org/mailman/listinfo/python-list


Re: break in a module

2011-06-14 Thread Erik Max Francis

Ethan Furman wrote:

MRAB wrote:

On 14/06/2011 23:28, Eric Snow wrote:

I would rather have something like this:

   some module

   import sys
   import importlib
   import util  # some utility module somewhere...

   if __name__ == __main__:
   name = util.get_module_name(sys.modules[__name__])
   module = importlib.import_module(name)
   sys.modules[__name__] = module
   break

   # do my normal stuff at 0 indentation level

So, any thoughts?  Thanks.


To me, the obvious choice would be return, not break.


To me, too -- too bad it doesn't work:

c:\temp\python32\python early_abort.py
  File early_abort.py, line 7
return
   ^
SyntaxError: 'return' outside function


Nor should it.  There's nothing to return out of.

--
Erik Max Francis  m...@alcyone.com  http://www.alcyone.com/max/
 San Jose, CA, USA  37 18 N 121 57 W  AIM/Y!M/Skype erikmaxfrancis
  There is _never_ no hope left. Remember.
   -- Louis Wu
--
http://mail.python.org/mailman/listinfo/python-list


Re: working with raw image files

2011-06-14 Thread kafooster
On 15 Cze, 00:06, MRAB pyt...@mrabarnett.plus.com wrote:


 Yes. Something like this:

 fileobj = open(hand.raw, 'rb')
 data = numpy.fromfile(fileobj, dtype=numpy.uint16)
 fileobj.close()
 data = data * float(0xFF) / float(0x)
 data = numpy.array(data, dtype=numpy.uint8)
 data = data.reshape((96, 470, 352))
 imshow(data[:, :, 40], cmap='gray')
 show()

thank you very much, it works and now I can display this data even
with Image.fromarray(). As I understand, it  multiplies data elements
by a fraction, so that when we have less levels (in 8uint), it can fit
there?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What is the Most Efficient Way of Printing A Dict's Contents Out In Columns?

2011-06-14 Thread Chris Angelico
On Wed, Jun 15, 2011 at 9:40 AM, Ben Finney ben+pyt...@benfinney.id.au wrote:
 Zachary Dziura zcdzi...@gmail.com writes:

 What I want to know is how I can print out that information in a
 column, where the header is the first line of the column, with the
 data following underneath, like so:

 I'm glad you got some good replies. It probably reflects badly on me
 that my first thought was URL:http://bash.org/?5804.

Well *OBVIOUSLY* the difference is that that snippet is referring to
Ms Access, and on this list we're working with Montgomery Python,
and as we all know, women simply cannot do these things.

Chris Angelico
/me ducks the slings and arrows of outrageous sexism
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: working with raw image files

2011-06-14 Thread kafooster
On 15 Cze, 01:25, Dave Angel da...@ieee.org wrote:
 On 01/-10/-28163 02:59 PM, kafooster wrote:

  On 14 Cze, 22:26, MRABpyt...@mrabarnett.plus.com  wrote:

  Multiply the numpy array by a scaling factor, which is
  float(max_8bit_value) / float(max_16bit_value).

  could you please explain it a little? I dont understand it. like
  multiplying each element?

 You said in an earlier message to ignore the RAW format.  However, if
 your file matches a typical camera's raw file, there are several problems:

 1) the data is typically 12 to 14 bits per pixel, only rarely 16 (very
 expensive cameras)
 2) the data does not have R, G and B values for each pixel, but only one
 of these.  The others are generated by Bayer interpolation.
 3) the data is linear (which is what the hardware produces), and
 traditional image data wants to be in some non-linear color space.  For
 example, most jpegs are sRGB 8*3 bits per pixel.

 The first would mean that you'd need to do a lot of shifting and
 masking.  The second would mean a pretty complex interpolation
 algorithm.  And the third would require an exponential function at the
 very least.

 DaveA

well, I am only working with grayscale MRI medical images(mainly 8 or
16bits), saved as .raw. I do not need to worry about rgb.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Keyboard Layout: Dvorak vs Colemak: is it Worthwhile to Improve the Dvorak Layout?

2011-06-14 Thread Chris Angelico
On Wed, Jun 15, 2011 at 12:50 AM, Dotan Cohen dotanco...@gmail.com wrote:
 And disproportionate usage of fingers. On QWERTY the weakest fingers
 (pinkies) do almost 1/4 of the keypresses when modifier keys, enter,
 tab, and backspace are taken into account.

That's true on a piano too, though. My pinkies are quite accustomed to
doing the extra work now, so whether I'm playing the church organ or
typing a post here, they're put to good use. It's the longer fingers
in the middle that aren't pulling their weight...

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


Re: Keyboard Layout: Dvorak vs Colemak: is it Worthwhile to Improve the Dvorak Layout?

2011-06-14 Thread Chris Angelico
On Wed, Jun 15, 2011 at 8:29 AM, Andrew Berg bahamutzero8...@gmail.com wrote:
 On 2011.06.13 08:58 PM, Chris Angelico wrote:
 That's one of the reasons I like my laptop keyboard so much.
 I find that the terribly tiny keys on a laptop keyboard make them very
 evil. I don't see how anyone could type fast on one of them without
 making tons of errors.

 Then again, maybe I just have a tiny keyboard; you
 might have one that actually fills the space on the bottom.

There are many different designs of laptop keyboard. Tiny netbooks
seem to have the very worst, leaving it nearly impossible to get any
decent work done (there may be exceptions to that, but I've seen a lot
of bad netbook keyboards). My current laptop is an IBM T60, one of the
last of the IBMs (now they're all Lenovos); prior to him, I've had
various other 14 or 15 laptops, all with the keyboards using most of
the available room. Obviously there's no numeric keypad on a keyboard
that small (having one overlaid on the main keyboard doesn't help when
you're playing Angband), but other than that, it's a complete keyboard
with enough room for the fingers to whack the right keys.

There's also a lot of difference in travel. The smaller keyboards have
keys that move about half a nanometer, but better keyboards feel
right. The worst keyboard of all, in that sense, would have to be the
virtual laser keyboard, no longer available on ThinkGeek but seems to
be here http://www.virtual-laser-devices.com/ - it's an incredibly
cool concept, but I can't imagine actually using one long-term. Typing
on concrete is not my idea of productivity.

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


Re: working with raw image files

2011-06-14 Thread MRAB

On 15/06/2011 00:59, kafooster wrote:

On 15 Cze, 00:06, MRABpyt...@mrabarnett.plus.com  wrote:



Yes. Something like this:

fileobj = open(hand.raw, 'rb')
data = numpy.fromfile(fileobj, dtype=numpy.uint16)
fileobj.close()
data = data * float(0xFF) / float(0x)
data = numpy.array(data, dtype=numpy.uint8)
data = data.reshape((96, 470, 352))
imshow(data[:, :, 40], cmap='gray')
show()


thank you very much, it works and now I can display this data even
with Image.fromarray(). As I understand, it  multiplies data elements
by a fraction, so that when we have less levels (in 8uint), it can fit
there?


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


Re: Looking for Coders or Testers for an Open Source File Organizer

2011-06-14 Thread zainul franciscus
Thank you for the reply. I should have mentioned where I am hosting
the code *doh slap on the wrist.

I am hosting the code in google code: 
http://code.google.com/p/mirandafileorganizer/

There is a link to the user/developer guide on how to get started with
the software:
https://docs.google.com/document/d/1OGvrS5offb27WlkZ5genMJX2El18AqrnfY0VvTOsPQk/edit?hl=en_USauthkey=CJ_q7Dw

Just email me directly if you are interested to join the project and I
will add you as a contributor in Google Code

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


Re: Question regarding DNS resolution in urllib2

2011-06-14 Thread Chris Angelico
On Wed, Jun 15, 2011 at 4:34 AM, saurabh verma nitw.saur...@gmail.com wrote:
 hi ,

 I trying to use urllib2 in my script , but the problem is lets say a domains 
 resolves to multiple IPs , If the URL is served by plain http , I can add 
 “Host: domain” header and check whether all IPs are returning proper 
 responses or not , but in case of https , I have to trust on my local 
 machines dns resolver and I can’t apply host header in the request .

Regarding Host: headers, experimentation showed that urllib2 did
indeed send one (I tested using Python 2.7.1 on Windows, talking to a
snooping HTTPS server running on a Linux box beside me - source code
available if you're curious, but it's not Python).

 import urllib2
 req=urllib2.Request(url='https://mirlemont/')
 f=urllib2.urlopen(req)
 f.read()
'Hello, world!'

Meanwhile the snoop server reports:

conn = Protocols.HTTP.Server.Request(GET /)
GET / HTTP/1.1
Accept-Encoding: identity
Host: mirlemont
Connection: close
User-Agent: Python-urllib/2.7

(Yes, my computer's name is Mirlemont. What's yours'? :) )

You could control the selection of IP address using a hosts file. In
Unix, that's /etc/hosts; in Windows,
c:\windows\system32\drivers\etc\hosts; in OS/2, c:\mptn\etc\hosts;
etc. The urllib2 resolver should respect that.

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


Re: break in a module

2011-06-14 Thread Ben Finney
Eric Snow ericsnowcurren...@gmail.com writes:

 When you want to stop execution of a statement body early, for flow
 control, there is a variety ways you can go, depending on the context.
  Loops have break and continue.  Functions have return.  Generators
 have yield (which temporarily stops execution).  Exceptions sort of
 work for everything, but have to be caught by a surrounding scope, and
 are not necessarily meant for general flow control.

 Is there a breaking flow control mechanism for modules?

Since your nominated use case is only to do it when ‘__name__ ==
'__main__'’, you could call ‘sys.exit()’.

 With modules I sometimes have code at the beginning to do some small
 task if a certain condition is met, and otherwise execute the rest of
 the module body.

I don't see how your use case needs to skip executing the rest of the
module code.

 Here's my main use case:

   some module

   import sys
   import importlib
   import util  # some utility module somewhere...

   if __name__ == __main__:
   name = util.get_module_name(sys.modules[__name__])
   module = importlib.import_module(name)
   sys.modules[__name__] = module
   else:
   # do my normal stuff at 1 indentation level

What “normal stuff” is the module doing that shouldn't be done when the
module is ‘__main__’? I can't see what the use case is for.

As you're no doubt aware, the normal pattern is to execute all the
“normal stuff” for a module unconditionally, which creates all the
objects in the module namespace (its imports, classes, functions, and
other attributes) without side effects; then check if the module is
‘__main__’ at the *end*.

So you'll probably need to be more specific about why your use case
differs from that.

-- 
 \ “Pinky, are you pondering what I'm pondering?” “I think so, |
  `\Brain, but if the plural of mouse is mice, wouldn't the plural |
_o__)  of spouse be spice?” —_Pinky and The Brain_ |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: break in a module

2011-06-14 Thread Eric Snow
On Tue, Jun 14, 2011 at 5:51 PM, Erik Max Francis m...@alcyone.com wrote:
 Ethan Furman wrote:

 To me, too -- too bad it doesn't work:

 c:\temp\python32\python early_abort.py
  File early_abort.py, line 7
    return
       ^
 SyntaxError: 'return' outside function

 Nor should it.  There's nothing to return out of.


Perhaps we have a misunderstanding then.  The contents of a module
file are the body of the module definition.  Like the body of any
other complex statement, that body is going to get executed [1].

Some of the complex statements have keywords that let you break out of
that execution, like break and continue in loops.  Some do not.
However, there is most certainly something out of which to return, the
execution of the module body.

That fact that the functionality is not there does not mean it has to
stay that way.  It may just be that no one has thought to add it.  I
don't agree that it's a bad idea.  I have a use case.  The alternative
is unappealing to me.  That's how new features are born.

I apologize if my example was unclear.  I kept it pretty simple.  I
expect using __main__ was misleading.  However, this is by no means
the only use case.  In general it would be nice to do some checks up
front and decide whether or not to continue executing the module,
rather than waiting until the end to decide:

  if condition_1:
  ...
  return
  if condition_2:
  ...
  return

  # now do my expensive module stuff

  # finally handle being run as a script
  if __name__ == __main__:
  ...

The only ways that I know of to accomplish this currently is either by
putting everything inside if-else blocks, or raise some kind of
ImportBreak exception and catch it in an import hook.  I would rather
not use either one.  The more levels of indentation in a module, the
harder it is to follow.  And exceptions really should not be involved
in execution flow control, but in the handling of abnormal situations
instead.

Considering that other complex statements have special flow control
statements, I don't see why modules shouldn't either.

-eric

[1] During import the module gets compiled and the result is exec'ed
in the context of the __dict__ of a new ModuleType object.  That
module object is then placed in sys.modules and bound to the name you
have in the import statement in the module from which you issued that
statement.  Remember, the module is executed once, when the import
statement is executed.  That is when the module flow control would
happen.


 --
 Erik Max Francis  m...@alcyone.com  http://www.alcyone.com/max/
  San Jose, CA, USA  37 18 N 121 57 W  AIM/Y!M/Skype erikmaxfrancis
  There is _never_ no hope left. Remember.
   -- Louis Wu
 --
 http://mail.python.org/mailman/listinfo/python-list

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


Re: Paramiko Threading Error

2011-06-14 Thread mud
On Jun 10, 3:47 am, David 71da...@libero.it wrote:
 Il Tue, 7 Jun 2011 19:25:43 -0700 (PDT), mud ha scritto:









  Hi All,

  Does anybody know what the following error means with paramiko, and
  how to fix it.

  I don't know what is causing it and why. I have updated paramiko to
  version 1.7.7.1 (George) but still has the same issue.

  Also I can not reproduce the problem and therefore debugging is harder
  for me.

  Exception in thread Thread-4 (most likely raised during interpreter
  shutdown):
  Traceback (most recent call last):
    File /usr/lib64/python2.6/threading.py, line 532, in
  __bootstrap_inner
    File /usr/lib/python2.6/site-packages/paramiko/transport.py, line
  1574, in run
  type 'exceptions.AttributeError': 'NoneType' object has no attribute
  'error'

 if I remember rightly, I got that kind of error when I tried to use a
 transport without setting up the paramiko's logging subsystem.
 Try to put in head of your code the line:

 pk.util.log_to_file(log file name.txt)

 D.

Hi David,

I have tried that already because I though that the logging might
indicate what the issue is.

What I have found is that paramiko seems to be using threading which
is not %100 thread safe in python. So it seems that when the script
exits, the interpreter is failing to close the threads running and
therefor giving the exception.

What I have tried now is to go through all the connections objects
that I have opened, close them first if they are open before the
script exists. It appears to be working so far but only time will
tell.

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


Re: Keyboard Layout: Dvorak vs Colemak: is it Worthwhile to Improve the Dvorak Layout?

2011-06-14 Thread Andrew Berg
On 2011.06.14 07:18 PM, Chris Angelico wrote:
 There are many different designs of laptop keyboard. Tiny netbooks
 seem to have the very worst, leaving it nearly impossible to get any
 decent work done (there may be exceptions to that, but I've seen a lot
 of bad netbook keyboards). My current laptop is an IBM T60, one of the
 last of the IBMs (now they're all Lenovos); prior to him, I've had
 various other 14 or 15 laptops, all with the keyboards using most of
 the available room.
I thought that might be the case. I can take a picture of mine if you're
keeping a collection of bad laptop keyboards. :D
Seriously, I have a 17.1 display, and the keyboard is almost small
enough for a large tablet. It takes up no more than 30% of the area
available.
Also, the left shift and left control keys don't want to work most of
the time, but that's another issue.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: working with raw image files

2011-06-14 Thread Nobody
On Tue, 14 Jun 2011 19:25:32 -0400, Dave Angel wrote:

 You said in an earlier message to ignore the RAW format.  However, if 
 your file matches a typical camera's raw file

It doesn't. He's dealing with a raw array of fixed-size integers (i.e.
what you would get if you took a C array and wrote the memory directly to
a file).

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


Re: break in a module

2011-06-14 Thread Chris Angelico
On Wed, Jun 15, 2011 at 10:51 AM, Eric Snow ericsnowcurren...@gmail.com wrote:
  if condition_1:
      ...
      return
  if condition_2:
      ...
      return

  # now do my expensive module stuff

  # finally handle being run as a script
  if __name__ == __main__:
      ...


The best way I can think of is:


def expensive_stuff_1():
...

def expensive_stuff_2():
...

if not condition_1:
expensive_stuff_1()
if not condition_2:
expensive_stuff_2()


Depending on what exactly you're doing, this might make perfect sense,
or might be a useless indentation level of its own. If the expensive
stuff divides nicely into units, where each unit is governed by one
condition, it might work out well that way; you could use the same
functions to build your 'if __main__' section too.

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


Re: break in a module

2011-06-14 Thread Ben Finney
Eric Snow ericsnowcurren...@gmail.com writes:

 I apologize if my example was unclear.  I kept it pretty simple.

That's a good goal, but unfortunately in this case it means the purpose
is opaque.

 In general it would be nice to do some checks up front and decide
 whether or not to continue executing the module, rather than waiting
 until the end to decide:

   if condition_1:
   ...
   return
   if condition_2:
   ...
   return

   # now do my expensive module stuff

I have never seen code that needs this, and can't imagine why the above
would be a good design for a module. Is there real code online somewhere
that we can see which serves as a real example for your use case?

-- 
 \   “There is no reason anyone would want a computer in their |
  `\ home.” —Ken Olson, president, chairman and founder of Digital |
_o__)Equipment Corp., 1977 |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: working with raw image files

2011-06-14 Thread Nobody
On Tue, 14 Jun 2011 13:13:07 -0700, kafooster wrote:

 Ok, I solved the problem with matplotlib
 
 fileobj = open(hand.raw, 'rb')
 data = numpy.fromfile(fileobj,dtype=np.uint16)
 data = numpy.reshape(data,(96,470,352))
 imshow(data[:,:,40],cmap='gray')
 show()
 
 the error was caused by different order of data, however it still
 reads the dataset as half of it size. whatever.
 
 please leave the part about .raw, lets just start thinking of it from
 level of numpy array.
 
 I would like to visualize this data with PIL, but PIL works only with
 8bit data. How could I resample my array from 16bit to 8bit?

Why bother? NumPy is a much better image-processing library than PIL. The
only reason I use PIL is for its import/export routines.

If you are going to use PIL, apply any corrections (gamma correction,
histogram equalisation, etc) before reducing the data to 8 bits.

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


Re: working with raw image files

2011-06-14 Thread Dave Angel

On 01/-10/-28163 02:59 PM, kafooster wrote:

On 15 Cze, 01:25, Dave Angelda...@ieee.org  wrote:

On 01/-10/-28163 02:59 PM, kafooster wrote:


On 14 Cze, 22:26, MRABpyt...@mrabarnett.plus.comwrote:



Multiply the numpy array by a scaling factor, which is
float(max_8bit_value) / float(max_16bit_value).



could you please explain it a little? I dont understand it. like
multiplying each element?


You said in an earlier message to ignore the RAW format.  However, if
your file matches a typical camera's raw file, there are several problems:

1) the data is typically 12 to 14 bits per pixel, only rarely 16 (very
expensive cameras)
2) the data does not have R, G and B values for each pixel, but only one
of these.  The others are generated by Bayer interpolation.
3) the data is linear (which is what the hardware produces), and
traditional image data wants to be in some non-linear color space.  For
example, most jpegs are sRGB 8*3 bits per pixel.

The first would mean that you'd need to do a lot of shifting and
masking.  The second would mean a pretty complex interpolation
algorithm.  And the third would require an exponential function at the
very least.

DaveA


well, I am only working with grayscale MRI medical images(mainly 8 or
16bits), saved as .raw. I do not need to worry about rgb.



Well, since you've already gotten results you like (per another msg from 
you), the gamma adjustment must already be made.  So they're an entirely 
different meaning of raw than used by DSLR's, for example.


Glad it's working for you.

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


Re: break in a module

2011-06-14 Thread Eric Snow
On Tue, Jun 14, 2011 at 7:33 PM, Ben Finney ben+pyt...@benfinney.id.au wrote:

 I have never seen code that needs this, and can't imagine why the above
 would be a good design for a module. Is there real code online somewhere
 that we can see which serves as a real example for your use case?


Unfortunately not.  Most of this line of thinking is the result of
looking at import functionality in different ways, including with
regards to the problem of modules getting imported twice (once as
__main__).  I've been doing work on multi-file modules, custom module
objects, and custom import hooks lately, so I have been exploring a
lot of the import related features.  The situation came up where I was
trying to actually apply some of that across a large package.

The use case I originally gave is the real-life one that got me
thinking about module flow control statements.  However, the situation
that led me there is not particularly wide-spread.  Keep in mind that
initially I was looking to see if there was something like return or
break for modules, and not asking that they be added.  That expensive
module stuff example I gave was purely hypothetical, and I haven't
really seen real code like it either.

Like I said, my main motivation is to reduce my levels of indentation
somewhat.  I was trying to see if I could apply a pattern I use in
functions and loops to modules.  Things like I have never seen...
are really helpful to hear, by the way, so thanks!

-eric

 --
  \           “There is no reason anyone would want a computer in their |
  `\     home.” —Ken Olson, president, chairman and founder of Digital |
 _o__)                                            Equipment Corp., 1977 |
 Ben Finney
 --
 http://mail.python.org/mailman/listinfo/python-list

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


Re: break in a module

2011-06-14 Thread Cameron Simpson
On 14Jun2011 18:51, Eric Snow ericsnowcurren...@gmail.com wrote:
| On Tue, Jun 14, 2011 at 5:51 PM, Erik Max Francis m...@alcyone.com wrote:
|  Ethan Furman wrote:
| 
|  To me, too -- too bad it doesn't work:
| 
|  c:\temp\python32\python early_abort.py
|   File early_abort.py, line 7
|     return
|        ^
|  SyntaxError: 'return' outside function
| 
|  Nor should it.  There's nothing to return out of.
| 
| 
| Perhaps we have a misunderstanding then.  The contents of a module
| file are the body of the module definition.  Like the body of any
| other complex statement, that body is going to get executed [1].

One might argue that a module is not a statement.

| Some of the complex statements have keywords that let you break out of
| that execution, like break and continue in loops.  Some do not.
| However, there is most certainly something out of which to return, the
| execution of the module body.

Ok...

| That fact that the functionality is not there does not mean it has to
| stay that way.  It may just be that no one has thought to add it.  I
| don't agree that it's a bad idea.  I have a use case.  The alternative
| is unappealing to me.  That's how new features are born.

One litmus test may be whether such a statement buys you much.
You say you have a use case, but so far it seems rather vague to me.

Speaking for myself, my modules tend to be a heap of class or function
definitions (cheap - a linear parse of the file) and a few
as-simple-as-possible initialisations of any supporting global data
structures. Actual examples of global data structures are hard to find,
but of the few I make, here's one:

  __seq = 0
  __seqLock = allocate_lock()
  def seq():
''' Allocate a new sequential number.
Useful for creating unique tokens.
'''
global __seq
global __seqLock
__seqLock.acquire()
__seq += 1
n = __seq
__seqLock.release()
return n

to support a free gimme-a-unique-number in other code:

  from cs.misc import seq
  ...
  n = seq()

| I apologize if my example was unclear.  I kept it pretty simple.

Too simple, IMO. Please present a real module excerpt from your own code
where significant not a class or function definition code is executed
so we can see what ind of stuff you do that would benefit.

| I
| expect using __main__ was misleading.  However, this is by no means
| the only use case.  In general it would be nice to do some checks up
| front and decide whether or not to continue executing the module,
| rather than waiting until the end to decide:
| 
|   if condition_1:
|   ...
|   return
|   if condition_2:
|   ...
|   return
| 
|   # now do my expensive module stuff
| 
|   # finally handle being run as a script
|   if __name__ == __main__:
|   ...

I think many people don't think of a module as something to execute.
Of course, it _is_ executed but for most modules the stuff executed is
unconditional and single pass class and function definitions, constant
definitions (such as the symbolic logging level of the logging module
etc).

All such stuff is usually unconditional (or trivially conditional, eg
only define this on MacOSX etc).

In my own case, the only counter example I can recall is stuff like a
main() function. In those cases my modules take the form:

  import stuff ...

  def main(argv):
xit = 0
... main program top level logic here ...
return xit

  ... classes, functions etc ...

  if __name__ == __'main__':
sys.exit(main(sys.argv))

This keeps the top level logic at the top where it is easy to find.

That covers the case where running the module becomes a little utility
(typically a basic tool to manipulate an instance of whatever facility
the module provides). For the other common case in tension with this, to
run unit tests, we just call the unittests at the bottom or if both
modes make sense I tend to make main() accept a selftest argument
to run the unittests.

So my own code doesn't cry out for what you seem to be asking.

Please make it more clear what you're doing that I'm not.

| The only ways that I know of to accomplish this currently is either by
| putting everything inside if-else blocks, or raise some kind of
| ImportBreak exception and catch it in an import hook.  I would rather
| not use either one.  The more levels of indentation in a module, the
| harder it is to follow.  And exceptions really should not be involved
| in execution flow control, but in the handling of abnormal situations
| instead.
| 
| Considering that other complex statements have special flow control
| statements, I don't see why modules shouldn't either.

Basicly because, in my experience, an approach like havig a main()
function often covers it. Counter/other examples needed!

Cheers,
-- 
Cameron Simpson c...@zip.com.au DoD#743
http://www.cskk.ezoshosting.com/cs/

The major difference between a thing that might go wrong and a thing that
cannot possibly go wrong is that when a thing that cannot possibly go wrong
goes 

Re: Keyboard Layout: Dvorak vs Colemak: is it Worthwhile to Improve the Dvorak Layout?

2011-06-14 Thread rusi
On Jun 15, 5:11 am, Chris Angelico ros...@gmail.com wrote:
 On Wed, Jun 15, 2011 at 12:50 AM, Dotan Cohen dotanco...@gmail.com wrote:
  And disproportionate usage of fingers. On QWERTY the weakest fingers
  (pinkies) do almost 1/4 of the keypresses when modifier keys, enter,
  tab, and backspace are taken into account.

 That's true on a piano too, though. My pinkies are quite accustomed to
 doing the extra work now, so whether I'm playing the church organ or
 typing a post here, they're put to good use. It's the longer fingers
 in the middle that aren't pulling their weight...

For keyboarding (in the piano/organ sense) the weakest finger is not
the fifth/pinky but the fourth.
Because for the fifth you will notice that the natural movement is to
stiffen the finger and then use a slight outward arm-swing; for thumb,
index and middle, they of course have their own strength.

The fourth has neither advantage.  IOW qwerty is not so bad as it
could have been if it were qewrty (or asd was sad)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: break in a module

2011-06-14 Thread Dave Angel

On 01/-10/-28163 02:59 PM, Eric Snow wrote:

snip

Unfortunately not.  Most of this line of thinking is the result of
looking at import functionality in different ways, including with
regards to the problem of modules getting imported twice (once as
__main__).  I've been doing work on multi-file modules, custom module



Watch out for that importing of the original script.  Doing that has 
many risks, only one of which is the problem of the two names.


In fact, any time you have mutual imports, you run a certain risk, if 
the modules involved have any code that's not inside defs.  It's not 
well defined what order the initialisation happens, so you may wind up 
calling code in another module that's not really there yet.


The module import tree should be strictly hierarchical, without cycles. 
 if you need stuff from the __main__, pass it to the other module, 
don't let the other module peek back over your shoulder.


In the case of a module importing things from your script, the solution 
is pretty simple.  Move the needed code elsewhere, and import it both 
from your script and from the other module.


DaveA



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


Dynamic URL shortening

2011-06-14 Thread Littlefield, Tyler

Hello all:
I started working on a project with someone else quite recently, and he 
has a request. The project requires an URL shortener, and he would like 
it to be dynamic for both users and developers. Apparently some 
applications on the mac allow for the user to input some data on a URL 
shortener and use that specific service to shorten URLS. So I'm curious 
if anyone has had any experience with this in python/can recommend a 
library to look at.


Secondly, my requirement to make this dynamic for developers. The way I 
did this was to use a metaclass that the base URLShortener will inherit, 
which will add itself to a shortener registry. This works well enough, 
and all I really need to do is something like:

shortener = factory.getShortener(bitly)
url = shortener.shorten(http://google.com;)
How viable is this solution? It seems like it's nice enough, are there 
other approaches to handling something like this?


--

Take care,
Ty
my website:
http://tds-solutions.net
my blog:
http://tds-solutions.net/blog
skype: st8amnd127
My programs don't have bugs; they're randomly added features!

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


Re: Dynamic URL shortening

2011-06-14 Thread Chris Angelico
On Wed, Jun 15, 2011 at 2:03 PM, Littlefield, Tyler ty...@tysdomain.com wrote:
 Hello all:
 I started working on a project with someone else quite recently, and he has
 a request. The project requires an URL shortener, and he would like it to be
 dynamic for both users and developers. Apparently some applications on the
 mac allow for the user to input some data on a URL shortener and use that
 specific service to shorten URLS. So I'm curious if anyone has had any
 experience with this in python/can recommend a library to look at.

In my MUD client, RosMud, there's a URL shortener that's designed for
people playing a text RPG. The client itself isn't open source (but is
free to download), but the URL shortener is. It's all written in C++,
so it may not be of much use to you, but feel free to grab it from my
rather ugly web site: http://www.kepl.com.au/esstu/rosmud.html

The code is Windows-specific, but the TinyURL code is mostly just
network work, so by the time you've ported it to Python it will be
cross-platform.

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


Re: Keyboard Layout: Dvorak vs Colemak: is it Worthwhile to Improve the Dvorak Layout?

2011-06-14 Thread Dotan Cohen
On Wed, Jun 15, 2011 at 06:00, rusi rustompm...@gmail.com wrote:
 For keyboarding (in the piano/organ sense) the weakest finger is not
 the fifth/pinky but the fourth.
 Because for the fifth you will notice that the natural movement is to
 stiffen the finger and then use a slight outward arm-swing; for thumb,
 index and middle, they of course have their own strength.

 The fourth has neither advantage.  IOW qwerty is not so bad as it
 could have been if it were qewrty (or asd was sad)


Thank you rusi! Tell me, where can I read more about the advantages of
each finger? Googling turns up nothing. My intention is to improved
the Noah ergonomic keyboard layout. Thanks!

-- 
Dotan Cohen

http://gibberish.co.il
http://what-is-what.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What is the Most Efficient Way of Printing A Dict's Contents Out In Columns?

2011-06-14 Thread Terry Reedy

On 6/14/2011 2:37 PM, MRAB wrote:

On 14/06/2011 18:48, Zach Dziura wrote:
[snip]

I just have one quick question. On the line where you have zip(*arr),
what is the * for? Is it like the pointer operator, such as with C? Or
is it exactly the pointer operator?


[snip]
The * in the argument list of a function call unpacks the following
list as arguments for the call, for example, zip(*[0, 1, 2]) becomes
zip(0, 1, 2), so zip(*arr) becomes zip(arr[0], arr[1], ...).

There's also **, which unpacks a dict as keyword arguments.


* and ** in a function call, which distribute arguments,
are essentially the inverse of * and ** in function definitions,
where they say to collect arguments.

--
Terry Jan Reedy

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


[issue12326] Linux 3: tests should avoid using sys.platform == 'linux2'

2011-06-14 Thread Martin v . Löwis

Martin v. Löwis mar...@v.loewis.de added the comment:

 This change is reasonable for the long term.  But it *will* break a lot of 
 code.

[If you favor a specific change, please indicate what that is. I'm
assuming you support my proposal for the moment :-]

I agree it will break a lot of code, but it's also somewhat urgent
because we will get 'linux3' if we don't act, which will also break
a lot of code (but more subtly, since people testing their code may
do so on Linux 2, only to get bug reports that it breaks on some
Linux systems). I'm sure Linus Torvalds is fully aware of the possible
consequences of the version change, and just accepted the breakage
that this would cause.

It's important that we set a policy before the Linux distributions
do (which may end up choosing different policies). We don't actually
have to *release* this change quickly, since Linux distributions
who release 3.x kernels will fix their Python packages themselves.

--

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



[issue12319] [http.client] HTTPConnection.putrequest not support chunked Transfer-Encodings to send data

2011-06-14 Thread Petri Lehtinen

Petri Lehtinen pe...@digip.org added the comment:

harobed wrote:
 I use http.client in WebDAV client.

 Mac OS X Finder WebDAV client perform all his request in chunk mode : PUT 
 and GET.

 Here, I use http.client to simulate Mac OS X Finder WebDAV client.

Now I'm confused. Per the HTTP specification, GET requests don't have
a body, so Transfer-Encoding: chunked doesn't apply to them.

Are you sure you don't confuse with the response that the server
sends? In responses, Transfer-Encoding: chunked is very common.

--

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



[issue10224] Build 3.x documentation using python3.x

2011-06-14 Thread Martin v . Löwis

Martin v. Löwis mar...@v.loewis.de added the comment:

Actually, on Windows, PYTHON is typically not set at all. So the likelihood of 
it being set to Python 3 is very low, unless you are trying to build Python 
documentation from time to time.

Sye: I fail to see the point of your patch. sphinx-build.py already issues an 
error message - why do you need more error messages?

--

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



[issue11934] build with --prefix=/dev/null and zlib enabled in Modules/Setup failed

2011-06-14 Thread Petri Lehtinen

Changes by Petri Lehtinen pe...@digip.org:


--
nosy: +petri.lehtinen

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



[issue12326] Linux 3: tests should avoid using sys.platform == 'linux2'

2011-06-14 Thread Amaury Forgeot d'Arc

Amaury Forgeot d'Arc amaur...@gmail.com added the comment:

The change to sys.platform=='linux' would break code even on current platforms.
OTOH, we have sys.platform=='win32' even on Windows 64bit; would this favor 
keeping 'linux2' on all versions of Linux as well?

--

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



[issue12326] Linux 3: tests should avoid using sys.platform == 'linux2'

2011-06-14 Thread Martin v . Löwis

Martin v. Löwis mar...@v.loewis.de added the comment:

 The change to sys.platform=='linux' would break code even on current 
 platforms.

Correct. Compared to introducing 'linux3', I consider this the better
change - it likely breaks earlier (i.e. when porting to Python 3.3).

 OTOH, we have sys.platform=='win32' even on Windows 64bit; would this
 favor keeping 'linux2' on all versions of Linux as well?

While this has better compatibility, it's also a constant source of
irritation. Introducing 'win64' would have been a worse choice (just
as introducing 'linux3' would: incompatibility for no gain, since
the distinction between win32 and win64, from a Python POV, is
irrelevant). Plus, Microsoft dislikes the term Win64 somewhat, and
rather wants people to refer to the Windows API.

I personally disliked 'linux2' when it was introduced, for its
incompatibilities. Anticipating that, some day, we may have 'Linux 4',
and so on, I still claim it is better to fix this now. We could even
come up with a 2to3 fixer for people who dual-source their code.

--

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



[issue12326] Linux 3: tests should avoid using sys.platform == 'linux2'

2011-06-14 Thread Charles-François Natali

Charles-François Natali neolo...@free.fr added the comment:

 I'm sure Linus Torvalds is fully aware of the possible
 consequences of the version change, and just accepted the breakage
 that this would cause.

Any application relying on sys.platform == 'linux2' is already broken.
It's exactly the same if an application checks for 'freebsd6' or
'openbsd4' : if you want to check for a specific operating system,
there's already POSIX' struct utsname sysname field, i.e. uname()[0].

--

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



[issue10527] multiprocessing.Pipe problem: handle out of range in select()

2011-06-14 Thread Dan Kenigsberg

Dan Kenigsberg dan...@redhat.com added the comment:

I would rate this issue as a performance bug, not a mere feature request. If 
the python process has more than 1023 open file descriptors, 
multiprocessing.Pipe.poll() becomes unusable. This is a serious barrier to 
using multiprocessing in a complex server.

--
nosy: +danken
type: feature request - performance

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



[issue12331] lib2to3 tests write into protected directory

2011-06-14 Thread Vinay Sajip

New submission from Vinay Sajip vinay_sa...@yahoo.co.uk:

Some of the tests for lib2to3 write into folders which are protected in an 
installed Python. This means that regression tests fail when run on an 
installed Python, even though they run wihtout these errors on a source build. 
I think writes should be done into temp files, so that you can run regressions 
on installed Pythons.

Example failure:

==
ERROR: test_refactor_file (lib2to3.tests.test_refactor.TestRefactoringTool)
--
Traceback (most recent call last):
  File /usr/local/lib/python3.3/lib2to3/tests/test_refactor.py, line 190, in 
check_file_refactoring
rt.refactor_file(test_file, True)
  File /usr/local/lib/python3.3/lib2to3/refactor.py, line 353, in 
refactor_file
write=write, encoding=encoding)
  File /usr/local/lib/python3.3/lib2to3/refactor.py, line 518, in 
processed_file
self.write_file(new_text, filename, old_text, encoding)
  File /usr/local/lib/python3.3/lib2to3/refactor.py, line 530, in write_file
f = _open_with_encoding(filename, w, encoding=encoding)
IOError: [Errno 13] Permission denied: 
'/usr/local/lib/python3.3/lib2to3/tests/data/fixers/parrot_example.py'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File /usr/local/lib/python3.3/lib2to3/tests/test_refactor.py, line 200, in 
test_refactor_file
self.check_file_refactoring(test_file, _DEFAULT_FIXERS)
  File /usr/local/lib/python3.3/lib2to3/tests/test_refactor.py, line 194, in 
check_file_refactoring
with open(test_file, wb) as fp:
IOError: [Errno 13] Permission denied: 
'/usr/local/lib/python3.3/lib2to3/tests/data/fixers/parrot_example.py'

--
components: 2to3 (2.x to 3.0 conversion tool), Tests
messages: 138302
nosy: benjamin.peterson, vinay.sajip
priority: normal
severity: normal
status: open
title: lib2to3 tests write into protected directory
versions: Python 3.3

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



  1   2   >