ANN: eGenix pyOpenSSL Distribution 0.13.0-1.0.0j

2012-05-16 Thread eGenix Team: M.-A. Lemburg

ANNOUNCING

   eGenix.com pyOpenSSL Distribution

 Version 0.13.0-1.0.0j


 An easy-to-install and easy-to-use distribution
 of the pyOpenSSL Python interface for OpenSSL -
available for Windows, Mac OS X and Unix platforms


This announcement is also available on our web-site for online reading:
http://www.egenix.com/company/news/eGenix-pyOpenSSL-Distribution-0.13.0-1.0.0j-1.html


INTRODUCTION

The eGenix.com pyOpenSSL Distribution includes everything you need to
get started with SSL in Python.

It comes with an easy-to-use installer that includes the most recent
OpenSSL library versions in pre-compiled form, making your application
independent of OS provided OpenSSL libraries:

http://www.egenix.com/products/python/pyOpenSSL/

pyOpenSSL is an open-source Python add-on that allows writing SSL/TLS-
aware network applications as well as certificate management tools:

https://launchpad.net/pyopenssl/

OpenSSL is an open-source implementation of the SSL/TLS protocol:

http://www.openssl.org/


NEWS

This new release of the eGenix.com pyOpenSSL Distribution updates the
included included OpenSSL version to 1.0.0g.

New features in OpenSSL 1.0.0j since 1.0.0g
---

OpenSSL 1.0.0j fixes several vulnerabilities relative to 1.0.0g:

http://openssl.org/news/vulnerabilities.html

and includes a number of stability enhancements as well as extra
protection against attacks:

http://openssl.org/news/changelog.html

New features in the eGenix pyOpenSSL Distribution
-

 * Fixed a compatibility problem with Python 2.7's distutils that
   was introduced in Python 2.7.3

As always, we provide binaries that include both pyOpenSSL and the
necessary OpenSSL libraries for all supported platforms:
Windows x86 and x64, Linux x86 and x64, Mac OS X PPC, x86 and x64.

We've also added egg-file distribution versions of our eGenix.com
pyOpenSSL Distribution for Windows, Linux and Mac OS X to the
available download options. These make setups using e.g. zc.buildout
and other egg-file based installers a lot easier.


DOWNLOADS

The download archives and instructions for installing the package can
be found at:

http://www.egenix.com/products/python/pyOpenSSL/


UPGRADING

Before installing this version of pyOpenSSL, please make sure that
you uninstall any previously installed pyOpenSSL version. Otherwise,
you could end up not using the included OpenSSL libs.

___
SUPPORT

Commercial support for these packages is available from eGenix.com.
Please see

http://www.egenix.com/services/support/

for details about our support offerings.


MORE INFORMATION

For more information about the eGenix pyOpenSSL Distributon, licensing
and download instructions, please visit our web-site or write to
sa...@egenix.com.

Enjoy,

-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Source  (#1, May 16 2012)
 Python/Zope Consulting and Support ...http://www.egenix.com/
 mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/
 mxODBC, mxDateTime, mxTextTools ...http://python.egenix.com/

2012-07-02: EuroPython 2012, Florence, Italy   47 days to go
2012-04-26: Released mxODBC 3.1.2 http://egenix.com/go28
2012-04-25: Released eGenix mx Base 3.2.4 http://egenix.com/go27

::: Try our new mxODBC.Connect Python Database Interface for free ! 


   eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48
D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
   Registered at Amtsgericht Duesseldorf: HRB 46611
   http://www.egenix.com/company/contact/
-- 
http://mail.python.org/mailman/listinfo/python-announce-list

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


Wing IDE 4.1.6 released

2012-05-16 Thread Wingware

Hi,

Wingware has released version 4.1.6 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, context-aware auto-editing, a powerful graphical debugger,
version control, unit testing, search, and many other features.

**Changes**

This release includes:

* Support for Django 1.4
* Syntax highlighting Qt Style Sheet (.qss) files
* Command to show selected file in OS-provided file manager
* Per-project configuration of Debug Network Port for remote debugging
* Several auto-editing fixes
* Several turbo completion mode fixes
* Replace All preserves fold state when possible
* Git blame support
* Fixed debugging QThreads in older PyQt versions
* Shorter delay in restarting Python Shell or debug process
* About 15 other bug fixes and minor improvements

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

**New Features in Version 4**

Version 4 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
* Auto-Editing -- Reduce typing by auto-entering expected code
* 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


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 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, context-aware 
auto-editing,

  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/featuresfor a detailed listing
of features by product level.

System requirements are Windows 2000 or later, OS X 10.3.9or 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.1

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

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

**Purchasing and Upgrading**

Wing 4.x 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:


Re: http://porn-extreme.2304310.n4.nabble.com/

2012-05-16 Thread jimmy970
http://porn-extreme.2304310.n4.nabble.com/
http://porn-extreme.2304310.n4.nabble.com/ 

--
View this message in context: 
http://python.6.n6.nabble.com/AMPUTEE-INCEST-MIDGET-2012-tp4708963p4974741.html
Sent from the Python - python-list mailing list archive at Nabble.com.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Looking for video/slides from PyCon 2011...

2012-05-16 Thread Monte Milanuk

On 05/13/2012 09:42 PM, Kushal Kumaran wrote:

On Fri, May 11, 2012 at 5:42 AM, Monte Milanukmemila...@gmail.com  wrote:

...specifically the two lectures on creating GUI applications with Python +
QT

http://us.pycon.org/2011/schedule/presentations/207/

Various searches on the 'Net don't seem to be turning up much... kinda
curious as to why?

Anyone here know?



Is it one of the videos at http://blip.tv/pycon-us-videos-2009-2010-2011



Unless its buried in one of the lightning talk vids, I'm not seein' it.

Thanks tho,

Monte

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


ANN: eGenix pyOpenSSL Distribution 0.13.0-1.0.0j

2012-05-16 Thread eGenix Team: M.-A. Lemburg

ANNOUNCING

   eGenix.com pyOpenSSL Distribution

 Version 0.13.0-1.0.0j


 An easy-to-install and easy-to-use distribution
 of the pyOpenSSL Python interface for OpenSSL -
available for Windows, Mac OS X and Unix platforms


This announcement is also available on our web-site for online reading:
http://www.egenix.com/company/news/eGenix-pyOpenSSL-Distribution-0.13.0-1.0.0j-1.html


INTRODUCTION

The eGenix.com pyOpenSSL Distribution includes everything you need to
get started with SSL in Python.

It comes with an easy-to-use installer that includes the most recent
OpenSSL library versions in pre-compiled form, making your application
independent of OS provided OpenSSL libraries:

http://www.egenix.com/products/python/pyOpenSSL/

pyOpenSSL is an open-source Python add-on that allows writing SSL/TLS-
aware network applications as well as certificate management tools:

https://launchpad.net/pyopenssl/

OpenSSL is an open-source implementation of the SSL/TLS protocol:

http://www.openssl.org/


NEWS

This new release of the eGenix.com pyOpenSSL Distribution updates the
included included OpenSSL version to 1.0.0g.

New features in OpenSSL 1.0.0j since 1.0.0g
---

OpenSSL 1.0.0j fixes several vulnerabilities relative to 1.0.0g:

http://openssl.org/news/vulnerabilities.html

and includes a number of stability enhancements as well as extra
protection against attacks:

http://openssl.org/news/changelog.html

New features in the eGenix pyOpenSSL Distribution
-

 * Fixed a compatibility problem with Python 2.7's distutils that
   was introduced in Python 2.7.3

As always, we provide binaries that include both pyOpenSSL and the
necessary OpenSSL libraries for all supported platforms:
Windows x86 and x64, Linux x86 and x64, Mac OS X PPC, x86 and x64.

We've also added egg-file distribution versions of our eGenix.com
pyOpenSSL Distribution for Windows, Linux and Mac OS X to the
available download options. These make setups using e.g. zc.buildout
and other egg-file based installers a lot easier.


DOWNLOADS

The download archives and instructions for installing the package can
be found at:

http://www.egenix.com/products/python/pyOpenSSL/


UPGRADING

Before installing this version of pyOpenSSL, please make sure that
you uninstall any previously installed pyOpenSSL version. Otherwise,
you could end up not using the included OpenSSL libs.

___
SUPPORT

Commercial support for these packages is available from eGenix.com.
Please see

http://www.egenix.com/services/support/

for details about our support offerings.


MORE INFORMATION

For more information about the eGenix pyOpenSSL Distributon, licensing
and download instructions, please visit our web-site or write to
sa...@egenix.com.

Enjoy,

-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Source  (#1, May 16 2012)
 Python/Zope Consulting and Support ...http://www.egenix.com/
 mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/
 mxODBC, mxDateTime, mxTextTools ...http://python.egenix.com/

2012-07-02: EuroPython 2012, Florence, Italy   47 days to go
2012-04-26: Released mxODBC 3.1.2 http://egenix.com/go28
2012-04-25: Released eGenix mx Base 3.2.4 http://egenix.com/go27

::: Try our new mxODBC.Connect Python Database Interface for free ! 


   eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48
D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
   Registered at Amtsgericht Duesseldorf: HRB 46611
   http://www.egenix.com/company/contact/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ucs2 and ucs4 python

2012-05-16 Thread zayatzz
On May 15, 7:42 pm, Miki Tebeka miki.teb...@gmail.com wrote:
  Can someone point me towards a resource or two which will tell me how
  to do this - im not very good with whole linux/servers stuff. Im using
  ubuntu linux - if that makes any difference.

 Did not test, but this is the direction I would take:
 * Download Python sources
 * Open Terminal
 * Run the following commands in the Terminal window
   - sudo apt-get build-dep python
   - tar -xjf Python-2.7.3.tar.bz2
   - cd Python-2.7.3
   - ./configure --prefix=/opt --enable-unicode=ucs2  make
   - sudo make install
 * Now you should have /opt/bin/python with ucs2

 HTH
 --
 Miki Tebeka miki.teb...@gmail.comhttp://pythonwise.blogspot.com

Thanks for reply :)

And it seems to work... When i type in
/opt/bin/python
import sys
sys.maxunicode

then i get the desired answer - 65535

But it seems the work only begins now, because i cant use other python
libraries now with this version of python and i probably have to
install them all again somehow...

But thanks for your help :)

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


Re: ucs2 and ucs4 python

2012-05-16 Thread zayatzz
There is one problem though...

when i start script with shebang like
#!/opt/bin/python

and then try to run the script i get:

/opt/bin/python^M: bad interpreter: No such file or directory

/opt/bin/python
/opt/bin/python2
/opt/bin/python2.7 all start this new version of python, but none of
those work in shebang

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


Re: ucs2 and ucs4 python

2012-05-16 Thread Stefan Behnel
zayatzz, 16.05.2012 10:22:
 On May 15, 7:42 pm, Miki Tebeka wrote:
 Can someone point me towards a resource or two which will tell me how
 to do this - im not very good with whole linux/servers stuff. Im using
 ubuntu linux - if that makes any difference.

 Did not test, but this is the direction I would take:
 * Download Python sources
 * Open Terminal
 * Run the following commands in the Terminal window
   - sudo apt-get build-dep python
   - tar -xjf Python-2.7.3.tar.bz2
   - cd Python-2.7.3
   - ./configure --prefix=/opt --enable-unicode=ucs2  make
   - sudo make install
 * Now you should have /opt/bin/python with ucs2

 HTH
 --
 Miki Tebeka miki.teb...@gmail.comhttp://pythonwise.blogspot.com
 
 Thanks for reply :)
 
 And it seems to work... When i type in
 /opt/bin/python
 import sys
 sys.maxunicode
 
 then i get the desired answer - 65535
 
 But it seems the work only begins now, because i cant use other python
 libraries now with this version of python and i probably have to
 install them all again somehow...

You should install distribute and pip into it, then you can use pip to
install packages directly and automatically from the Python Package Index
(PyPI), including any dependencies.

Even better, use virtualenv to create a local copy of your installation
and then install packages into that. This allows you to use completely
separate environments of the same Python installation, which can be very
handy for testing.

Stefan

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


Re: ucs2 and ucs4 python

2012-05-16 Thread Matej Cepl

On 16.5.2012 10:36, zayatzz wrote:

/opt/bin/python^M: bad interpreter: No such file or directory


Your script has CRLF end-of-lines. Change it to plain Unix LF.

Matěj
--
http://mail.python.org/mailman/listinfo/python-list


Re: ucs2 and ucs4 python

2012-05-16 Thread Chris Angelico
On Wed, May 16, 2012 at 6:36 PM, zayatzz alan.kesselm...@gmail.com wrote:
 There is one problem though...

 when i start script with shebang like
 #!/opt/bin/python

 and then try to run the script i get:

 /opt/bin/python^M: bad interpreter: No such file or directory

You have a Windows end-of-line \r\n instead of a Unix end-of-line \n -
how are you editing the files? If nothing else, run the script through
dos2unix or equivalent before executing.

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


Re: ucs2 and ucs4 python

2012-05-16 Thread zayatzz
On May 16, 11:50 am, Matej Cepl mc...@redhat.com wrote:
 On 16.5.2012 10:36, zayatzz wrote:

  /opt/bin/python^M: bad interpreter: No such file or directory

 Your script has CRLF end-of-lines. Change it to plain Unix LF.

 Matěj

Thanks :) but i have no idea what that means or how to achieve that.

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


Re: ucs2 and ucs4 python

2012-05-16 Thread Dave Angel
On 05/16/2012 05:20 AM, zayatzz wrote:
 On May 16, 11:50 am, Matej Cepl mc...@redhat.com wrote:
 On 16.5.2012 10:36, zayatzz wrote:

 /opt/bin/python^M: bad interpreter: No such file or directory
 Your script has CRLF end-of-lines. Change it to plain Unix LF.

 Matěj
 Thanks :) but i have no idea what that means or how to achieve that.

 Alan

See in the echo of the shebang line the ^M at the end ?  That's a
carriage return, hex(0d).  Unix/Linux use a single linefeed (hex(0a)) at
the end of the line.  At some point, you probably edited this file with
a Windows (aka DOS) editor, and it used the CRLF form (hex(0d0a)),
carriage return/line feed at the end of each line.

Your Linux text editor probably has a menu option to convert them back
to simple linefeeds, but if not, your Linux/Unix probably has a utility

dos2unix

which can do the job.



-- 

DaveA

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


Re: Good data structure for finding date intervals including a given date

2012-05-16 Thread Jean-Daniel
On Sun, May 13, 2012 at 2:29 PM, Alec Taylor alec.tayl...@gmail.com wrote:
 There is an ordered dict type since Python 3.1[1] and Python 2.7.3[2].

Ordered dict are useful, but they only remember the ordered in which
they were added, you can not order them a on key.

Thanks for the links.


 If you are looking for the best possible self-sorting structure for
 searching, then perhaps you are looking for what's outlined in the
 2002 article by Han  Thorup: Integer Sorting in O(n sqrt(log log n))
 Expected Time and Linear Space[3].

 [1] http://www.python.org/getit/releases/3.1/
 [2] http://www.python.org/getit/releases/2.7.3/
 [3] http://dl.acm.org/citation.cfm?id=645413.652131

 On Sat, May 12, 2012 at 10:17 PM, Jean-Daniel
 jeandaniel.bro...@gmail.com wrote:

 Hello,

 I have a long list of n date intervals that gets added or suppressed
 intervals regularly. I am looking for a fast way to find the intervals
 containing a given date, without having to check all intervals (less
 than O(n)).

 Do you know the best way to do this in Python with the stdlib?

 A variant of the red black trees can do the job quickly [1], is this a
 good enough use case to discuss the inclusion of a red black tree
 implementation in the stdlib?

 This has been discussed here: http://bugs.python.org/issue1324770 ,
 and lack of good use case was the reason the bug was closed. A dict
 implemented with red black trees is slower (but not too slow) at
 inserting, searching and deleting but the dict is always kept ordered.
 Bigger projects have their own implementation of ordered dict so such
 datastructures in the standard library would help the porting of the
 project to other platforms. Take the example of the zodb and the
 C-only implementation of the btree: btree in the stdlib in Python
 would help the porting to GAE or pypy [2].

 Cheers,

 [1] in the Cormen book:
 http://en.wikipedia.org/wiki/Introduction_to_Algorithms
 [2] https://blueprints.launchpad.net/zodb/+spec/remove-btree-dependency
 --
 http://mail.python.org/mailman/listinfo/python-list
-- 
http://mail.python.org/mailman/listinfo/python-list


what does newP = func(code,p) do?

2012-05-16 Thread e-mail mgbg25171
def execute (code) :
p = 0
while p  len(code) :
func = code[p]
p += 1
newP = func(code,p)
if newP != None :
p = newP

I'm trying to work out what this does

code is a list of function addresses and numbers
What on earth is funct(code,p) doing???

My understanding so far is...
set p to 0
while p is less than the number of elements in list code keep doing what
follows...
set func to the first element in the list
increment the list index p
?
if newP is not null then set the list index p to ?
Can someone please explain in english what ? is
Thank you in anticipation

BTW the link for this stuff is

http://openbookproject.net/py4fun/forth/forth.html
to see the thing in action ie the download link is on the above page

Here's a listing of the output from this proc for the following forth input
i.e. I put some print statements in
but have no idea how
newP set to func( [function rPush at 0x0164F570, 4] , 1 ) i.e.  2
results in 2
and then
newP set to func( [function rAdd at 0x0164F130] , 1 ) i.e.  None
results in None
???


Forth 5 4 + .

1st line of execute__
code =  [function rPush at 0x0164F570, 5]
p =  0
1st line of while__
func = code[ 0 ] i.e.  function rPush at 0x0164F570
incrementing p to  1
newP set to func( [function rPush at 0x0164F570, 5] , 1 ) i.e.  2
p = newP i.e.  2

1st line of execute__
code =  [function rPush at 0x0164F570, 4]
p =  0
1st line of while__
func = code[ 0 ] i.e.  function rPush at 0x0164F570
incrementing p to  1
newP set to func( [function rPush at 0x0164F570, 4] , 1 ) i.e.  2
p = newP i.e.  2

1st line of execute__
code =  [function rAdd at 0x0164F130]
p =  0
1st line of while__
func = code[ 0 ] i.e.  function rAdd at 0x0164F130
incrementing p to  1
newP set to func( [function rAdd at 0x0164F130] , 1 ) i.e.  None

1st line of execute__
code =  [function rDot at 0x0164F430]
p =  0
1st line of while__
func = code[ 0 ] i.e.  function rDot at 0x0164F430
incrementing p to  1
13
newP set to func( [function rDot at 0x0164F430] , 1 ) i.e.  5
None
Forth
-- 
http://mail.python.org/mailman/listinfo/python-list


python and xml

2012-05-16 Thread Nibin V M
Hi,

I am trying to use cPanel XML-API and every API call return data in XML
format. I would like to know how to manipulate the data here.

For eg: How can I read the CPU load data from the below output


 loadavgone0.00/onefive0.00/fivefifteen0.00/fifteen/loadavg!--
whostmgrd --

Thank you,
-- 
Regards

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


Re: python and xml

2012-05-16 Thread Stefan Behnel
Nibin V M, 16.05.2012 16:16:
 I am trying to use cPanel XML-API and every API call return data in XML
 format. I would like to know how to manipulate the data here.
 
 For eg: How can I read the CPU load data from the below output
 
 
  
 loadavgone0.00/onefive0.00/fivefifteen0.00/fifteen/loadavg!--
 whostmgrd --

Here's some untested code to print the text values:

  import xml.etree.ElementTree as ET

  loadavg = ET.fromstring('loadavgone0.00/onefive0.00/five'
  'fifteen0.00/fifteen/loadavg')

  for interval_tag in ('one', 'five', 'fifteen'):
  print(loadavg.findtext(interval_tag))


Stefan

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


Wing IDE 4.1.6 released

2012-05-16 Thread Wingware

Hi,

Wingware has released version 4.1.6 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, context-aware auto-editing, a powerful graphical debugger,
version control, unit testing, search, and many other features.

**Changes**

This release includes:

* Support for Django 1.4
* Syntax highlighting Qt Style Sheet (.qss) files
* Command to show selected file in OS-provided file manager
* Per-project configuration of Debug Network Port for remote debugging
* Several auto-editing fixes
* Several turbo completion mode fixes
* Replace All preserves fold state when possible
* Git blame support
* Fixed debugging QThreads in older PyQt versions
* Shorter delay in restarting Python Shell or debug process
* About 15 other bug fixes and minor improvements

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

**New Features in Version 4**

Version 4 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
* Auto-Editing -- Reduce typing by auto-entering expected code
* 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


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 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, context-aware 
auto-editing,

  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/featuresfor a detailed listing
of features by product level.

System requirements are Windows 2000 or later, OS X 10.3.9or 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.1

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

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

**Purchasing and Upgrading**

Wing 4.x 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:


Re: python and xml

2012-05-16 Thread Nibin V M
thank you Stefan. but the XML output is assigned to a variable; how to
process the variable with XML contents?

On Wed, May 16, 2012 at 7:53 PM, Stefan Behnel stefan...@behnel.de wrote:

 Nibin V M, 16.05.2012 16:16:
  I am trying to use cPanel XML-API and every API call return data in XML
  format. I would like to know how to manipulate the data here.
 
  For eg: How can I read the CPU load data from the below output
 
 
 
  
 loadavgone0.00/onefive0.00/fivefifteen0.00/fifteen/loadavg!--
  whostmgrd --

 Here's some untested code to print the text values:

  import xml.etree.ElementTree as ET

  loadavg = ET.fromstring('loadavgone0.00/onefive0.00/five'
  'fifteen0.00/fifteen/loadavg')

  for interval_tag in ('one', 'five', 'fifteen'):
  print(loadavg.findtext(interval_tag))


 Stefan

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




-- 
Regards

Nibin.

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


Re: python and xml

2012-05-16 Thread Stefan Behnel
Hi,

please don't top-post (I fixed the citation order below).


Nibin V M, 16.05.2012 16:30:
 On Wed, May 16, 2012 at 7:53 PM, Stefan Behnel wrote:
 Nibin V M, 16.05.2012 16:16:
 I am trying to use cPanel XML-API and every API call return data in XML
 format. I would like to know how to manipulate the data here.

 For eg: How can I read the CPU load data from the below output



  loadavgone0.00/onefive0.00/fivefifteen0.00/fifteen
  /loadavg!-- whostmgrd --

 Here's some untested code to print the text values:

  import xml.etree.ElementTree as ET

  loadavg = ET.fromstring('loadavgone0.00/onefive0.00/five'
  'fifteen0.00/fifteen/loadavg')

  for interval_tag in ('one', 'five', 'fifteen'):
  print(loadavg.findtext(interval_tag))

 thank you Stefan. but the XML output is assigned to a variable; how to
 process the variable with XML contents?

Not sure what you mean. Maybe something like this?

xml = 'loadavgone0.00/onefive0.00/five.../loadavg'
loadavg = ET.fromstring(xml)

Stefan

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


How to embed python2 into python3?

2012-05-16 Thread ytj
Hello, all:

I have two programs, one is written in py3k, the other is written in
python 2. I am wondering how to make them work together except port
the python 2 code to py3k? Is that possible to expose python2's
function to py3k? In other words, I want to embed the Python 2
interpreter into my py3k program. So I can call python2's function in
py3k's code.

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


Re: what does newP = func(code,p) do?

2012-05-16 Thread Ian Kelly
On Wed, May 16, 2012 at 8:08 AM, e-mail mgbg25171
mgbg25...@blueyonder.co.uk wrote:
 def execute (code) :
     p = 0
     while p  len(code) :
     func = code[p]
     p += 1
     newP = func(code,p)
     if newP != None :
     p = newP

 I'm trying to work out what this does

 code is a list of function addresses and numbers
 What on earth is funct(code,p) doing???

code represents the bytecode of the Forth program being executed.  It
contains functions that represent operations and the data arguments used by
those operations.  p is the program counter, keeping track of which
opcode should be executed next.  func is the operation function that
was pulled from code at the current program counter.  func(code, p)
calls that function, passing in both the entire bytecode, and the
index into the bytecode at which the operation can find its data (if
any).  If the function returns a value, it means that the program
counter should be updated -- either to skip past a data element used
for the operation just executed, or to perform a jump to somewhere
else in the bytecode.  If the program counter ever falls off the end
of the bytecode, then the program terminates.
-- 
http://mail.python.org/mailman/listinfo/python-list


Difference between str.isdigit() and str.isdecimal() in Python 3

2012-05-16 Thread Marco

Hi all, because

There should be one-- and preferably only one --obvious way to do it,

there should be a difference between the two methods in the subject, but 
I can't find it:


 '123'.isdecimal(), '123'.isdigit()
(True, True)
 print('\u0660123')
٠123
 '\u0660123'.isdigit(), '\u0660123'.isdecimal()
(True, True)
 print('\u216B')
Ⅻ
 '\u216B'.isdecimal(), '\u216B'.isdigit()
(False, False)

Can anyone give me some help?
Regards, Marco
--
http://mail.python.org/mailman/listinfo/python-list


what does newP = func(code,p) do?

2012-05-16 Thread e-mail mgbg25171
It's been a long time since I did any Python and I've never done that
In C I'm used to storing function ptrs and then having to use some other
constructs to call them.
To be able to store func and then use func to call itself like that threw
me...it's very elegant.
Thank you very much for your very lucid explanation and for taking the time
to provide it.
Best Regards
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Difference between str.isdigit() and str.isdecimal() in Python 3

2012-05-16 Thread Ian Kelly
On Wed, May 16, 2012 at 9:48 AM, Marco marc...@nsgmail.com wrote:
 Hi all, because

 There should be one-- and preferably only one --obvious way to do it,

 there should be a difference between the two methods in the subject, but I
 can't find it:

 '123'.isdecimal(), '123'.isdigit()
 (True, True)
 print('\u0660123')
 ٠123
 '\u0660123'.isdigit(), '\u0660123'.isdecimal()
 (True, True)
 print('\u216B')
 Ⅻ
 '\u216B'.isdecimal(), '\u216B'.isdigit()
 (False, False)

 Can anyone give me some help?

Here's one example:

 '\u00B2'.isdecimal()
False
 '\u00B2'.isdigit()
True
 '\u00B2'
'²'

The distinction is explained in the docs at:
http://docs.python.org/py3k/library/stdtypes.html#str.isdigit

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


Re: Difference between str.isdigit() and str.isdecimal() in Python 3

2012-05-16 Thread MRAB

On 16/05/2012 16:48, Marco wrote:

Hi all, because

There should be one-- and preferably only one --obvious way to do it,

there should be a difference between the two methods in the subject, but
I can't find it:

'123'.isdecimal(), '123'.isdigit()
(True, True)
print('\u0660123')
٠123
'\u0660123'.isdigit(), '\u0660123'.isdecimal()
(True, True)
print('\u216B')
Ⅻ
'\u216B'.isdecimal(), '\u216B'.isdigit()
(False, False)

Can anyone give me some help?
Regards, Marco


Try this:

 different = [chr(c) for c in range(0x1) if chr(c).isdigit() != 
chr(c).isdecimal()]

 print(different)
['²', '³', '¹', '፩', '፪', '፫', '፬', '፭', '፮', '፯', '፰', '፱', '⁰', '⁴', 
'⁵', '⁶', '⁷', '⁸', '⁹', '₀', '₁', '₂', '₃', '₄', '₅', '₆', '₇', '₈', 
'₉', '①', '②', '③', '④', '⑤', '⑥', '⑦', '⑧', '⑨', '⑴', '⑵', '⑶', '⑷', 
'⑸', '⑹', '⑺', '⑻', '⑼', '⒈', '⒉', '⒊', '⒋', '⒌', '⒍', '⒎', '⒏', '⒐', 
'⓪', '⓵', '⓶', '⓷', '⓸', '⓹', '⓺', '⓻', '⓼', '⓽', '⓿', '❶', '❷', '❸', 
'❹', '❺', '❻', '❼', '❽', '❾', '➀', '➁', '➂', '➃', '➄', '➅', '➆', '➇', 
'➈', '➊', '➋', '➌', '➍', '➎', '➏', '➐', '➑', '➒']

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


Re: Difference between str.isdigit() and str.isdecimal() in Python 3

2012-05-16 Thread Ulrich Eckhardt
Marco wrote:
   '123'.isdecimal(), '123'.isdigit()
 (True, True)
   print('\u0660123')
 ٠123
   '\u0660123'.isdigit(), '\u0660123'.isdecimal()
 (True, True)
   print('\u216B')
 Ⅻ
   '\u216B'.isdecimal(), '\u216B'.isdigit()
 (False, False)

[chr(a) for a in range(0x2) if chr(a).isdigit()]

Congratulations, you found a bug! Or maybe not, it all depends on whether 
Roman numbers are considered digits or not. I could imagine there being a 
difference.

:)

Uli

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


Re: Difference between str.isdigit() and str.isdecimal() in Python 3

2012-05-16 Thread Ian Kelly
On Wed, May 16, 2012 at 10:24 AM, Ulrich Eckhardt dooms...@knuut.de wrote:
 Marco wrote:
   '123'.isdecimal(), '123'.isdigit()
 (True, True)
   print('\u0660123')
 ٠123
   '\u0660123'.isdigit(), '\u0660123'.isdecimal()
 (True, True)
   print('\u216B')
 Ⅻ
   '\u216B'.isdecimal(), '\u216B'.isdigit()
 (False, False)

 [chr(a) for a in range(0x2) if chr(a).isdigit()]

 Congratulations, you found a bug! Or maybe not, it all depends on whether
 Roman numbers are considered digits or not. I could imagine there being a
 difference.

They're not.  The word digit specifically refers to the symbols used
by a positional numeral system, e.g. Arabic numerals.  Roman numerals
are not a positional system.  The word decimal in this case more
specifically means a digit character that is actually suitable for
using to compose a decimal number.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to embed python2 into python3?

2012-05-16 Thread Chris Rebert
On Wed, May 16, 2012 at 7:59 AM, ytj ytj...@gmail.com wrote:
 Hello, all:

 I have two programs, one is written in py3k, the other is written in
 python 2. I am wondering how to make them work together except port
 the python 2 code to py3k?

Porting the Python 3 code to Python 2 is also an option:
http://pypi.python.org/pypi/3to2

But unless you're dependent on a library not available for Python 3
yet, the normal 2to3 route is probably preferable.

In either direction, this library may help ease the transition:
http://pypi.python.org/pypi/six/

 Is that possible to expose python2's
 function to py3k? In other words, I want to embed the Python 2
 interpreter into my py3k program. So I can call python2's function in
 py3k's code.

That's very likely possible using the C API; I don't know of any
prepackaged solution though.
Another obvious approach to connect the two interpreters would be to
use some form of IPC or RPC (e.g. XML-RPC, Unix domain sockets, etc.).
There will be some degree of extra overhead involved no matter which
route you go.

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


Re: How to embed python2 into python3?

2012-05-16 Thread Ian Kelly
On Wed, May 16, 2012 at 8:59 AM, ytj ytj...@gmail.com wrote:
 Hello, all:

 I have two programs, one is written in py3k, the other is written in
 python 2. I am wondering how to make them work together except port
 the python 2 code to py3k? Is that possible to expose python2's
 function to py3k? In other words, I want to embed the Python 2
 interpreter into my py3k program. So I can call python2's function in
 py3k's code.

I think you're likely to run into conflicts doing that.  Here's the
result of a quick test using ctypes:

Python 3.2 (r32:88445, Feb 20 2011, 21:29:02) [MSC v.1500 32 bit
(Intel)] on win32
Type help, copyright, credits or license for more information.
 from ctypes import *
 python27 = cdll.python27
 python27.Py_Initialize()
  File c:\python32\lib\site.py, line 159
file=sys.stderr)
^
SyntaxError: invalid syntax

For some reason, even though I loaded the Python 2.7 DLL, it's then
trying to import the Python 3.2 libraries.  My suggestion: instead of
embedding, use the subprocess module, and keep both Python
interpreters firmly entrenched in separate processes.

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


Re: Difference between str.isdigit() and str.isdecimal() in Python 3

2012-05-16 Thread Marco

On 05/16/2012 06:24 PM, Ulrich Eckhardt wrote:


Marco wrote:

  '123'.isdecimal(), '123'.isdigit()
  (True, True)
  print('\u0660123')
  ٠123
  '\u0660123'.isdigit(), '\u0660123'.isdecimal()
  (True, True)
  print('\u216B')
  Ⅻ
  '\u216B'.isdecimal(), '\u216B'.isdigit()
  (False, False)



[chr(a) for a in range(0x2) if chr(a).isdigit()]


Thanks to your list comprehension I found they are not equal:

 set([chr(a) for a in range(0x10) if chr(a).isdigit()]) - \
... set([chr(a) for a in range(0x10) if chr(a).isdecimal()])

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


Re: Difference between str.isdigit() and str.isdecimal() in Python 3

2012-05-16 Thread jmfauth
On 16 mai, 17:48, Marco marc...@nsgmail.com wrote:
 Hi all, because

 There should be one-- and preferably only one --obvious way to do it,

 there should be a difference between the two methods in the subject, but
 I can't find it:

   '123'.isdecimal(), '123'.isdigit()
 (True, True)
   print('\u0660123')
 ٠123
   '\u0660123'.isdigit(), '\u0660123'.isdecimal()
 (True, True)
   print('\u216B')
 Ⅻ
   '\u216B'.isdecimal(), '\u216B'.isdigit()
 (False, False)

 Can anyone give me some help?
 Regards, Marco

It seems to me that it is correct, and the reason lies in this:

 import unicodedata as ud
 ud.category('\u216b')
'Nl'
 ud.category('1')
'Nd'

 # Note
 ud.numeric('\u216b')
12.0

jmf

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


Re: which book?

2012-05-16 Thread Ashraf Fouda
I recommend this book :- beginning python from novice to professional

On Wed, May 9, 2012 at 4:13 PM, Miki Tebeka miki.teb...@gmail.com wrote:

  I am going to learn python for some plot issues. which book or sources,
 do you recommend please?
 The tutorial is pretty good if you already know how to program.
 I also heard a lot of good things on Python Essential Reference.

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




-- 
yours
Ashraf Fouda
Software Engineer
*
*
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Difference between str.isdigit() and str.isdecimal() in Python 3

2012-05-16 Thread Thomas 'PointedEars' Lahn
Marco wrote:

 Hi all, because
 
 There should be one-- and preferably only one --obvious way to do it,
 
 there should be a difference between the two methods in the subject, but
 I can't find it:
 
   '123'.isdecimal(), '123'.isdigit()
 (True, True)
   print('\u0660123')
 ٠123
   '\u0660123'.isdigit(), '\u0660123'.isdecimal()
 (True, True)
   print('\u216B')
 Ⅻ
   '\u216B'.isdecimal(), '\u216B'.isdigit()
 (False, False)
 
 Can anyone give me some help?

RTFM.

$ python3 -c 'print(42.isdecimal.__doc__ + \n); 
print(42.isdigit.__doc__)'
S.isdecimal() - bool

Return True if there are only decimal characters in S,
False otherwise.

S.isdigit() - bool

Return True if all characters in S are digits
and there is at least one character in S, False otherwise.

-- 
PointedEars

Please do not Cc: me. / Bitte keine Kopien per E-Mail.
-- 
http://mail.python.org/mailman/listinfo/python-list


cPython, IronPython, Jython, and PyPy (Oh my!)

2012-05-16 Thread Ethan Furman

Just hit a snag:

In cPython the deterministic garbage collection allows me a particular 
optimization when retrieving records from a dbf file -- namely, by using 
weakrefs I can tell if the record is still in memory and active, and if 
so not hit the disk to get the data;  with PyPy (and probably the 
others) this doesn't work because the record may still be around even 
when it is no longer active because it hasn't been garbage collected yet.


For PyPy I can use `'PyPy' in sys.version` to set a constant 
(REFRESH_FROM_DISK in this case) to disable the cPython optimization; 
does anyone know what strings to look for for the other implementations?


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


Re: Difference between str.isdigit() and str.isdecimal() in Python 3

2012-05-16 Thread Ian Kelly
On Wed, May 16, 2012 at 3:07 PM, Thomas 'PointedEars' Lahn
pointede...@web.de wrote:
 RTFM.

 $ python3 -c 'print(42.isdecimal.__doc__ + \n);
 print(42.isdigit.__doc__)'
 S.isdecimal() - bool

 Return True if there are only decimal characters in S,
 False otherwise.

 S.isdigit() - bool

 Return True if all characters in S are digits
 and there is at least one character in S, False otherwise.

Those doc strings are not very helpful at all.  I read them myself and
then had to go to the library docs to figure out what the actual
difference was.
-- 
http://mail.python.org/mailman/listinfo/python-list


non-pickle persistance for dicts?

2012-05-16 Thread Charles Hixson
I want to persist simple dicts, but due to the security problems with 
(un)pickle, I'd prefer to not use shelve, and the only way I could see 
to persist them onto sqlite also invoked pickle.


As (un)pickle allows arbitrary system commands to be issued, I'd really 
rather just use a simple convert to and from either bytes or strings.  
repr works well for the conversion into string (I said they were 
simple), but I'd really rather be able to turn {'a': 'A', 1: 23, 2: 
['b', 2]} back into a dict without allowing the execution of arbitrary 
commands.


Any suggestions?

--
Charles Hixson

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


Re: cPython, IronPython, Jython, and PyPy (Oh my!)

2012-05-16 Thread Ian Kelly
On Wed, May 16, 2012 at 3:33 PM, Ethan Furman et...@stoneleaf.us wrote:
 Just hit a snag:

 In cPython the deterministic garbage collection allows me a particular
 optimization when retrieving records from a dbf file -- namely, by using
 weakrefs I can tell if the record is still in memory and active, and if so
 not hit the disk to get the data;  with PyPy (and probably the others) this
 doesn't work because the record may still be around even when it is no
 longer active because it hasn't been garbage collected yet.

 For PyPy I can use `'PyPy' in sys.version` to set a constant
 (REFRESH_FROM_DISK in this case) to disable the cPython optimization; does
 anyone know what strings to look for for the other implementations?

Python 2.7.1 (r271:86832, Nov 27 2010, 18:30:46) [MSC v.1500 32 bit
(Intel)] on win32
Type help, copyright, credits or license for more information.
 import sys
 sys.subversion
('CPython', 'tags/r271', '86832')

Jython 2.5.2 (Release_2_5_2:7206, Mar 2 2011, 23:12:06)
[Java HotSpot(TM) Client VM (Sun Microsystems Inc.)] on java1.6.0_31
Type help, copyright, credits or license for more information.
 import sys
 sys.subversion
('Jython', 'tags/Release_2_5_2', '7206')

I don't know what IronPython or PyPy return, but it should be
something other than 'CPython'.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: non-pickle persistance for dicts?

2012-05-16 Thread Ian Kelly
On Wed, May 16, 2012 at 3:52 PM, Charles Hixson
charleshi...@earthlink.net wrote:
 I want to persist simple dicts, but due to the security problems with
 (un)pickle, I'd prefer to not use shelve, and the only way I could see to
 persist them onto sqlite also invoked pickle.

 As (un)pickle allows arbitrary system commands to be issued, I'd really
 rather just use a simple convert to and from either bytes or strings.  repr
 works well for the conversion into string (I said they were simple), but I'd
 really rather be able to turn {'a': 'A', 1: 23, 2: ['b', 2]} back into a
 dict without allowing the execution of arbitrary commands.

 Any suggestions?

Either json, or repr with ast.literal_eval will be safe.

 import json
 d = {'a': 'A', 1: 23, 2: ['b', 2]}
 json.dumps(d)
'{a: A, 1: 23, 2: [b, 2]}'
 json.loads(json.dumps(d))
{'a': 'A', '1': 23, '2': ['b', 2]}
 import ast
 ast.literal_eval(repr(d))
{'a': 'A', 1: 23, 2: ['b', 2]}

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


Re: cPython, IronPython, Jython, and PyPy (Oh my!)

2012-05-16 Thread Tim Delaney
On 17 May 2012 07:33, Ethan Furman et...@stoneleaf.us wrote:

 Just hit a snag:

 In cPython the deterministic garbage collection allows me a particular
 optimization when retrieving records from a dbf file -- namely, by using
 weakrefs I can tell if the record is still in memory and active, and if so
 not hit the disk to get the data;  with PyPy (and probably the others) this
 doesn't work because the record may still be around even when it is no
 longer active because it hasn't been garbage collected yet.


What is the distinguishing feature of an active record? What is the
problem if you get back a reference to an inactive record? And if there is
indeed a problem, don't you already have a race condition on CPython?

1. Record is active;
2. Get reference to record through weak ref;
3. Record becomes inactive;
4. Start trying to use the (now inactive) record.

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


Re: How to call and execute C code in Python?

2012-05-16 Thread Barry Scott
There are many choices rather then raw python C API calls. Boost, PyCXX and 
ctypes are worth investigating. PyCXX requires you code in C++ but hides lots 
of the issues of using the Python API from you. It also supports python 2 and 
3. 

Barry - PyCXX maintainer

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


Re: cPython, IronPython, Jython, and PyPy (Oh my!)

2012-05-16 Thread Ethan Furman

Ian Kelly wrote:

On Wed, May 16, 2012 at 3:33 PM, Ethan Furman et...@stoneleaf.us wrote:

Just hit a snag:

In cPython the deterministic garbage collection allows me a particular
optimization when retrieving records from a dbf file -- namely, by using
weakrefs I can tell if the record is still in memory and active, and if so
not hit the disk to get the data;  with PyPy (and probably the others) this
doesn't work because the record may still be around even when it is no
longer active because it hasn't been garbage collected yet.

For PyPy I can use `'PyPy' in sys.version` to set a constant
(REFRESH_FROM_DISK in this case) to disable the cPython optimization; does
anyone know what strings to look for for the other implementations?


Python 2.7.1 (r271:86832, Nov 27 2010, 18:30:46) [MSC v.1500 32 bit
(Intel)] on win32
Type help, copyright, credits or license for more information.

import sys
sys.subversion

('CPython', 'tags/r271', '86832')

Jython 2.5.2 (Release_2_5_2:7206, Mar 2 2011, 23:12:06)
[Java HotSpot(TM) Client VM (Sun Microsystems Inc.)] on java1.6.0_31
Type help, copyright, credits or license for more information.

import sys
sys.subversion

('Jython', 'tags/Release_2_5_2', '7206')

I don't know what IronPython or PyPy return, but it should be
something other than 'CPython'.


Thanks!  That will do the trick.  On CPython 2.4 .subversion does not 
exist, so I'll use:


subversion = getattr(sys, 'subversion', None)
if subversion is not None and subversion[0] != 'CPython':
...

Hopefully all the others do have it defined (PyPy does, at least as of 1.8).

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


Re: non-pickle persistance for dicts?

2012-05-16 Thread Charles Hixson

On 05/16/2012 03:11 PM, Ian Kelly wrote:

On Wed, May 16, 2012 at 3:52 PM, Charles Hixson
charleshi...@earthlink.net  wrote:
   

I want to persist simple dicts, but due to the security problems with
(un)pickle, I'd prefer to not use shelve, and the only way I could see to
persist them onto sqlite also invoked pickle.

As (un)pickle allows arbitrary system commands to be issued, I'd really
rather just use a simple convert to and from either bytes or strings.  repr
works well for the conversion into string (I said they were simple), but I'd
really rather be able to turn {'a': 'A', 1: 23, 2: ['b', 2]} back into a
dict without allowing the execution of arbitrary commands.

Any suggestions?
 

Either json, or repr with ast.literal_eval will be safe.

   

import json
d = {'a': 'A', 1: 23, 2: ['b', 2]}
json.dumps(d)
 

'{a: A, 1: 23, 2: [b, 2]}'
   

json.loads(json.dumps(d))
 

{'a': 'A', '1': 23, '2': ['b', 2]}
   

import ast
ast.literal_eval(repr(d))
 

{'a': 'A', 1: 23, 2: ['b', 2]}

Cheers,
Ian

   
Thanks.  It looks like either would do what I need.  Any suggestion as 
to how to choose between them?  E.g., is AST better supported?  faster?  
(I'm tending towards AST purely because it seems more tied to Python, 
but of course that *could* be a disadvantage, if there were more 
external tools for working with json.)


--
Charles Hixson

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


Re: non-pickle persistance for dicts?

2012-05-16 Thread Ian Kelly
On Wed, May 16, 2012 at 4:53 PM, Charles Hixson
charleshi...@earthlink.net wrote:
 On 05/16/2012 03:11 PM, Ian Kelly wrote:

 On Wed, May 16, 2012 at 3:52 PM, Charles Hixson
 charleshi...@earthlink.net  wrote:


 I want to persist simple dicts, but due to the security problems with
 (un)pickle, I'd prefer to not use shelve, and the only way I could see to
 persist them onto sqlite also invoked pickle.

 As (un)pickle allows arbitrary system commands to be issued, I'd really
 rather just use a simple convert to and from either bytes or strings.
  repr
 works well for the conversion into string (I said they were simple), but
 I'd
 really rather be able to turn {'a': 'A', 1: 23, 2: ['b', 2]} back into
 a
 dict without allowing the execution of arbitrary commands.

 Any suggestions?


 Either json, or repr with ast.literal_eval will be safe.



 import json
 d = {'a': 'A', 1: 23, 2: ['b', 2]}
 json.dumps(d)


 '{a: A, 1: 23, 2: [b, 2]}'


 json.loads(json.dumps(d))


 {'a': 'A', '1': 23, '2': ['b', 2]}


 import ast
 ast.literal_eval(repr(d))


 {'a': 'A', 1: 23, 2: ['b', 2]}

 Cheers,
 Ian



 Thanks.  It looks like either would do what I need.  Any suggestion as to
 how to choose between them?  E.g., is AST better supported?  faster?  (I'm
 tending towards AST purely because it seems more tied to Python, but of
 course that *could* be a disadvantage, if there were more external tools for
 working with json.)

You pretty much just summed it up.  JSON is more portable because it's
a well-known standard with implementations in a lot of different
languages.  On the downside, since it essentially involves translating
your data into *JavaScript* literals and back, it's not going to be
quite as faithful.  Notice in the example that the numeric dictionary
keys got turned into strings.  AST will do a cleaner job since you're
just converting Python objects into Python literals and back, but the
serialized data will only be easily readable using Python.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: cPython, IronPython, Jython, and PyPy (Oh my!)

2012-05-16 Thread Ethan Furman

Tim Delaney wrote:

On 17 May 2012 07:33, Ethan Furman wrote:

Just hit a snag:

In cPython the deterministic garbage collection allows me a
particular optimization when retrieving records from a dbf file --
namely, by using weakrefs I can tell if the record is still in
memory and active, and if so not hit the disk to get the data;  with
PyPy (and probably the others) this doesn't work because the record
may still be around even when it is no longer active because it
hasn't been garbage collected yet.



What is the distinguishing feature of an active record? What is the 
problem if you get back a reference to an inactive record? And if there 
is indeed a problem, don't you already have a race condition on CPython?


1. Record is active;
2. Get reference to record through weak ref;
3. Record becomes inactive;
4. Start trying to use the (now inactive) record.


A record is an interesting critter -- it is given life either from the 
user or from the disk-bound data;  its fields can then change, but those 
changes are not reflected on disk until .write_record() is called;  I do 
this because I am frequently moving data from one table to another, 
making changes to the old record contents before creating the new record 
with the changes -- since I do not call .write_record() on the old 
record those changes do not get backed up to disk.


With CPython as soon as a record goes out of scope it dies, and the next 
time I try to access that record I will get the disk version, without 
the temporary changes I had made earlier (this is good).  However, with 
PyPy (and others) not all records are destroyed before I try to access 
them again, and I end up seeing the temp data instead of the disk data.


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


Re: Difference between str.isdigit() and str.isdecimal() in Python 3

2012-05-16 Thread Steven D'Aprano
On Wed, 16 May 2012 17:48:19 +0200, Marco wrote:

 Hi all, because
 
 There should be one-- and preferably only one --obvious way to do it,
 
 there should be a difference between the two methods in the subject, but
 I can't find it:

The Fine Manual has more detail, although I admit it isn't *entirely* 
clear what it is talking about if you're not a Unicode expert:


http://docs.python.org/py3k/library/stdtypes.html#str.isdecimal

str.isdecimal()
Return true if all characters in the string are decimal characters 
and there is at least one character, false otherwise. Decimal characters 
are those from general category “Nd”. This category includes digit 
characters, and all characters that can be used to form decimal-radix 
numbers, e.g. U+0660, ARABIC-INDIC DIGIT ZERO.

str.isdigit()
Return true if all characters in the string are digits and there is 
at least one character, false otherwise. Digits include decimal 
characters and digits that need special handling, such as the 
compatibility superscript digits. Formally, a digit is a character that 
has the property value Numeric_Type=Digit or Numeric_Type=Decimal.


And also:

str.isnumeric()
Return true if all characters in the string are numeric characters, 
and there is at least one character, false otherwise. Numeric characters 
include digit characters, and all characters that have the Unicode 
numeric value property, e.g. U+2155, VULGAR FRACTION ONE FIFTH. Formally, 
numeric characters are those with the property value Numeric_Type=Digit, 
Numeric_Type=Decimal or Numeric_Type=Numeric.


Examples:

py c = '\u2155'
py print(c)
⅕
py c.isdecimal(), c.isdigit(), c.isnumeric()
(False, False, True)
py import unicodedata
py unicodedata.numeric(c)
0.2

py c = '\u00B2'
py print(c)
²
py c.isdecimal(), c.isdigit(), c.isnumeric()
(False, True, True)
py unicodedata.numeric(c)
2.0


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


Re: non-pickle persistance for dicts?

2012-05-16 Thread Devin Jeanpierre
On Wed, May 16, 2012 at 6:53 PM, Charles Hixson
charleshi...@earthlink.net wrote:
 Thanks.  It looks like either would do what I need.  Any suggestion as to
 how to choose between them?  E.g., is AST better supported?  faster?  (I'm
 tending towards AST purely because it seems more tied to Python, but of
 course that *could* be a disadvantage, if there were more external tools for
 working with json.)

I'd pick json, because it will tell you if you try to serialize
something that can't be deserialized. repr() will just dump it, and
then you'll find out later (on load) that it wasn't serialized
properly.

repr() is not meant for storing data, it's meant for presenting it to
a programmer.

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


Re: cPython, IronPython, Jython, and PyPy (Oh my!)

2012-05-16 Thread Chris Angelico
On Thu, May 17, 2012 at 9:01 AM, Ethan Furman et...@stoneleaf.us wrote:
 A record is an interesting critter -- it is given life either from the user
 or from the disk-bound data;  its fields can then change, but those changes
 are not reflected on disk until .write_record() is called;  I do this
 because I am frequently moving data from one table to another, making
 changes to the old record contents before creating the new record with the
 changes -- since I do not call .write_record() on the old record those
 changes do not get backed up to disk.

I strongly recommend being more explicit about usage and when it gets
written and re-read, rather than relying on garbage collection.
Databasing should not be tied to a language's garbage collection.
Imagine you were to reimplement the equivalent logic in some other
language - could you describe it clearly? If so, then that's your
algorithm. If not, you have a problem.

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


Re: cPython, IronPython, Jython, and PyPy (Oh my!)

2012-05-16 Thread Tim Delaney
On 17 May 2012 11:13, Chris Angelico ros...@gmail.com wrote:

 On Thu, May 17, 2012 at 9:01 AM, Ethan Furman et...@stoneleaf.us wrote:
  A record is an interesting critter -- it is given life either from the
 user
  or from the disk-bound data;  its fields can then change, but those
 changes
  are not reflected on disk until .write_record() is called;  I do this
  because I am frequently moving data from one table to another, making
  changes to the old record contents before creating the new record with
 the
  changes -- since I do not call .write_record() on the old record those
  changes do not get backed up to disk.

 I strongly recommend being more explicit about usage and when it gets
 written and re-read, rather than relying on garbage collection.
 Databasing should not be tied to a language's garbage collection.
 Imagine you were to reimplement the equivalent logic in some other
 language - could you describe it clearly? If so, then that's your
 algorithm. If not, you have a problem.


Agreed. To me, this sounds like a perfect case for with: blocks and
explicit reference counting.  Something like (pseudo-python - not runnable):

class Record:
def __init__(self):
self.refs = 0
self.lock = threading.Lock()

def __enter__(self):
with self.lock:
self.refs += 1

def __exit__(self):
with self.lock:
self.refs -=1

if self.refs == 0:
self.write_record()

rest of Record class

rec = record_weakrefs.get('record_name')

if rec is None:
rec = load_record()
record_weakrefs.put('record_name', rec)

with rec:
do_stuff

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


Newbie questions on import cmd line run

2012-05-16 Thread gwhite
Hi,

I am a newbie running the latest pythonxy (2.7.2.1)  spyder and
python 2.7.2.   I suspect my questions are mostly basic to python, and
not specific to Spyder or iPython.

Note: Up until now, I mainly used MATLAB, and thus need to de-program
myself appropriately.

I use Win7-64.

I wrote the following .py file:

-
#! what is supposed to go here?
# Filename: newbie00.py

if __name__ == '__main__':
print 'This program was called from the \
system command line.'
print __name__ + '.py'
else:
print 'This program was imported on the \
Python command line.'
print __name__ + '.py'

-

If I run from the system (win cmd) command, I get:

C:\engineer\engruser\pythonpython  newbie00.py

This program was called from the system command line.
__main__.py

-
If I hit the run button in Sypder, I get (in the iPython command
console):

In [70]: runfile(r'C:\engineer\engruser\python\newbie00.py', wdir=r'C:
\engineer\engruser\python')
This program was called from the system command line.
__main__.py


-
If I import on the iPython command, I get:

In [71]: import newbie00
This program was imported on the Python command line.
newbie00.py

-
If I import *again* on the iPython command, I get:

In [72]: import newbie00

In [73]:

nothing that I can see

-
If I hit the run button (again) in Sypder, I get (in the iPython
command console):

In [73]: runfile(r'C:\engineer\engruser\python\newbie00.py', wdir=r'C:
\engineer\engruser\python')
UMD has deleted: newbie00
This program was called from the system command line.
__main__.py

---

Some questions:

1.  If running from the system command line, or the Sypder run
button, __name__ is __main__ rather than newbie00, as seen
above.

So, how would I get the file name newbie00.py in these two noted
cases?  I mean, what other function do I use to get it?  (This
functionality is something that occasionally came in handy back in my
m-file writing days.  Perhaps I am wrong in anticipating such an
occasional need, but I would not know that yet.)

2.  In python, there seems to be a distinction between running
something as if it is a system command of C:\...python myPyFile.py
compared to simply entering that same .py file name directly on the
python console command line.  In fact, the latter does not work unless
the somewhat lengthy  runfile(r'C:\... wdir=r'C:\...) stuff is
entered (in iPython).  (I mean, my old MATLAB habit of simply entering
 mfilename on the command line seems to be quite wrong in python.)

Is there a shortened syntax of running a .py from the python command
prompt, if not using a Spyder run button?  Or should I always run as
if from the system prompt?  That is, dispense with the MATLAB-like
run from MATLAB/python command line bias I may be holding.

3.  In injecting my old MATLAB bias of running via the command line
 mfilename, I tried a tweak of  import newbie00.  That sort
of worked, but only the first time.

Why did the subsequent run of import newbie00 print nothing?  I'm
just trying to understand how python works.

4.  The final case shown of hitting the Spyder run button included
this:

UMD has deleted: newbie00

What does that mean?  I noted that after this automatic deletion, I
could do the import newbie00 once again and get the print.  (I
did not show that above.)

5.  I think #4 implies an import can be removed.  (Yes/No?)  I am not
sure why that would be desired, but I will ask how to remove an
import, or to refresh the run, of that is the appropriate question.

I think I saw someplace where a .pyc file is created on an initial run
and subsequently run instead of the .py.  I'm not sure if that applies
here, but if related, I guess an auxiliary question is how to easily
force the .py to run rather than the .pyc?

6.  Perhaps peripherally related to getting a running script/function/
module name, is getting a call listing of all the functions (and
modules) called by a .py program.  How would I get that?  I only ask
as it comes in handy if one distributes a program.  I mean, you only
give people what they actually need.

---
Advance thanks to any one who answers any of my questions.  I am sure
they appear from misguided to rudimentary in character.  I'm don't
claim to be a programmer; I did okay with MATLAB.  I'm trying to
bootstrap here, and appreciate any help.

Thanks!
Greg




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


bash/shell to python

2012-05-16 Thread Rita
Hello,

I currently build a lot of interfaces/wrappers to other applications using
bash/shell. One short coming for it is it lacks a good method to handle
arguments so I switched to python a while ago to use 'argparse' module. Its
a great complement to subprocess module. I was wondering if there is a
generic framework people follow to build python scripts which are replacing
shell scripts? Is there a guide or a template to follow?





-- 
--- Get your facts first, then you can distort them as you please.--
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: cPython, IronPython, Jython, and PyPy (Oh my!)

2012-05-16 Thread Ethan Furman

Chris Angelico wrote:

On Thu, May 17, 2012 at 9:01 AM, Ethan Furman et...@stoneleaf.us wrote:

A record is an interesting critter -- it is given life either from the user
or from the disk-bound data;  its fields can then change, but those changes
are not reflected on disk until .write_record() is called;  I do this
because I am frequently moving data from one table to another, making
changes to the old record contents before creating the new record with the
changes -- since I do not call .write_record() on the old record those
changes do not get backed up to disk.


I strongly recommend being more explicit about usage and when it gets
written and re-read, rather than relying on garbage collection.
Databasing should not be tied to a language's garbage collection.
Imagine you were to reimplement the equivalent logic in some other
language - could you describe it clearly? If so, then that's your
algorithm. If not, you have a problem.


Yeah, I've been thinking about this for a couple hours now;  initially 
(way back when) I didn't want to keep hitting the disk unnecessarily 
-- but all my other supporting data structures go to great lengths to 
not keep records in memory unless the user has them explicitly named or 
contained... I think I've been fighting against myself!  Good news is 
I'm winning.  ;)


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


Where is the most recent Tkinter information

2012-05-16 Thread Mark R Rivet
It seems like all the info on tkinter is around the 2000 time frame.
Is tkinter still being developed/supported?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Where is the most recent Tkinter information

2012-05-16 Thread Terry Reedy

On 5/16/2012 11:02 PM, Mark R Rivet wrote:

It seems like all the info on tkinter is around the 2000 time frame.
Is tkinter still being developed/supported?


tkinter is CPython's tk interface. tcl/tk is still being developed at 
Active State. The Windows release for Py 3.3 will come with 8.5.11, 
released a couple of months ago. tkinter does not change much because tk 
does not change much. But bugs are fixed as reported. A fix for an 
obscure bug affecting certain *nix systems was committed just today. The 
docs do need improving.


--
Terry Jan Reedy

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


Re: Are there any instrumentation widgets for wxpython or tkinter?

2012-05-16 Thread Mark R Rivet
On Sat, 12 May 2012 12:40:28 -0700 (PDT), Sverre
sverreodeg...@gmail.com wrote:

I searched for widgets used for PLC automation or lab instrumentation
like gauges, led's etc. in the net, but didn't found anything because
of those massive link spam sites. In the case there isn't any
solution, with which toolkit would it be easiest to build gauges?

I just skimmed through the book Python and Tkinter by John E.
Grayson. This book goes through everything I think you will need for
instrumentation type widgets. It even shows how to create your own new
widgets. A lot of information in this book. Its dated, but there isn't
any other book available. But try some of the code, see how it works.
I know I'm going to.
-- 
http://mail.python.org/mailman/listinfo/python-list


Python and Tkinter by John E Grayson

2012-05-16 Thread Mark R Rivet
 I have a copy of this book and was wondering how relevant the content
is considering the publish date is 2000. Are people still using this
information? Anyone have any experience with this book? I guess what I
mean, is, any of the code in this book deprecated? or does it still
contain information used today the same as then. I mean, I guess some
things don't change right? For instance,  the derivative of x^2 is 2x
now and in the 1800's.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Where is the most recent Tkinter information

2012-05-16 Thread Simon Cropper

On 17/05/12 13:02, Mark R Rivet wrote:

It seems like all the info on tkinter is around the 2000 time frame.
Is tkinter still being developed/supported?


The main page of the python 3.2.3 documentation for tkinter can be found 
here... 
http://docs.python.org/py3k/library/tkinter.html?highlight=tkinter#tkinter 
it is dated 2012.


This seems to be duplicated from the ActiveState site here...
http://docs.activestate.com/activepython/3.1/python/library/tkinter.html 
also dated 2012.


Here are some other resources I have stumbled on...

http://www.tutorialspoint.com/python/python_gui_programming.htm

http://infohost.nmt.edu/tcc/help/pubs/tkinter/

http://www.tkdocs.com/tutorial/index.html

http://www.ibm.com/developerworks/linux/library/l-tkprg/

--
Cheers Simon

   Simon Cropper - Open Content Creator / Website Administrator

   Free and Open Source Software Workflow Guides
   
   Introduction   http://www.fossworkflowguides.com
   GIS Packages   http://www.fossworkflowguides.com/gis
   bash / Pythonhttp://www.fossworkflowguides.com/scripting
--
http://mail.python.org/mailman/listinfo/python-list


Re: Newbie questions on import cmd line run

2012-05-16 Thread Terry Reedy

On 5/16/2012 9:45 PM, gwhite wrote:

Hi,

I am a newbie running the latest pythonxy (2.7.2.1)  spyder and
python 2.7.2.   I suspect my questions are mostly basic to python, and
not specific to Spyder or iPython.

Note: Up until now, I mainly used MATLAB, and thus need to de-program
myself appropriately.

I use Win7-64.

I wrote the following .py file:

-
#!what is supposed to go here?
# Filename: newbie00.py

if __name__ == '__main__':
 print 'This program was called from the \
system command line.'
 print __name__ + '.py'
else:
 print 'This program was imported on the \
Python command line.'
 print __name__ + '.py'

-

If I run from the system (win cmd) command, I get:

C:\engineer\engruser\pythonpython  newbie00.py

This program was called from the system command line.
__main__.py

-
If I hit the run button in Sypder, I get (in the iPython command
console):

In [70]: runfile(r'C:\engineer\engruser\python\newbie00.py', wdir=r'C:
\engineer\engruser\python')
This program was called from the system command line.
__main__.py


-
If I import on the iPython command, I get:

In [71]: import newbie00
This program was imported on the Python command line.
newbie00.py

-
If I import *again* on the iPython command, I get:

In [72]: import newbie00

In [73]:

nothing that I can see


Read the doc for the import command. It only runs code when needed to 
create the module to import. When you import again, you re-import the 
existing module.



If I hit the run button (again) in Sypder, I get (in the iPython
command console):

In [73]: runfile(r'C:\engineer\engruser\python\newbie00.py', wdir=r'C:
\engineer\engruser\python')
UMD has deleted: newbie00


This output is Spyder specific. When you run from an Idle window, it prints
== RESTART 
which means that the user main namespace is reset. Idle usually does 
this by starting a new user subprocess (and terminating the old one), 
but the alternative would be to try to clean the existing subprocess by 
reversing and resetting everything that was done. Wiping out everything 
and restarting is easier ;-).



1.  If running from the system command line, or the Sypder run
button, __name__ is __main__ rather than newbie00, as seen
above. [how to get latter]


# Running in 3.3 Idle from edit window: tem.py
print(dir())
print(__file__)
# output in shell window
['__builtins__', '__doc__', '__file__', '__name__', '__package__']
F:\Python\mypy\tem.py

os.path.something() can isolate the last part in a cross-platform manner.


2.  In python, there seems to be a distinction between running
something as if it is a system command of C:\...python myPyFile.py


You use dos syntax in the dos command prompt window.


compared to simply entering that same .py file name directly on the
python console command line.


You use python syntax in the interactive python console. The Idle Shell 
closes simulates that. Other shells add extra syntax that only works in 
the specific shell.


 In fact, the latter does not work unless

the somewhat lengthy   runfile(r'C:\... wdir=r'C:\...) stuff is
entered (in iPython).  (I mean, my old MATLAB habit of simply entering
  mfilename on the command line seems to be quite wrong in python.)


I believe runfile is ipython (?) specific.

 exec(open(F:\\Python\\mypy\\tem.py).read())
['__builtins__', '__doc__', '__file__', '__name__', '__package__', 
'__warningregistry__']

F:\Python\mypy\tem.py

It is relatively unusual to run a file in the main space rather than 
importing it.



5.  I think #4 implies an import can be removed.  (Yes/No?)


Yes, but it is not a newbie thing to do, and it often does not do what 
people expect or want. My advice: forget about it.



I think I saw someplace where a .pyc file is created on an initial run
and subsequently run instead of the .py.


A .pyc file is only generated when the .py is imported. But this is 
unreleated to the above and a CPython-specific behind-the-scenes time 
optimization you should not worry about.



here, but if related, I guess an auxiliary question is how to easily
force the .py to run rather than the .pyc?


You do not want to do that. If the .py is changed, the .pyc is 
regenerated on the next import.



6.  Perhaps peripherally related to getting a running script/function/
module name, is getting a call listing of all the functions (and
modules) called by a .py program.  How would I get that?  I only ask
as it comes in handy if one distributes a program.  I mean, you only
give people what they actually need.


Look at the trace module. Of course, you distribute files, not 
functions. There are various packaging programs that do a module import 
trace rather than function call trace.


--
Terry Jan Reedy

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


Re: Newbie questions on import cmd line run

2012-05-16 Thread Chris Rebert
On Wed, May 16, 2012 at 6:45 PM, gwhite gwh...@ti.com wrote:
 Hi,

 I am a newbie running the latest pythonxy (2.7.2.1)  spyder and
 python 2.7.2.   I suspect my questions are mostly basic to python, and
 not specific to Spyder or iPython.

 Note: Up until now, I mainly used MATLAB, and thus need to de-program
 myself appropriately.

 I use Win7-64.

 I wrote the following .py file:

 -
 #! what is supposed to go here?

That's a shebang line. See http://en.wikipedia.org/wiki/Shebang_(Unix)
It's doesn't matter at all since you're on Windows. On Unix-like
systems, one typically writes:
#!/usr/bin/env python

 # Filename: newbie00.py

 if __name__ == '__main__':

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


Algorithms in Python, #n+1

2012-05-16 Thread Antti J Ylikoski

I have continued my research in literature algorithms in Python.  The
algorithms in Knuth's volumes 1 -- 3 either have been incorporated
into Python, or they can be easily implemented with Python.  Quite as
John Nagle said here.  However, the Fascicles in Vol. 4 to my opinion
contain nontrivially useful material.

And, Vol. 2 has something interesting, however -- e. g. the statistical
tests on random number generators.

I have included in this entry a working Python program which carries
out the chi squared test on different random number generators.  It
demonstrates the paradigm of building Knuth's equations directly into
one's Python program, instead of the DFA/FSA approach.  Moreover,
someone over there may wish to test his/her random number generators.
Therefore, I feel that it is relevant to show this program (which is
about two pages long) in this context.

I have carried out the chi squared test on Python's own random number
generator, which to my knowledge is based on the Mersenne twister:

http://en.wikipedia.org/wiki/Mersenne_twister

and Knuth's (old) Linear Congruential method:

http://en.wikipedia.org/wiki/Linear_congruential_generator

If you run the program (with Python 3) you will see that the both
generators will pass the chi squared test.



# Random number generation and analysis after D. E. Knuth.
#
# See The Art of Computer Programming, VOL 2, Seminumerical Algorithms,
# 3rd Edition, pp. 1 --
#
# AJY 05-16-2012.

import math, random

# First do the MIX simulator.
# AJY 05-16-2012.

# -

# Python based MIX simulator.
#
# Written in the object oriented manner.
#
# AJY 05-16-2012.
#
# Do as follows:
#
# MIX_computer = MIXSIM(memory_size, word_size)
# A, X = MIX_computer.MUL(A, X)
#
# etc etc. in the same vein.
# This constitutes just a maximally simple demo.


class MIXSIM(object):
 Maximally simple object oriented MIX simulator. 
def __init__(self, mem_size, word_size):
self.mem_size  = mem_size
self.word_size = word_size
self.w = 10**word_size # Assume a base 10 computer, 
after Knuth.


# No other methods in this class.  I said it only constitutes a demo.


# --

class LCRNG(object):
 The Linear Congruential Random Number Generator. AJY 
05-16-2012. 


def __init__(self, modulus, multiplier, increment, seed):
self.modulus= modulus# Modulus == m in Knuth's text.
self.multiplier = multiplier # Multiplier == a in Knuth's text.
self.increment  = increment  # Increment == c in Knuth.
 # Seed == X0 in Knuth.
self.reg_X  = seed   # Initial value X0 to Register X.
self.MIX= MIXSIM(5000, 12) # Demo sample MIX computer.

def rand(self):
# See Knuth VOL 2 on p. 12.

# Following calculate the next pseudo random integer:
self.reg_A = (self.multiplier * self.reg_X) % (self.MIX.w + 1)

# Transfer A to X for the next round.
self.reg_X = self.reg_A

# And now return a floating point number x such that 0 = x  1.
return float(self.reg_A) / float (self.modulus)


class chi_squared_test(object):
 Instances are chi squared tests of random number generators. 

def __init__(self, generator_f, buckets, iterations, name):
self.generator_f = generator_f  # The function to be tested.
self.buckets = buckets  # How many discrete buckets are 
used
self.iterations  = iterations   # The # of random numbers 
generated.

self.name= name # name of this test.
self.B = [0] * self.buckets # initially all buckets are empty

def run_test(self):
 Generate random numbers and place them in buckets. 

for i in range(self.iterations):
random_nr = self.generator_f() # Random number, in interval 
[0, 1)
ind_bucket = int(self.buckets * random_nr) # Index, 0 .. 
#buckets-1

self.B[ind_bucket] += 1

def chi2test(self):
 Carry out the chi squared test of the material generated. 

 # Calculate the chi squared statistics value.  See Knuth VOL 2
 # on Page 43.

Vsum = 0
for i in range(self.buckets):
Vsum += (self.B[i] - self.iterations * (1.0 / 
float(self.buckets)))**2 \

/ (self.iterations * (1.0 / float(self.buckets)))

V = Vsum

print(\n Chi squared test.  Name = , self.name)
print(\n Chi squared value V = , V)
print(\n Degrees of freedom:   , self.buckets - 1)

chi2_1  = (self.buckets - 1) + math.sqrt(2.0 * self.buckets) \
  * -2.33 + (2.0/3.0)*(-2.33)**2 - (2.0/3.0)

chi2_99 = (self.buckets - 1) + math.sqrt(2.0 * self.buckets) \
 

Re: Newbie questions on import cmd line run

2012-05-16 Thread Steven D'Aprano
On Wed, 16 May 2012 18:45:39 -0700, gwhite wrote:

 #! what is supposed to go here?
 # Filename: newbie00.py

Supposed to? Nothing -- it is completely optional.

#! (hash-bang) lines currently do nothing on Windows machines, they are 
just comments. However, on Unix and Linux machines (and Macintosh?) they 
are interpreted by the shell (equivalent to cmd.exe or command.com), in 
order to tell the shell what interpreter to use to execute the program if 
you run it directly. It is common to use something like:

#!/usr/bin/env python

but I stress that this is completely optional, and doesn't do anything on 
Windows.


 if __name__ == '__main__':
 print 'This program was called from the \
 system command line.'
 print __name__ + '.py'
 else:
 print 'This program was imported on the \
 Python command line.'
 print __name__ + '.py'
 
 -
 
 If I run from the system (win cmd) command, I get:
 
 C:\engineer\engruser\pythonpython  newbie00.py
 
 This program was called from the system command line. __main__.py

The magic variable __name__ is special in Python. When you run a Python 
module as a script from the command line, it gets set to __main__. Note 
that there is no such file __main__.py (unless you have happened to 
create one yourself).

When you import a module, rather than run it, __name__ gets set to the 
actual filename of the module, minus the file extension.


 -
 If I hit the run button in Sypder, I get (in the iPython command
 console):
 
 In [70]: runfile(r'C:\engineer\engruser\python\newbie00.py', wdir=r'C:
 \engineer\engruser\python')
 This program was called from the system command line. __main__.py

I'm not sure what Spyder is. Is it part of iPython? You may need to 
consult the iPython or Spyder docs to find out exactly what tricks it 
plays in its interactive console.


 -
 If I import on the iPython command, I get:
 
 In [71]: import newbie00
 This program was imported on the Python command line. newbie00.py

In this case, __name__ is set to the module name (the file name less the 
file extension). Your script adds the .py at the end.


 -
 If I import *again* on the iPython command, I get:
 
 In [72]: import newbie00
 
 In [73]:
 
 nothing that I can see

That is correct. Python modules are only executed *once*, the first time 
they are imported. From then on, additional imports refer back to a 
cached module object.

When you say import newbie00, the (highly simplified!) process is this:

* Python looks in sys.modules for the name newbie00. If it finds
  something in the cache (usually a module object), it fetches that thing
  and assigns it to the variable newbie00, and the import process is
  complete.

* But if it doesn't find anything in the cache, Python searches the
  locations listed in sys.path for a module, package, or library. That
  could mean any of:

  - newbie00.py   (source code)
  - newbie00.pyc  (compiled byte-code)
  - newbie00.pyo  (compiled optimized byte-code)
  - newbie00.pyw  (Windows only)
  - newbie00.dll  (Windows only C library)
  - newbie00.so   (Linux and Unix C library)

  as well as others (e.g. packages).

* If no module is found, Python raises an error, otherwise the first
  found module is used.

* If a compiled module (e.g. newbie00.pyc) is found, and is no older than
  the source code (newbie00.py), then Python uses the pre-compiled file.

  (If the compiled module is older than the source module, it is ignored.)

* Otherwise Python parses the newbie00.py source code, compiles it to
  byte-code, and writes it to the file newbie00.pyc so that the next time
  the import will be faster.

* At this point, Python now has a compiled chunk of Python byte-code. 
  It then sets the special global variable __name__ to the file name (less
  extension), and executes that code.

* If no fatal error occurs, Python now bundles the results of the
  executed code (any functions, classes, variables, etc.) into a module
  object, stores the module object in the cache sys.modules for next time,
  and finally assigns it to the name newbie00.


There is a *lot* that goes on the first time you import a module, which 
is why Python tries really hard to avoid running modules unless you 
explicitly ask it to. So import newbie00 only *executes* the code once 
per Python session. Subsequent imports use the cached version.

The process is quite different when you run a Python module as a script. 
In this case, the .pyc file (if any) is ignored, the script is parsed and 
compiled from scratch every single time, the magic variable __name__ is 
set to __main__, and the script is executed every single time.


[...]
 Some questions:
 
 1.  If running from the system command line, or the Sypder run button,
 __name__ is __main__ rather than newbie00, as seen above.
 
 So, how would I get the file name newbie00.py in these two noted cases? 

The special variable __file__ is set to the filename:

 import string
 

Re: Newbie questions on import cmd line run

2012-05-16 Thread alex23
On May 17, 11:45 am, gwhite gwh...@ti.com wrote:
 1.  If running from the system command line, or the Sypder run
 button, __name__ is __main__ rather than newbie00, as seen
 above.

 So, how would I get the file name newbie00.py in these two noted
 cases?

You can get it from the file name:

import os.path
name = os.path.split(__file__)[-1]

However, you might find it better in the long term to always separate
your code into import-only modules and execute-only scripts. It avoids
this issue and others.

 2.  Is there a shortened syntax of running a .py from the python command
 prompt, if not using a Spyder run button?  Or should I always run as
 if from the system prompt?  That is, dispense with the MATLAB-like
 run from MATLAB/python command line bias I may be holding.

Generally, the correct way of running Python code from the interpreter
is 'import module'. You might find this pattern useful:

In your module:

def main(): # code goes here

if __name__ == '__main__': main()

Then from the interpreter:

import mymodule; mymodule.main()

 3.  In injecting my old MATLAB bias of running via the command line
  mfilename, I tried a tweak of  import newbie00.  That sort
 of worked, but only the first time.

 Why did the subsequent run of import newbie00 print nothing?  I'm
 just trying to understand how python works.

The import mechanism only imports a module once, as all files use the
same module instance (they're effectively singletons). This happens
with repeated imports in one module as well as across various modules
during a single execution. So re-importing a module does nothing; to
force a re-import, you can use the reload() function, although that
doesn't guarantee updating all references. For example:

import mymodule
from mymodule import myfunc

# modify myfunc code externally

reload(mymodule)
myfunc() # original reference
mymodule.myfunc()  # newly modified function

I don't think that only-one-import is true for scripts that are run
from the command line, though. They can exist as both '__main__' and
their actual name in the module table. (Someone please correct me if
this understanding is wrong...)

 4.  The final case shown of hitting the Spyder run button included
 this:

 UMD has deleted: newbie00

 What does that mean?  I noted that after this automatic deletion, I
 could do the import newbie00 once again and get the print.  (I
 did not show that above.)

Spyder provides a convenience feature to force the reimport of user-
defined modules, like your newbie00. After execution, it appears to
drop all references to your module, forcing a garbage collection. As
its no longer loaded, a subsequent import works.

 5.  I think #4 implies an import can be removed.  (Yes/No?)  I am not
 sure why that would be desired, but I will ask how to remove an
 import, or to refresh the run, of that is the appropriate question.

reload(module)

However, the only way to guarantee you've updated all references
correctly is to close the interpreter and re-start it. For this kind
of development process of modifying code and seeing the changes, it's
probably better to look into writing tests instead. These will always
be run in isolation, so you're guaranteed of having the correct
environment each time.

 I think I saw someplace where a .pyc file is created on an initial run
 and subsequently run instead of the .py.  I'm not sure if that applies
 here, but if related, I guess an auxiliary question is how to easily
 force the .py to run rather than the .pyc?

A .pyc file won't be created for .py files that are run directly, only
for those that are imported. You really shouldn't need to worry about
this, though. It's an implementation detail that isn't influencing the
issues you're seeing. However, if you do ever need to do it, you can
stop .pyc files by passing the -B flag to the interpreter, or by
setting the environment variable PYTHONDONTWRITEBYTECODE.

 6.  Perhaps peripherally related to getting a running script/function/
 module name, is getting a call listing of all the functions (and
 modules) called by a .py program.  How would I get that?  I only ask
 as it comes in handy if one distributes a program.  I mean, you only
 give people what they actually need.

Perhaps this might be of use: http://pycallgraph.slowchop.com/

Hope this helps.
-- 
http://mail.python.org/mailman/listinfo/python-list


[issue14825] Interactive Shell vs Executed code

2012-05-16 Thread Marcelo Delgado

New submission from Marcelo Delgado marde...@gmail.com:

I have found inconsistency between running this code in the interactive shell 
and running it from a file:

Int. Shell:
n**0 ## n is a negative number
result: -1

File:
n**0 ## n is a negative number
result: 1

I am fairly new to Python, so I don't know what result should be the correct 
one, but if thit IS a mistake i would prefer the result of the Int. Shell :)

--
components: Regular Expressions
messages: 160806
nosy: Marcelo.Delgado, ezio.melotti, mrabarnett
priority: normal
severity: normal
status: open
title: Interactive Shell vs Executed code
type: behavior
versions: Python 3.3

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



[issue14825] Interactive Shell vs Executed code

2012-05-16 Thread Marcelo Delgado

Changes by Marcelo Delgado marde...@gmail.com:


--
components: +Interpreter Core -Regular Expressions

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



[issue14811] decoding_fgets() truncates long lines and fails with a SyntaxError(Non-UTF-8 code starting with...)

2012-05-16 Thread STINNER Victor

STINNER Victor victor.stin...@gmail.com added the comment:

 Function decoding_fgets (Parser/tokenizer.c) reads line in buffer
 of fixed size 8192 (line truncated to size 8191) and then fails
 because line is cut in the middle of a multibyte UTF-8 character.

It looks like BUFSIZ is much smaller than 8192 on Windows: it's maybe only 1024 
bytes.

Attached patch detects when a line is truncated (longer than the internal 
buffer).

A better solution is maybe to reallocate the buffer if the string is longer 
than the buffer (write a universal fgets which allocates the buffer while the 
line is read). Most functions parsing Python source code uses a dynamic buffer. 
For example import module now reads the whole file content before parsing it 
(see FileLoader.get_data() in Lib/importlib/_bootstrap.py).

At least, we should use a longer buffer on Windows (ex: use 8192 on all 
platforms?).

I only found two functions parsing the a Python file line by line: 
PyRun_InteractiveOneFlags() and PyRun_FileExFlags(). There are many variant of 
these functions (ex: PyRun_InteractiveOne and PyRun_File). These functions are 
part of the C Python API and used by programs to execute Python code when 
Python is embeded in a program.

PS: As noticed by Serhiy Storchaka, the bug is not specific to Windows. It's 
just that the internal buffer is much smaller on Windows.

--
components: +Interpreter Core -Windows
keywords: +patch
nosy: +haypo
title: Syntax error on long UTF-8 lines - decoding_fgets() truncates long 
lines and fails with a SyntaxError(Non-UTF-8 code starting with...)
Added file: http://bugs.python.org/file25605/detect_truncate.patch

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



[issue14825] Interactive Shell vs Executed code

2012-05-16 Thread Mark Dickinson

Mark Dickinson dicki...@gmail.com added the comment:

It sounds like you're seeing the difference between this:

 n = -7
 n ** 0
1

and this:

 -7 ** 0
-1

This isn't a bug;  it's to do with how Python expressions are parsed:  in the 
second case, the expression is grouped as -(7 ** 0) rather than (-7) ** 0.

BTW, it's helpful to post exact code when filing a possible bug. :-)

--
nosy: +mark.dickinson
resolution:  - invalid
status: open - closed

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



[issue14674] Add link to RFC 4627 from json documentation

2012-05-16 Thread Chris Rebert

Changes by Chris Rebert pyb...@rebertia.com:


Removed file: http://bugs.python.org/file25592/json.rst.patch

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



[issue14674] Add link to RFC 4627 from json documentation

2012-05-16 Thread Chris Rebert

Changes by Chris Rebert pyb...@rebertia.com:


Added file: http://bugs.python.org/file25606/json.rst.patch

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



[issue14674] Add link to RFC 4627 from json documentation

2012-05-16 Thread Chris Rebert

Changes by Chris Rebert pyb...@rebertia.com:


Removed file: http://bugs.python.org/file25591/json.rst.patch

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



[issue14817] pkgutil.extend_path has no tests

2012-05-16 Thread Antoine Pitrou

Antoine Pitrou pit...@free.fr added the comment:

This has broken all 3.x buildbots.

--
nosy: +pitrou

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



[issue14824] reprlib documentation references string module

2012-05-16 Thread Chris Rebert

Chris Rebert pyb...@rebertia.com added the comment:

Patch. Though I ponder whether the expression in question might be equivalent 
to simply:
type(obj).__name__.replace('_', ' ')

--
keywords: +patch
nosy: +cvrebert
Added file: http://bugs.python.org/file25607/reprlib.rst.patch

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



[issue14826] urllib2.urlopen fails to load URL

2012-05-16 Thread Wichert Akkerman

New submission from Wichert Akkerman wich...@wiggy.net:

There appears to be an odd networking issue with how urllib2 sends HTTP 
requests. Downloading an image from maw.liquifire.com gives an error:

$ python -c 'import urllib2 ; 
urllib2.urlopen(http://maw.liquifire.com/maw?set=image[2302.000.13314 
a]call=url[file:325x445])'
Traceback (most recent call last):
  File string, line 1, in module
  File /usr/lib/python2.7/urllib2.py, line 126, in urlopen
return _opener.open(url, data, timeout)
  File /usr/lib/python2.7/urllib2.py, line 400, in open
response = self._open(req, data)
  File /usr/lib/python2.7/urllib2.py, line 418, in _open
'_open', req)
  File /usr/lib/python2.7/urllib2.py, line 378, in _call_chain
result = func(*args)
  File /usr/lib/python2.7/urllib2.py, line 1207, in http_open
return self.do_open(httplib.HTTPConnection, req)
  File /usr/lib/python2.7/urllib2.py, line 1180, in do_open
r = h.getresponse(buffering=True)
  File /usr/lib/python2.7/httplib.py, line 1030, in getresponse
response.begin()
  File /usr/lib/python2.7/httplib.py, line 407, in begin
version, status, reason = self._read_status()
  File /usr/lib/python2.7/httplib.py, line 365, in _read_status
line = self.fp.readline()
  File /usr/lib/python2.7/socket.py, line 447, in readline
data = self._sock.recv(self._rbufsize)
socket.error: [Errno 104] Connection reset by peer

Downloading the same image using wget works fine:

$ wget 'http://maw.liquifire.com/maw?set=image[2302.000.13314 
a]call=url[file:325x445]' 
--2012-05-16 10:53:27--  
http://maw.liquifire.com/maw?set=image[2302.000.13314%20a]call=url[file:325x445]
Resolving maw.liquifire.com (maw.liquifire.com)... 184.169.78.6
Connecting to maw.liquifire.com (maw.liquifire.com)|184.169.78.6|:80... 
connected.
HTTP request sent, awaiting response... 200 OK
Length: 11393 (11K) [image/jpeg]
Saving to: `maw?set=image[2302.000.13314 a]call=url[file:325x445]'

100%[==] 11,393  --.-K/s   in 0.003s  

2012-05-16 10:53:27 (3.49 MB/s) - `maw?set=image[2302.000.13314 
a]call=url[file:325x445]' saved [11393/11393]

--
components: Library (Lib)
messages: 160811
nosy: wichert
priority: normal
severity: normal
status: open
title: urllib2.urlopen fails to load URL
versions: Python 2.7

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



[issue1602] windows console doesn't print or input Unicode

2012-05-16 Thread Glenn Linderman

Glenn Linderman v+pyt...@g.nevcal.com added the comment:

Has something incompatible changed between 3.2.2 and 3.2.3 with respect to this 
bug?

I have a program that had an earlier version of the workaround (Michael's 
original, I think), and it worked fine, then I upgraded from 3.2.2 to 3.2.3 due 
to testing for issue 14811 and then the old workaround started complaining 
about no attribute 'errors'.

So I grabbed unicode3.py, but it does the same thing:

AttributeError: 'UnicodeConsole' object has no attribute 'errors'

I have no clue how to fix this, other than going back to Python 3.2.2...

--

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



[issue1602] windows console doesn't print or input Unicode

2012-05-16 Thread Glenn Linderman

Glenn Linderman v+pyt...@g.nevcal.com added the comment:

Oh, and is this issues going to be fixed for 3.3, so we don't have to use the 
workaround in the future?

--

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



[issue11959] smtpd cannot be used without affecting global state

2012-05-16 Thread Vinay Sajip

Vinay Sajip vinay_sa...@yahoo.co.uk added the comment:

 Well, other tests manage it even without using a private socket map.
 Leaving dangling sockets in the socket map could mean your code
 forgets to close them, for example.

This issue is not about getting test_logging to work in a particular way; 
test_logging is exercising SMTPHandler and (AFAIK) tidying up after itself, 
with no sockets left open.

When working on the test, I just noticed that smtpd forces use of the global 
socket map, which is not ideal (The fact that asyncore uses a global socket 
map is surely unfortunate - Giampaolo). Given that asyncore's design allows 
for a socket map to be passed in (at least in part - RDM's comment), ISTM that 
it should support this consistently, and also that smtpd should support this 
mode of use.

--

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



[issue11959] smtpd cannot be used without affecting global state

2012-05-16 Thread Antoine Pitrou

Antoine Pitrou pit...@free.fr added the comment:

 Given that asyncore's design allows for a socket map to be passed in
 (at least in part - RDM's comment), ISTM that it should support this
 consistently, and also that smtpd should support this mode of use.

Well, I would argue that asyncore's design is thoroughly broken, and
passing a socket map is a poor kludge to avoid global state; in a
sophisticated event loop, the socket map wouldn't be the only piece of
state to pass around.
(look at twisted's reactors for a comparison)

--

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



[issue14809] Add HTTP status codes introduced by RFC 6585

2012-05-16 Thread Roundup Robot

Roundup Robot devn...@psf.upfronthosting.co.za added the comment:

New changeset 981aabe6ea2f by Hynek Schlawack in branch 'default':
#14809: Add HTTP status codes from RFC 6585 to http.server and http.client
http://hg.python.org/cpython/rev/981aabe6ea2f

--
nosy: +python-dev

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



[issue11959] smtpd cannot be used without affecting global state

2012-05-16 Thread Vinay Sajip

Vinay Sajip vinay_sa...@yahoo.co.uk added the comment:


 Well, I would argue that asyncore's design is thoroughly broken, and

 passing a socket map is a poor kludge to avoid global state; in a
 sophisticated event loop, the socket map wouldn't be the only piece of
 state to pass around.


I don't disagree with you, but since it's there in the stdlib, there's no 
reason not to make incremental improvements involving small changes.

--

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



[issue14732] PEP 3121 Refactoring applied to _csv module

2012-05-16 Thread Roundup Robot

Roundup Robot devn...@psf.upfronthosting.co.za added the comment:

New changeset 2496602a56e5 by Antoine Pitrou in branch 'default':
Issue #14732: The _csv module now uses PEP 3121 module initialization.
http://hg.python.org/cpython/rev/2496602a56e5

--

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



[issue14732] PEP 3121 Refactoring applied to _csv module

2012-05-16 Thread Antoine Pitrou

Antoine Pitrou pit...@free.fr added the comment:

Thanks for the updated patch, Robin. I have now committed it to the default 
branch.

--
resolution:  - fixed
stage: patch review - committed/rejected
status: open - closed

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



[issue14773] fwalk breaks on dangling symlinks

2012-05-16 Thread Hynek Schlawack

Changes by Hynek Schlawack h...@ox.cx:


--
stage: commit review - committed/rejected
status: open - closed

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



[issue14809] Add HTTP status codes introduced by RFC 6585

2012-05-16 Thread Hynek Schlawack

Hynek Schlawack h...@ox.cx added the comment:

Thank you for your contribution to Python, EungJun!

Just two small remarks:

 - Please sign and submit the contributor form from 
http://www.python.org/psf/contrib/ . You'll get a nice star next to your name 
in return. :)
 - I have fixed the flow of one of the lines. It's no big deal, but pep8 asks 
for a max line length of 79 characters.

--
resolution:  - fixed
stage: needs patch - committed/rejected
status: open - closed

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



[issue14773] fwalk breaks on dangling symlinks

2012-05-16 Thread Hynek Schlawack

Changes by Hynek Schlawack h...@ox.cx:


--
resolution:  - fixed

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



[issue14827] IDLE crash when typing ^ character on Mac OS X

2012-05-16 Thread Julien Pecqueur

New submission from Julien Pecqueur jpe...@gmail.com:

IDLE crash when i type the character ^ (for example writing ê in a comment).

I have the crash only on Mac OS X (Mac OS X 64-bit/32-bit Installer (3.2.3) for 
Mac OS X 10.6 and 10.7).

I don't have this crash on Linux.

--
components: IDLE
messages: 160821
nosy: JPEC
priority: normal
severity: normal
status: open
title: IDLE crash when typing ^ character on Mac OS X
type: crash
versions: Python 3.2

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



[issue14828] itertools.groupby not working as expected

2012-05-16 Thread Jiba

New submission from Jiba jibal...@free.fr:

In some situation, itertools.groupby fails to group the objects, and produces 
several groups with the same key. For example, the following code :


from itertools import *

class P(object):
  def __init__(self, key):
self.key = key

p1 = P(1)
p2 = P(2)
p3 = P(1)

for key, ps in groupby([p1, p2, p3], lambda p: p.key):
  print group, key
  for p in ps:
print   - object, p


Produces the following result :

group 1
  - object __main__.P object at 0xb73d6acc
group 2
  - object __main__.P object at 0xb73d6aec
group 1
  - object __main__.P object at 0xb73d6b0c


While I would expect to have only a single group 1, e.g. something like :

group 1
  - object __main__.P object at 0xb73d6acc
  - object __main__.P object at 0xb73d6b0c
group 2
  - object __main__.P object at 0xb73d6aec


It seems that this bug also affects Python 3 (tested on Python 3.1.2)

--
components: Library (Lib)
messages: 160822
nosy: Jiba
priority: normal
severity: normal
status: open
title: itertools.groupby not working as expected
type: behavior
versions: Python 2.7

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



[issue14732] PEP 3121 Refactoring applied to _csv module

2012-05-16 Thread Antoine Pitrou

Antoine Pitrou pit...@free.fr added the comment:

Robin, I forgot: could you please sign and send the contrib form at 
http://www.python.org/psf/contrib/ ?
It is not a copyright assignment, just a piece of paper that formally allows us 
to license your contribution for distribution with Python.

--

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



[issue14780] urllib.request could use the default CA store

2012-05-16 Thread Antoine Pitrou

Antoine Pitrou pit...@free.fr added the comment:

 Something like this perhaps?

For example, yes. Now we need to find a way of testing this...

--
nosy: +orsenthil
title: SSL should use OpenSSL-defined default certificate store if ca_certs 
parameter is omitted - urllib.request could use the default CA store

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



[issue14828] itertools.groupby not working as expected

2012-05-16 Thread Petri Lehtinen

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

groupby() changes the group when the key changes in the input it iterates. If 
you want to have p1 and p3 to go to the same group, you need to sort the input 
by P.key first.

This is clearly documented, too:

The operation of groupby() is similar to the uniq filter in Unix.
It generates a break or new group every time the value of the key 
function changes (which is why it is usually necessary to have 
sorted the data using the same key function). That behavior differs
from SQL’s GROUP BY which aggregates common elements regardless of
their input order.

--
nosy: +petri.lehtinen
resolution:  - invalid
status: open - closed

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



[issue14816] compilation failed on Ubuntu shared buildbot

2012-05-16 Thread Antoine Pitrou

Antoine Pitrou pit...@free.fr added the comment:

Fixed in 1ecd10260649.

--
resolution:  - fixed
stage:  - committed/rejected
status: open - closed

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



[issue14813] Can't build under VS2008 anymore

2012-05-16 Thread Stefan Krah

Stefan Krah stefan-use...@bytereef.org added the comment:

Here's a patch. I can build win32 and Release|x64. However, the
executables immediately exit; this might be related to #14822.

--
keywords: +patch
Added file: http://bugs.python.org/file25608/vs-9.0.diff

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



[issue14822] Build unusable when compiled for Win 64-bit release

2012-05-16 Thread Stefan Krah

Changes by Stefan Krah stefan-use...@bytereef.org:


--
nosy: +skrah

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



[issue14828] itertools.groupby not working as expected

2012-05-16 Thread Jiba

Jiba jibal...@free.fr added the comment:

Ok, I understand.

However, in my initial problem, the sequence passed to groupby was a set, e.g. 
(modifying my previous example) :

   groupby(set([p1, p2, p3]), lambda p: p.key)

If I understand well how groupby() works, the result of a groupby performed on 
a set is unpredictable, since it depends of the order of the items when 
iterating over the set. Perhaps the behavior of groupby() should be modified 
for unsorted sequences, possibly not taking the order into account, or raising 
an error ?

--

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



[issue14828] itertools.groupby not working as expected

2012-05-16 Thread Petri Lehtinen

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

You're right, the result over a set would be unpredictable.

The point of the itertools module is to be able to a) cope with massive amounts 
of data and b) be a set of tools instead of complete solutions for all problems.

Because of both of the points above, groupby() doesn't load all the data into 
memory or attempt to sort the data by itself. Furthermore, there's no way for 
groupby() to know whether the iterable it's passed is going to yield sorted or 
unsorted data.

It's your responsibility to know whether the iterable you're passing is already 
sorted or not, and sort it first, if it's possible and there's a need to do so.

--

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



[issue14813] Can't build under VS2008 anymore

2012-05-16 Thread Stefan Krah

Stefan Krah stefan-use...@bytereef.org added the comment:

Regarding the VS 2010 build failure, using the cross tools builds
python_d.exe:

C:\Program Files (x86)\Microsoft Visual Studio 
10.0\VC\bin\x86_amd64\vcvarsx86_amd64.bat
msbuild /p:useenv=true pcbuild.sln /p:Configuration=Debug /p:Platform=x64

Again, the executables immediately exit (#14822 ?).

--

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



[issue14813] Can't build under VS2008 anymore

2012-05-16 Thread Antoine Pitrou

Antoine Pitrou pit...@free.fr added the comment:

The patch doesn't apply here, line endings perhaps?

--

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



[issue14827] IDLE crash when typing ^ character on Mac OS X

2012-05-16 Thread Ramchandra Apte

Ramchandra Apte maniandra...@gmail.com added the comment:

Please run IDLE from the command line and send the output when it crashes. (If 
I knew Mac better I would tell you the precise instructions)

--
nosy: +ramchandra.apte

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



[issue14827] IDLE crash when typing ^ character on Mac OS X

2012-05-16 Thread Ramchandra Apte

Changes by Ramchandra Apte maniandra...@gmail.com:


--
assignee:  - ronaldoussoren
components: +Macintosh
nosy: +ronaldoussoren

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



[issue14827] IDLE crash when typing ^ character on Mac OS X

2012-05-16 Thread Julien Pecqueur

Julien Pecqueur jpe...@gmail.com added the comment:

I'll send the output this evening.

--

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



[issue14813] Can't build under VS2008 anymore

2012-05-16 Thread Stefan Krah

Stefan Krah stefan-use...@bytereef.org added the comment:

Probably line endings. It applies with cygwin's patch:

C:\Users\stefan\pydev\cpythonpatch -p1  vs-9.0.diff   

patching file PC/VS9.0/_bz2.vcproj  

patching file PC/VS9.0/_ctypes.vcproj
[...]

I'm uploading a dos version.

--
Added file: http://bugs.python.org/file25609/vs-9.0-dos.diff

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



[issue14813] Can't build under VS2008 anymore

2012-05-16 Thread Antoine Pitrou

Antoine Pitrou pit...@free.fr added the comment:

 I'm uploading a dos version.

Still doesn't work. It may be because I'm doing all this in a Linux checkout 
without the hgeol extension enabled, though.

--

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



[issue14827] IDLE crash when typing ^ character on Mac OS X

2012-05-16 Thread Ronald Oussoren

Ronald Oussoren ronaldousso...@mac.com added the comment:

Do you have a recent version of ActiveState's Tcl/Tk distribution installed?  

If you do not have this installed you ran into a known issue in Apple's copy of 
Tcl/Tk, see http://www.python.org/download/mac/tcltk/ for more information.

--

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



  1   2   3   >