Re: Programming puzzle with boolean circuits

2013-12-10 Thread Chris Angelico
On Tue, Dec 10, 2013 at 1:21 PM, Chris Angelico  wrote:
> Output: (I tweaked my __repr__ functions to parenthesize for clarity)
>
> (((not ((($1 and $2) or ($1 and $4)) or ($2 and $4)) and not ((($1 and
> $2) and $4) or (not ((($1 and $2) or ($1 and $4)) or ($2 and $4)) and
> (($1 or $2) or $4 or ((not ((($1 and $2) or ($1 and $4)) or ($2
> and $4)) and (($1 or $2) or $4)) and ($2 or $4))) or ((not ((($1 and
> $2) and $4) or (not ((($1 and $2) or ($1 and $4)) or ($2 and $4)) and
> (($1 or $2) or $4))) and ((($1 and $2) or ($1 and $4)) or ($2 and
> $4))) and ($2 and $4)))
> (((not ((($1 and $2) or ($1 and $4)) or ($2 and $4)) and not ((($1 and
> $2) and $4) or (not ((($1 and $2) or ($1 and $4)) or ($2 and $4)) and
> (($1 or $2) or $4 or ((not ((($1 and $2) or ($1 and $4)) or ($2
> and $4)) and (($1 or $2) or $4)) and ($1 or $4))) or ((not ((($1 and
> $2) and $4) or (not ((($1 and $2) or ($1 and $4)) or ($2 and $4)) and
> (($1 or $2) or $4))) and ((($1 and $2) or ($1 and $4)) or ($2 and
> $4))) and ($1 and $4)))
> (((not ((($1 and $2) or ($1 and $4)) or ($2 and $4)) and not ((($1 and
> $2) and $4) or (not ((($1 and $2) or ($1 and $4)) or ($2 and $4)) and
> (($1 or $2) or $4 or ((not ((($1 and $2) or ($1 and $4)) or ($2
> and $4)) and (($1 or $2) or $4)) and ($2 or $1))) or ((not ((($1 and
> $2) and $4) or (not ((($1 and $2) or ($1 and $4)) or ($2 and $4)) and
> (($1 or $2) or $4))) and ((($1 and $2) or ($1 and $4)) or ($2 and
> $4))) and ($2 and $1)))
>
> Okay, so maybe the brute-force-discovered version isn't so bad after all. :)

I added the same parenthesizing to the brute force searcher and reran
it through 'time'.

~$1 = (($4 or not (($1 and $2) or ($4 and ($1 or $2 and (($4 and
not (($1 and $2) or ($4 and ($1 or $2 or (($2 or not (($1 and $2)
or ($4 and ($1 or $2 and (($2 and not (($1 and $2) or ($4 and ($1
or $2 or not (($2 or ($1 or $4)) and (($2 and ($1 and $4)) or not
(($1 and $2) or ($4 and ($1 or $2)
~$2 = (($4 or not (($1 and $2) or ($4 and ($1 or $2 and (($4 and
not (($1 and $2) or ($4 and ($1 or $2 or (($1 or not (($1 and $2)
or ($4 and ($1 or $2 and (($1 and not (($1 and $2) or ($4 and ($1
or $2 or not (($2 or ($1 or $4)) and (($2 and ($1 and $4)) or not
(($1 and $2) or ($4 and ($1 or $2)
~$4 = (($2 or not (($1 and $2) or ($4 and ($1 or $2 and (($2 and
not (($1 and $2) or ($4 and ($1 or $2 or (($1 or not (($1 and $2)
or ($4 and ($1 or $2 and (($1 and not (($1 and $2) or ($4 and ($1
or $2 or not (($2 or ($1 or $4)) and (($2 and ($1 and $4)) or not
(($1 and $2) or ($4 and ($1 or $2)

real 362m12.261s
user 362m7.186s
sys 0m0.064s

Yes, that is indeed six full hours of CPU time for a simple problem. Ha!

It seems to have come up with something fairly similar, actually. A
bit shorter than the algebraic solution.

brute: (($4 or not (($1 and $2) or ($4 and ($1 or $2 and (($4 and
not (($1 and $2) or ($4 and ($1 or $2 or (($2 or not (($1 and $2)
or ($4 and ($1 or $2 and (($2 and not (($1 and $2) or ($4 and ($1
or $2 or not (($2 or ($1 or $4)) and (($2 and ($1 and $4)) or not
(($1 and $2) or ($4 and ($1 or $2)

algebra: (((not ((($1 and $2) or ($1 and $4)) or ($2 and $4)) and not
((($1 and $2) and $4) or (not ((($1 and $2) or ($1 and $4)) or ($2 and
$4)) and (($1 or $2) or $4 or ((not ((($1 and $2) or ($1 and $4))
or ($2 and $4)) and (($1 or $2) or $4)) and ($2 or $4))) or ((not
((($1 and $2) and $4) or (not ((($1 and $2) or ($1 and $4)) or ($2 and
$4)) and (($1 or $2) or $4))) and ((($1 and $2) or ($1 and $4)) or ($2
and $4))) and ($2 and $4)))

Here's the most notable difference:
two_or_three = (a & b) | (a & c) | (b & c)
can be simplified to:
two_or_three = (a & b) | (c & (a | b))
That's one less gate in an early step. Even applying that change,
though, the brute-forced solution is still a bit shorter. Looks like
the algebraic solution could have a bit of optimization done!

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


Re: interactive help on the base object

2013-12-10 Thread Mark Lawrence

On 10/12/2013 05:16, rusi wrote:

On Tuesday, December 10, 2013 10:40:27 AM UTC+5:30, Steven D'Aprano wrote:

By the way, I'm curious. Why are discussions about object oriented coding
off-topic to Python? This is not a rhetorical question.


Well OOP on the python list is certainly on topic.

Interminable discussions about why redrawing the inheritance arrows
the other way round will save the world is OT (for me!)



One of the great joys of reading this list is how wonderfully OT it can 
get.  I have the right to make this statement as I started *THIS* 
thread.  Now what *WERE* we talking about? :)


--
My fellow Pythonistas, ask not what our language can do for you, ask 
what you can do for our language.


Mark Lawrence

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


ANN: eGenix mx Base Distribution 3.2.7 (mxDateTime, mxTextTools, etc.)

2013-12-10 Thread eGenix Team: M.-A. Lemburg


ANNOUNCING

   eGenix.com mx Base Distribution

 mxDateTime, mxTextTools, mxProxy, mxURL, mxUID,
  mxBeeBase, mxStack, mxQueue, mxTools

Version 3.2.7


Open Source Python extensions providing
 important and useful services
for Python programmers.

This announcement is also available on our web-site for online reading:
http://www.egenix.com/company/news/eGenix-mx-Base-Distribution-3.2.7-GA.html



ABOUT

The eGenix.com mx Base Distribution for Python is a collection of
professional quality software tools which enhance Python's usability
in many important areas such as fast text searching, date/time
processing and high speed data types.

The tools have a proven record of being portable across many Unix and
Windows platforms. You can write applications which use the tools on
Windows and then run them on Unix platforms without change due to the
consistent platform independent interfaces.

Contents of the distribution:

 * mxDateTime - Easy to use Date/Time Library for Python
 * mxTextTools - Fast Text Parsing and Processing Tools for Python
 * mxProxy - Object Access Control for Python
 * mxBeeBase - On-disk B+Tree Based Database Kit for Python
 * mxURL - Flexible URL Data-Type for Python
 * mxUID - Fast Universal Identifiers for Python
 * mxStack - Fast and Memory-Efficient Stack Type for Python
 * mxQueue - Fast and Memory-Efficient Queue Type for Python
 * mxTools - Fast Everyday Helpers for Python

The package also include a number of helpful smaller modules in the
mx.Misc subpackage, such as mx.Misc.ConfigFile for config file parsing
or mx.Misc.CommandLine to quickly write command line applications in
Python.

All available packages have proven their stability and usefulness in
many mission critical applications and various commercial settings all
around the world.

For more information, please see the distribution page:

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



NEWS

The 3.2.7 release of the eGenix mx Base Distribution is the latest
release of our open-source Python extensions. It includes these fixes
and enhancements:

Fixes
-

 * mxBeeBase: Fixed a problem with using larger BeeDict keysizes on
   64-bit platforms. These now work for keysizes between 25 and 659
   characters as well. Also extended the possible keysizes for 32-bit
   platform to 670 characters. Thanks to Andrey Rzhetsky for pointing
   us to the problem.

 * mx.Misc.FileLock: Fixed a typo in a FileLock class name.

eGenix mx Base Distribution 3.2.0 was release on 2012-08-28. Please
see the eGenix mx Base Distribution 3.2.0 announcement for new
features in the 3.2 major release:

http://www.egenix.com/company/news/eGenix-mx-Base-Distribution-3.2.0-GA.html

For a full list of changes, please refer to the eGenix mx Base
Distribution change log and the change logs of the various included
Python packages.

http://www.egenix.com/products/python/mxBase/changelog.html



UPGRADING

We encourage all users to upgrade to this latest eGenix mx Base
Distribution release.

If you are upgrading from eGenix mx Base 3.1.x, please see the eGenix
mx Base Distribution 3.2.0 release notes for details on what has
changed since the 3.1 major release.

http://www.egenix.com/company/news/eGenix-mx-Base-Distribution-3.2.0-GA.html

For a full list of changes, please refer to the eGenix mx Base Distribution
change log at

http://www.egenix.com/products/python/mxBase/changelog.html

and the change logs of the various included Python packages.



LICENSE

The eGenix mx Base package is distributed under the eGenix.com Public
License 1.1.0 which is an Open Source license similar to the Python
license. You can use the packages in both commercial and non-commercial
settings without fee or charge.

The package comes with full source code



DOWNLOADS

The download archives and instructions for installing the packages can
be found on the eGenix mx Base Distribution page:

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

As always, we are providing pre-built binaries for all common
platforms: Windows 32/64-bit, Linux 32/64-bit, FreeBSD 32/64-bit, Mac
OS X 32/64-bit. Source code archives are available for installation on
all other Python platforms, such as Solaris, AIX, HP-UX, etc.

To simplify installation in Zope/Plone and other egg-based systems, we
have also precompiled egg distributions for all platforms. These are
available on our own PyPI-style index server for easy and automatic
downlo

Re: Experiences/guidance on teaching Python as a first programming language

2013-12-10 Thread Oscar Benjamin
On 9 December 2013 19:57, Terry Reedy  wrote:
> On 12/9/2013 7:23 AM, Oscar Benjamin wrote:
>>
>> Hi all,
>>
>> I work in a University Engineering faculty teaching, among other
>> things, programming. In our last meeting about improving our teaching
>> syllabus and delivery we've identified the first year programming
>> courses as an area where there is room for improvement and we're
>> considering (mainly on my suggestion) switching to using Python as the
>> first programming language that we use to introduce our students to
>> programming. I'm interested to know if anyone can share experience of
>> a similar situation or can point to any case studies about this.
>
>
> A few years ago, MIT switched from Scheme (which I believe originated at
> MIT) to Python for its first course. There might faculty blogs discussing
> the reasons.

Thanks Terry. The best I've found is this:
http://cemerick.com/2009/03/24/why-mit-now-uses-python-instead-of-scheme-for-its-undergraduate-cs-program/

It doesn't really describe why Python was chosen and I can't find any
actual evaluation of how well it worked but I guess if they haven't
backed out of the decision then that says something.

> In any case, the course is one of MIT's free online offerings.
> There is a draft of a syllabus for your school. Certainly, most of the
> concept taught in the current C course could be taught with Python instead.

I guess you mean this:
http://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-00sc-introduction-to-computer-science-and-programming-spring-2011/

The description there sounds like exactly what we're aiming for:
'''
This subject is aimed at students with little or no programming
experience. It aims to provide students with an understanding of the
role computation can play in solving problems. It also aims to help
students, regardless of their major, to feel justifiably confident of
their ability to write small programs that allow them to accomplish
useful goals. The class will use the Python programming language.
'''

I'll have a bit of a look at that. In our case the course would
probably be called something like "Introduction to [scientific]
programming using Python" so we may want to put more time into
numpy/matplotlib etc than some other courses would.


Oscar
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Qml Error on CentOS6.4 when ./configure ?

2013-12-10 Thread Steven D'Aprano
On Mon, 09 Dec 2013 16:38:19 +0800, levinie wrote:

> I install latest QT5 and PyQt5 on CentOS6.4 And here is some error:

Sorry, I have no experience installing QT or PyQT. If you don't get a 
response here, perhaps you should try on a dedicated QT or PyQT forum.

It will probably help if you explain:

- How did you install QT and PyQT? Did you use yum or did you install 
from source?

- Is this error when you are installing QT or PyQT?

- Which exact version? Is it a stable or unstable version?


Good luck!



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


Re: interactive help on the base object

2013-12-10 Thread Ian Kelly
On Mon, Dec 9, 2013 at 8:19 PM, Steven D'Aprano  wrote:
> While I'm very confident at this point that he is a crank, in the same
> category as circle-squarers, cold fusion proponents, pi-is-a-rational-
> number theorists, perpetual motion machine inventors, evolution or AGW
> Denialists[1], and other such obsessive examples of Dunning-Kruger, I'm
> not *totally* confident that he is a crank. Maybe he'll prove me wrong
> and actually learn something. Who knows, maybe *I'll* learn something!

I would compare him more closely to the "Einstein was wrong" armchair
physics revisionists, myself.
-- 
https://mail.python.org/mailman/listinfo/python-list


Permission for contribution: http://bugs.python.org/issue19940

2013-12-10 Thread shankha
I wish to make contribution to Python source code. I have studied the
developers guide and made myself familiar with mercurial. I wish to start
of with some doc bugs as this will give me insight into
how the whole process(review, tests, patches) works. Is it okay if to take:

http://bugs.python.org/issue19940.


Will update the bug report once you guys are fine with it. My platform will
primarily be Linux.

Background:

I have worked with runtime analysis tools, MPI, OpenMP and now currently
working on Java.
Let me know if there are areas where I can be of help to you. Thanks for
the maintaining this wonderful language.

-- 
Thanks
Gudge
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: interactive help on the base object

2013-12-10 Thread rusi
On Tuesday, December 10, 2013 3:07:36 PM UTC+5:30, Mark Lawrence wrote:
> On 10/12/2013 05:16, rusi wrote:
> > On Tuesday, December 10, 2013 10:40:27 AM UTC+5:30, Steven D'Aprano wrote:
> >> By the way, I'm curious. Why are discussions about object oriented coding
> >> off-topic to Python? This is not a rhetorical question.
> > Well OOP on the python list is certainly on topic.
> > Interminable discussions about why redrawing the inheritance arrows
> > the other way round will save the world is OT (for me!)

> One of the great joys of reading this list is how wonderfully OT it can 
> get.  I have the right to make this statement as I started *THIS* 
> thread.  Now what *WERE* we talking about? :)


My boy, I see that you are making progress towards your guru -- Nikos.

"You are spamming MY THREAD"
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Permission for contribution: http://bugs.python.org/issue19940

2013-12-10 Thread Tim Golden
On 10/12/2013 11:35, shankha wrote:
> I wish to make contribution to Python source code. I have studied the
> developers guide and made myself familiar with mercurial. I wish to
> start of with some doc bugs as this will give me insight into
> how the whole process(review, tests, patches) works. Is it okay if to take:
> 
> http://bugs.python.org/issue19940.
> 
> 
> Will update the bug report once you guys are fine with it. My platform
> will primarily be Linux.


> Thanks
> Gudge

Welcome Gudge, and thanks for wanting to contribute. We're a fairly open
organisation, so you don't need anyone's permission to start
contributing: just add your comments or your patch to the issue you want
to work on.

The core-mentorship mailing list might be of use to you: it is
specifically aimed at people wanting help with contributing to Python.
It has special conditions to make it more friendly to people who might
be shy of looking foolish on a public mailing list. Feel free to subscribe:

  https://mail.python.org/mailman/listinfo/core-mentorship

(see also http://pythonmentors.com/ which acts as a landing page for the
list)

Good luck

TJG
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Permission for contribution: http://bugs.python.org/issue19940

2013-12-10 Thread Tim Golden
On 10/12/2013 11:35, shankha wrote:
> I wish to make contribution to Python source code. I have studied the
> developers guide and made myself familiar with mercurial. I wish to
> start of with some doc bugs as this will give me insight into
> how the whole process(review, tests, patches) works. Is it okay if to take:
> 
> http://bugs.python.org/issue19940.


Having just glanced at that issue, I would point out that there's been a
lot of development around the ssl module for the 3.4 release, so you
definitely want to confirm the issue against the hg tip to ensure it
still applies.

TJG
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: squeeze out some performance

2013-12-10 Thread Robert Voigtländer
> Actually for optimised code it looks very similar to some code posted 
> 
> here 
> 
> http://www.daniweb.com/software-development/python/threads/321181/python-bresenham-circle-arc-algorithm
>  
> 
> over three years ago.
> 

This is where it origins from. I just extended it for my needs and now want to 
optimize it.
List comprehensions instead of some for loops brought another 25%. And made the 
code shorter.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: squeeze out some performance

2013-12-10 Thread Robin Becker

On 09/12/2013 20:46, Dave Angel wrote:

On Mon, 09 Dec 2013 15:54:36 +, Robin Becker  wrote:

On 06/12/2013 22:07, Joel Goldstick wrote:
>  end, start = start, end



a similar behaviour for simple assignments



for less than 4 variables the tuple method is faster.


What does speed have to do with it?  When you want to swap two variables,  the
tuple assignment reads better.

Well the OP is asking about performance so I guess the look and feel might be 
sacrificed for speed in some circumstances.


The tuple approach is more appealing when the lhs & rhs are connected, but it 
seems that even for more general assignments the tuple assignment may be faster 
for small numbers of variables. Looking at the output of dis for this case


d,e,f=c,b,a

it seems that we get code like this
LOAD_NAME3 (c)
LOAD_NAME2 (b)
LOAD_NAME1 (a)
ROT_THREE
ROT_TWO
STORE_NAME   4 (d)
STORE_NAME   5 (e)
STORE_NAME   6 (f)



for

d = c
e = b
f = a

we get this
LOAD_NAME3 (c)
STORE_NAME   4 (d)
LOAD_NAME2 (b)
STORE_NAME   5 (e)
LOAD_NAME1 (a)
STORE_NAME   6 (f)

which is not obviously slower, but I consistently get the former to be faster. I 
suppose it's a cache issue or something. However, for this particular case when 
the variables are not connected I find the tuple assignment less pythonic, but 
perhaps faster (even though in this case no tuples are built).

--
Robin Becker

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


RE: noobie needs help with ctypes

2013-12-10 Thread Sells, Fred
Mucho apologies for rich text, I think I picked that up when replying to a post 
without properly checking.  Thanks for heads up.

Fred.

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


Re: Problem when applying Patch from issue1424152 to get https over authenticating proxies working with urllib2 in Python 2.5

2013-12-10 Thread harish . barvekar
On Monday, July 20, 2009 11:28:53 PM UTC+5:30, tvashtar wrote:
> On Jul 20, 4:42 pm, Nike  wrote:
> > hi!
> >  It's looks like a ssl error . Under the following step to help u :
> >   1. takes a simple code to confirm your pupose without ssl protocol.
> >   2. to confirm python version and extended libs work well
> >   3. to confirm ssl work well.
> >
> > goog luck!
> >
> > nikekoo
> 
> I've reduced my code to the following:
> 
> import urllib2
> 
> p = "https://user:pass@myproxy:port";
> proxy_handler = urllib2.ProxyHandler({"https": p})
> urllib2.install_opener(urllib2.build_opener(proxy_handler))
> request = urllib2.Request( "https://groups.google.com";)
> response = urllib2.urlopen(request)
> 
> and it is now failing with:
> 
> Traceback (most recent call last):
>   File "D:\p4\depot\Development\HEAD\Build\ReleaseSystem\DownloadSystem
> \test.py", line 12, in 
> response = urllib2.urlopen(request)
>   File "C:\Python25\lib\urllib2.py", line 121, in urlopen
> return _opener.open(url, data)
>   File "C:\Python25\lib\urllib2.py", line 379, in open
> response = self._open(req, data)
>   File "C:\Python25\lib\urllib2.py", line 397, in _open
> '_open', req)
>   File "C:\Python25\lib\urllib2.py", line 358, in _call_chain
> result = func(*args)
>   File "C:\Python25\lib\urllib2.py", line 1115, in https_open
> return self.do_open(httplib.HTTPSConnection, req)
>   File "C:\Python25\lib\urllib2.py", line 1082, in do_open
> raise URLError(err)
> urllib2.URLError:  Authentication Required>
> 
> I thought the proxy_handler should take care of the authentication?
> 
> Thanks for your help

Is this issue fixed. I am also facing the same issue of tunneling in https 
request. Please suggest how to proceed further
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Problem when applying Patch from issue1424152 to get https over authenticating proxies working with urllib2 in Python 2.5

2013-12-10 Thread Chris Angelico
On Wed, Dec 11, 2013 at 12:35 AM,   wrote:
> Is this issue fixed. I am also facing the same issue of tunneling in https 
> request. Please suggest how to proceed further

You're responding to something from 2009. It's highly likely things
have changed.

Does the same code cause an error in Python 2.7? That would be the
first thing to check.

Also: You appear to be using Google Groups, which is the Mos Eisley of
the newsgroup posting universe. You'll do far better to instead use
some other means of posting, such as the mailing list:

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

It's probably a good idea also to search the bug tracker before
posting. It may well be that this has been fixed, in which case the
tracker issue would tell you when the fix went out. Of course, it may
also state that it's not a bug, in which case you'd know why.

http://bugs.python.org/

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


Re: Problem when applying Patch from issue1424152 to get https over authenticating proxies working with urllib2 in Python 2.5

2013-12-10 Thread Mark Lawrence

On 10/12/2013 13:35, [email protected] wrote:

On Monday, July 20, 2009 11:28:53 PM UTC+5:30, tvashtar wrote:

On Jul 20, 4:42 pm, Nike  wrote:

hi!
  It's looks like a ssl error . Under the following step to help u :
   1. takes a simple code to confirm your pupose without ssl protocol.
   2. to confirm python version and extended libs work well
   3. to confirm ssl work well.

goog luck!

nikekoo


I've reduced my code to the following:

import urllib2

p = "https://user:pass@myproxy:port";
proxy_handler = urllib2.ProxyHandler({"https": p})
urllib2.install_opener(urllib2.build_opener(proxy_handler))
request = urllib2.Request( "https://groups.google.com";)
response = urllib2.urlopen(request)

and it is now failing with:

Traceback (most recent call last):
   File "D:\p4\depot\Development\HEAD\Build\ReleaseSystem\DownloadSystem
\test.py", line 12, in 
 response = urllib2.urlopen(request)
   File "C:\Python25\lib\urllib2.py", line 121, in urlopen
 return _opener.open(url, data)
   File "C:\Python25\lib\urllib2.py", line 379, in open
 response = self._open(req, data)
   File "C:\Python25\lib\urllib2.py", line 397, in _open
 '_open', req)
   File "C:\Python25\lib\urllib2.py", line 358, in _call_chain
 result = func(*args)
   File "C:\Python25\lib\urllib2.py", line 1115, in https_open
 return self.do_open(httplib.HTTPSConnection, req)
   File "C:\Python25\lib\urllib2.py", line 1082, in do_open
 raise URLError(err)
urllib2.URLError: 

I thought the proxy_handler should take care of the authentication?

Thanks for your help


Is this issue fixed. I am also facing the same issue of tunneling in https 
request. Please suggest how to proceed further



Please read the whole history of this here 
http://bugs.python.org/issue1424152


--
My fellow Pythonistas, ask not what our language can do for you, ask 
what you can do for our language.


Mark Lawrence

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


Re: using ffmpeg command line with python's subprocess module

2013-12-10 Thread Andreas Perstinger
iMath  wrote:
>we don't have permission to use the temporary file while it has not
>been closed,but when the file is closed , it will be destroyed by
>default(delete=True),but once we set delete=False,then we couldn't
>depend on the convenience of letting the temporary file automatically
>delete itself after it has been used(then we have to delete it later
>by os.remove()) ,thus there is nearly no convenience in creating a
>temporary file or a persistent one when using NamedTemporaryFile.

In your OP you asked for a platform independent solution thus I don't
think it's possible to do what you want if the OS doesn't support
opening a file another time while it's still open.

Otherwise, on my Linux system this works:

>>> import tempfile, subprocess
>>> with tempfile.NamedTemporaryFile() as fp:   
...   fp.write(b"foo\nbar\nbaz\n")
...   fp.flush()
...   subprocess.call(["cat", fp.name])
... 
12
foo
bar
baz
0

Bye, Andreas
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Problem when applying Patch from issue1424152 to get https over authenticating proxies working with urllib2 in Python 2.5

2013-12-10 Thread Mark Lawrence

On 10/12/2013 13:47, Chris Angelico wrote:

On Wed, Dec 11, 2013 at 12:35 AM,   wrote:

Is this issue fixed. I am also facing the same issue of tunneling in https 
request. Please suggest how to proceed further


You're responding to something from 2009. It's highly likely things
have changed.



Says who?  Sadly IMHO this has been one of the worst aspects of Python 
development.  I've seen 10 year old bugs happily sitting on the bug 
tracker.  Thankfully that is slowly changing.  The core mentorship 
program is helping, plus the gradual reduction in the number of versions 
that need supporting as 2.6 is now out of support and we move towards 
3.4.  However there are still 4275 open issues on the bug tracker. 
Anyone up to help out, the pay and perks are really good? :)


--
My fellow Pythonistas, ask not what our language can do for you, ask 
what you can do for our language.


Mark Lawrence

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


Re: Problem when applying Patch from issue1424152 to get https over authenticating proxies working with urllib2 in Python 2.5

2013-12-10 Thread Chris Angelico
On Wed, Dec 11, 2013 at 1:06 AM, Mark Lawrence  wrote:
> On 10/12/2013 13:47, Chris Angelico wrote:
>>
>> On Wed, Dec 11, 2013 at 12:35 AM,   wrote:
>>>
>>> Is this issue fixed. I am also facing the same issue of tunneling in
>>> https request. Please suggest how to proceed further
>>
>>
>> You're responding to something from 2009. It's highly likely things
>> have changed.
>>
>
> Says who?  Sadly IMHO this has been one of the worst aspects of Python
> development.  I've seen 10 year old bugs happily sitting on the bug tracker.
> Thankfully that is slowly changing.  The core mentorship program is helping,
> plus the gradual reduction in the number of versions that need supporting as
> 2.6 is now out of support and we move towards 3.4.  However there are still
> 4275 open issues on the bug tracker. Anyone up to help out, the pay and
> perks are really good? :)

There've been two minor versions since the version cited in the post
(2.5), not counting Python 3 at all. It's definitely worth rechecking
on 2.7 or 3.3, to see if the same still occurs. (Or, of course, to
read the tracker issue, which in this case was known and needn't be
searched for, a fact that I missed noticing when I went reading.) Yes,
four years' worth of bug fixes does make it at least somewhat likely
that something's changed.

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


Re: Programming puzzle with boolean circuits

2013-12-10 Thread Antoon Pardon
Op 09-12-13 12:49, Johannes Bauer schreef:
> Hi group,
> 
> it's somewhat OT here, but I have a puzzle to which I would like a
> solution -- but I'm unsure how I should tackle the problem with Python.
> But it's a fun puzzle, so maybe it'll be appreciated here.
> 
> The question is: How do you design a boolean circuit that contains at
> most 2 NOT gates, but may contain as many AND or OR gates that inverts
> three inputs? IOW: Build three inverters by using only two inverters
> (and an infinite amount of AND/OR).
> 
> Surprisingly, this is possible (and I even know the solution, but won't
> give it away just yet).
> 
> I found this puzzle again and was thinking about: How would I code a
> brute-force approach to this problem in Python? And to my surprise, it
> isn't as easy as I thought. So I'm looking for some advice from you guys
> (never huts to improve ones coding skills).

Well I would make some kind of connecter type, that would have a binary
vector associated with it. How do we calculate bit n of a connector?

Take the three input signals, i0, i1, i2, these can be seen as a binary
digits. So suppose we have input 0, 1, 0 then bit 2 of the connector
would be the value of that connector with these input signals.

The original three connectors would have the following values:
01010101, 00110011, .

What you can do now is make new connectors by combining them with
an or, and or not port and search for those whose value is 10101010,
11001100 and .

-- 
Antoon Pardon

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


Re: Problem when applying Patch from issue1424152 to get https over authenticating proxies working with urllib2 in Python 2.5

2013-12-10 Thread Mark Lawrence

On 10/12/2013 14:14, Chris Angelico wrote:

On Wed, Dec 11, 2013 at 1:06 AM, Mark Lawrence  wrote:

On 10/12/2013 13:47, Chris Angelico wrote:


On Wed, Dec 11, 2013 at 12:35 AM,   wrote:


Is this issue fixed. I am also facing the same issue of tunneling in
https request. Please suggest how to proceed further



You're responding to something from 2009. It's highly likely things
have changed.



Says who?  Sadly IMHO this has been one of the worst aspects of Python
development.  I've seen 10 year old bugs happily sitting on the bug tracker.
Thankfully that is slowly changing.  The core mentorship program is helping,
plus the gradual reduction in the number of versions that need supporting as
2.6 is now out of support and we move towards 3.4.  However there are still
4275 open issues on the bug tracker. Anyone up to help out, the pay and
perks are really good? :)


There've been two minor versions since the version cited in the post
(2.5), not counting Python 3 at all. It's definitely worth rechecking
on 2.7 or 3.3, to see if the same still occurs. (Or, of course, to
read the tracker issue, which in this case was known and needn't be
searched for, a fact that I missed noticing when I went reading.) Yes,
four years' worth of bug fixes does make it at least somewhat likely
that something's changed.

ChrisA



How many minor versions since this was created on 2002-01-16 at 04:56 
http://bugs.python.org/issue504219  ?  The issue originally referenced 
is closed, this is still open.  Age on the bug tracker is no guarantee 
of anything, except that the issue exists.


--
My fellow Pythonistas, ask not what our language can do for you, ask 
what you can do for our language.


Mark Lawrence

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


Re: Experiences/guidance on teaching Python as a first programming language

2013-12-10 Thread rusi
On Tuesday, December 10, 2013 4:12:53 PM UTC+5:30, Oscar Benjamin wrote:
> On 9 December 2013 19:57, Terry Reedy  wrote:
> > On 12/9/2013 7:23 AM, Oscar Benjamin wrote:
> >> Hi all,
> >> I work in a University Engineering faculty teaching, among other
> >> things, programming. In our last meeting about improving our teaching
> >> syllabus and delivery we've identified the first year programming
> >> courses as an area where there is room for improvement and we're
> >> considering (mainly on my suggestion) switching to using Python as the
> >> first programming language that we use to introduce our students to
> >> programming. I'm interested to know if anyone can share experience of
> >> a similar situation or can point to any case studies about this.
> > A few years ago, MIT switched from Scheme (which I believe originated at
> > MIT) to Python for its first course. There might faculty blogs discussing
> > the reasons.

> Thanks Terry. The best I've found is this:
> http://cemerick.com/2009/03/24/why-mit-now-uses-python-instead-of-scheme-for-its-undergraduate-cs-program/

There's this
http://danweinreb.org/blog/why-did-mit-switch-from-scheme-to-python
which seems to have died -- the internet archive has it here
https://web.archive.org/web/20120429151818/http://danweinreb.org/blog/why-did-mit-switch-from-scheme-to-python

Neither really talks of why python was chosen

In that direction you may want to see why Java has been ousted from CMU:
http://existentialtype.wordpress.com/2011/03/15/teaching-fp-to-freshmen/
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Problem when applying Patch from issue1424152 to get https over authenticating proxies working with urllib2 in Python 2.5

2013-12-10 Thread rurpy
On 12/10/2013 06:47 AM, Chris Angelico wrote:
> On Wed, Dec 11, 2013 at 12:35 AM,   wrote:
> Also: You appear to be using Google Groups, which is the Mos Eisley of
> the newsgroup posting universe. You'll do far better to instead use
> some other means of posting, such as the mailing list:
 
Using Google Groups is also fine.  I and many other posters here
use it.  Chris and some others here dislike Google Groups and want 
everyone to not use it, but that is their personal opinion.

If Google Groups is most convenient for you please feel free to
continue using it.  You might want to take a look at this page 
which describes how to reduce some of things that annoy people 
like Chris:

  https://wiki.python.org/moin/GoogleGroupsPython

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


Re: Problem when applying Patch from issue1424152 to get https over authenticating proxies working with urllib2 in Python 2.5

2013-12-10 Thread Mark Lawrence

On 10/12/2013 15:48, [email protected] wrote:

On 12/10/2013 06:47 AM, Chris Angelico wrote:

On Wed, Dec 11, 2013 at 12:35 AM,   wrote:
Also: You appear to be using Google Groups, which is the Mos Eisley of
the newsgroup posting universe. You'll do far better to instead use
some other means of posting, such as the mailing list:


Using Google Groups is also fine.  I and many other posters here
use it.  Chris and some others here dislike Google Groups and want
everyone to not use it, but that is their personal opinion.

If Google Groups is most convenient for you please feel free to
continue using it.  You might want to take a look at this page
which describes how to reduce some of things that annoy people
like Chris:

   https://wiki.python.org/moin/GoogleGroupsPython



There is no "you might want to" about it.  There are two options here, 
either read and action the page so we don't see double spaced crap 
amongst other things, use another tool, or don't post.


--
My fellow Pythonistas, ask not what our language can do for you, ask 
what you can do for our language.


Mark Lawrence

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


Re: ProgrammingError: (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'S SIZE 11.5 NEW IN BOX', '$49.99')'

2013-12-10 Thread Dan Stromberg
On Mon, Dec 9, 2013 at 12:41 AM, Jai  wrote:

>
> sql = """insert into `category` (url, catagory,price) VAlUES
> ('%s', '%s', '%s')"""%(link1,x,y)
>

Is that VALUES or VAlUES or VAIUES?   It probably should be VALUES.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: ProgrammingError: (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'S SIZE 11.5 NEW IN BOX', '$49.99')'

2013-12-10 Thread Chris Angelico
On Wed, Dec 11, 2013 at 3:23 AM, Dan Stromberg  wrote:
>
> On Mon, Dec 9, 2013 at 12:41 AM, Jai  wrote:
>>
>>
>> sql = """insert into `category` (url, catagory,price) VAlUES
>> ('%s', '%s', '%s')"""%(link1,x,y)
>
>
> Is that VALUES or VAlUES or VAIUES?   It probably should be VALUES.

SQL's case insensitive. But I did have to check carefully to see that
that really was correct.

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


Re: Movie (MPAA) ratings and Python?

2013-12-10 Thread Dan Stromberg
On Mon, Dec 9, 2013 at 10:40 PM, Ben Finney wrote:

> Dan Stromberg  writes:
>
> > Is anyone using a module or database that gives Python 3.x access to MPAA
> > ratings (EG G, PG, PG-13, etc.)?
>
> What information would you want access to? Why would a library (rather
> than, say, a short set of strings) be needed?
>
Movie ratings.   EG G, PG, PG-13, etc.

A library might query a REST interface or screenscrape, though most
relevant websites have policies against screenscraping.


> > I explored a few of the possibilities on Pypi, a couple of web
> interfaces,
> > and the IMDB flat text file with ratings and reasons for those ratings,
> but
> > I've not been really impressed yet.
>
> You seem to be talking about some MPAA document, where is it so we can
> know what specifically you're referring to?
> It's available from many places, EG:
> http://www.filewatcher.com/m/mpaa-ratings-reasons.list.gz.203532-0.html
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Movie (MPAA) ratings and Python?

2013-12-10 Thread Dan Stromberg
On Mon, Dec 9, 2013 at 10:48 PM, Paul Scott  wrote:

> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA1
>
> On 10/12/2013 08:40, Ben Finney wrote:
> > Dan Stromberg  writes:
> >
> >> Is anyone using a module or database that gives Python 3.x access
> >> to MPAA ratings (EG G, PG, PG-13, etc.)?
>
> If you are already using IMDB you should have a look at
> http://imdbpy.sourceforge.net/downloads.html as well. It provides a
> relatively simple Python interface to either a local or hosted IMDB
> dataset and allows you to grab the MPAA rating directly from the
> canonical movie name.
>
I believe this was the module I got the farthest with.  I was using it
without a local database, instead querying IMDB's website.  However, it
appeared to be 2.x only (no 3.x yet), and it was tracebacking a lot.

The rest of the IMDB-related packages on Pypi appeared to have tiny version
numbers, or to have not been updated in quite a while.
-- 
https://mail.python.org/mailman/listinfo/python-list


Trouble with Multi-threading

2013-12-10 Thread dan . rose
I am running PYTHON 2.7.3 and executing a PYTHON program that uses 
multi-threading.  I am running this on a 64-bit Windows 2008 R2 server 
(Service Pack 1).

Three months ago, I was able to execute this program just fine.  I ran the 
program and opened Task Manager and verified that the program successfully 
obtained all of the multiple threads it requested.

Now, when I go to run this same program (no changes to the program), I am 
getting this message:

Python 2.7.3 (default, Apr 10 2012, 23:24:47) [MSC v.1500 64 bit (AMD64)] 
on win32
Type "copyright", "credits" or "license()" for more information.
>>>  RESTART 

>>> 

>>> 

I look in Task Manager and I don't see any threads for PYTHON.

So, I am hoping that somebody in this forum could help me out.

What is it that I should look for or turn on to find out what is blocking 
this program from creating the threads.

---
 Daniel Rose
 IT Technical Analyst, MSS Development
 Parker Hannifin Corporation
 [email protected]
 216-896-3351

"PLEASE NOTE: The preceding information may be confidential or
privileged. It only should be used or disseminated for the purpose
of conducting business with Parker. If you are not an intended
recipient, please notify the sender by replying to this message and
then delete the information from your system. Thank you for your
cooperation."
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Trouble with Multi-threading

2013-12-10 Thread Dan Stromberg
On Tue, Dec 10, 2013 at 8:21 AM,  wrote:

> I am running PYTHON 2.7.3 and executing a PYTHON program that uses
> multi-threading.  I am running this on a 64-bit Windows 2008 R2 server
> (Service Pack 1).
>
> Three months ago, I was able to execute this program just fine.  I ran the
> program and opened Task Manager and verified that the program successfully
> obtained all of the multiple threads it requested.
>
> Now, when I go to run this same program (no changes to the program), I am
> getting this message:
>
> Python 2.7.3 (default, Apr 10 2012, 23:24:47) [MSC v.1500 64 bit (AMD64)]
> on win32
> Type "copyright", "credits" or "license()" for more information.
> >>>  RESTART
> 
> >>>
> 
> >>>
>
> I look in Task Manager and I don't see any threads for PYTHON.
>

It looks to me like you may be using multiprocessing rather than
multithreading...

Multiprocessing uses multiple processes with shared memory.  Multithreading
uses multiple Program Counter's in the same process.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Problem when applying Patch from issue1424152 to get https over authenticating proxies working with urllib2 in Python 2.5

2013-12-10 Thread rusi
On Tuesday, December 10, 2013 9:52:47 PM UTC+5:30, Mark Lawrence wrote:
> On 10/12/2013 15:48, rurpy wrote:
> > On 12/10/2013 06:47 AM, Chris Angelico wrote:
> >> On Wed, Dec 11, 2013 at 12:35 AM,  harish.barvekar wrote:
> >> Also: You appear to be using Google Groups, which is the Mos Eisley of
> >> the newsgroup posting universe. You'll do far better to instead use
> >> some other means of posting, such as the mailing list:
> > Using Google Groups is also fine.  I and many other posters here
> > use it.  Chris and some others here dislike Google Groups and want
> > everyone to not use it, but that is their personal opinion.
> > If Google Groups is most convenient for you please feel free to
> > continue using it.  You might want to take a look at this page
> > which describes how to reduce some of things that annoy people
> > like Chris:
> >https://wiki.python.org/moin/GoogleGroupsPython

> There is no "you might want to" about it.  There are two options here, 
> either read and action the page so we don't see double spaced crap 
> amongst other things, use another tool, or don't post.

There are 10 kinds of people in the world: those who understand 
binary and those who dont.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Problem when applying Patch from issue1424152 to get https over authenticating proxies working with urllib2 in Python 2.5

2013-12-10 Thread Chris Angelico
On Wed, Dec 11, 2013 at 3:49 AM, rusi  wrote:
> There are 10 kinds of people in the world: those who understand
> binary and those who dont.

There are 10 kinds of people in the world: those who understand Gray
Code, those who don't, and those who confuse it with binary.

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


Re: Trouble with Multi-threading

2013-12-10 Thread Roy Smith
In article ,
 [email protected] wrote:

> "PLEASE NOTE: The preceding information may be confidential or
> privileged. It only should be used or disseminated for the purpose
> of conducting business with Parker. If you are not an intended
> recipient, please notify the sender by replying to this message and
> then delete the information from your system. Thank you for your
> cooperation."

Dan,

Pursuant to your legal notice, I hereby inform you that I received your 
message in error.  Unfortunately, I am unable to delete it from my 
system since I do not control my ISP's news server (and Time Machine has 
probably backed up a copy of the local temp file anyway).  Please advise 
on how I should proceed, so that I am fully in compliance with your 
information confidentiality policy.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Problem when applying Patch from issue1424152 to get https over authenticating proxies working with urllib2 in Python 2.5

2013-12-10 Thread Mark Lawrence

On 10/12/2013 16:49, rusi wrote:

On Tuesday, December 10, 2013 9:52:47 PM UTC+5:30, Mark Lawrence wrote:

On 10/12/2013 15:48, rurpy wrote:

On 12/10/2013 06:47 AM, Chris Angelico wrote:

On Wed, Dec 11, 2013 at 12:35 AM,  harish.barvekar wrote:
Also: You appear to be using Google Groups, which is the Mos Eisley of
the newsgroup posting universe. You'll do far better to instead use
some other means of posting, such as the mailing list:

Using Google Groups is also fine.  I and many other posters here
use it.  Chris and some others here dislike Google Groups and want
everyone to not use it, but that is their personal opinion.
If Google Groups is most convenient for you please feel free to
continue using it.  You might want to take a look at this page
which describes how to reduce some of things that annoy people
like Chris:
https://wiki.python.org/moin/GoogleGroupsPython



There is no "you might want to" about it.  There are two options here,
either read and action the page so we don't see double spaced crap
amongst other things, use another tool, or don't post.


There are 10 kinds of people in the world: those who understand
binary and those who dont.



There are 10 kinds of people in the world: those who understand that 
google groups sends out double spaced crap and those who don't.


--
My fellow Pythonistas, ask not what our language can do for you, ask 
what you can do for our language.


Mark Lawrence

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


Re: Problem when applying Patch from issue1424152 to get https over authenticating proxies working with urllib2 in Python 2.5

2013-12-10 Thread rurpy
On 12/10/2013 09:22 AM, Mark Lawrence wrote:
> On 10/12/2013 15:48, [email protected] wrote:
> [...]
> There is no "you might want to" about it.  There are two options here, 
> either read and action the page so we don't see double spaced crap 
> amongst other things, use another tool, or don't post.

Mark is one of the resident trolls here.  Among his other traits 
is his delusion that he is Lord High Commander of this list.
Like with other trolls, the best advice is to ignore him (which
I'm not doing this once as a public service).

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


Re: problem with graph of python(show)

2013-12-10 Thread Asemaneh Allame
در دوشنبه 9 دسامبر 2013، ساعت 23:04:43 (UTC+3:30)، Asemaneh Allame نوشته:
> hi everybody
> 
> i recently  install python & vpython(v:2.6.7) in my windows(32bit)
> 
> it install succesfully but dont show some of  graphes that involved their 
> code in the lib.python ,
> 
> i dont know what s problem...
> 
> please giude me
> 
> thanks



thanks for your attention
my mean is obvios
i cont get any graph of vpython
it shows me a maseage in this form:
" pythonw.exe has stopped working"
i m sure that have a good & perfect install and i dont khnow what s problem
is that enouph??
by regards

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


Re: Problem when applying Patch from issue1424152 to get https over authenticating proxies working with urllib2 in Python 2.5

2013-12-10 Thread Mark Lawrence

On 10/12/2013 16:59, [email protected] wrote:

On 12/10/2013 09:22 AM, Mark Lawrence wrote:

On 10/12/2013 15:48, [email protected] wrote:
[...]
There is no "you might want to" about it.  There are two options here,
either read and action the page so we don't see double spaced crap
amongst other things, use another tool, or don't post.


Mark is one of the resident trolls here.  Among his other traits
is his delusion that he is Lord High Commander of this list.
Like with other trolls, the best advice is to ignore him (which
I'm not doing this once as a public service).



That is entirely correct.  I also spend a lot of my time defending the 
indefensible, like defending people who use crap tools to send double 
spaced crap around the whole world.  Not.


--
My fellow Pythonistas, ask not what our language can do for you, ask 
what you can do for our language.


Mark Lawrence

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


Re: Problem when applying Patch from issue1424152 to get https over authenticating proxies working with urllib2 in Python 2.5

2013-12-10 Thread Grant Edwards
On 2013-12-10, Chris Angelico  wrote:
> On Wed, Dec 11, 2013 at 3:49 AM, rusi  wrote:
>> There are 10 kinds of people in the world: those who understand
>> binary and those who dont.
>
> There are 10 kinds of people in the world: those who understand Gray
> Code, those who don't, and those who confuse it with binary.

Let me pause and reflect on that for a moment...

-- 
Grant Edwards   grant.b.edwardsYow! All of life is a blur
  at   of Republicans and meat!
  gmail.com
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Problem when applying Patch from issue1424152 to get https over authenticating proxies working with urllib2 in Python 2.5

2013-12-10 Thread David Robinow
On Tue, Dec 10, 2013 at 11:59 AM,   wrote:
> On 12/10/2013 09:22 AM, Mark Lawrence wrote:
...
> Mark is one of the resident trolls here.  Among his other traits
> is his delusion that he is Lord High Commander of this list.
> Like with other trolls, the best advice is to ignore him (which
> I'm not doing this once as a public service).
Please don't do this. I can decide for myself whether I prefer to read
Mark's posts.
[By the way, I don't consider Mark Lawrence a troll. He's just a guy
who can't help himself. I've chosen not to listen any more but others
are entitled to their own choices.]+
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Trouble with Multi-threading

2013-12-10 Thread Walter Hurry
On Tue, 10 Dec 2013 11:21:32 -0500, dan.rose wrote:

> "PLEASE NOTE: The preceding information may be confidential or
> privileged. It only should be used or disseminated for the purpose of
> conducting business with Parker. If you are not an intended recipient,
> please notify the sender by replying to this message and then delete the
> information from your system. Thank you for your cooperation."

Regretfully I am unable to delete the message from my Usenet provider's 
servers.

However, in accordance with your request I have expunged the body of your 
request so as to avoid disseminating it.

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


Re: Trouble with Multi-threading

2013-12-10 Thread Mark Lawrence

On 10/12/2013 16:21, [email protected] wrote:

* 216-896-3351* "PLEASE NOTE: The preceding information may be
confidential or privileged. It only should be used or disseminated for
the purpose of conducting business with Parker. If you are not an
intended recipient, please notify the sender by replying to this message
and then delete the information from your system. Thank you for your
cooperation."



Which Parker?  If my memory serves me correctly there was Malcolm and 
his brothers Stephen and Keith, and sisters Sandra and Yvonne and I'm 
certain there were more.  Plus there was the counsins David and 
Jennifer.  How do I know if I'm an intended recipient if you don't tell 
me?  I also can't delete the message.  Hum, anything I've forgotten?


--
My fellow Pythonistas, ask not what our language can do for you, ask 
what you can do for our language.


Mark Lawrence

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


Re: problem with graph of python(show)

2013-12-10 Thread Andreas Perstinger

On 10.12.2013 18:03, Asemaneh Allame wrote:

my mean is obvios
i cont get any graph of vpython
it shows me a maseage in this form:
" pythonw.exe has stopped working"
i m sure that have a good & perfect install and i dont khnow what s problem
is that enouph??


No, that's not enough. You need to be more specific.

How do you run your program? From the command line or some IDE? Or are 
you using the python shell?


What code are you trying to run?

How do you know that you have a "good & perfect install"?

Have you tried the example from the official site?
http://www.vpython.org/contents/bounce_example.html

There is also a forum for VPython:
https://groups.google.com/forum/?fromgroups&hl=en#!forum/vpython-users

Bye, Andreas
--
https://mail.python.org/mailman/listinfo/python-list


Re: Problem when applying Patch from issue1424152 to get https over authenticating proxies working with urllib2 in Python 2.5

2013-12-10 Thread rurpy
On 12/10/2013 10:36 AM, David Robinow wrote:
> On Tue, Dec 10, 2013 at 11:59 AM,   wrote:
>> On 12/10/2013 09:22 AM, Mark Lawrence wrote:
> ...
>> Mark is one of the resident trolls here.  Among his other traits
>> is his delusion that he is Lord High Commander of this list.
>> Like with other trolls, the best advice is to ignore him (which
>> I'm not doing this once as a public service).
>
> Please don't do this. I can decide for myself whether I prefer to read
> Mark's posts.

I didn't post it for you, I posted it for the OP who
may be new here (or may not, I didn't check) and for 
others from Google Groups who may erroneously think
that Mark/Chris et.al. have some kind of authority or
speak for everyone here.
 
Nor was it a suggestion to not read Mark's posts but
a suggestion to not add to the flamage.

> [By the way, I don't consider Mark Lawrence a troll. He's just a guy
> who can't help himself. I've chosen not to listen any more but others
> are entitled to their own choices.]+
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: problem with graph of python(show)

2013-12-10 Thread Terry Reedy

On 12/10/2013 12:03 PM, Asemaneh Allame wrote:


thanks for your attention
my mean is obvios
i cont get any graph of vpython


I am fairly expert with python but know almost nothing about vpython. I 
have no idea what 'graph of python' or 'graph of vpython' means. I 
suggest that you find a vpython list.



it shows me a maseage in this form:
" pythonw.exe has stopped working"


If you do, post the complete traceback, not just the final message.
Also, describe what you did to get the message.

--
Terry Jan Reedy

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


Re: Permission for contribution: http://bugs.python.org/issue19940

2013-12-10 Thread Terry Reedy

On 12/10/2013 6:35 AM, shankha wrote:

I wish to make contribution to Python source code. I have studied the
developers guide and made myself familiar with mercurial. I wish to
start of with some doc bugs as this will give me insight into
how the whole process(review, tests, patches) works. Is it okay if to take:

http://bugs.python.org/issue19940.


Follow the suggestion to join the core-mentorship list. I will just add 
here that issues are 'assigned' for review and commitment to one of the 
core developers with commit rights to the python.org repository. Anyone 
can submit a patch to the tracker. It is ok to post that you are working 
on an issue, if indeed you are. Perhaps about half the commits involve 
contributions from non-core developers.


--
Terry Jan Reedy

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


ANN: Wing IDE 5.0.1 released

2013-12-10 Thread Wingware

Hi,

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

Wing IDE includes a professional quality 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.  For details see http://wingware.com/

Changes in this minor release include:

* Support for Python 3.4beta1+
* Fix file type registration on OS X
* Fix potential segfault after using tab to move from field to field
* Fix creating and renaming snippets and snippets tool drop down menu
* Fix exception when closing windows and failure to quit on win32
* Optimize message tool, which could substantially slow down the IDE
* Fix problems setting custom colors via the Editor -> Syntax Coloring 
preferences

* Updates and corrections in French localization (thanks to Jean Sanchez)
* Fix intermittant failure to include all selected files in a version 
control operation
* Fix switching to alphabetizing file tabs and keeping active tab 
visible when there are 2+ splits

* 21 other bug fixes

For details see http://wingware.com/pub/wingide/5.0.1/CHANGELOG.txt

New features in Wing 5 include:

* Now runs native on OS X
* Draggable tools and editors
* Configurable toolbar and editor & project context menus
* Optionally opens a different sets of files in each editor split
* Lockable editor splits
* Optional Python Turbo completion (context-appropriate completion on 
all non-symbol keys)

* Sharable color palettes and syntax highlighting configurations
* Auto-editing is on by default (except some operations that have a 
learning curve)

* Named file sets
* Sharable launch configurations
* Asynchronous I/O in Debug Probe and Python Shell
* Expanded and rewritten tutorial
* Support for Python 3.4

For more information on what's new in Wing 5, see 
http://wingware.com/wingide/whatsnew


Free trial: http://wingware.com/wingide/trial
Downloads: http://wingware.com/downloads
Feature matrix: http://wingware.com/wingide/features
Sales: http://wingware.com/store/purchase
Upgrades: https://wingware.com/store/upgrade

Questions?  Don't hesitate to email us at [email protected].

Thanks,

--

Stephan Deibel
Wingware | Python IDE
Advancing Software Development

www.wingware.com
--
https://mail.python.org/mailman/listinfo/python-list


Re: Trouble with Multi-threading

2013-12-10 Thread feedthetroll
Am Dienstag, 10. Dezember 2013 17:21:32 UTC+1 schrieb [email protected]:
> "PLEASE NOTE: The preceding information may be confidential or
> privileged. It only should be used or disseminated for the purpose
> of conducting business with Parker. If you are not an intended
> recipient, please notify the sender by replying to this message and
> then delete the information from your system. Thank you for your
> cooperation."

As the above clause demands I hereby inform you, that I am - presumably  - not 
an intended recipient, because I am - as far as I know - not in any business 
with whatever Parker.
Nevertheless I am very sorry, but I am not able to delete the message. Neither 
from the usenet nor from Google-Groups.
-- 
https://mail.python.org/mailman/listinfo/python-list


Alternate initializer pattern?

2013-12-10 Thread buchanae
Hello.

I've been pondering an alternate initializer pattern that I've attempted to 
document here:

https://gist.github.com/abuchanan/7882317


Instead of using classmethod, I invent a new descriptor "alt_init" that creates 
an instance and passes it to the decorated function as the first argument 
(where classmethod would pass the class object).

I haven't used it in TheRealWord(tm), and maybe it's just a crappy Factory 
pattern (or is it Builder? or maybe Argile?), and I'm sure it has downsides, 
but I wanted to share anyway, to see what kind of feedback it would produce.

Thanks!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Movie (MPAA) ratings and Python?

2013-12-10 Thread Ben Finney
Dan Stromberg  writes:

> On Mon, Dec 9, 2013 at 10:40 PM, Ben Finney wrote:
> > What information would you want access to? Why would a library
> > (rather than, say, a short set of strings) be needed?
> >
> Movie ratings.   EG G, PG, PG-13, etc.

That tells me only that you want short strings. Based on what you've
said so far, your requirements can be met with code like this:

movie_ratings = ["G", "PG", "PG-13", …]

which doesn't need a library to access.

So, I ask again: What data do you want access to? Can you describe what
you want your program to receive when it accesses movie ratings?

Is this information held specifically by the MPAA? If so, where is it
online, and how do the MPAA make it available publicly? These are
questions to answer prior to asking about Python libraries.

Before asking “how do I use Python for this job?”, you need to help us
understand what “this job” is.

-- 
 \ “For your convenience we recommend courteous, efficient |
  `\self-service.” —supermarket, Hong Kong |
_o__)  |
Ben Finney

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


Re: Movie (MPAA) ratings and Python?

2013-12-10 Thread Petite Abeille

On Dec 10, 2013, at 6:25 AM, Dan Stromberg  wrote:

> The IMDB flat text file probably came the closest, but it appears to have 
> encoding issues; it's apparently nearly windows-1255, but not quite.

It's ISO-8859-1.

Both certificates.list.gz and mpaa-ratings-reasons.list.gz are rather 
straightforward to parse.

For the US, you will get something along these lines out of 
certificates.list.gz:

USA:(Banned)
USA:12
USA:AO
USA:Approved
USA:C
USA:E
USA:E10+
USA:G
USA:GP
USA:K-A
USA:M
USA:M/PG
USA:NC-17
USA:Not Rated
USA:Open
USA:PG
USA:PG-13
USA:Passed
USA:R
USA:T
USA:TV-14
USA:TV-G
USA:TV-MA
USA:TV-PG
USA:TV-Y
USA:TV-Y7
USA:Unrated
USA:X

And as mentioned, imdbpy handles all this out-of-the-box if you don’t feel like 
doing it yourself.




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


Re: Experiences/guidance on teaching Python as a first programming language

2013-12-10 Thread Gregory Ewing

Chris Angelico wrote:

But in teaching woodwork you SHOULD let people use basic tools, and
not just a CNC lathe.

Programming shouldn't be painful just for the sake of making it
painful.


That's the only point I was trying to make. Pain in and
of itself doesn't help anyone to learn anything!

--
Greg
--
https://mail.python.org/mailman/listinfo/python-list


ANN: pathlib 0.97 released

2013-12-10 Thread Antoine Pitrou

Hello,

As you may know, pathlib has recently been accepted for inclusion into
the Python 3.4 standard library.  You can view the new module's
documentation here: http://docs.python.org/dev/library/pathlib.html

As part of the inclusion process, many API changes were done to the
original pathlib API (*) so as to satisfy the python-dev community's 
comments and complaints. Yet, the PyPI version of pathlib (0.8) was still 
featuring the legacy API.

(*) INCLUDING COMPATIBILITY-BREAKING CHANGES

I am now releasing version 0.97 of pathlib, which brings the standalone
PyPI module up-to-date with the standard library version. The version
number reflects this. It isn't yet "officially" stable, since Python 3.4
hasn't been released yet; I plan to do a standalone 1.0 release by the
time Python 3.4 is released.

If you are not under Python 3.4:

Install
---

Download from https://pypi.python.org/pypi/pathlib/
or use `pip` or `easy_install`.
(be sure to *force* the upgrade if pathlib 0.8 or earlier is already
installed!)

Documentation
-

Standalone documentation is at https://pathlib.readthedocs.org/

Changes from 0.8
-

The API changes are too long to list; if you are already a pathlib user,
I would recommend you read the documentation and find out what has changed 
for you (your code will likely break loudly, anyway!).


Regards

Antoine.


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


Re: Experiences/guidance on teaching Python as a first programming language

2013-12-10 Thread Ethan Furman

On 12/09/2013 05:24 AM, Gene Heskett wrote:


I toss out that

1. a semester is insufficient to gain a working familiarity with either
python or java.


I don't know about java, but it would certainly be enough to get a good start 
in Python.



2. If you want to start at the nuts and bolts level, (and you should)


Doesn't sound like they do, as that's causing plenty of problems.  In today's world that level of knowledge isn't always 
necessary, especially if your degree is not in CS.  One of the (many) nice things about Python is one doesn't need to 
know that stuff to Get Things Done.


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


Re: Experiences/guidance on teaching Python as a first programming language

2013-12-10 Thread Ethan Furman

On 12/09/2013 08:10 AM, Gene Heskett wrote:

On Monday 09 December 2013 10:46:42 Larry Martell did opine:

On Mon, Dec 9, 2013 at 8:24 AM, Gene Heskett wrote:

On Monday 09 December 2013 07:51:12 Oscar Benjamin did opine:


[weapon of mass snippage]

Okay, folks, it's really okay to snip stuff!  ;)

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


Re: Movie (MPAA) ratings and Python?

2013-12-10 Thread Michael Torrie
On 12/10/2013 01:26 PM, Ben Finney wrote:
>> Movie ratings.   EG G, PG, PG-13, etc.
> 
> That tells me only that you want short strings. Based on what you've
> said so far, your requirements can be met with code like this:
> 
> movie_ratings = ["G", "PG", "PG-13", …]
> 
> which doesn't need a library to access.
> 
> So, I ask again: What data do you want access to? Can you describe what
> you want your program to receive when it accesses movie ratings?

I'm not sure whether there's actual confusion here on your part, or
deliberate obtuseness.  From the other comments on this thread, it seems
some people at least understand what he wants to do and I believe he's
been pointed in the right direction.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Movie (MPAA) ratings and Python?

2013-12-10 Thread Ben Finney
Michael Torrie  writes:

> I'm not sure whether there's actual confusion here on your part, or
> deliberate obtuseness.

Not confusion, but a desire to avoid guesses based on very vague
requirements.

> From the other comments on this thread, it seems some people at least
> understand what he wants to do and I believe he's been pointed in the
> right direction.

Okay, but it would be good if the OP could clearly state what he wants
so the answers have some context for other readers.

Anyway, I'll bow out of this thread now.

-- 
 \ “I used to think that the brain was the most wonderful organ in |
  `\   my body. Then I realized who was telling me this.” —Emo Philips |
_o__)  |
Ben Finney

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


Re: Movie (MPAA) ratings and Python?

2013-12-10 Thread Dan Stromberg
On Tue, Dec 10, 2013 at 1:07 PM, Petite Abeille wrote:

>
> On Dec 10, 2013, at 6:25 AM, Dan Stromberg  wrote:
>
> > The IMDB flat text file probably came the closest, but it appears to
> have encoding issues; it's apparently nearly windows-1255, but not quite.
>
> It's ISO-8859-1.
>
Thanks - that reads well from CPython 3.3.

Now the question becomes: Why did chardet tell me it was windows-1255?  :)


> Both certificates.list.gz and mpaa-ratings-reasons.list.gz are rather
> straightforward to parse.
>
Sure, with an appropriate encoding.


> For the US, you will get something along these lines out of
> certificates.list.gz:
>
> USA:(Banned)
> USA:12
> USA:AO
> USA:Approved
> USA:C
> USA:E
> USA:E10+
> USA:G
> USA:GP
> USA:K-A
> USA:M
> USA:M/PG
> USA:NC-17
> USA:Not Rated
> USA:Open
> USA:PG
> USA:PG-13
> USA:Passed
> USA:R
> USA:T
> USA:TV-14
> USA:TV-G
> USA:TV-MA
> USA:TV-PG
> USA:TV-Y
> USA:TV-Y7
> USA:Unrated
> USA:X
>
> And as mentioned, imdbpy handles all this out-of-the-box if you don’t feel
> like doing it yourself.

But I believe imdbpy is 2.7 only.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Movie (MPAA) ratings and Python?

2013-12-10 Thread Dan Stromberg
On Tue, Dec 10, 2013 at 3:34 PM, Ben Finney wrote:

> Michael Torrie  writes:
>
> > I'm not sure whether there's actual confusion here on your part, or
> > deliberate obtuseness.
>
> Not confusion, but a desire to avoid guesses based on very vague
> requirements.
>

What part of "movie ratings (EG G, PG, PG-13)" don't you understand?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: PEP 450 Adding a statistics module to Python

2013-12-10 Thread CM
On Friday, August 9, 2013 9:10:18 PM UTC-4, Steven D'Aprano wrote:
> I am seeking comments on PEP 450, Adding a statistics module to Python's 
> standard library:

I just saw today that this will be included in Python 3.4.  Congratulations, 
Steven, this is a nice addition.

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


Re: Movie (MPAA) ratings and Python?

2013-12-10 Thread Ben Finney
Dan Stromberg  writes:

> What part of "movie ratings (EG G, PG, PG-13)" don't you understand?

As stated, that example requirement is satisfied by a list of strings
‘["G", "PG", "PG-13"]’. If your example of “movie ratings” is a small
collection of short strings, then that's all I've got to go on before
needing to guess from a wide space of possible options.

I understand what MPAA movie ratings are, but that doesn't clarify what
*you* mean in terms of what data you want your program to access beyond
the strings “G”, “PG”, “PG-13” themselves.

Anyway, it appears others have accurately guessed your intent from
information beyond what you presented in your request. But you'll
probably agree that's not a very reliable way of getting effective
answers.

-- 
 \“I was in Las Vegas, at the roulette table, having a furious |
  `\ argument over what I considered to be an odd number.” —Steven |
_o__)   Wright |
Ben Finney

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


Re: Movie (MPAA) ratings and Python?

2013-12-10 Thread Mark Lawrence

On 10/12/2013 23:50, Dan Stromberg wrote:


But I believe imdbpy is 2.7 only.



I guess it wouldn't be that difficult to run it through 2to3.  Try that 
and see what happens?


--
My fellow Pythonistas, ask not what our language can do for you, ask 
what you can do for our language.


Mark Lawrence

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


Re: interactive help on the base object

2013-12-10 Thread alex23

On 10/12/2013 7:37 PM, Mark Lawrence wrote:

One of the great joys of reading this list is how wonderfully OT it can
get.  I have the right to make this statement as I started *THIS*
thread.  Now what *WERE* we talking about? :)


The God Object (or Higgs Object for the non-theists).

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


Re: Experiences/guidance on teaching Python as a first programming language

2013-12-10 Thread Denis McMahon
On Tue, 10 Dec 2013 20:35:47 -0500, Dennis Lee Bieber wrote:

> On Tue, 10 Dec 2013 18:25:48 +1300, Gregory Ewing
>  declaimed the following:

>>That's like saying that when teaching woodwork we shouldn't let people
>>use hammers, we should make them use rocks to bang nails in, because it
>>will make them better carpenters in the long run.

>   NAILS
>   Nails were verboten in my high school wood working class...
>   We used dowels and glue; chisels to carve dove-tails; etc.

We were allowed to use screws, but they had to be brass, not steel, we 
had to drill appropriate clearance and pilot holes, and countersink where 
appropriate.

And god help you if you deformed the slot in a brass screw head by over 
tightening - I think that may have been why they made us use brass ones 
only, so that such damage was easier to spot and more likely to happen.

And yes, I can dovetail, mortise and tenon, dowel etc etc etc.

-- 
Denis McMahon, [email protected]
-- 
https://mail.python.org/mailman/listinfo/python-list


Unit testing asynchronous processes

2013-12-10 Thread Tim Chase
I've got some code that kicks off a background request to a remote
server over an SSL connection using client-side certificates.  Since
the request is made from a separate thread, I'm having trouble testing
that everything is working without without spinning up an out-of-band
mock server and actually making all the request.  Are there some best
practices for testing/mocking when things are asynchronous and
involve SSL connections to servers?

I'm currently just ignoring the SSL/client-cert thing and trusting my
calls work. But I'd like to at least have some tests that cover these
aspects so that things don't fall through the cracks.

Thanks,

-tkc


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


grab dict keys/values without iterating ?!

2013-12-10 Thread Tamer Higazi

Hi people!

Is there a way to get dict by search terms without iterating the entire 
dictionary ?!


Let us assume I have:

{'Amanda':'Power','Amaly':'Higgens','Joseph':'White','Arlington','Black','Arnold','Schwarzenegger'}

I want to grab the dict's key and values started with 'Ar'...

I could make an iterator and look if it's inside.
I wasn't able to find it, but I am asking myself if dict has a builtin 
method to get me these key/values on the fly.


Why do I ask you?! I am working with the ZODB Database, where I make use 
of a PersistentDict and PersistentList, and I want



I would thank you for a short reply.



Tamer
--
https://mail.python.org/mailman/listinfo/python-list


Re: Unit testing asynchronous processes

2013-12-10 Thread Terry Reedy

On 12/10/2013 9:24 PM, Tim Chase wrote:

I've got some code that kicks off a background request to a remote
server over an SSL connection using client-side certificates.  Since
the request is made from a separate thread, I'm having trouble testing
that everything is working without without spinning up an out-of-band
mock server and actually making all the request.  Are there some best
practices for testing/mocking when things are asynchronous and
involve SSL connections to servers?

I'm currently just ignoring the SSL/client-cert thing and trusting my
calls work. But I'd like to at least have some tests that cover these
aspects so that things don't fall through the cracks.


Take a look in the Python test suite (lib/test/test_xyz)

--
Terry Jan Reedy

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


Re: grab dict keys/values without iterating ?!

2013-12-10 Thread MRAB

On 11/12/2013 00:02, Tamer Higazi wrote:

Hi people!

Is there a way to get dict by search terms without iterating the entire
dictionary ?!

Let us assume I have:

{'Amanda':'Power','Amaly':'Higgens','Joseph':'White','Arlington','Black','Arnold','Schwarzenegger'}

I want to grab the dict's key and values started with 'Ar'...

I could make an iterator and look if it's inside.
I wasn't able to find it, but I am asking myself if dict has a builtin
method to get me these key/values on the fly.

Why do I ask you?! I am working with the ZODB Database, where I make use
of a PersistentDict and PersistentList, and I want


I would thank you for a short reply.


There isn't a special shortcut because it's already a short journey. :-)

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


Re: grab dict keys/values without iterating ?!

2013-12-10 Thread Tim Chase
On 2013-12-11 02:02, Tamer Higazi wrote:
> Is there a way to get dict by search terms without iterating the
> entire dictionary ?!
> 
> Let us assume I have:
> 
> {'Amanda':'Power','Amaly':'Higgens','Joseph':'White','Arlington','Black','Arnold','Schwarzenegger'}
  ^
Assuming this is a colon...

> I want to grab the dict's key and values started with 'Ar'...
> 
> I could make an iterator and look if it's inside.
> I wasn't able to find it, but I am asking myself if dict has a
> builtin method to get me these key/values on the fly.
> 
> I would thank you for a short reply.

No.

If you want a longer reply, keep reading. :-)

There are a couple ways you could get the results you want, but it
depends on what you want to test.  If you just want to test the
presence/absence of something matching your pattern, you can bail
early with

  if any(k.startswith(s) or v.startswith(s) for k,v in d.iteritems()):
yep()
  else:
nope()

which will only pull items from the iterator until the first one is
found.

If you want to find all the results, you have to look at all the
results, either at search time, or at the time of dictionary
construction (although in this case, you'd also need to know the
search term at the time of construction).  That might look something
like

  d = {}
  interesting = []

  def is_interesting(term, *args):
return any(s.startswith(term) for s in args)

  for key, value, other in data_source:
if is_interesting(term, key, value):
  interesting.append((key, value))
d[key] = value

  for key, value in interesting:
just_iterating_over_those_not_all(key, value)


Alternatively, you could use a different data-structure, something
like (untested)

  SENTINEL = object()
 
  def build_structure(i):
# "i" is some iterable of key/value pairs
# such as from {}.iteritems()
root = {}
for key, value in i:
  loc = root
  for letter in key:
loc = loc.setdefault(letter, {})
  loc[SENTINEL] = value
return root
  
  def just_matches(root, pattern):
if pattern:
  first_letter = pattern[0]
  if first_letter in root:
for result in just_matches(root[first_letter], pattern[1:]):
  yield result
else:
  # show all sub-items
  for k,v in root.iteritems():
if k is SENTINEL:
  yield v
else:
  for result in just_matches(v, None):
yield result
  
  s = build_structure(data.iteritems())
  # print repr(s)
  for result in just_matches(s, "Ar"):
print result

I'm not sure this is a good trade-off, but it does limit your
iteration to only those that begin with your chosen search term,
rather than all items in the dictionary once the initial
data-structure is built.

(I think in the span of 20 minutes, I managed to recreate a college
homework assignment that took me nearly a week in C)

-tkc







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


Re: grab dict keys/values without iterating ?!

2013-12-10 Thread Ben Finney
Tamer Higazi  writes:

> Is there a way to get dict by search terms without iterating the
> entire dictionary ?!

(A language note: you may be unaware that “?!” does not connote a simple
question, but outrage or incredulity or some other indignant expression.
This implies not a polite query, but more a harsh demand for the other
person to explain.

I think your questions will communicate better punctuated simply with
“?”.)

> I want to grab the dict's key and values started with 'Ar'...

surnames_by_givenname = {
"Amanda": "Power",
"Amaly": "Higgens",
"Joseph": "White",
"Arlington": "Black",
"Arnold": "Schwarzenegger",
}
items_whose_keys_start_with_Ar = [
(key, value)
for (key, value) in surnames_by_givenname.items()
if key.startswith("Ar")]

> I could make an iterator and look if it's inside.
> I wasn't able to find it, but I am asking myself if dict has a builtin
> method to get me these key/values on the fly.

Not a method on the dict, but a method on the string and a list
comprehension (or, if you prefer, use a generator expression or dict
comprehension, etc.).

> Why do I ask you?! I am working with the ZODB Database, where I make
> use of a PersistentDict and PersistentList, and I want

I'll be interested to know the rest of that paragraph, to know whether
the above list comprehension meets your constraints.

-- 
 \ “I was in the first submarine. Instead of a periscope, they had |
  `\   a kaleidoscope. ‘We're surrounded.’” —Steven Wright |
_o__)  |
Ben Finney

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


Re: Movie (MPAA) ratings and Python?

2013-12-10 Thread Dan Stromberg
On Tue, Dec 10, 2013 at 4:07 PM, Mark Lawrence wrote:

> On 10/12/2013 23:50, Dan Stromberg wrote:
>
>>
>> But I believe imdbpy is 2.7 only.
>>
>
> I guess it wouldn't be that difficult to run it through 2to3.  Try that
> and see what happens?
>

2to3 doesn't necessarily produce working code.  I've had better luck
porting to 3.x (while continuing to support 2.x) using a single codebase.
http://stromberg.dnsalias.org/~dstromberg/Intro-to-Python/Python%202%20and%203.pdf

That said, porting imdbpy to 3.x is more of a time commitment than I'm
looking for.  Now that I have an encoding that works with the MPAA text
files, I'll probably use that; that should be quick and painless, assuming
that difflib or similar can do the sort of fuzzy matching I'm hoping for.

BTW, I tried using metals ("meta ls", not multiple kinds of metal) for a
while, which I believe is based on imdbpy, but it was tracebacking quite a
bit - on 2.7.  I had to make a one line change to get it to use 2.7 instead
of 2.6; this suggests to me that metals and/or imdbpy aren't being
supported very actively.

I'd prefer to use something with an active community around it, but failing
that, I'd prefer to use something _small_ I write myself.
-- 
https://mail.python.org/mailman/listinfo/python-list


python import error

2013-12-10 Thread smilesonisamal
Hi,
   I am a new bie in python I was trying to execute the python script aaa.py in 
fedora which imports different modules. Actually when I am executing the aaa.py 
I am getting the following error and PYTHON_PATH=/bin/python which has a 
symlink to python-2.7. Please help me in this regard? I am not getting any clue 
where I am wrong.


python -c "import sys; print sys.path"
['', '/usr/lib64/python27.zip', '/usr/lib64/python2.7', 
'/usr/lib64/python2.7/plat-linux2', '/usr/lib64/python2.7/lib-tk', 
'/usr/lib64/python2.7/lib-old', '/usr/lib64/python2.7/lib-dynload', 
'/usr/lib64/python2.7/site-packages', 
'/usr/lib64/python2.7/site-packages/gst-0.10', 
'/usr/lib64/python2.7/site-packages/gtk-2.0', 
'/usr/lib/python2.7/site-packages', 
'/usr/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg-info']


aaa.py
===
Traceback (most recent call last):
  File "aaa.py", line 5, in 
from ccc.ddd import sss
ImportError: No module named ccc.ddd

directory structure as follows:

ccc
|
 ddd
   |
aaa.py
sss.py


Regards
Pradeep
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: python import error

2013-12-10 Thread Michael Torrie
On 12/10/2013 08:56 PM, [email protected] wrote:
> Traceback (most recent call last):
>   File "aaa.py", line 5, in 
> from ccc.ddd import sss
> ImportError: No module named ccc.ddd
> 
> directory structure as follows:
> 
> ccc
> |
>  ddd
>|
> aaa.py
> sss.py

This is because directories have no inherent meaning to python.  A
module is normally a file.  If you want to group a bunch of files
together you have to use a package. See the docs on how to make a
package.  But the namespace structure within a package isn't based on
the directory tree either.  It's usually set up by __init__.py within
the package which imports modules defined in the package into the
namespace.

http://docs.python.org/3/tutorial/modules.html#packages

Hope this helps.

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


Re: grab dict keys/values without iterating ?!

2013-12-10 Thread Dave Angel
On Wed, 11 Dec 2013 02:02:20 +0200, Tamer Higazi 
 wrote:
Is there a way to get dict by search terms without iterating the 
entire 

dictionary ?!



I want to grab the dict's key and values started with 'Ar'...


Your wording is so ambiguous that each respondent has guessed 
differently. 

I'm guessing that you want all key/value pairs for which the key 
begins with the two letters 'Ar' I'm guessing further that your 
objection to iterating the entire dictionary is not code size but 
performance. 

If both assumptions are valid then I'll point out that a dict has no 
ordering to it. If you want an approach that doesn't iterate over the 
entire structure you'll need to store the data differently.  For 
example if you stored all the keys in a sorted list you could use 
bisect.


--
DaveA

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


Re: python import error

2013-12-10 Thread John Gordon
In <[email protected]> 
[email protected] writes:

>   File "aaa.py", line 5, in 
> from ccc.ddd import sss
> ImportError: No module named ccc.ddd

> directory structure as follows:

> ccc
> |
>  ddd
>|
> aaa.py
> sss.py

A python file isn't importable unless the directory also contains a file
named __init__.py .

Try making __init__.py files in the ccc and ddd directories.  If you
don't know what to put in them, just leave them blank.

-- 
John Gordon Imagine what it must be like for a real medical doctor to
[email protected] 'House', or a real serial killer to watch 'Dexter'.

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


Re: python import error

2013-12-10 Thread Michael Torrie
On 12/10/2013 09:25 PM, Michael Torrie wrote:
> On 12/10/2013 08:56 PM, [email protected] wrote:
>> Traceback (most recent call last):
>>   File "aaa.py", line 5, in 
>> from ccc.ddd import sss
>> ImportError: No module named ccc.ddd
>>
>> directory structure as follows:
>>
>> ccc
>> |
>>  ddd
>>|
>> aaa.py
>> sss.py
> 
> This is because directories have no inherent meaning to python.  A
> module is normally a file.  If you want to group a bunch of files
> together you have to use a package. See the docs on how to make a
> package.  But the namespace structure within a package isn't based on
> the directory tree either.  It's usually set up by __init__.py within
> the package which imports modules defined in the package into the
> namespace.
> 
> http://docs.python.org/3/tutorial/modules.html#packages
> 
> Hope this helps.
> 

I didn't quite get that right.  Follow John's advice on __init.py__ and
you'll have what you want I think.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: python import error

2013-12-10 Thread smilesonisamal
On Wednesday, December 11, 2013 10:23:34 AM UTC+5:30, John Gordon wrote:
> In <[email protected]> 
> [email protected] writes:
> 
> 
> 
> >   File "aaa.py", line 5, in 
> 
> > from ccc.ddd import sss
> 
> > ImportError: No module named ccc.ddd
> 
> 
> 
> > directory structure as follows:
> 
> 
> 
> > ccc
> 
> > |
> 
> >  ddd
> 
> >|
> 
> > aaa.py
> 
> > sss.py
> 
> 
> 
> A python file isn't importable unless the directory also contains a file
> 
> named __init__.py .
> 
> 
> 
> Try making __init__.py files in the ccc and ddd directories.  If you
> 
> don't know what to put in them, just leave them blank.
> 
> 
> It is having __init__.py as blank in ccc and ddd directories. But it still 
> doesnot work.
> -- 
> 
> John Gordon Imagine what it must be like for a real medical doctor to
> 
> [email protected] 'House', or a real serial killer to watch 'Dexter'.

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


Re: python import error

2013-12-10 Thread Benjamin Kaplan
On Tue, Dec 10, 2013 at 9:45 PM,   wrote:
> On Wednesday, December 11, 2013 10:23:34 AM UTC+5:30, John Gordon wrote:
>> In <[email protected]> 
>> [email protected] writes:
>>
>>
>>
>> >   File "aaa.py", line 5, in 
>>
>> > from ccc.ddd import sss
>>
>> > ImportError: No module named ccc.ddd
>>
>>
>>
>> > directory structure as follows:
>>
>>
>>
>> > ccc
>>
>> > |
>>
>> >  ddd
>>
>> >|
>>
>> > aaa.py
>>
>> > sss.py
>>
>>
>>
>> A python file isn't importable unless the directory also contains a file
>>
>> named __init__.py .
>>
>>
>>
>> Try making __init__.py files in the ccc and ddd directories.  If you
>>
>> don't know what to put in them, just leave them blank.
>>
>>
>> It is having __init__.py as blank in ccc and ddd directories. But it still 
>> doesnot work.
>> --


What directory are you in when you execute the script? Python doesn't
look up for packages so if you're in ddd and calling "python aaa.py",
Python doesn't know about the ccc package. You'd just import sss, or
add the parent directory of ccc to sys.path.
-- 
https://mail.python.org/mailman/listinfo/python-list


load_module for import entire package

2013-12-10 Thread Sergey
Hi,
I need to import package and instantiate a class, defined in one of modules, 
located in package.

Package is located in folder "tmp". basedir - path to running python script.

I'm doing it so:

import imp

def load_package_strict(p_package_name, p_package_path):
f, filename, description = imp.find_module(p_package_name, [p_package_path])
try:
result = imp.load_module(p_package_name, f, filename, description)
finally:
if f: f.close
return result

def get_obj():
  pkg = load_package_strict("tmp", basedir)
  from tmp import main
  return main.TTT()

It is working, but if package code changes on disc at runtime and I call 
get_obj again, it returns instance of class, loaded for the first time 
previously. 

How to replace line "from tmp import main" by getting properties of pkg?

Regards,
Sergey
-- 
https://mail.python.org/mailman/listinfo/python-list