cannot open shared object file

2012-03-16 Thread Steven Lo


Hi,

We are getting the following error during a 'make' process on a CentOS 
release 5.4 system:


Running mkfontdir...
Creating SELinux policy...
/usr/bin/python: error while loading shared libraries: 
libpython2.4.so.1.0: cannot open shared object file: No such file or 
directory



However, we are able to execute 'python' without any problem

# which python
/usr/bin/python

# python
Python 2.4.3 (#1, Sep  3 2009, 15:37:37)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-46)] on linux2
Type help, copyright, credits or license for more information.



# ldd /usr/bin/python
libpython2.4.so.1.0 = /usr/lib64/libpython2.4.so.1.0 
(0x003fb760)

libpthread.so.0 = /lib64/libpthread.so.0 (0x003b5960)
libdl.so.2 = /lib64/libdl.so.2 (0x003b5920)
libutil.so.1 = /lib64/libutil.so.1 (0x003b6400)
libm.so.6 = /lib64/libm.so.6 (0x003b58e0)
libc.so.6 = /lib64/libc.so.6 (0x003b58a0)
/lib64/ld-linux-x86-64.so.2 (0x003b5860)


# ls -lad /usr/lib64/*python*
lrwxrwxrwx  1 root root  19 Feb 27 21:15 /usr/lib64/libpython2.4.so 
- libpython2.4.so.1.0

-r-xr-xr-x  1 root root 1236344 Sep  3  2009 /usr/lib64/libpython2.4.so.1.0
drwxr-xr-x 18 root root   20480 Feb 27 21:15 /usr/lib64/python2.4



In this 'make' process, we are suppose to execute the applicate-specific 
python

(/opt/rocks/bin/python) which has static link (not dynamic link)

# ldd /opt/rocks/bin/python
libpthread.so.0 = /lib64/libpthread.so.0 (0x003b5960)
libdl.so.2 = /lib64/libdl.so.2 (0x003b5920)
libutil.so.1 = /lib64/libutil.so.1 (0x003b6400)
libstdc++.so.6 = /usr/lib64/libstdc++.so.6 (0x003b6b40)
libm.so.6 = /lib64/libm.so.6 (0x003b58e0)
libgcc_s.so.1 = /lib64/libgcc_s.so.1 (0x003b67c0)
libc.so.6 = /lib64/libc.so.6 (0x003b58a0)
/lib64/ld-linux-x86-64.so.2 (0x003b5860)



Basically, we try to understand:
  * why /opt/rocks/bin/python not being used ?
  * why /usr/bin/python can not find the dynamic library


Please let us know if you have any suggestion on how to troubleshoot 
this problem.


If this is not the list to ask this type of question, please point us to 
the appropriate

list.


Thanks.

S.

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


Re: Is it technically possible to give Python option of naming process of running script?

2012-03-16 Thread xliiv

  Seems like an awfully obtuse way of doing things -- I don't really
  want to have 15 different copies of Python (or even links), and it
  requires root privleges every time you want to run a Python program
  with the correct name.
 
 Why do you need root? Can't you copy / link into your own home directory?
 
 I may have misunderstood something here.
 
 ChrisA

It's nice walkaround for now and for linux. But how about my question and 
future? :)


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


new release 0.38 of OpenOpt, FuncDesigner, SpaceFuncs, DerApproximator

2012-03-16 Thread dmitrey
Hi all,
I'm glad to inform you about new release 0.38 (2012-March-15):

OpenOpt:

interalg can handle discrete variables
interalg can handle multiobjective problems (MOP)
interalg can handle problems with parameters fixedVars/freeVars
Many interalg improvements and some bugfixes
Add another EIG solver: numpy.linalg.eig
New LLSP solver pymls with box bounds handling

FuncDesigner:

Some improvements for sum()
Add funcs tanh, arctanh, arcsinh, arccosh
Can solve EIG built from derivatives of several functions,
obtained by automatic differentiation by FuncDesigner

SpaceFuncs:

Add method point.symmetry(Point|Line|Plane)
Add method LineSegment.middle
Add method Point.rotate(Center, angle)

DerApproximator:

Minor changes

See http://openopt.org for more details

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


Re: Python is readable

2012-03-16 Thread Duncan Booth
Thomas Rachel nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915
@spamschutz.glglgl.de wrote:

 Or, more likely, lock creates an object which keeps the lock acquired.
 The lock is released when we leave the block.
 So we could inspect the lock with
 with lock as l:
 inspect l...
 do_some.
 
 Or just inspect l - I don't know if a lock's __enter__ methos returns it 
 again for assignment with as...
 

No, if you do `with lock as l:` then l will get the boolean True.

The lock's __enter__ method is the same as lock.acquire(). That method 
takes an optional argument which can be used to conditionally acquire the 
lock and return a boolean indicating success or failure. When used inside a 
`with` statement you can't pass in the optional argument so it acquires it 
unconditionally but still returns the success status which is either True 
or it never returns.

-- 
Duncan Booth http://kupuguy.blogspot.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Android

2012-03-16 Thread Peter Condon
Dear Sirs,

 

I am a new student learning this and am getting an Android tablet for my
birthday will python be able to run on android?

 

Kindest regards

 

Peter



This email and any attachments to it may contain information which is 
confidential, legally privileged, subject to the Official Secrets Act, or 
otherwise not disclosable by law, and is protected by copyright. It is intended 
only for the addressee named above. If you are not the intended recipient you 
must delete this email immediately and not use, distribute, copy, disclose or 
take any action in reliance on this email or its contents. If you have received 
this email in error please notify us by return email immediately. 
Airwave Solutions Limited is a company registered in England and Wales having 
company number 03985643. 
Registered Office: Airwave Solutions Ltd, Charter Court, 50 Windsor Road, 
Slough, Berkshire, SL1 2EJ.
-- 
http://mail.python.org/mailman/listinfo/python-list


AW: Android

2012-03-16 Thread Szabo, Patrick (LNG-VIE)
You might be interested in this:

 

http://www.linuxjournal.com/article/10940 
http://www.linuxjournal.com/article/10940  

 

I had this installed on my Desire and it ran pretty nicely. 

 

regards

 

Von: python-list-bounces+patrick.szabo=lexisnexis...@python.org 
[mailto:python-list-bounces+patrick.szabo=lexisnexis...@python.org] Im Auftrag 
von Peter Condon
Gesendet: Freitag, 16. März 2012 10:21
An: python-list@python.org
Betreff: Android

 

Dear Sirs,

 

I am a new student learning this and am getting an Android tablet for my 
birthday will python be able to run on android?

 

Kindest regards

 

Peter

 

This email and any attachments to it may contain information which is 
confidential, legally privileged, subject to the Official Secrets Act, or 
otherwise not disclosable by law, and is protected by copyright. It is intended 
only for the addressee named above. If you are not the intended recipient you 
must delete this email immediately and not use, distribute, copy, disclose or 
take any action in reliance on this email or its contents. If you have received 
this email in error please notify us by return email immediately. 

Airwave Solutions Limited a company registered in England and Wales having 
company number 03985643. 

Registered Office: Airwave Solutions Ltd, Charter Court, 50 Windsor Road, 
Slough, Berkshire, SL1 2EJ.

 


. . . . . . . . . . . . . . . . . . . . . . . . . .
Ing. Patrick Szabo
 XSLT Developer 
LexisNexis
A-1030 Wien, Marxergasse 25

mailto:patrick.sz...@lexisnexis.at
Tel.: +43 1 53452 1573 
Fax: +43 1 534 52 146 





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


Re: Python is readable

2012-03-16 Thread Kiuhnm

On 3/16/2012 0:58, Mark Lawrence wrote:

On 15/03/2012 23:46, Kiuhnm wrote:

On 3/16/2012 0:00, Arnaud Delobelle wrote:

On 15 March 2012 22:35, Ben Finneyben+pyt...@benfinney.id.au wrote:

Kiuhnmkiuhnm03.4t.yahoo.it writes:


Moreover, I think that
if (

):



is not very readable anyway.


I agree, and am glad PEP 8 has been updated to recommend an extra level
of indentation for continuation, to distinguish from the new block that
followsURL:http://www.python.org/dev/peps/pep-0008/#indentation.


Personally I solve this by never writing if conditions that span more
than one line. If the worst comes to the worst, I would write:

aptly_named_condition = (
very long condition
that goes over
plenty of lines
)
if aptly_named_condition:
do stuff


Will I be able to use extra indentation in Python code?
For instance,

res = and(or(cond1,
cond2),
cond3,
or(and(cond4,
cond5,
cond6),
and(cond7,
cond8)))

I like it because it reads like a tree.

Kiuhnm


Why not find out for yourself by slapping the code into an interactive
Python interpreter and seeing what the result is?


Ok, it works. I had to use different names though.

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


Re: Python is readable

2012-03-16 Thread Kiuhnm

On 3/16/2012 4:55, Steven D'Aprano wrote:

On Fri, 16 Mar 2012 00:32:52 +0100, Kiuhnm wrote:


Pick up two math books about the same topic but on two different levels
(e.g. under-graduated and graduated). If you compare the proofs you'll
see that those in the higher-level book are almost always sketched. Why
is that? Because they're more readable for a mature reader.


No. They're not more readable. They simply have less to read (per proof),
or another way of putting it, you can fit more of the good stuff that the
experienced reader wants (yes yes, I know about the associative law, get
to the part where you prove the Goldbach conjecture...) in the same
amount of space. The text is compressed by leaving out the parts that an
experienced reader can infer from her knowledge of the domain.

Since an expert can infer meaning more quickly than they can read the
actual words, this is a big win for efficiency. But the text is not more
readable, there's just less to read for a given result. The same amount,
or even more, brain processing occurs. It just happens in a different
part of the brain.


Maybe we should define *exactly* what readability is (in less then 500 
lines, if possible).
According to your view, ASM code is more readable than Python code. It's 
just that there's more to read in ASM.


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


Re: Python is readable

2012-03-16 Thread Kiuhnm

On 3/16/2012 0:52, Steven D'Aprano wrote:

On Fri, Mar 16, 2012 at 1:30 AM, Kiuhnm
kiuhnm03.4t.yahoo...@mail.python.org  wrote:

Sorry, but I can't see how it would make it harder for humans to
understand. Are there particular situations you're referring to?


In a trivial example, it's mostly just noise:

if a == b# who needs the colon?
 print(c)


The reader, for the same reason that above you wrote:

In a trivial example, it's mostly just noise COLON

and indeed I too used a colon for the same reason. It ties the lead
sentence to the following block without ending the sentence, but still
introducing a new grouping or clause.

It is *remarkable* how people take the colon for granted. It is so simple
and so obvious that they use it in their own writing often without
thinking about it, but because it is not strictly necessary to avoid
ambiguity in the grammar, they fool themselves into thinking that it is
just noise or pointless. It is not noise, it is a hint to the reader.


IMHO, Python misuses colons.
No grammarian would ever write
  If you can: take the bus.
Natural languages are irregular while Python strives to be as regular as 
possible.

BTW, I prefer
The matrix
   []
can be . and it gives
   []
which .
to
The matrix:
   []
can be . and it gives:
   []
which 
Colons should introduce more specific information, not all the 
information. For instance, I like many things in life: list is way 
better than I like: list.
As you can see, I'm not an English native speaker, but I think I know a 
few things about punctuation. We second language learners remember all 
the wrong things :(


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


Why not use juxtaposition to indicate function application

2012-03-16 Thread Ray Song
I confess i've indulged in Haskell and found
f a
more readable than
f(a)

And why aren't functions curried (partially applied function is another 
function which takes the rest arguments) by default?


Thanks in advance for any suggestions.

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


Re: Python is readable

2012-03-16 Thread Neil Cerutti
On 2012-03-16, Kiuhnm kiuhnm03.4t.yahoo.it wrote:
 As you can see, I'm not an English native speaker, but I think
 I know a few things about punctuation. We second language
 learners remember all the wrong things :(

English's punctuation rules have to be a lot easier to remember
than the seemingly random way in which we apply articles to our
nouns.

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


Re: Python simulate browser activity

2012-03-16 Thread Roy Smith
In article 
214c4c0c-f8ec-4030-946b-8becc8e1a...@ur9g2000pbc.googlegroups.com,
 choi2k rex.0...@gmail.com wrote:

 Hi, everyone
 
 I am trying to write a small application using python but I am not
 sure whether it is possible to do so..
 The application aims to simulate user activity including visit a
 website and perform some interactive actions (click on the menu,
 submit a form, redirect to another pages...etc)
 I have found some libraries / plugins which aims to simulate browser
 activity but ... none of them support AJAX request and/or running
 javascript.
 
 Here is one of the simple tasks which I would like to do using the
 application:
 1. simulate the user activity, visit the website (https://
 www.abc.com)
 2. find out the target element by id (submitBtn) and simulate mouse
 click on the item.
 3. perform some javascript functions which invoked by click event from
 step 2. ( the function is bind to the item by jquery)
 4. post ajax request using javascript and if the page has been
 redirected, load the new page content
 
 Is it possible to do so?
 
 Thank you in advance.

Depending on exactly what you're trying to test, this may or may not be 
possible.

#1 is easy.  Just get the URL with urllib (or, even better, Kenneth 
Reitz's  very cool requests library (http://docs.python-requests.org/).

#2 gets a little more interesting, but still not that big a deal.  Parse 
the HTML you get back with something like lxml (http://lxml.de/).  
Navigate the DOM with a CSSSelector to find the element you're looking 
for.  Use urllib/requests again to get the href.

#3 is where things get fun.  What, exactly, are you trying to test?  Are 
you trying to test that the js works, or are you really trying to test 
your server and you're just using the embedded js as a means to generate 
the next HTTP request?

If the former, then you really want to be exploring something like 
selenium (http://seleniumhq.org/).  If the latter, then skip all the js 
crap and just go a GET or POST (back to urllib/requests) on the 
appropriate url.

#4 falls into the same bucket as #3.

Once you have figured all this out, you will get a greater appreciation 
for the need to cleanly separate your presentation (HTML, CSS, 
Javascript) from your business logic and data layers.  If there is a 
clean interface between them, it becomes easy to test one in isolation 
from the other.  If not, then you end up playing games with screen 
scraping via lxml and selenium just to test your database queries.  
Which will quickly lead to you running screaming into the night.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python is readable

2012-03-16 Thread Kiuhnm

On 3/16/2012 2:53, Steven D'Aprano wrote:

On Thu, 15 Mar 2012 00:34:47 +0100, Kiuhnm wrote:


I've just started to read
The Quick Python Book (2nd ed.)


Is this the one?

http://manning.com/ceder/



The author claims that Python code is more readable than Perl code and
provides this example:

--- Perl ---
sub pairwise_sum {
  my($arg1, $arg2) = @_;
  my(@result) = ();
  @list1 = @$arg1;
  @list2 = @$arg2;


I don't understand the reason for $arg1 and $arg2. Is there some reason
why the code couldn't do this instead?

my(@list1, @list2) = @_;


@_ contains references to arrays. You can't pass two arrays to a function.

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


Re: Python is readable

2012-03-16 Thread Steven D'Aprano
On Fri, 16 Mar 2012 13:36:25 +0100, Kiuhnm wrote:

 On 3/16/2012 0:52, Steven D'Aprano wrote:

 It is *remarkable* how people take the colon for granted. It is so
 simple and so obvious that they use it in their own writing often
 without thinking about it, but because it is not strictly necessary to
 avoid ambiguity in the grammar, they fool themselves into thinking that
 it is just noise or pointless. It is not noise, it is a hint to the
 reader.
 
 IMHO, Python misuses colons.

According to the rules of which language?

Latin? Cantonese? Russian? Or perhaps Perl? Javascript? Forth?


 No grammarian would ever write
If you can: take the bus.

A grammarian might very well write:

Your assignment, if you choose to accept it, is to:

1. Take the bus to Swansea.
2. Go across the road to the little shop on the corner.
3. Ask for Dave.
4. Tell him George sent you.
5. He will give you a package. Take it to the park down the street.
6. You will see a man making balloon animals. Give him the package.
7. He will give you a balloon giraffe. Take it to the pub.
8. Put the giraffe on the piano in the public bar, and leave.


In English, one typical use for colons is to introduce a list or sequence 
of items, including instructions. A sequence of instructions is an 
algorithm, program or routine. You may have heard of them :)

A one line routine is still a routine. There is nothing ungrammatical 
about If you can: take the bus., although it is non-idiomatic English.


 Natural languages are irregular while Python strives to be as regular as
 possible.

So what?



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


Re: Python is readable

2012-03-16 Thread Neil Cerutti
On 2012-03-16, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote:
 A grammarian might very well write:

 Your assignment, if you choose to accept it, is to:

 1. Take the bus to Swansea.
 ...

 In English, one typical use for colons is to introduce a list
 or sequence of items, including instructions. A sequence of
 instructions is an algorithm, program or routine. You may have
 heard of them :)

A grammarian always uses complete sentence before a colon, even
when introducing a list.

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


Re: Why not use juxtaposition to indicate function application

2012-03-16 Thread bruno.desthuilli...@gmail.com
On Mar 16, 1:45 pm, Ray Song emacs...@gmail.com wrote:
 I confess i've indulged in Haskell and found
     f a
 more readable than
     f(a)

Hmmm... What about:

f a b

versus

f(a(b))

or was it supposed to be read as

f(a)(b)


or as

   f(a, b)

?-)



 And why aren't functions curried (partially applied function is another 
 function which takes the rest arguments) by default?


If you're asking why isn't Python like Haskell, the obvious answer
is, well, because Python is not Haskell ;)

Remember that Pythons is first and foremost an object-oriented
language, where most of the support for functional idioms comes from
the underlying object model. functions are central to fp, objects are
central to OOP, so better to use objects than functions (hint: there's
a builtin partial type).

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


Re: Is it technically possible to give Python option of naming process of running script?

2012-03-16 Thread Grant Edwards
On 2012-03-16, Chris Angelico ros...@gmail.com wrote:
 On Fri, Mar 16, 2012 at 5:39 AM, Grant Edwards invalid@invalid.invalid 
 wrote:
 Seems like an awfully obtuse way of doing things -- I don't really
 want to have 15 different copies of Python (or even links), and it
 requires root privleges every time you want to run a Python program
 with the correct name.

 Why do you need root? Can't you copy / link into your own home directory?

I was thinging about daemons and system-type stuff.

One possible problem with linking from one's home directory is that
home directories are often on different filesystems than /usr/bin (or
wherever python is).   Using a symlink doesn't work, the process name
still ends up as python2.6 (or whatever the real binary is called).

-- 
Grant Edwards   grant.b.edwardsYow! Where do your SOCKS
  at   go when you lose them in
  gmail.comth' WASHER?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why not use juxtaposition to indicate function application

2012-03-16 Thread Colin J. Williams

On 16/03/2012 8:45 AM, Ray Song wrote:

I confess i've indulged in Haskell and found
 f a
more readable than
 f(a)

And why aren't functions curried (partially applied function is another 
function which takes the rest arguments) by default?


Thanks in advance for any suggestions.

--
Ray

+1

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


Re: Why not use juxtaposition to indicate function application

2012-03-16 Thread Kiuhnm

On 3/16/2012 14:14, bruno.desthuilli...@gmail.com wrote:

On Mar 16, 1:45 pm, Ray Songemacs...@gmail.com  wrote:

I confess i've indulged in Haskell and found
 f a
more readable than
 f(a)


Hmmm... What about:

 f a b

versus

 f(a(b))

or was it supposed to be read as

 f(a)(b)


or as

f(a, b)

?-)


That would be
  f (a b)  # Haskell
  f(a(b))  # Python

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


RE: Why not use juxtaposition to indicate function application

2012-03-16 Thread Prasad, Ramit
  I confess i've indulged in Haskell and found
   f a
  more readable than
   f(a)
 
  Hmmm... What about:
 
   f a b
 
  versus
 
   f(a(b))
 
  or was it supposed to be read as
 
   f(a)(b)
 
 
  or as
 
  f(a, b)
 
  ?-)
 
 That would be
f (a b)  # Haskell
f(a(b))  # Python

I have not used Haskell so far, but in this case I think I prefer the
'Explicit is better than implicit.'

I would probably always forget if it should be 

f a b 

or

f ( a b )

Not to mention the first line look like text rather than a function call
because my mind tends to filter out whitespaces like that when reading.
I blame variable width fonts (and the mind being a strange thing).


Ramit


Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology
712 Main Street | Houston, TX 77002
work phone: 713 - 216 - 5423

--
This email is confidential and subject to important disclaimers and
conditions including on offers for the purchase or sale of
securities, accuracy and completeness of information, viruses,
confidentiality, legal privilege, and legal entity disclaimers,
available at http://www.jpmorgan.com/pages/disclosures/email.  
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why not use juxtaposition to indicate function application

2012-03-16 Thread Robert Kern

On 3/16/12 12:45 PM, Ray Song wrote:

I confess i've indulged in Haskell and found
 f a
more readable than
 f(a)

And why aren't functions curried (partially applied function is another 
function which takes the rest arguments) by default?


Python isn't a strongly functional language. We just don't do partial function 
application all that frequently to make it a language feature. Leaving out an 
argument is a common enough mistake, though, and using curry-by-default would 
postpone the error and make for even more inscrutable error messages.


--
Robert Kern

I have come to believe that the whole world is an enigma, a harmless enigma
 that is made terrible by our own mad attempt to interpret it as though it had
 an underlying truth.
  -- Umberto Eco

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


Re: Python is readable

2012-03-16 Thread Steven D'Aprano
On Fri, 16 Mar 2012 13:55:06 +0100, Kiuhnm wrote:


 I don't understand the reason for $arg1 and $arg2. Is there some reason
 why the code couldn't do this instead?

 my(@list1, @list2) = @_;
 
 @_ contains references to arrays. You can't pass two arrays to a
 function.


Why ever not? That seems like basic functionality to me. I can't imagine 
any modern language that lacks such a simple feature. Even Pascal allows 
you to pass arrays as arguments to functions.

Is there some design principle that I'm missing that explains why Perl 
lacks this feature?


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


Re: Python is readable

2012-03-16 Thread Steven D'Aprano
On Fri, 16 Mar 2012 13:08:49 +, Neil Cerutti wrote:

 On 2012-03-16, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info
 wrote:
 A grammarian might very well write:

 Your assignment, if you choose to accept it, is to:

 1. Take the bus to Swansea.
 ...

 In English, one typical use for colons is to introduce a list or
 sequence of items, including instructions. A sequence of instructions
 is an algorithm, program or routine. You may have heard of them :)
 
 A grammarian always uses complete sentence before a colon, even when
 introducing a list.

Ah, perhaps you're talking about *prescriptivist* grammarians, who insist 
on applying grammatical rules that exist only in their own fevered 
imagination. Sorry, I was talking about the other sort, the ones who 
apply the grammatical rules used by people in real life. You know the 
ones: linguists. My mistake.

Colons don't end sentences, therefore there is no need to use a complete 
sentence before a colon.


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


Re: Why not use juxtaposition to indicate function application

2012-03-16 Thread Kiuhnm

On 3/16/2012 17:13, Prasad, Ramit wrote:

I confess i've indulged in Haskell and found
  f a
more readable than
  f(a)


Hmmm... What about:

  f a b

versus

  f(a(b))

or was it supposed to be read as

  f(a)(b)


or as

 f(a, b)

?-)


That would be
f (a b)  # Haskell
f(a(b))  # Python


I have not used Haskell so far, but in this case I think I prefer the
'Explicit is better than implicit.'


Are you sure that
  call the function f with the params a and b
is better than
  f a b
or
  f(a,b)
?


I would probably always forget if it should be

f a b

or

f ( a b )


You wouldn't, because Haskel's way is more regular and makes a lot of 
sense: parentheses are for grouping and that's it.


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


avoid import short-circuiting

2012-03-16 Thread Andrea Crotti

I started the following small project:

https://github.com/AndreaCrotti/import-tree

because I would like to find out what exactly depends on what at 
run-time, using an import hook.


It works quite well for small examples but the main problem is that once 
a module is imported
it's added to sys.modules and then it doesn't go through the import hook 
anymore.


I tried to mess around with sys.modules but it might not be a good idea, 
and it leads to easy

infinite loops.
Is there a good way to achieve this?
I guess I could do the loop detection myself, but that should not be too 
hard..


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


Re: Why not use juxtaposition to indicate function application

2012-03-16 Thread Steven D'Aprano
On Fri, 16 Mar 2012 17:31:06 +0100, Kiuhnm wrote:

 You wouldn't, because Haskel's way is more regular and makes a lot of
 sense: parentheses are for grouping and that's it.

If f is a function which normally takes (for the sake of the argument) 
one argument, then f would call the function with no arguments (which may 
return a curried function, or may apply default arguments, or perhaps 
raise an exception). So how would you refer to the function itself 
without calling it?



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


Re: Python is readable

2012-03-16 Thread Steven D'Aprano
On Fri, 16 Mar 2012 13:10:12 +0100, Kiuhnm wrote:

 Maybe we should define *exactly* what readability is (in less then 500
 lines, if possible).

If you can't be bothered to read my post before replying, save yourself 
some more time and don't bother to reply at all.

I quote from the part of the my post you deleted:

When people talk about readability, they normally mean to 
ask how much mental effort is needed to interpret the 
meaning of the text, not how much time does it take to 
pass your eyes over the characters. In other words they 
are actually talking about comprehensibility.


Unless I've made a mistake counting, that's less than 500 lines.


 According to your view, ASM code is more readable than Python code. It's
 just that there's more to read in ASM.

What a ridiculous misrepresentation of my position. Readability is not 
proportional to length.




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


Re: avoid import short-circuiting

2012-03-16 Thread Ethan Furman

Andrea Crotti wrote:

I started the following small project:

https://github.com/AndreaCrotti/import-tree

because I would like to find out what exactly depends on what at 
run-time, using an import hook.


It works quite well for small examples but the main problem is that once 
a module is imported
it's added to sys.modules and then it doesn't go through the import hook 
anymore.


I tried to mess around with sys.modules but it might not be a good idea, 
and it leads to easy

infinite loops.
Is there a good way to achieve this?
I guess I could do the loop detection myself, but that should not be too 
hard..


I believe sys.modules is a dictionary; you might try replacing it with 
your own custom dictionary that does whatever when the keys are accessed.


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


Re: Python is readable

2012-03-16 Thread Kiuhnm

On 3/16/2012 17:25, Steven D'Aprano wrote:

On Fri, 16 Mar 2012 13:55:06 +0100, Kiuhnm wrote:



I don't understand the reason for $arg1 and $arg2. Is there some reason
why the code couldn't do this instead?

 my(@list1, @list2) = @_;


@_ contains references to arrays. You can't pass two arrays to a
function.



Why ever not? That seems like basic functionality to me. I can't imagine
any modern language that lacks such a simple feature. Even Pascal allows
you to pass arrays as arguments to functions.

Is there some design principle that I'm missing that explains why Perl
lacks this feature?


Perl uses references only when explicitly told so.
For instance,
  my @a = (1,2,3);
  my @b = @a;
creates two distinct arrays and you can modify @b without touching @a at 
all.

Another odd thing is that Perl flattens lists or arrays. If you write
  my @a = (1,2,3);
  my @b = (0,@a,4);
you'll end up with @b = (0,1,2,3,4).
If you want nested data structures, you'll need to use explicit references:
  my @b = (0,\@a,4);   # '\' = take the ref of
Now you can write
  $b[1][0]
but that's short-hand for
  $b[1]-[0]  # deref. $b[1] and get the first elem
which is short-hand for
  ${$b[1]}[0]
Square brackets build an array and return a reference to it:
  my $ref = [0,1,2];
(Notice that, in Perl, '$' means one ($ref is one reference), while '@' 
means many.)

Now you can write
  my @a = (1,[2,3,4],5)
because you're putting a reference into $a[1]!

So, let's go back to this code:
  sub pairwise_sum {
  my($arg1, $arg2) = @_;
  my(@result) = ();
  @list1 = @$arg1;
  @list2 = @$arg2;
  for($i=0; $i  length(@list1); $i++) {
  push(@result, $list1[$i] + $list2[$i]);
  }
  return(\@result);
  }

Here @list1 and @list2 are copies. No careful Perl programmer would do 
such extra copies. And no Perl programmer would use a C-style for loop.


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


RE: Python is readable

2012-03-16 Thread Prasad, Ramit
  I don't understand the reason for $arg1 and $arg2. Is there some reason
  why the code couldn't do this instead?
 
  my(@list1, @list2) = @_;
 
  @_ contains references to arrays. You can't pass two arrays to a
  function.
 
 
 Why ever not? That seems like basic functionality to me. I can't imagine
 any modern language that lacks such a simple feature. Even Pascal allows
 you to pass arrays as arguments to functions.
 
 Is there some design principle that I'm missing that explains why Perl
 lacks this feature?


My understanding is that it assigns each scalar argument until it finds a list
to assign and then it assigns everything remaining to the list.

my @arr = ( 'test', 'blah', '1234', 'boop', 'foo', 'bar' );
my @arr2 = ( 'adsf', 'qwerty' );
print @arr\n;
my @arr3 = (@arr, @arr2);
print arr3:@arr3\n;
my ($arg1, $arg2, @arg3) = @arr3;
print arg3:@arg3\n;

bash-3.2$ perl temp.pl
testblah1234boopfoobar
arr3:test blah 1234 boop foo bar adsf qwerty
arg3:1234 boop foo bar adsf qwerty


I assume this is because it combines both elements of the list into one 
giant list and then if you try and assign two lists it does not know
where to split it. Now if you pass a reference to the two arrays instead 
of the values it should work as expected, but now you are dealing with pointers 
/ 
references.


bash-3.2$ cat temp.pl
my @arr = ( 'test', 'blah', '1234', 'boop', 'foo', 'bar' );
my @arr2 = ( 'adsf', 'qwerty' );
print @arr\n;
my @arr3 = (\@arr, \@arr2);
print arr3:@arr3\n;
my ($arg1, $arg2, @arg3) = @arr3;
print arg1:@$arg1\narg2:@$arg2\narg3:@arg3\n;

bash-3.2$ perl temp.pl
test blah 1234 boop foo bar
arr3:ARRAY(0xb2f0f90) ARRAY(0xb2f1020)
arg1:test blah 1234 boop foo bar
arg2:adsf qwerty
arg3:





Ramit


Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology
712 Main Street | Houston, TX 77002
work phone: 713 - 216 - 5423

--
This email is confidential and subject to important disclaimers and
conditions including on offers for the purchase or sale of
securities, accuracy and completeness of information, viruses,
confidentiality, legal privilege, and legal entity disclaimers,
available at http://www.jpmorgan.com/pages/disclosures/email.  
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why not use juxtaposition to indicate function application

2012-03-16 Thread Kiuhnm

On 3/16/2012 17:45, Steven D'Aprano wrote:

On Fri, 16 Mar 2012 17:31:06 +0100, Kiuhnm wrote:


You wouldn't, because Haskel's way is more regular and makes a lot of
sense: parentheses are for grouping and that's it.


If f is a function which normally takes (for the sake of the argument)
one argument, then f would call the function with no arguments (which may
return a curried function, or may apply default arguments, or perhaps
raise an exception). So how would you refer to the function itself
without calling it?


Thanks to Referential Transparency, a function with no params is a constant.
But that's a good observation. It would cause some problems in Python. 
ML languages use the empty tuple: f().


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


Re: avoid import short-circuiting

2012-03-16 Thread Robert Kern

On 3/16/12 4:49 PM, Andrea Crotti wrote:

I started the following small project:

https://github.com/AndreaCrotti/import-tree

because I would like to find out what exactly depends on what at run-time, using
an import hook.

It works quite well for small examples but the main problem is that once a
module is imported
it's added to sys.modules and then it doesn't go through the import hook 
anymore.

I tried to mess around with sys.modules but it might not be a good idea, and it
leads to easy
infinite loops.
Is there a good way to achieve this?
I guess I could do the loop detection myself, but that should not be too hard..


You want to monkeypatch __builtin__.__import__() instead. It always gets called.

--
Robert Kern

I have come to believe that the whole world is an enigma, a harmless enigma
 that is made terrible by our own mad attempt to interpret it as though it had
 an underlying truth.
  -- Umberto Eco

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


Re: Python is readable

2012-03-16 Thread Neil Cerutti
On 2012-03-16, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote:
 Ah, perhaps you're talking about *prescriptivist* grammarians,
 who insist on applying grammatical rules that exist only in
 their own fevered imagination. Sorry, I was talking about the
 other sort, the ones who apply the grammatical rules used by
 people in real life. You know the ones: linguists. My mistake.

I am not pedantic. You are wrong.

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


Re: Why not use juxtaposition to indicate function application

2012-03-16 Thread Ian Kelly
On Fri, Mar 16, 2012 at 10:45 AM, Steven D'Aprano
steve+comp.lang.pyt...@pearwood.info wrote:
 On Fri, 16 Mar 2012 17:31:06 +0100, Kiuhnm wrote:

 You wouldn't, because Haskel's way is more regular and makes a lot of
 sense: parentheses are for grouping and that's it.

 If f is a function which normally takes (for the sake of the argument)
 one argument, then f would call the function with no arguments (which may
 return a curried function, or may apply default arguments, or perhaps
 raise an exception). So how would you refer to the function itself
 without calling it?

A partial application of f with no arguments is still just f.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python is readable

2012-03-16 Thread Steven D'Aprano
On Fri, 16 Mar 2012 17:53:24 +, Neil Cerutti wrote:

 On 2012-03-16, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info
 wrote:
 Ah, perhaps you're talking about *prescriptivist* grammarians, who
 insist on applying grammatical rules that exist only in their own
 fevered imagination. Sorry, I was talking about the other sort, the
 ones who apply the grammatical rules used by people in real life. You
 know the ones: linguists. My mistake.
 
 I am not pedantic. You are wrong.


Whether you like it or not, it simply is a fact that in English (I won't 
speak for other languages) people use colons without the first clause 
*necessarily* being a complete sentence. They write things like this:

Star Wars Episode IV: A New Hope

Also like these:

Example: this is an example of a colon following a sentence fragment.

Last update: Oct 4, 2007.

Shopping list:
- eggs
- milk
- cheese

They even use the reverse construction:

Lists, quotations, explanations, examples: some of the things 
which follow after a colon.

Check the use of colons here:

http://articles.baltimoresun.com/2012-03-15/features/bal-the-raven-reviews-20120313_1_edgar-allan-poe-john-cusack-mystery-writer

I count at least ten colons on the page (including the title) and *not 
one of them* uses a complete sentence before the colon.

While it is common for the clause preceding the colon to be an 
independent clause (i.e. it would stand alone as a complete sentence) it 
is not required that it be so.


I think I'll end this with a quote from Gore Vidal:

The four most beautiful words in our common language: I told you so.

http://grammar.about.com/od/c/g/colon.htm



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


Re: Python simulate browser activity

2012-03-16 Thread Chris Angelico
On Fri, Mar 16, 2012 at 1:23 PM, choi2k rex.0...@gmail.com wrote:
 The application aims to simulate user activity including visit a
 website and perform some interactive actions (click on the menu,
 submit a form, redirect to another pages...etc)
 I have found some libraries / plugins which aims to simulate browser
 activity but ... none of them support AJAX request and/or running
 javascript.

 Here is one of the simple tasks which I would like to do using the
 application:
 4. post ajax request using javascript and if the page has been
 redirected, load the new page content

To the web server, everything is a request. Don't think in terms of
Javascript; there is no Javascript, there is no AJAX, there is not
even a web browser. There's just a TCP socket connection and an HTTP
request. That's all you have.

On that basis, your Python script most definitely can simulate the
request. It needs simply to make the same HTTP query that the
Javascript would have made. The only tricky part is figuring out what
that request would be. If you can use a non-SSL connection, that'll
make your job easier - just get a proxy or packet sniffer to monitor
an actual web browser, then save the request headers and body. You can
then replay that using Python; it's not difficult to handle cookies
and such, too.

Hope that helps!

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


Re: Python is readable

2012-03-16 Thread Neil Cerutti
On 2012-03-16, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote:
 On Fri, 16 Mar 2012 17:53:24 +, Neil Cerutti wrote:

 On 2012-03-16, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info
 wrote:
 Ah, perhaps you're talking about *prescriptivist* grammarians, who
 insist on applying grammatical rules that exist only in their own
 fevered imagination. Sorry, I was talking about the other sort, the
 ones who apply the grammatical rules used by people in real life. You
 know the ones: linguists. My mistake.
 
 I am not pedantic. You are wrong.

 Whether you like it or not, it simply is a fact that in English
 (I won't speak for other languages) people use colons without
 the first clause *necessarily* being a complete sentence. They
 write things like this:

People spell your name Stephen, sometimes too. Thinking of changing it?

Gore Vidal's quote has panache, a valid compensation for breaking
the usual rule. How many other uses on that page are similar?

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


Re: Python is readable

2012-03-16 Thread Mel Wilson
Steven D'Aprano wrote:

 On Fri, 16 Mar 2012 17:53:24 +, Neil Cerutti wrote:
 
 On 2012-03-16, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info
 wrote:
 Ah, perhaps you're talking about *prescriptivist* grammarians, who
 insist on applying grammatical rules that exist only in their own
 fevered imagination. Sorry, I was talking about the other sort, the
 ones who apply the grammatical rules used by people in real life. You
 know the ones: linguists. My mistake.
 
 I am not pedantic. You are wrong.
 
 
 Whether you like it or not, it simply is a fact that in English (I won't
 speak for other languages) people use colons without the first clause
 *necessarily* being a complete sentence. They write things like this:
 
 Star Wars Episode IV: A New Hope

Come to think of it, just about every serious book title works this way.

Mel.

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


RE: Python is readable

2012-03-16 Thread Prasad, Ramit
 People spell your name Stephen, sometimes too. Thinking of changing it?
 Gore Vidal's quote has panache, a valid compensation for breaking
the usual rule. How many other uses on that page are similar?


He provided common examples and reference links. Seems like a pretty 
reasonable way of trying to prove a point. If you don't like reference 
links, what would convince you that the point was correct? I have
not seen any counter examples or counter references on your behalf...

Ramit


Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology
712 Main Street | Houston, TX 77002
work phone: 713 - 216 - 5423

--
This email is confidential and subject to important disclaimers and
conditions including on offers for the purchase or sale of
securities, accuracy and completeness of information, viruses,
confidentiality, legal privilege, and legal entity disclaimers,
available at http://www.jpmorgan.com/pages/disclosures/email.  
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: Is it technically possible to give Python option of naming process of running script?

2012-03-16 Thread Prasad, Ramit
 I was thinging about daemons and system-type stuff.
 
 One possible problem with linking from one's home directory is that
 home directories are often on different filesystems than /usr/bin (or
 wherever python is).   Using a symlink doesn't work, the process name
 still ends up as python2.6 (or whatever the real binary is called).


Try a hardlink instead of symlink? It seems to work for me.


Ramit


Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology
712 Main Street | Houston, TX 77002
work phone: 713 - 216 - 5423

--
 
This email is confidential and subject to important disclaimers and
conditions including on offers for the purchase or sale of
securities, accuracy and completeness of information, viruses,
confidentiality, legal privilege, and legal entity disclaimers,
available at http://www.jpmorgan.com/pages/disclosures/email.  
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: cannot open shared object file

2012-03-16 Thread Dan Stromberg
A suggestion:
1) strace it.
http://stromberg.dnsalias.org/~strombrg/debugging-with-syscall-tracers.html
2) Show the output to a C programmer, or take some educated guesses
yourself.

On Thu, Mar 15, 2012 at 11:47 PM, Steven Lo s...@hep.caltech.edu wrote:

 **

 Hi,

 We are getting the following error during a 'make' process on a CentOS
 release 5.4 system:

 Running mkfontdir...
 Creating SELinux policy...
 /usr/bin/python: error while loading shared libraries:
 libpython2.4.so.1.0: cannot open shared object file: No such file or
 directory


 However, we are able to execute 'python' without any problem

 # which python
 /usr/bin/python

 # python
 Python 2.4.3 (#1, Sep  3 2009, 15:37:37)
 [GCC 4.1.2 20080704 (Red Hat 4.1.2-46)] on linux2
 Type help, copyright, credits or license for more information.
 


 # ldd /usr/bin/python
 libpython2.4.so.1.0 = /usr/lib64/libpython2.4.so.1.0
 (0x003fb760)
 libpthread.so.0 = /lib64/libpthread.so.0 (0x003b5960)
 libdl.so.2 = /lib64/libdl.so.2 (0x003b5920)
 libutil.so.1 = /lib64/libutil.so.1 (0x003b6400)
 libm.so.6 = /lib64/libm.so.6 (0x003b58e0)
 libc.so.6 = /lib64/libc.so.6 (0x003b58a0)
 /lib64/ld-linux-x86-64.so.2 (0x003b5860)


 # ls -lad /usr/lib64/*python*
 lrwxrwxrwx  1 root root  19 Feb 27 21:15 /usr/lib64/libpython2.4.so- 
 libpython2.4.so.1.0
 -r-xr-xr-x  1 root root 1236344 Sep  3  2009 /usr/lib64/libpython2.4.so.1.0
 drwxr-xr-x 18 root root   20480 Feb 27 21:15 /usr/lib64/python2.4



 In this 'make' process, we are suppose to execute the applicate-specific
 python
 (/opt/rocks/bin/python) which has static link (not dynamic link)

 # ldd /opt/rocks/bin/python
 libpthread.so.0 = /lib64/libpthread.so.0 (0x003b5960)
 libdl.so.2 = /lib64/libdl.so.2 (0x003b5920)
 libutil.so.1 = /lib64/libutil.so.1 (0x003b6400)
 libstdc++.so.6 = /usr/lib64/libstdc++.so.6 (0x003b6b40)
 libm.so.6 = /lib64/libm.so.6 (0x003b58e0)
 libgcc_s.so.1 = /lib64/libgcc_s.so.1 (0x003b67c0)
 libc.so.6 = /lib64/libc.so.6 (0x003b58a0)
 /lib64/ld-linux-x86-64.so.2 (0x003b5860)



 Basically, we try to understand:
   * why /opt/rocks/bin/python not being used ?
   * why /usr/bin/python can not find the dynamic library


 Please let us know if you have any suggestion on how to troubleshoot this
 problem.

 If this is not the list to ask this type of question, please point us to
 the appropriate
 list.


 Thanks.

 S.


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


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


Re: Python is readable

2012-03-16 Thread Ethan Furman

Neil Cerutti wrote:

On 2012-03-16, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote:

Ah, perhaps you're talking about *prescriptivist* grammarians,
who insist on applying grammatical rules that exist only in
their own fevered imagination. Sorry, I was talking about the
other sort, the ones who apply the grammatical rules used by
people in real life. You know the ones: linguists. My mistake.


I am not pedantic. You are wrong.



When saying somebody is wrong, you really should back it up with 
references (wiki, dictionary, etc.).


At this point, if I had to decide between Steven and you, I'd go with 
Steven.


Of course, it doesn't hurt that everything he has said matches with my 
experience on the topic.


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


Re: Is it technically possible to give Python option of naming process of running script?

2012-03-16 Thread Grant Edwards
On 2012-03-16, Prasad, Ramit ramit.pra...@jpmorgan.com wrote:

 One possible problem with linking from one's home directory is that
 home directories are often on different filesystems than /usr/bin (or
 wherever python is).  Using a symlink doesn't work, the process name
 still ends up as python2.6 (or whatever the real binary is called).
 
 Try a hardlink instead of symlink? It seems to work for me.

Not across different filesystems -- which was what I was talking
about.

-- 
Grant Edwards   grant.b.edwardsYow! As President I have
  at   to go vacuum my coin
  gmail.comcollection!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why not use juxtaposition to indicate function application

2012-03-16 Thread Serhiy Storchaka

16.03.12 18:45, Steven D'Aprano написав(ла):

If f is a function which normally takes (for the sake of the argument)
one argument, then f would call the function with no arguments (which may
return a curried function, or may apply default arguments, or perhaps
raise an exception). So how would you refer to the function itself
without calling it?


lambda:f

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


Re: Python is readable

2012-03-16 Thread Chris Angelico
On Sat, Mar 17, 2012 at 7:30 AM, Ethan Furman et...@stoneleaf.us wrote:
 Neil Cerutti wrote:

 I am not pedantic. You are wrong.


 When saying somebody is wrong, you really should back it up with references
 (wiki, dictionary, etc.).

I interpret this simply as a witty statement, one that can be thrown
into any argument that has descended into pure pedantry. As such, it
needs no backing, and is completely on topic for this thread (if not
for python-list itself). Personally, I find it amusing.

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


Re: Why not use juxtaposition to indicate function application

2012-03-16 Thread Chris Rebert
On Fri, Mar 16, 2012 at 1:57 PM, Serhiy Storchaka storch...@gmail.com wrote:
 16.03.12 18:45, Steven D'Aprano написав(ла):
 If f is a function which normally takes (for the sake of the argument)
 one argument, then f would call the function with no arguments (which may
 return a curried function, or may apply default arguments, or perhaps
 raise an exception). So how would you refer to the function itself
 without calling it?

 lambda:f

Doesn't help; wouldn't the lambda be implicitly called?

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


Re: avoid import short-circuiting

2012-03-16 Thread Andrea Crotti

On 03/16/2012 05:19 PM, Robert Kern wrote:

On 3/16/12 4:49 PM, Andrea Crotti wrote:

I started the following small project:

https://github.com/AndreaCrotti/import-tree

because I would like to find out what exactly depends on what at 
run-time, using

an import hook.

It works quite well for small examples but the main problem is that 
once a

module is imported
it's added to sys.modules and then it doesn't go through the import 
hook anymore.


I tried to mess around with sys.modules but it might not be a good 
idea, and it

leads to easy
infinite loops.
Is there a good way to achieve this?
I guess I could do the loop detection myself, but that should not be 
too hard..


You want to monkeypatch __builtin__.__import__() instead. It always 
gets called.




Seems like a good idea :)

My first attempt failes though


def full(module):
from __builtin__ import __import__
ls = []
orig = __import__

def my_import(name):
ls.append(name)
orig(name)

__import__ = my_import
__import__(module)
__import__ = orig
return ls


it imports only the first element and doesn't import the dependencies..
Any hints?
--
http://mail.python.org/mailman/listinfo/python-list


Re: Why not use juxtaposition to indicate function application

2012-03-16 Thread Serhiy Storchaka

16.03.12 23:02, Chris Rebert написав(ла):

On Fri, Mar 16, 2012 at 1:57 PM, Serhiy Storchakastorch...@gmail.com  wrote:

lambda:f


Doesn't help; wouldn't the lambda be implicitly called?


No, the lambda is only for declaration. I prefer to use braces for 
lambda syntax, it will be fine with 'if' and 'while' functions.


But all this for some other, fictitious, language, not for Python.

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


Re: avoid import short-circuiting

2012-03-16 Thread Ian Kelly
On Fri, Mar 16, 2012 at 4:04 PM, Andrea Crotti
andrea.crott...@gmail.com wrote:
 You want to monkeypatch __builtin__.__import__() instead. It always gets
 called.


 Seems like a good idea :)

 My first attempt failes though


 def full(module):
    from __builtin__ import __import__
    ls = []
    orig = __import__

    def my_import(name):
        ls.append(name)
        orig(name)

    __import__ = my_import
    __import__(module)
    __import__ = orig
    return ls


 it imports only the first element and doesn't import the dependencies..
 Any hints?

You didn't actually monkey-patch it.  You just created a local called
__import__ that stores a wrapped version of the function.  You need to
actually replace it in the __builtin__ module:

import __builtin__
__builtin__.__import__ = my_import

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


Re: avoid import short-circuiting

2012-03-16 Thread Robert Kern

On 3/16/12 10:04 PM, Andrea Crotti wrote:

On 03/16/2012 05:19 PM, Robert Kern wrote:

On 3/16/12 4:49 PM, Andrea Crotti wrote:

I started the following small project:

https://github.com/AndreaCrotti/import-tree

because I would like to find out what exactly depends on what at run-time, using
an import hook.

It works quite well for small examples but the main problem is that once a
module is imported
it's added to sys.modules and then it doesn't go through the import hook
anymore.

I tried to mess around with sys.modules but it might not be a good idea, and it
leads to easy
infinite loops.
Is there a good way to achieve this?
I guess I could do the loop detection myself, but that should not be too hard..


You want to monkeypatch __builtin__.__import__() instead. It always gets called.



Seems like a good idea :)

My first attempt failes though


def full(module):
from __builtin__ import __import__
ls = []
orig = __import__

def my_import(name):
ls.append(name)
orig(name)

__import__ = my_import
__import__(module)
__import__ = orig
return ls


it imports only the first element and doesn't import the dependencies..
Any hints?


You need to replace it in __builtin__. Don't forget to handle all of the 
arguments.


import __builtin__

orig_import = __builtin__.__import__

all_imports = []

def my_import(*args, **kwds):
module = orig_import(*args, **kwds)
# Get the fully-qualified module name from the module object itself
# instead of trying to compute it yourself.
all_imports.append(module.__name__)
return module

__builtin__.__import__ = my_import


For extra points, make a context manager that hooks and then unhooks your
custom importer.

You may also want to take a look at an import profiler that I once made:

http://www.enthought.com/~rkern/cgi-bin/hgwebdir.cgi/import_profiler/file/tip/import_profiler.py#l23

--
Robert Kern

I have come to believe that the whole world is an enigma, a harmless enigma
 that is made terrible by our own mad attempt to interpret it as though it had
 an underlying truth.
  -- Umberto Eco

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


Re: avoid import short-circuiting

2012-03-16 Thread Andrea Crotti

On 03/16/2012 10:20 PM, Robert Kern wrote:

On 3/16/12 10:04 PM, Andrea Crotti wrote:

On 03/16/2012 05:19 PM, Robert Kern wrote:

On 3/16/12 4:49 PM, Andrea Crotti wrote:

I started the following small project:

https://github.com/AndreaCrotti/import-tree

because I would like to find out what exactly depends on what at 
run-time, using

an import hook.

It works quite well for small examples but the main problem is that 
once a

module is imported
it's added to sys.modules and then it doesn't go through the import 
hook

anymore.

I tried to mess around with sys.modules but it might not be a good 
idea, and it

leads to easy
infinite loops.
Is there a good way to achieve this?
I guess I could do the loop detection myself, but that should not 
be too hard..


You want to monkeypatch __builtin__.__import__() instead. It always 
gets called.




Seems like a good idea :)

My first attempt failes though


def full(module):
from __builtin__ import __import__
ls = []
orig = __import__

def my_import(name):
ls.append(name)
orig(name)

__import__ = my_import
__import__(module)
__import__ = orig
return ls


it imports only the first element and doesn't import the dependencies..
Any hints?


You need to replace it in __builtin__. Don't forget to handle all of 
the arguments.



import __builtin__

orig_import = __builtin__.__import__

all_imports = []

def my_import(*args, **kwds):
module = orig_import(*args, **kwds)
# Get the fully-qualified module name from the module object itself
# instead of trying to compute it yourself.
all_imports.append(module.__name__)
return module

__builtin__.__import__ = my_import


For extra points, make a context manager that hooks and then unhooks your
custom importer.

You may also want to take a look at an import profiler that I once made:

http://www.enthought.com/~rkern/cgi-bin/hgwebdir.cgi/import_profiler/file/tip/import_profiler.py#l23 






Very nice thanks, here it is
class ImportMock:

def _my_import(self, *args, **kwargs):
self.ls.append(args[0])
self.orig(*args, **kwargs)

def __enter__(self):
self.orig = __builtin__.__import__
self.ls = []
__builtin__.__import__ = self._my_import
return self

def __exit__(self, type, value, traceback):
__builtin__.__import__ = self.orig

now I only need to make it create also the graph and then I should be 
done :)

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


Re: Python is readable

2012-03-16 Thread Michael Torrie
On 03/16/2012 10:48 AM, Steven D'Aprano wrote:
 On Fri, 16 Mar 2012 13:10:12 +0100, Kiuhnm wrote:
 
 Maybe we should define *exactly* what readability is (in less then 500
 lines, if possible).
 
 If you can't be bothered to read my post before replying, save yourself 
 some more time and don't bother to reply at all.
 
 I quote from the part of the my post you deleted:
 
 When people talk about readability, they normally mean to 
 ask how much mental effort is needed to interpret the 
 meaning of the text, not how much time does it take to 
 pass your eyes over the characters. In other words they 
 are actually talking about comprehensibility.
 
 
 Unless I've made a mistake counting, that's less than 500 lines.
 
 
 According to your view, ASM code is more readable than Python code. It's
 just that there's more to read in ASM.
 
 What a ridiculous misrepresentation of my position. Readability is not 
 proportional to length.

For someone who claims he's merely examining the language and seeking to
learn about it, Kiuhnm is jumping awfully quickly into the realm of
trolling.

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


Re: avoid import short-circuiting

2012-03-16 Thread Robert Kern

On 3/16/12 11:14 PM, Andrea Crotti wrote:


Very nice thanks, here it is
class ImportMock:

def _my_import(self, *args, **kwargs):
self.ls.append(args[0])
self.orig(*args, **kwargs)


There's a bug here. You need to return the module object you got from calling 
self.orig(). By the way, you really should follow my example of getting the 
.__name__ from the module object instead of the argument in order to properly 
account for relative imports inside packages. __import__() will be passed the 
relative name, not the fully-qualified name.


--
Robert Kern

I have come to believe that the whole world is an enigma, a harmless enigma
 that is made terrible by our own mad attempt to interpret it as though it had
 an underlying truth.
  -- Umberto Eco

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


Currying in Python

2012-03-16 Thread Kiuhnm
Here we go.

---
def genCur(f, unique = True, minArgs = -1):
 Generates a 'curried' version of a function. 
def geng(curArgs, curKwargs):
def g(*args, **kwargs):
nonlocal f, curArgs, curKwargs, minArgs;# our STATIC data

if len(args) or len(kwargs):
# Allocates data for the next 'g'. We don't want to modify our
# static data.
newArgs = curArgs[:];
newKwargs = dict.copy(curKwargs);

# Adds positional arguments.
newArgs += args;

# Adds/updates keyword arguments.
if unique:
# We don't want repeated keyword arguments.
for k in kwargs.keys():
if k in newKwargs:
raise(Exception(Repeated kw arg while unique = 
True));
newKwargs.update(kwargs);

# Checks whether it's time to evaluate f.
if minArgs = 0 and minArgs = len(newArgs) + len(newKwargs):
return f(*newArgs, **newKwargs);# f has enough args
else:
return geng(newArgs, newKwargs);# f needs some more args
else:
return f(*curArgs, **curKwargs);# the caller forced the 
evaluation
return g;
return geng([], {});

def cur(f, minArgs = -1):
return genCur(f, True, minArgs);

def curr(f, minArgs = -1):
return genCur(f, False, minArgs);

# Simple Function.
def f(a, b, c, d, e, f, g = 100):
print(a, b, c, d, e, f, g);

# NOTE: '' means this line prints to the screen.

# Example 1.
c1 = cur(f)(1);
c2 = c1(2, d = 4);  # Note that c is still unbound
c3 = c2(3)(f = 6)(e = 5);   # now c = 3
c3();   # () forces the evaluation  
c4 = c2(30)(f = 60)(e = 50);# now c = 30
c4();   # () forces the evaluation  

print(\n--\n);

# Example 2.
c1 = curr(f)(1, 2)(3, 4);   # curr = cur with possibly repeated
# keyword args
c2 = c1(e = 5)(f = 6)(e = 10)();# ops... we repeated 'e' because we 
# changed our mind about it!
# again, () forces the evaluation

print(\n--\n);

# Example 3.
c1 = cur(f, 6); # forces the evaluation after 6 arguments
c2 = c1(1, 2, 3);   # num args = 3
c3 = c2(4, f = 6);  # num args = 5
c4 = c3(5); # num args = 6 == evalution
c5 = c3(5, g = -1); # num args = 7 == evaluation   
# we can specify more than 6 arguments, but
# 6 are enough to force the evaluation

print(\n--\n);

# Example 4.
def printTree(func, level = -1):
if level == -1:
printTree(cur(func), level + 1);
elif level == 6:
func(g = '')(); # or just func('')()
else:
printTree(func(0), level + 1);
printTree(func(1), level + 1);

printTree(f);

print(\n--\n);

def f2(*args):
print(, .join([%3d%(x) for x in args]));

def stress(f, n):
if n: stress(f(n), n - 1)
else: f();  # enough is enough

stress(cur(f2), 100);
---

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


Does anyone actually use PyPy in production?

2012-03-16 Thread John Nagle

  Does anyone run PyPy in production?

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


Re: Currying in Python

2012-03-16 Thread Steven D'Aprano
On Sat, 17 Mar 2012 02:21:32 +0100, Kiuhnm wrote:

 Here we go.
[snip code]


Have you looked at functools.partial?


import functools
new_func = functools.partial(func, ham, spam=23)


(I am aware that, technically, currying and partial function application 
are not quite the same thing, but it seems to me on a superficial reading 
that your function performs partial function application rather than 
actually currying. But I haven't read it in enough detail to be sure.)



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


Re: Python simulate browser activity

2012-03-16 Thread NA

selenium is the best bet.

http://github.com/antlong/selenium

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


PIL for py3k not picking up external libraries

2012-03-16 Thread Collin Day

Hi all,

I am using python 3.2 on an amd64 Gentoo system.  I was trying to 
compile an unofficial version of PIL to work in 3.2 that I found here:


http://www.lfd.uci.edu/~gohlke/pythonlibs

Anyway, when I run the setup.py to compile the source, it doesn't pick 
up tkinter, zlib, or freetype.  When I use pdb to step through the code 
where it is looking for libraries (for example zlib here), I make it all 
the way into unixcompiler.py:


 /usr/lib64/python3.2/distutils/unixccompiler.py(318)find_library_file()
- shared_f = self.library_filename(lib, lib_type='shared')
which returns 'libz.cpython-32.so' or 'libtcl8.5.cpython-32.py', 
depending on what it is looking for.


If I step in further to ccompiler.py

)
881  fmt = getattr(self, lib_type + _lib_format)
882  ext = getattr(self, lib_type + _lib_extension)
883
884  -dir, base = os.path.split(libname)
885  filename = fmt % (base, ext)

The extension returns .cpython-32.so

I have a lot of these extensions for site packages, but how do I 
generate libraries compatible with this for say tkinter, zlib, etc.  For 
example, I see libtcl8.5.so, but no libtcl8.5.cpython-32.so.


Can someone tell me what I am missing?

Thanks!


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


Daemonization / Popen / pipe issue

2012-03-16 Thread Lee Clemens
Hello,

I am new to the list, have many years of Java experience but an fairly new to 
Python. I am hoping this is an issue caused by my  misuse of Python in a 
multi-threaded way, but so far no one has identified such to me.

I have a multi-threaded application, each thread has an instance of a class 
which calls Popen. The command(s) being executed (shell=True) include pipes. 
The errors I have seen involve broken pipe and unexepected output (as 
demonstrated in the test case).

This issues only seem to occur when the application is daemonized, using a 
double-fork and os.dup2, as shown here:
http://www.jejik.com/articles/2007/02/a_simple_unix_linux_daemon_in_python/

I have provided a test-case here: https://gist.github.com/2054194

Please test how flipping DAEMONIZE between True and False yield different 
results.

I have used this on Red Hat/CentOS/Fedora using Python 2.6.x (latest) and 2.7.1 
and on Solaris with 2.6.4.

I know it's a bit long, but I have added comments to explain where the oddities 
appear and how it is called (fairly straight-forward multi-threaded). Please 
keep in mind this is a test-case based on a much larger application - I 
understand a lot of pieces included here are not necessary in this case.

Any assistance/advice would be greatly appreciated.

Thanks,
Lee

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


Re: Currying in Python

2012-03-16 Thread Steven D'Aprano
On Sat, 17 Mar 2012 01:46:59 +, Steven D'Aprano wrote:

 On Sat, 17 Mar 2012 02:21:32 +0100, Kiuhnm wrote:
 
 Here we go.
 [snip code]
 
 
 Have you looked at functools.partial?
 
 
 import functools
 new_func = functools.partial(func, ham, spam=23)
 
 
 (I am aware that, technically, currying and partial function application
 are not quite the same thing, but it seems to me on a superficial
 reading that your function performs partial function application rather
 than actually currying. But I haven't read it in enough detail to be
 sure.)

Okay, that was an incredibly superficial reading, because on a second 
reading, I can see it's nothing like partial function application. Sorry 
for the noise.



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


Re: Daemonization / Popen / pipe issue

2012-03-16 Thread John O'Hagan
On Fri, 16 Mar 2012 22:12:14 -0400
Lee Clemens j...@leeclemens.net wrote:


 
 I have a multi-threaded application, each thread has an instance of a class
 which calls Popen. The command(s) being executed (shell=True) include pipes.
 The errors I have seen involve broken pipe and unexepected output (as
 demonstrated in the test case).
 
 This issues only seem to occur when the application is daemonized, using a
 double-fork and os.dup2, as shown here:
 http://www.jejik.com/articles/2007/02/a_simple_unix_linux_daemon_in_python/
 
 I have provided a test-case here: https://gist.github.com/2054194
 
 Please test how flipping DAEMONIZE between True and False yield different
 results.


I haven't looked at your test case yet, but a possible cause is the fact that
the main application (or main thread) exits if it has finished executing and
only daemon threads remain. This can  abruptly terminate threads which may be
busy, for example, communicating via a pipe. The best solution IMO is not to
use daemon threads, but to give all threads a way to terminate cleanly before
the main thread does, even if this means using a flag or the like.

HTH,

John


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


Re: Why not use juxtaposition to indicate function application

2012-03-16 Thread Terry Reedy

On 3/16/2012 9:14 AM, bruno.desthuilli...@gmail.com wrote:

On Mar 16, 1:45 pm, Ray Songemacs...@gmail.com  wrote:

I confess i've indulged in Haskell and found
 f a
more readable than
 f(a)


Hmmm... What about:

 f a b

versus

 f(a(b))

or was it supposed to be read as

 f(a)(b)


or as

f(a, b)

?-)


One also has to consider Python calls with *args, **kwds, and arg=obj. 
These are all compile-time SyntaxErrors unless inside parens that follow 
a expression.


Also, function calls, especially in a functional language without 
side-effects, do not usually occur in isolation.
'f(a) + 3' would have to be written as '(f a) + 3', so saving of parens 
anyway.


Also, is 'f a - 2' f(a -2) or f(a, -2)? A new precedence rule is needed 
to disambiguage.


--
Terry Jan Reedy

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


Re: Python is readable

2012-03-16 Thread Terry Reedy

On 3/16/2012 9:08 AM, Neil Cerutti wrote:


A grammarian always uses complete sentence before a colon, even
when introducing a list.


The Chicago Manual of Style*, 13th edition, says The colon is used to 
mark a discontinuity of grammatical construction greater than that 
indicated by the semicolon and less than that indicated by the period.


While most of the examples in that section have what would be a complete 
sentence before the colon, not all do. Not in that section is this, from 
the Table of Contents: Documentation: References, Notes, and 
Bibliographies. Here are a couple more from their Library of Congress 
Cataloging in Publication data: Rev. ed. of: A manual of style. and 
Bibliography: p.. And in letters: To:, From:, and Date:


*A major style guide for general American writing and publication: used 
by some as the 'Bible'.


--
Terry Jan Reedy

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


Re: Does anyone actually use PyPy in production?

2012-03-16 Thread Terry Reedy

On 3/16/2012 9:44 PM, John Nagle wrote:

Does anyone run PyPy in production?


The pypy list, accessible via gmane, might be a better place to ask. But 
my impression is yes, and that they are getting commercial $$$ support.


--
Terry Jan Reedy

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


Haskellizing python (was Why not use juxtaposition to indicate function application)

2012-03-16 Thread rusi
On Mar 16, 5:45 pm, Ray Song emacs...@gmail.com wrote:
 I confess i've indulged in Haskell and found
     f a
 more readable than
     f(a)

 And why aren't functions curried (partially applied function is another 
 function which takes the rest arguments) by default?

 Thanks in advance for any suggestions.

 --
 Ray

In Haskell
a b c d is short for (((a b) c) d)

This works nicely when the latter is commonly required, as for example
happens in a language where what one may call 'the currying
convention' is the default.
It fails when one wants the opposite convention -- a (b (c (d))) --
which may be called the 'function-composition convention.'

The fact that the default convention in haskell is not always a good
idea is seen in the existence of a special application operator $ with
low precedence which allows
a (b (c (d))) to be written as a $ b $ c $ d

It is another matter: as someone pointed out that () is overloaded in
python to denote:
- function application
- tupling
- grouping

Comes from the hegemony of ASCII.
A from-first-principles unicode language would use more of these:
http://xahlee.org/comp/unicode_matching_brackets.html
-- 
http://mail.python.org/mailman/listinfo/python-list


How to get a reference of the 'owner' class to which a method belongs in Python 3.X?

2012-03-16 Thread Cosmia Luna
I'm porting my existing work to Python 3.X, but...

class Foo:
def bar(self):
pass

mthd = Foo.bar

assert mthd.im_class is Foo # this does not work in py3k

So, how can I get a reference to Foo? This is important when writing
decorators, the only way I can think out is:

class Foo:
def bar(self):
'Foo' # manually declare the owner class
pass

mthd = Foo.bar

assert mthd.__globals__[mthd.__doc__] is Foo # this works

class Child(Foo):
def bar(self):
'Child' # I have to override all method defined by bar but do nothing
pass

child_mthd = Child.bar

assert child_mthd.__globals__[child_mthd.__doc__] is Child # this works

But the code above is quite ugly and abuses the __doc__. Is there any
equivalent in py3k of im_class?

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


Re: How to get a reference of the 'owner' class to which a method belongs in Python 3.X?

2012-03-16 Thread Chris Rebert
On Fri, Mar 16, 2012 at 10:30 PM, Cosmia Luna cosm...@gmail.com wrote:
 I'm porting my existing work to Python 3.X, but...

 class Foo:
    def bar(self):
        pass

 mthd = Foo.bar

 assert mthd.im_class is Foo # this does not work in py3k

 So, how can I get a reference to Foo? This is important when writing
 decorators,

Could you give an example of such a decorator?

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


[issue14331] Python/import.c uses a lot of stack space due to MAXPATHLEN

2012-03-16 Thread Gregory P. Smith

Gregory P. Smith g...@krypto.org added the comment:

Here's a patch for python 2.7.  test cases pass but it could use review to see 
if I missed any free()s.

--
keywords: +patch
Added file: 
http://bugs.python.org/file24882/malloc-import-pathbufs-py27.001.diff

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



[issue2486] Recode (parts of) decimal module in C

2012-03-16 Thread Ramchandra Apte

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

If issue7652 finishes. There's no point in fixing this bug.

--
nosy: +ramchandra.apte

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



[issue14207] ElementTree.ParseError - needs documentation and consistent CPy implementations

2012-03-16 Thread Roundup Robot

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

New changeset b76fa310e73d by Eli Bendersky in branch 'default':
Issue #14207: the ParseError exception raised by _elementtree was made
http://hg.python.org/cpython/rev/b76fa310e73d

--
nosy: +python-dev

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



[issue14207] ElementTree.ParseError - needs documentation and consistent CPy implementations

2012-03-16 Thread Eli Bendersky

Changes by Eli Bendersky eli...@gmail.com:


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

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



[issue10484] http.server.is_cgi fails to handle CGI URLs containing PATH_INFO

2012-03-16 Thread Senthil Kumaran

Senthil Kumaran sent...@uthcode.com added the comment:

To note in the tracker, the original 2.6 code was changed in Issue 2254 and the 
relevant changeset is c6c4398293bd

I find, Glenn's suggestion a possibly okay solution for PATH_INFO problem, 
keeping in tact the security issue the the previous change dealt with.

--

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



[issue14009] Clearer documentation for cElementTree

2012-03-16 Thread Eli Bendersky

Eli Bendersky eli...@gmail.com added the comment:

Éric, what stops us from closing this issue?

Given Ezio and Fred's feedback, I don't object to indexing cET in 3.3 - I guess 
it can't hurt.

--

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



[issue14328] Add keyword-only parameter support to PyArg_ParseTupleAndKeywords

2012-03-16 Thread Larry Hastings

Larry Hastings la...@hastings.org added the comment:

Attached is r3 of my patch incorporated Benjamin's suggestions.

 I want #14325 to go in first.

Why do you care?  If I get signoff before 14325 does please explain to me why I 
should wait.  They don't touch the same lines; should be a clean merge no 
matter who goes first.

--
Added file: http://bugs.python.org/file24883/larry.parsekwonly.diff.3.txt

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



[issue9257] cElementTree iterparse requires events as bytes; ElementTree uses strings

2012-03-16 Thread Roundup Robot

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

New changeset 84e4d76bd146 by Eli Bendersky in branch '3.2':
Issue #9257: clarify the events iterparse accepts
http://hg.python.org/cpython/rev/84e4d76bd146

New changeset 00c7142ee54a by Eli Bendersky in branch 'default':
Issue #9257: clarify the events iterparse accepts
http://hg.python.org/cpython/rev/00c7142ee54a

--
nosy: +python-dev

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



[issue9257] cElementTree iterparse requires events as bytes; ElementTree uses strings

2012-03-16 Thread Eli Bendersky

Changes by Eli Bendersky eli...@gmail.com:


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

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



[issue12908] Update dev-in-a-box for new coverage steps

2012-03-16 Thread Eli Bendersky

Changes by Eli Bendersky eli...@gmail.com:


--
nosy:  -eli.bendersky

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



[issue14127] add st_*time_ns fileds to os.stat(), add ns keyword to os.*utime*(), os.*utimens*() expects a number of nanoseconds

2012-03-16 Thread Larry Hastings

Larry Hastings la...@hastings.org added the comment:

Updated patch incorporating only one of Antoine's latest suggestions.  Please 
see my reply on Reitveld for r3 as to why I skipped two of your three 
suggestions.

--
Added file: http://bugs.python.org/file24884/larry.st_mtime_ns.patch.4.txt

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



[issue10484] http.server.is_cgi fails to handle CGI URLs containing PATH_INFO

2012-03-16 Thread Senthil Kumaran

Senthil Kumaran sent...@uthcode.com added the comment:

Actually no.  I revert back my previous statement. Meddling with splitpath 
breaks all the tests.

--

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



[issue13709] Capitalization mistakes in the documentation for ctypes

2012-03-16 Thread Roundup Robot

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

New changeset d2460ff173ff by Eli Bendersky in branch 'default':
Issue #13709: some fixes to the ctypes documentation. In addition to fixing
http://hg.python.org/cpython/rev/d2460ff173ff

--
nosy: +python-dev

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



[issue13709] Capitalization mistakes in the documentation for ctypes

2012-03-16 Thread Eli Bendersky

Eli Bendersky eli...@gmail.com added the comment:

Fixed in 3.3

I don't think this is important enough to spend time on backporting.

--
resolution:  - fixed
stage: needs patch - commit review
status: open - closed
versions: +Python 3.3

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



[issue2486] Recode (parts of) decimal module in C

2012-03-16 Thread Mark Dickinson

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

No, this should be closed.

--

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



[issue14320] set.add can return boolean indicate newly added item

2012-03-16 Thread Matt Joiner

Matt Joiner anacro...@gmail.com added the comment:

Is there still some value to at least exposing this in the C API, per the 
precedents I mentioned? 

The patch also contains some adjustment to the set_add_entry/set_add_key 
abstraction dance, and some future proofing of PySet_Add return values that 
have merit on their own.

--

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



[issue14333] queue unittest errors

2012-03-16 Thread Matt Joiner

New submission from Matt Joiner anacro...@gmail.com:

$ python3.3 -m unittest test.test_queue

Generates errors in the unit test code of the form

AttributeError: 'BaseQueueTest' object has no attribute 'type2test'

--
components: Tests
messages: 156006
nosy: anacrolix, benjamin.peterson, rhettinger
priority: normal
severity: normal
status: open
title: queue unittest errors
type: behavior
versions: Python 3.3

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



[issue10484] http.server.is_cgi fails to handle CGI URLs containing PATH_INFO

2012-03-16 Thread Glenn Linderman

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

I'm not sure what tests break or why, I suppose it is the ones for the security 
patch.  I'm not sure which code you are referring to... the code in msg122259 I 
tested only cursorily, the (different) code in issue 13893 is what I'm running 
today, and so has been tested more heavily, but I haven't run the regression 
tests (haven't figured out how).

The latter code fixes the _url_collapse_path_split function, instead of working 
around it, which the code in msg122259 tries to do.

I would be highly interested if it fails any tests, and why, and would be glad 
to help analyze and fix.

--

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



[issue2486] Recode (parts of) decimal module in C

2012-03-16 Thread Mark Dickinson

Changes by Mark Dickinson dicki...@gmail.com:


--
resolution:  - rejected
status: open - closed

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



[issue8739] Update to smtpd.py to RFC 5321

2012-03-16 Thread Michele Orrù

Michele Orrù maker...@gmail.com added the comment:

David: yes, I did. About two weeks ago.
Probably I'll take a look to those issues :)

--

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



[issue8739] Update to smtpd.py to RFC 5321

2012-03-16 Thread Michele Orrù

Michele Orrù maker...@gmail.com added the comment:

David, can you tag this issue as dependency for issue14261 ?

--

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



[issue10484] http.server.is_cgi fails to handle CGI URLs containing PATH_INFO

2012-03-16 Thread Roundup Robot

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

New changeset bab9f29c93fd by Senthil Kumaran in branch '2.7':
2.7 - Issue #10484: Fix the CGIHTTPServer's PATH_INFO handling problem
http://hg.python.org/cpython/rev/bab9f29c93fd

New changeset 88c86869ce92 by Senthil Kumaran in branch '3.2':
closes issue10484 - Fix the http.server's cgi PATH_INFO handling problem
http://hg.python.org/cpython/rev/88c86869ce92

New changeset 13c44ad094b4 by Senthil Kumaran in branch 'default':
closes issue10484 - Fix the http.server's cgi PATH_INFO handling problem
http://hg.python.org/cpython/rev/13c44ad094b4

--
nosy: +python-dev
resolution:  - fixed
stage:  - committed/rejected
status: open - closed

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



[issue10484] http.server.is_cgi fails to handle CGI URLs containing PATH_INFO

2012-03-16 Thread Senthil Kumaran

Senthil Kumaran sent...@uthcode.com added the comment:

I treated this as a regression from 2.6. A cgi url with 
/cgi-bin/hello.py/hello/world would have PATH_INFO as '/hello/world' 
I saw some apache specs saying that it should be 'hello/world', but I relied on 
python2.6's behavior with had initial '/'.

Glenn, I referred to Lib/test/test_httpservers.py.

Thanks for raising this and other issues (and patches)!

--

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



[issue10487] http.server doesn't process Status header from CGI scripts

2012-03-16 Thread Senthil Kumaran

Changes by Senthil Kumaran sent...@uthcode.com:


--
assignee:  - orsenthil

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



[issue10487] http.server doesn't process Status header from CGI scripts

2012-03-16 Thread Senthil Kumaran

Changes by Senthil Kumaran sent...@uthcode.com:


--
superseder:  - Make CGIHTTPServer capable of redirects (and status other than 
200)

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



[issue10485] http.server fails when query string contains addition '?' characters

2012-03-16 Thread Senthil Kumaran

Changes by Senthil Kumaran sent...@uthcode.com:


--
assignee:  - orsenthil

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



[issue10484] http.server.is_cgi fails to handle CGI URLs containing PATH_INFO

2012-03-16 Thread Glenn Linderman

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

In reviewing my code in this area, I also see that in addition to fixing 
_url_collapse_path_split, I override the location that uses it, which is the 
is_cgi function.  Here is my code for the override, which actually creates a 
proper PATH_INFO string:

def is_cgi(self):
Test whether self.path corresponds to a CGI script.

Returns True and updates the cgi_info attribute to the tuple
(dir, rest) if self.path requires running a CGI script.
Returns False otherwise.

If any exception is raised, the caller should assume that
self.path was rejected as invalid and act accordingly.

The default implementation tests whether the normalized url
path begins with one of the strings in self.cgi_directories
(and the next character is a '/' or the end of the string).



splitpath = server._url_collapse_path_split(self.path)
# more processing required due to possible PATHINFO parts
# not clear above function really does what is needed here,
# nor just how general it is!
splitpath = '/'.join( splitpath ).split('/', 2 )
head = '/' + splitpath[ 1 ]
tail = splitpath[ 2 ]
if head in self.cgi_directories:
self.cgi_info = head, tail
return True
return False

I have no idea what applications might depend on the improper handling of 
PATH_INFO that the current code is performing, so that is why I applied my fix 
for that in my overridden code, rather than in the server.py source file.

It may be that the actual fix for this issue is in the overridden code above 
(but the fix to _url_collapse_path_split also seemed necessary, there was a 
corner case that it did incorrectly, but after 16 months, I couldn't tell you 
what that corner case was, any more.

Yes, the biggest issue here was the regression from 2.6, the security fix 
seemed to break the PATH_INFO feature.

--

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



[issue10484] http.server.is_cgi fails to handle CGI URLs containing PATH_INFO

2012-03-16 Thread Glenn Linderman

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

Senthil, the patch you submitted breaks the encapsulation of cgi_directories -- 
this should be changeable per particular application via subclassing or 
assignment, but you've built those directories into the code.  Perhaps you 
should take a look at my code for is_cgi (which I was trying to post while you 
were posting the patches, sorry I was slow).

Perhaps there should be one more test, which actually changes the 
cgi_directories, and tests a few more things, to prove that the code does not 
hard code those directories (it shouldn't).

--
status: closed - open

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



[issue10484] http.server.is_cgi fails to handle CGI URLs containing PATH_INFO

2012-03-16 Thread Glenn Linderman

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

Another issue with the patch, is that it doesn't do .. and . collapsing on the 
PATH_INFO part of the path.

It is possible for a path like

/cgi-bin/script.py/../../plain-file.html

to be passed to the server.  I guess the question is if it should serve 
plain-file.html or if it should pass ../../plain-file.html to script.py as 
its PATH_INFO. I would think the former would be appropriate.  I would have to 
do research to determine if some standard states otherwise.

--

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



[issue10484] http.server.is_cgi fails to handle CGI URLs containing PATH_INFO

2012-03-16 Thread Glenn Linderman

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

I just tested what Apache does with such a path as 
/cgi-bin/script.py/../../plain-file.html, and it serves the plain-file.html.

--

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



[issue14202] The docs of xml.dom.pulldom are almost nonexistent

2012-03-16 Thread Florian Mladitsch

Changes by Florian Mladitsch florian.mladit...@googlemail.com:


--
keywords: +patch
Added file: http://bugs.python.org/file24885/xml.dom.pulldom.rst.patch

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



[issue14133] improved PEP 409 implementation

2012-03-16 Thread Nick Coghlan

Nick Coghlan ncogh...@gmail.com added the comment:

With the decision on whether or not to suppress the context moved out to a 
separate flag, I think we need to allow it. Requiring that the flag be False 
*and* that the context also be None gets us back to asking the question of why 
the flag doesn't work when the context is set to a different value. That 
question was part of the genesis of the Ellipsis-as-sentinel approach in the 
original 409 implementation.

I wouldn't stress too much about the formatting though. Perhaps note in the 
suppress context docs that the output can get *very* noisy if you turn it off 
when both cause and context are set, so while it does display all the exception 
information, the default output isn't going to be very easy to read.

--

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



[issue14334] Invalid free in _PyUnicode_Ready()

2012-03-16 Thread Stefan Krah

New submission from Stefan Krah stefan-use...@bytereef.org:

Hi -- I'm getting a segfault running the attached crasher.py script.
Valgrind traces it down to an Invalid free() / delete / delete[] in
_PyUnicode_Ready().

Reproduce:
==

Rev: 870c0ef7e8a2
Build: ./configure --without-pymalloc CFLAGS=-O0 -g  make

$ ./python crasher.py 
Segmentation fault


$ valgrind --db-attach=yes --suppressions=./Misc/valgrind-python.supp ./python 
crasher.py
==3476== Memcheck, a memory error detector
==3476== Copyright (C) 2002-2010, and GNU GPL'd, by Julian Seward et al.
==3476== Using Valgrind-3.6.1 and LibVEX; rerun with -h for copyright info
==3476== Command: ./python crasher.py
==3476== 
==3476== Invalid free() / delete / delete[]
==3476==at 0x4C2748D: free (vg_replace_malloc.c:366)
==3476==by 0x44763C: _PyUnicode_Ready (unicodeobject.c:1405)
==3476==by 0x44ACF8: PyUnicode_FromFormatV (unicodeobject.c:2500)
==3476==by 0x4A1CF4: PyErr_Format (errors.c:621)
==3476==by 0x42F8FE: type_getattro (typeobject.c:2551)
==3476==by 0x43493A: wrap_binaryfunc (typeobject.c:4317)
==3476==by 0x550008: wrapper_call (descrobject.c:1067)
==3476==by 0x532C93: PyObject_Call (abstract.c:2150)
==3476==by 0x49012B: PyEval_CallObjectWithKeywords (ceval.c:3920)
==3476==by 0x54F136: wrapperdescr_call (descrobject.c:309)
==3476==by 0x532C93: PyObject_Call (abstract.c:2150)
==3476==by 0x491A1E: ext_do_call (ceval.c:4355)
==3476==  Address 0x4 is not stack'd, malloc'd or (recently) free'd
==3476==

--
components: Interpreter Core
files: crasher.py
messages: 156017
nosy: haypo, loewis, skrah
priority: high
severity: normal
stage: needs patch
status: open
title: Invalid free in _PyUnicode_Ready()
type: crash
versions: Python 3.3
Added file: http://bugs.python.org/file24886/crasher.py

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



  1   2   3   >