Re: Python 2.7 released

2010-07-06 Thread Tim Golden

On 06/07/2010 07:06, David Bolen wrote:

I tend to need multiple versions around when developing, so I keep a
bunch of versions all installed in separate directories as \Python\x.y
(so I only have a single root directory).  With 2.7, my current box
has 6 Python interpreters (2.4-3.1) installed at the moment.

I use Cygwin (wouldn't try to work on a Windows system without it), so
just use bash aliases to execute the right interpreter, but a batch
file could be used with the cmd interpreter, and you could link GUI
shortcuts to that batch file.


I, too, have multiple versions installed -- newer ones for running code
I haven't upgraded; older ones for compatibility testing where needed.
I just install to the default c:\pythonxy directories (although I like
the idea of a common root) and I put NTFS hardlinks into my general
c:\tools directory which is on the path. The out-of-context hardlinks
work because of the registry settings which pick up the correct context
for each version.

(I've never quite clicked with cygwin or MingW despite giving them
several goes on the basis of others' enthusiasm...)

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


Re: delegation pattern via descriptor

2010-07-06 Thread Bruno Desthuilliers

kedra marbun a écrit :

On Jul 5, 3:42 pm, Bruno Desthuilliers  wrote:

kedra marbun a écrit :




i'm confused which part that doesn't make sense?
this is my 2nd attempt to py, the 1st was on april this year, it was
just a month, i'm afraid i haven't got the fundamentals right yet. so
i'm gonna lay out how i got to this conclusion, CMIIW
**explanation of feeling (0) on my 1st post**
to me, descriptor is a particular kind of delegation, it takes the job
of coding the delegation by having a contract with programmers that
the tree meta operations (get, set, del) on attr are delegated to the
obj that is bound to the attr
are we agree that descriptor is a kind of delegation?
the mechanism that makes descriptor works is in __getattribute__,
__setattr__, __delattr__ of 'object' & 'type'
now, if i want a single descriptor obj to be delegated to multiple
tasks, i can't do it since __get__ doesn't get info that can be used
to determine which task to do
i must have diff descriptor obj for each task
class Helper:
   def __init__(self, name):
   self.name = name
   def __get__(self, ins, cls):
   if self.name == 'task0': ...
   elif self.name == 'task1': ...
   else: ...

Replacing such "big switch" code with polymorphic dispatch is one of the
  goals (and feature) of OO. This should be:

class Task0(object):
 def __get__(self, obj, cls):
 # code here

class Task1(object):
 def __get__(self, obj, cls):
 # code here

class A(object):
 task0 = Task0()
 task1 = Task1()

If you have common code to share between TaskO and Task1 then factor it
out into a base class.


if __get__ receives the name, then i could do
class Helper:
   def __get__(self, ins, cls, name):
   ...
class a:
   task0 = task1 = Helper()

Yuck.


what's so 'Yuck' about it? ;)


It's an implicit, obfuscated and overcomplicated way to do a very simple 
thing. To be true, I just don't see the point of this pattern - Python 
has better solutions for delegation (cf the __getattr__ method), and 
that's not what descriptors are for.




i guess i need a strong stmt: is descriptor a kind of delegation? or
is it not?


The descriptor protocol is the primary support for computed attributes. 
As such it can be used as a support for delegation, but it's not "a kind 
of delegation" by itself.



* if it is a kind of delegation, then the code that you labeled as
'Yuck' is just a result of applying delegation
what's wrong with delegating multiple tasks to a single obj?


Nothing wrong with delegating multiple tasks to a single object - but 
not that way. If you want to use descriptors to specify which tasks 
should be delegated, you'd be better doing it more explicitely - that 
is, only use the descriptor as a gateway, and use one descriptor per task.


Else just use __getattr__ !-)

Sorry, I don't have much time to elaborate on this now.


that code is similar to this

class Helper:
def do_this(self, ins): ...
def do_that(self, ins): ...

class a:
delegate = Helper()
def task0(self): self.delegate.do_that(self)
def task1(self): self.delegate.do_this(self)



It's not similar. This second example is explicit, and doesn't couple 
Helper to a.



My 2 cents.
--
http://mail.python.org/mailman/listinfo/python-list


Re: The real problem with Python 3 - no business case for conversion (was "I strongly dislike Python 3")

2010-07-06 Thread David Cournapeau
On Tue, Jul 6, 2010 at 4:30 AM, D'Arcy J.M. Cain  wrote:
> On Mon, 05 Jul 2010 14:42:13 -0400
> Terry Reedy  wrote:
>> Good start. Now what is blocking those four?
>> Lack of developer interest/time/ability?
>> or something else that they need?
>
> How about a basic how-to document?  I maintain PyGreSQL and would like
> to move it to 3.x right now but I don't even know what the issues are.

One thing that would be very useful is how to maintain something that
works on 2.x and 3.x, but not limiting yourself to 2.6. Giving up
versions below 2.6 is out of the question for most projects with a
significant userbase IMHO. As such, the idea of running the python 3
warnings is not so useful IMHO - unless it could be made to work
better for python 2.x < 2.6, but I am not sure the idea even makes
sense.

>
> Or is there no change at the C level?  That would make things easy.

There are quite a few, but outside of the big pain point of
strings/byte/unicode which is present at python level as well, a lot
of the issues are not so big (and even simpler to deal with). For
example, although numpy took time to port (and is still experimental
in nature), it took me a couple of hours to get a basic scipy working
(numpy uses a lot of C api dark corners, whereas scipy is much more
straightforward in its usage of the C API).

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


Re: The real problem with Python 3 - no business case for conversion (was "I strongly dislike Python 3")

2010-07-06 Thread Stefan Behnel

Steven D'Aprano, 05.07.2010 08:31:

On Sun, 04 Jul 2010 17:34:04 -0700, sturlamolden wrote:


Using Python 2.x for new
projects is not advisable (at least many will think so), and using 3.x
is not possible. What to do? It's not a helpful situation for Python.


That's pure FUD.

Python 2.7 will be supported longer than the normal support period for
versions 2.6, 2.5, 2.4, ... so if you have a new project that requires
libraries that aren't available for 3.1, then go right ahead and use 2.7.
By the time 2.7 is no longer supported (probably around the time 3.4
comes out?), the library situation will be fixed.

Those 3.1 features that can be backported to 2.x have been, specifically
to reduce the pain in porting 2.7-based applications to 3.x. Feature-
wise, 2.7 is designed to ease the transition from the 2.x series to the
3.x series. Claiming that it's not advisable to use 2.7 is simply
nonsense.


Not to forget about the 2to3 tool. If you write code for 2.6 or 2.7 now, 
you can actually port it automatically and continuously, and do the final 
switch when you think it's time. So both choices (2 or 3) are real and 
available.


Stefan

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


Re: Getting pyparsing to backtrack

2010-07-06 Thread Thomas Jollans
On 07/06/2010 04:21 AM, Dennis Lee Bieber wrote:
> On Mon, 05 Jul 2010 15:19:53 -0700, John Nagle 
> declaimed the following in gmane.comp.python.general:
> 
>>I'm working on street address parsing again, and I'm trying to deal
>> with some of the harder cases.
>>
> 
>   Hasn't it been suggested before, that the sanest method to parse
> addresses is from the end backwards... 
> 
>   So that: 
> 
> 123 N South St.
> 
> is parsed as
> 
> St. South N 123

You will of course need some trickery for that to work with

Hauptstr. 12





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


Changing Locale for datetime.strptime conversions

2010-07-06 Thread AlienBaby
Hi,

I'm using datetime.strptime(string,format) to convert dates parsed
from a file into datetime objects.

However, the files come from various places around the world, and
strptime fails when non-english month names are used.

strptime says it converts month names using the current locales
version of the name.  I've looked into the locale module but can't see
how I would setup.change a locales date/time representations, I can
only see categories related to decimal number / currency
representations.

Can anyone show how I could change the locale such that strptime could
parse a date string that used say, German month names?

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


Re: Changing Locale for datetime.strptime conversions

2010-07-06 Thread AlienBaby
On 6 July, 10:55, AlienBaby  wrote:
> Hi,
>
> I'm using datetime.strptime(string,format) to convert dates parsed
> from a file into datetime objects.
>
> However, the files come from various places around the world, and
> strptime fails when non-english month names are used.
>
> strptime says it converts month names using the current locales
> version of the name.  I've looked into the locale module but can't see
> how I would setup.change a locales date/time representations, I can
> only see categories related to decimal number / currency
> representations.
>
> Can anyone show how I could change the locale such that strptime could
> parse a date string that used say, German month names?
>
> Thankyou

I just solved this I believe. I didnt spot LC_ALL or LC_TIME
previously.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python as a scripting language. Alternative to bash script?

2010-07-06 Thread sturlamolden
On 28 Jun, 19:39, Michael Torrie  wrote:

> In python I could simply take the output of "ps ax" and use python's
> own, superior, cutting routines (using my module):
>
> (err, stdout, stderr) = runcmd.run( [ 'ps', 'ax' ] )
> for x in stdout.split('\n'):
>     print x.strip().split()[0]

Or you just pass the stdout of one command as stdin to another. That
is equivalent of piping with bash.

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


[no subject]

2010-07-06 Thread francisco dorset

hey am a programmer i have good knowledge of the c language and i will like to 
now how i can use to python to provide graphical user-interface for my c 
programs and or the steps involved in doing this and is it possible

if yes i will also like some resources or books to learn from.

any info will be useful thankss 
  
_
Your E-mail and More On-the-Go. Get Windows Live Hotmail Free.
https://signup.live.com/signup.aspx?id=60969-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Changing Locale for datetime.strptime conversions

2010-07-06 Thread AlienBaby
I'm still having a bit of trouble,  for example trying to set  the
locale to Denmark


locale.setlocale(locale.LC_ALL, locale.normalize('da_DK'))

returns with

locale.setlocale(locale.LC_ALL, locale.normalize('da_DK'))
  File "C:\Python26\lib\locale.py", line 494, in setlocale
return _setlocale(category, locale)
locale.Error: unsupported locale setting


Though, from the docs I understand normalize should return a local
formatted for use with setlocale?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Changing Locale for datetime.strptime conversions

2010-07-06 Thread Antoine Pitrou
On Tue, 6 Jul 2010 03:21:21 -0700 (PDT)
AlienBaby  wrote:
> I'm still having a bit of trouble,  for example trying to set  the
> locale to Denmark
> 
> 
> locale.setlocale(locale.LC_ALL, locale.normalize('da_DK'))
> 
> returns with
> 
> locale.setlocale(locale.LC_ALL, locale.normalize('da_DK'))
>   File "C:\Python26\lib\locale.py", line 494, in setlocale
> return _setlocale(category, locale)
> locale.Error: unsupported locale setting
> 
> 
> Though, from the docs I understand normalize should return a local
> formatted for use with setlocale?

I think normalize works ok, but setlocale then fails (*). You can only
use a locale if it's installed on the computer. That, and other issues
(such as the fact that the locale setting is process-wide and can
interfere with other parts of your program, or third-party libraries;
or the fact that a given locale can have differences depending on the
vendor) make the locale mechanism very fragile and annoying.

If you want to do this seriously, I suggest you instead take a look at
third-party libraries such as Babel:
http://babel.edgewall.org/


(*):

>>> import locale
>>> locale.normalize('da_DK')
'da_DK.ISO8859-1'
>>> locale.setlocale(locale.LC_ALL, locale.normalize('da_DK'))
Traceback (most recent call last):
  File "", line 1, in 
  File "/usr/lib64/python2.6/locale.py", line 513, in setlocale
return _setlocale(category, locale)
locale.Error: unsupported locale setting


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


Re: Another Regexp Question

2010-07-06 Thread andrew cooke
http://bugs.python.org/issue9179

On Jul 5, 9:38 pm, MRAB  wrote:
> andrew cooke wrote:
> > On Jul 5, 8:56 pm, MRAB  wrote:
> >> andrew cooke wrote:
> >>> What am I missing this time? :o(
> >> Nothing. It's a bug. :-(
>
> > Sweet :o)
>
> > Thanks - do you want me to raise an issue or will you?
>
> You found it. You can have the pleasure.

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


Re: Python 3 put-downs: What's the point?

2010-07-06 Thread Gregor Horvath
Am Mon, 05 Jul 2010 14:32:13 -0500
schrieb Tim Chase :

> On 07/05/2010 02:50 AM, Gregor Horvath wrote:
> > Am Sun, 04 Jul 2010 18:51:54 -0500
> > schrieb Tim Chase:
> >
> >> I think it's the same venting of frustration that caused veteran
> >> VB6 developers to start calling VB.Net "Visual Fred" -- the
> >> language was too different and too non-backwards-compatible.
> >>
> >
> > VB6 ->  VB.NET and Python 2 ->  3 is not a valid comparison.
> >
> > VB6 and VB.NET are totally different languages and technologies,
> > with some similarity in syntax. This is not true for Python 2->3.
> > This is an healthy organic language growth, not an abandon of a
> > language.
> 
> The quintessential example is Py3's breaking of Hello World. 
> It's a spectrum of language changes -- Visual Fred just happens 
> to be MUCH further down the same spectrum having more dramatic 
> changes.  Only a subset of $OLD_VER (whether Py2 or VB6) code 
> will run unmodified under $NEW_VER (whether Py3 or VB.Net).  It 

Don't you think that there is a really huge difference in an
evolutionary development of a language with some well founded
incompatibilities due to some muck outs on one side and and on the other
side stopping the development of a language and replacing it with one
derived from a completely different one and giving it a related name
and syntax?

And that such a big difference forbids any comparison, although there
are some superficial similarities?

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


RE: Python-list Digest, Vol 82, Issue 48

2010-07-06 Thread francisco dorset

i need resources or books on how to embedding python into c/c++...and also 
extending it

am allergic to cheating, i hate failures, but am in love with achievements
<º><.·´¯`·.F®an©ï§CØ`·.¸¸¸.·´¯`·.¸><º>




From: python-list-requ...@python.org
Subject: Python-list Digest, Vol 82, Issue 48
To: python-list@python.org
Date: Tue, 6 Jul 2010 08:25:02 +0200

Send Python-list mailing list submissions to
python-list@python.org
 
To subscribe or unsubscribe via the World Wide Web, visit
http://mail.python.org/mailman/listinfo/python-list
or, via email, send a message with subject or body 'help' to
python-list-requ...@python.org
 
You can reach the person managing the list at
python-list-ow...@python.org
 
When replying, please edit your Subject line so it is more specific
than "Re: Contents of Python-list digest..."


--Forwarded Message Attachment--
From: mar...@v.loewis.de
To: python-list@python.org
Date: Tue, 6 Jul 2010 05:28:00 +0200
Subject: Re: Python 2.7 released

> Benjamin (or anyone else), do you know where I can get the Compiled
> Windows Help file -- python27.chm -- for this release?
 
I have now put that file separately on the release page.
 
Regards,
Martin
 


--Forwarded Message Attachment--
From: kedra.mar...@gmail.com
To: python-list@python.org
Date: Mon, 5 Jul 2010 21:10:51 -0700
Subject: Re: delegation pattern via descriptor

On Jul 5, 3:42 pm, Bruno Desthuilliers  wrote:
> kedra marbun a écrit :
>
>
>
> > i'm confused which part that doesn't make sense?
> > this is my 2nd attempt to py, the 1st was on april this year, it was
> > just a month, i'm afraid i haven't got the fundamentals right yet. so
> > i'm gonna lay out how i got to this conclusion, CMIIW
>
> > **explanation of feeling (0) on my 1st post**
> > to me, descriptor is a particular kind of delegation, it takes the job
> > of coding the delegation by having a contract with programmers that
> > the tree meta operations (get, set, del) on attr are delegated to the
> > obj that is bound to the attr
> > are we agree that descriptor is a kind of delegation?
>
> > the mechanism that makes descriptor works is in __getattribute__,
> > __setattr__, __delattr__ of 'object' & 'type'
>
> > now, if i want a single descriptor obj to be delegated to multiple
> > tasks, i can't do it since __get__ doesn't get info that can be used
> > to determine which task to do
> > i must have diff descriptor obj for each task
>
> > class Helper:
> >def __init__(self, name):
> >self.name = name
> >def __get__(self, ins, cls):
> >if self.name == 'task0': ...
> >elif self.name == 'task1': ...
> >else: ...
>
> Replacing such "big switch" code with polymorphic dispatch is one of the
>   goals (and feature) of OO. This should be:
>
> class Task0(object):
>  def __get__(self, obj, cls):
>  # code here
>
> class Task1(object):
>  def __get__(self, obj, cls):
>  # code here
>
> class A(object):
>  task0 = Task0()
>  task1 = Task1()
>
> If you have common code to share between TaskO and Task1 then factor it
> out into a base class.
>
> > if __get__ receives the name, then i could do
>
> > class Helper:
> >def __get__(self, ins, cls, name):
> >...
>
> > class a:
> >task0 = task1 = Helper()
>
> Yuck.
 
what's so 'Yuck' about it? ;)
i guess i need a strong stmt: is descriptor a kind of delegation? or
is it not?
* if it is a kind of delegation, then the code that you labeled as
'Yuck' is just a result of applying delegation
what's wrong with delegating multiple tasks to a single obj?
 
that code is similar to this
 
class Helper:
def do_this(self, ins): ...
def do_that(self, ins): ...
 
class a:
delegate = Helper()
def task0(self): self.delegate.do_that(self)
def task1(self): self.delegate.do_this(self)
 
the diff is that this code manually code the delegation, that's why it
can branches to 2 funcs. while descriptor takes all to __get__,
because it works on more meta lv
 
* if it's not, then there's nothing to be argued, the name
'descriptor' is perfectly fit: descriptor obj describes attr of class,
with 'describe' translates to: . = del, in py vocabularies. then, to
think a single descriptor obj describing a single attr is acceptable,
it's a common sense
 


--Forwarded Message Attachment--
From: kedra.mar...@gmail.com
To: python-list@python.org
Date: Mon, 5 Jul 2010 21:12:47 -0700
Subject: Re: delegation pattern via descriptor

On Jul 5, 7:49 am, Gregory Ewing  wrote:
> kedra marbun wrote:
> > now, i'm asking another favor, what about the 2nd point in my 1st post?
>
> Your original post has dropped off my newsscope, so
> you'll have to remind me what the 2nd point was.
>
> --
> Greg
 
it's like 'name', it's about info that i think should be passed to
descriptor's __{get|set|delete}__. i wonder what are the reasons for
not passing the class on which the descriptor is attached to, what

Re: Python-list Digest, Vol 82, Issue 48

2010-07-06 Thread Thomas Jollans
On 07/06/2010 12:03 PM, francisco dorset wrote:
> i need resources or books on how to embedding python into c/c++...and
> also extending it
> 
> [snip]

What is the digest doing at the end of your message then?

Anyway:

http://docs.python.org/py3k/c-api/index.html
http://docs.python.org/py3k/extending/index.html

or, if you feel like using the archaic 2.x series of CPython,

http://docs.python.org/c-api/index.html
http://docs.python.org/extending/index.html

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


Re: Python GUI for C program [was: ]

2010-07-06 Thread Thomas Jollans
On 07/06/2010 12:15 PM, francisco dorset wrote:
> hey am a programmer i have good knowledge of the c language and i will
> like to now how i can use to python to provide graphical user-interface
> for my c programs and or the steps involved in doing this and is it
> possible
> 
> if yes i will also like some resources or books to learn from.
> 
> any info will be useful thankss

Three ways of doing this:

1. Turn your C program into a library, and write a Python extension
   module to interface it.

2. Embed Python in your C program.

3. If you're talking command-line programs, you can interface the
   compiled programs with the subprocess module.

For (1) and (2), start with the Extending/Embedding section at
http://docs.python.org/py3k/ (or http://docs.python.org/). With (1),
using Cython or SWIG might make writing the "glue" between Python and
your C code easier.

For (3), check the docs of the subprocess module.

It might, however, be best to simply write the GUI in C as well, which
would avoid the overhead of loading Python and isn't all that difficult
either. If you know C++, check out wxWidgets and Qt4. To stick with
plain C, have a look at GTK+.

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


Re: The real problem with Python 3 - no business case for conversion (was "I strongly dislike Python 3")

2010-07-06 Thread D'Arcy J.M. Cain
On Tue, 6 Jul 2010 16:30:34 +0800
David Cournapeau  wrote:
> One thing that would be very useful is how to maintain something that
> works on 2.x and 3.x, but not limiting yourself to 2.6. Giving up
> versions below 2.6 is out of the question for most projects with a

Yes, PyGreSQL officially supports 2.3 and up.  That means that we can't
use "from __future__".  We might be able to bump that to 2.4 in the
next release but I wouldn't want to jump all the way to 2.6 in one
version release.

-- 
D'Arcy J.M. Cain  |  Democracy is three wolves
http://www.druid.net/darcy/|  and a sheep voting on
+1 416 425 1212 (DoD#0082)(eNTP)   |  what's for dinner.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python GUI for C program [was: ]

2010-07-06 Thread bobicanprogram
On Jul 6, 7:45 am, Thomas Jollans  wrote:
> On 07/06/2010 12:15 PM, francisco dorset wrote:
>
> > hey am a programmer i have good knowledge of the c language and i will
> > like to now how i can use to python to provide graphical user-interface
> > for my c programs and or the steps involved in doing this and is it
> > possible
>
> > if yes i will also like some resources or books to learn from.
>
> > any info will be useful thankss
>
> Three ways of doing this:
>
> 1. Turn your C program into a library, and write a Python extension
>module to interface it.
>
> 2. Embed Python in your C program.
>
> 3. If you're talking command-line programs, you can interface the
>compiled programs with the subprocess module.
>
> For (1) and (2), start with the Extending/Embedding section 
> athttp://docs.python.org/py3k/(orhttp://docs.python.org/). With (1),
> using Cython or SWIG might make writing the "glue" between Python and
> your C code easier.
>
> For (3), check the docs of the subprocess module.
>
> It might, however, be best to simply write the GUI in C as well, which
> would avoid the overhead of loading Python and isn't all that difficult
> either. If you know C++, check out wxWidgets and Qt4. To stick with
> plain C, have a look at GTK+.
>
> Cheers,
> Thomas


You might want to also look at the SIMPL toolkit (http://
www.icanprogram.com/06py/lesson1/lesson1.html).  You could use Send/
Receive/Reply (QNX style) messaging to add a Python GUI to a C
program.   There are examples of just this at the link above.

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


Re: The real problem with Python 3 - no business case for conversion (was "I strongly dislike Python 3")

2010-07-06 Thread Steven
On Jul 5, 2:56 am, John Nagle  wrote:
>     The Twisted team has a list of what they need:
>
> "http://stackoverflow.com/questions/172306/how-are-you-planning-on-han...";

Here's what I got from a quick google review of the below four
projects and python 3.
>      * Zope Interface
Here's a blog from a core contributer to Zope, Lennart Regebro
claiming Zope Interface now works with Python 3:
http://regebro.wordpress.com/2010/04/29/zope-interface-3-6-0-released-with-python-3-support/
I have no idea if this is official Zope, but it does indicate strong
progress.

>      * PyCrypto
Couldn't find much.  Found this from an email on Pycrypto mailing
list:
http://lists.dlitz.net/pipermail/pycrypto/2010q2/000244.html
"""
Hi Tobias

 > Does Pycrypto work with Python 3.x now?

To my knowledge PyCrypto doesn't work yet with Python 3.x.
Around 30% of the test cases are still fail. If you want me
to check which of the components are pass, please let me know.

Cheers,
Christoph"""
So someone has been looking at Python 3, but doesn't look like much is
being done.

>      * PyOpenSSL
Couldn't find anything.

>      * PyGTK
This one shows real progress.  There is a bug filed for Python 3
support:
https://bugzilla.gnome.org/show_bug.cgi?id=566641
Key comment on that bug:
"""John Ehresman   [developer]  2010-04-17 16:02:43 UTC

I just pushed to the py3k branch a couple of fixes to bugs that are
independent
of the changes for python3 so all tests pass under both python 2.5 and
python3.1.  It's probably time to think about landing this on the
master
branch; obviously we want to avoid regressions in python2 support.
What needs
to be done before this lands on master?"""
A couple of comments follow about when to merge Python 3 support.  So
it looks like they are almost there.

Conclusion:  2 of 4 dependencies that Twisted needs to port to Python
3 show strong progress towards completing the port.

Steven Rumbalski

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


Re: Python as a scripting language. Alternative to bash script?

2010-07-06 Thread Michael Torrie
On 07/06/2010 04:12 AM, sturlamolden wrote:
> On 28 Jun, 19:39, Michael Torrie  wrote:
> 
>> In python I could simply take the output of "ps ax" and use python's
>> own, superior, cutting routines (using my module):
>>
>> (err, stdout, stderr) = runcmd.run( [ 'ps', 'ax' ] )
>> for x in stdout.split('\n'):
>> print x.strip().split()[0]
> 
> Or you just pass the stdout of one command as stdin to another. That
> is equivalent of piping with bash.

Consider this contrived example:

tail -f /var/log/messages | grep openvpn

While it's possible to set up pipes and spawn programs in parallel to
operate on the pipes, in practice it's simpler to tell subprocess.Popen
to use a shell and then just rely on Bash's very nice syntax for setting
up the pipeline.  Then just read the final output in python.  If you set
the stdout descriptor to non-blocking, you could read output as it came.
-- 
http://mail.python.org/mailman/listinfo/python-list


Pdf download using mechanize

2010-07-06 Thread srinivasan srinivas
HI,
I am using mechanize module for web scraping projects. One of y tasks is to 
download pdf file from a page and store it.
Is there a way to download pdf file using mechanize how we do it in Perl's 
WWW::Mechanize?

Thanks,
Srini


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


Re: Confusion over etree.ElementTree.Element.getiterator

2010-07-06 Thread Aahz
In article ,
Terry Reedy   wrote:
>On 7/5/2010 6:40 AM, Ben Sizer wrote:
>
>>> Admittedly, it's three clicks away from the library docs on docs.python.org.
>>>
>>> http://effbot.org/zone/element.htm#xml-namespaces
>>
>> Hopefully someone will see fit to roll this important documentation
>> into docs.python.org before the next release... oops, too late. ;)
>
>Not too late for next release. Open a doc issue with as specific a 
>suggestion as possible.

Actually, it's not too late for this release, either (or at least it
used not to be): the docs on the website can be updated even if the
downloadable package itself can't be.
-- 
Aahz (a...@pythoncraft.com)   <*> http://www.pythoncraft.com/

"If you don't know what your program is supposed to do, you'd better not
start writing it."  --Dijkstra
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python app development

2010-07-06 Thread Ed Leafe
On Jul 3, 2010, at 1:48 PM, mo reina wrote:

> an anyone recommend a resource (book,tutorial,etc.) that focuses on
> application development in python? something similar to Practical
> Django Projects, but for stand alone applications instead of web apps
> (for now).

You should definitely check out Dabo. Several years ago we were looking 
for something in Python for developing desktop apps, and while there were 
several useful tools, there wasn't anything that integrated them together. That 
was our motivation for creating Dabo.

We have a few screencasts to help you get acquainted with Dabo; I'd 
recommend these two to start:

http://cdn.cloudfiles.mosso.com/c129431/dataenvironment1.html
http://cdn.cloudfiles.mosso.com/c129432/dataenvironment1.html

We also have a pretty comprehensive tutorial document, available at:

http://dabodev.com/pycon_tutorial

If you have any other questions, join our email discussion list and 
post them there. There are many helpful people there to answer your questions.

http://leafe.com/mailman/listinfo/dabo-users



-- Ed Leafe



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


Re: The real problem with Python 3 - no business case for conversion (was "I strongly dislike Python 3")

2010-07-06 Thread Giampaolo Rodolà
2010/7/6 David Cournapeau :
>> Or is there no change at the C level?  That would make things easy.
>
> There are quite a few, but outside of the big pain point of
> strings/byte/unicode which is present at python level as well, a lot
> of the issues are not so big (and even simpler to deal with). For
> example, although numpy took time to port (and is still experimental
> in nature), it took me a couple of hours to get a basic scipy working
> (numpy uses a lot of C api dark corners, whereas scipy is much more
> straightforward in its usage of the C API).
>
> David
> --
> http://mail.python.org/mailman/listinfo/python-list


As for this aspect, I made a port as such (C extension) for psutil,
and it hasn't been too difficult, I must admit.

For those interested here is a detailed explanation of all the steps I
faced, along with revision changes:
http://code.google.com/p/psutil/issues/detail?id=75&can=1&q=python%203&colspec=ID%20Summary%20Type%20Opsys%20Status%20Milestone%20Opened%20Owner%20Progress#c9


--- Giampaolo
http://code.google.com/p/pyftpdlib
http://code.google.com/p/psutil/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Plot problem.. ?? No sign at all

2010-07-06 Thread Alan G Isaac

On 7/6/2010 8:05 AM, Ritchy lelis wrote:

 1 - "import numpy as np
  import matplotlib.pyplot as plt"

  In what help's me making the call's of the libraries that way?


http://bytebaker.com/2008/07/30/python-namespaces/


 2 - What's the instruction linspace means/does?


>>> help(np.linspace)
Help on function linspace in module numpy.core.function_base:

linspace(start, stop, num=50, endpoint=True, retstep=False)
Return evenly spaced numbers over a specified interval.

Returns `num` evenly spaced samples, calculated over the
interval [`start`, `stop` ].



 3 - Last but more important: "V0 = ... #create an array" if I
 understood, there i'm supposed to introduce the for loop as in my
 initial example. correct?


It is better to create your arrays without looping,
if possible.  But create it however you wish.
(Note than numpy arrays have a fixed length;
create a Python list if you wish to append to it.)

Cheers,
Alan Isaac


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


Re: Changing Locale for datetime.strptime conversions

2010-07-06 Thread python
Antoine,

> If you want to do this seriously, I suggest you instead take a look at 
> third-party libraries such as Babel: http://babel.edgewall.org/

Not the OP, but has Babel implemented parsing support? Last time I
looked, Babel did a great job with locale specific formatting, but
locale specific formatting was still incomplete.

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


Download Microsoft C/C++ compiler for use with Python 2.6/2.7 ASAP

2010-07-06 Thread sturlamolden

Just a little reminder:

Microsoft has withdrawn VS2008 in favor of VS2010. The express version
is also unavailable for download. >:((

We can still get a VC++ 2008 compiler required to build extensions for
the official Python 2.6 and 2.7 binary installers here (Windows 7 SDK
for .NET 3.5 SP1):

http://www.microsoft.com/downloads/details.aspx?familyid=71DEB800-C591-4F97-A900-BEA146E4FAE1&displaylang=en

Download today, before it goes away!

Microsoft has now published a download for Windows 7 SDK for .NET 4.
It has the VC++ 2010 compiler. It can be a matter of days before the VC
++ 2008 compiler is totally unavailable.

It is possible to build C and Fortran extensions for official Python
2.6/2.7 binaries on x86 using mingw. AFAIK, Microsoft's compiler is
required for C++ or amd64 though. (Intel's compiler requires VS2008,
which has now perished.)

Remember Python on Windows will still require VS2008 for a long time.
Just take a look at the recent Python 3 loath threads.

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


Re: Changing Locale for datetime.strptime conversions

2010-07-06 Thread Antoine Pitrou
On Tue, 06 Jul 2010 11:54:46 -0400
pyt...@bdurham.com wrote:
> Antoine,
> 
> > If you want to do this seriously, I suggest you instead take a look at 
> > third-party libraries such as Babel: http://babel.edgewall.org/
> 
> Not the OP, but has Babel implemented parsing support? Last time I
> looked, Babel did a great job with locale specific formatting, but
> locale specific formatting was still incomplete.

No idea, but if you just want to recognize month names, you can produce
all the month names in the desired natural language and then recognize
them yourself (using e.g. a regexp). Probably imperfect, but probably
sufficient in many cases too.

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


Re: Pdf download using mechanize

2010-07-06 Thread Aaron Watters
On Jul 6, 10:00 am, srinivasan srinivas 
wrote:
> HI,
> I am using mechanize module for web scraping projects. One of y tasks is to 
> download pdf file from a page and store it.
> Is there a way to download pdf file using mechanize how we do it in Perl's 
> WWW::Mechanize?
>
> Thanks,
> Srini

Mechanize seems to have a mailing list ;c)

   https://lists.sourceforge.net/lists/listinfo/wwwsearch-general

Also, it would be helpful to know what specific problems you are
having.
Have you tried following the excellent documentation?

   http://wwwsearch.sourceforge.net/mechanize/doc.html

It looks like downloading any sort of file and saving it should be
straightforward to me, but I haven't tried it.

   Aaron Watters
   http://whiffdoc.appspot.com

===
% man less
less is more.

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


Re: Download Microsoft C/C++ compiler for use with Python 2.6/2.7 ASAP

2010-07-06 Thread Alf P. Steinbach /Usenet

* sturlamolden, on 06.07.2010 17:50:


Just a little reminder:

Microsoft has withdrawn VS2008 in favor of VS2010. The express version
is also unavailable for download.>:((

We can still get a VC++ 2008 compiler required to build extensions for
the official Python 2.6 and 2.7 binary installers here (Windows 7 SDK
for .NET 3.5 SP1):

http://www.microsoft.com/downloads/details.aspx?familyid=71DEB800-C591-4F97-A900-BEA146E4FAE1&displaylang=en

Download today, before it goes away!

Microsoft has now published a download for Windows 7 SDK for .NET 4.
It has the VC++ 2010 compiler. It can be a matter of days before the VC
++ 2008 compiler is totally unavailable.

It is possible to build C and Fortran extensions for official Python
2.6/2.7 binaries on x86 using mingw. AFAIK, Microsoft's compiler is
required for C++ or amd64 though. (Intel's compiler requires VS2008,
which has now perished.)

Remember Python on Windows will still require VS2008 for a long time.
Just take a look at the recent Python 3 loath threads.


Perhaps this all for the good.

There is no *technical* problem creating a compiler-independent C/C++ language 
binding. I believe that Java's JNI works fine no matter what compiler you use, 
although it's many many years since I've done JNI things. Similarly, Python 
should IMHO just have a well defined compiler independent native code interface, 
e.g. "PNI", or "pynacoin", the PYthon NAtive COde INterface :-)



Cheers,

- Alf

--
blog at http://alfps.wordpress.com>
--
http://mail.python.org/mailman/listinfo/python-list


Re: Pdf download using mechanize

2010-07-06 Thread Aldo Ceccarelli
On 6 Lug, 16:00, srinivasan srinivas  wrote:
> HI,
> I am using mechanize module for web scraping projects. One of y tasks is to 
> download pdf file from a page and store it.
> Is there a way to download pdf file using mechanize how we do it in Perl's 
> WWW::Mechanize?
>
> Thanks,
> Srini

Hi, Srini:

unfortunately I have no direct experience of downloading PDF with
mechanize but I'd like to share this IBM article which gives some
mechanize snippet and hint (in case of any help to your research)
http://www.ibm.com/developerworks/linux/library/l-python-mechanize-beautiful-soup/index.html

kind regards,
Aldo
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Plot problem.. ?? No sign at all

2010-07-06 Thread Ritchy lelis
On 6 jul, 16:18, Alan G Isaac  wrote:
> On 7/6/2010 8:05 AM, Ritchy lelis wrote:
>
> >  1 - "import numpy as np
> >       import matplotlib.pyplot as plt"
>
> >       In what help's me making the call's of the libraries that way?
>
> http://bytebaker.com/2008/07/30/python-namespaces/
>
> >  2 - What's the instruction linspace means/does?
>
>  >>> help(np.linspace)
>          Help on function linspace in module numpy.core.function_base:
>
>          linspace(start, stop, num=50, endpoint=True, retstep=False)
>              Return evenly spaced numbers over a specified interval.
>
>              Returns `num` evenly spaced samples, calculated over the
>              interval [`start`, `stop` ].
>
> >  3 - Last but more important: "V0 = ... #create an array" if I
> >  understood, there i'm supposed to introduce the for loop as in my
> >  initial example. correct?
>
> It is better to create your arrays without looping,
> if possible.  But create it however you wish.
> (Note than numpy arrays have a fixed length;
> create a Python list if you wish to append to it.)
>
> Cheers,
> Alan Isaac

-

My intention with de for loop was to iterate each point of the arrays
Vi and Vref at the math calculations. The V0 it's the result of the
math expressions between the Vi and Vref. I can't just create one V0
by a function set by parametters (i don't see how).

Could you give a clue?

Cheers

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


Re: markmin 0.1

2010-07-06 Thread Vlastimil Brom
2010/7/6 Chris Rebert :
> On Mon, Jul 5, 2010 at 4:56 PM, Massimo Di Pierro
>  wrote:
>> Markmin is a wiki markup language
>> implemented in less than 100 lines of code (one file, no dependencies)
>> easy to read
>> secure
>> ...
>
> Okay, but where can it be downloaded from? You didn't include a link.
>
> Cheers,
> Chris
> --
> http://mail.python.org/mailman/listinfo/python-list
>

It looks like
http://www.web2py.com/examples/static/markmin.html

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


Re: Download Microsoft C/C++ compiler for use with Python 2.6/2.7 ASAP

2010-07-06 Thread Thomas Jollans
On 07/06/2010 05:50 PM, sturlamolden wrote:
> It is possible to build C and Fortran extensions for official Python
> 2.6/2.7 binaries on x86 using mingw. AFAIK, Microsoft's compiler is
> required for C++ or amd64 though. (Intel's compiler requires VS2008,
> which has now perished.)

mingw gcc should work for building C++ extensions if it also works for C
extensions. There's no difference on the binding side - you simply have
to include everything as extern "C", which I am sure the header does for
you.

As for amd64 - I do not know if there is a mingw64 release for windows
already. If there isn't, there should be ;-) But that doesn't really
change anything: the express edition of Microsoft's VC++ doesn't include
an amd64 compiler anyway, AFAIK.

Also, VS2010 should work as well - doesn't it?

> 
> Remember Python on Windows will still require VS2008 for a long time.
> Just take a look at the recent Python 3 loath threads.
> 

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


Re: Plot problem.. ?? No sign at all

2010-07-06 Thread Alan G Isaac

On 7/6/2010 12:11 PM, Ritchy lelis wrote:

My intention with de for loop was to iterate each point of the arrays
Vi and Vref at the math calculations. The V0 it's the result of the
math expressions between the Vi and Vref. I can't just create one V0
by a function set by parametters (i don't see how).



Unfortunately I cannot make sense of the code you posted.
Provide a detailed description in words (or psuedocode)
of what you are trying to accomplish.  Be very careful
and detailed is you want a useful response.

Alan Isaac


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


Re: Download Microsoft C/C++ compiler for use with Python 2.6/2.7 ASAP

2010-07-06 Thread sturlamolden
On 6 Jul, 18:00, "Alf P. Steinbach /Usenet"  wrote:

> There is no *technical* problem creating a compiler-independent C/C++ language
> binding. I believe that Java's JNI works fine no matter what compiler you use,
> although it's many many years since I've done JNI things. Similarly, Python
> should IMHO just have a well defined compiler independent native code 
> interface,
> e.g. "PNI", or "pynacoin", the PYthon NAtive COde INterface :-)

Yes but Python currently does not, due to dependency on VS2003 (2.5)
or VS2008 (2.6, 2.7, 3.1) C and C++ runtime DLLs.

It's not the binary interface that is the trouble, but CRT
versioning.

C++ is extra troublesome due to name mangling, standard runtime and
exceptions.

Here are the issues:

C++:
VS2010 - does not link with msvcp90.dll but msvcp100.dll.
mingw - linkes statically with its own C++ library.

Win32, ANSI C:
VS2010 - does not link with msvcr90.dll but msvcr100.dll.
mingw - ok for C if passed -lmsvcr90 on linking step

Win64, ANSI C:
VS2010 - does not link with msvcr90.dll but msvcr100.dll.
mingw - missing import libraries (libmsvcr90.a and libpython26.a)

Visual Studio 2008's C/C++ compiler is the only sane solution. It is
still there so go get it if you don't already have a copy (I guess Alf
does).












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


Re: Download Microsoft C/C++ compiler for use with Python 2.6/2.7 ASAP

2010-07-06 Thread sturlamolden
On 6 Jul, 18:21, Thomas Jollans  wrote:

> mingw gcc should work for building C++ extensions if it also works for C
> extensions.

No, it uses an incompatible statically linked C++ runtime. We need to
use msvcp90.dll with Python 2.6/2.7.


> As for amd64 - I do not know if there is a mingw64 release for windows
> already. If there isn't, there should be ;-)

There is. But it does not have an import library for msvcr90.dll. It's
omitted from mingw-w64. Also libpython26.a is missing from Python on
Windows 64.


> Also, VS2010 should work as well - doesn't it?

The problem with Microsoft's compilers is that they just let you pick
between two CRTs (single- or multi-threaded). We need to specify the
version number as well.

So no, VS2010 will not work. (At least not without some ugly hacks.)










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


Re: Download Microsoft C/C++ compiler for use with Python 2.6/2.7 ASAP

2010-07-06 Thread Christian Heimes
Am 06.07.2010 18:21, schrieb Thomas Jollans:
> mingw gcc should work for building C++ extensions if it also works for C
> extensions. There's no difference on the binding side - you simply have
> to include everything as extern "C", which I am sure the header does for
> you.

You need unofficial version of MinGW with gcc 4.x for several C++
extension like PyLucene's JCC. Some project like pywin32 don't work with
MinGW, too.

> Also, VS2010 should work as well - doesn't it?

It may work, it may segfault.

The official Python binaries are build with VS 2008. Although you are
able to build and use extensions build with other versions of VS it can
lead to segfaults. So far every version of VS has introduced its own C
runtime library (MSVCRT). If you try to close a FILE* from one MSVCRT
with fclose() from another MSVCRT your program SEGFAULT. malloc() and
free() suffer from the same problem.


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


Re: Lockless algorithms in python (Nothing to do with GIL)

2010-07-06 Thread Zac Burns
I'm not an expert on this, but wouldn't it be more dependent on the platform
than python version? Perhaps it is Windows 7 that is very slow. Perhaps my
processor architecture. Not sure...

Here are some for 3.1.2x64

>>> import timeit
>>> timeit.timeit('Lock()', 'from threading import Lock')
1.4162585386092708
>>> timeit.timeit('dict()', 'from threading import Lock')
0.2730348901369162
>>> timeit.timeit('list()', 'from threading import Lock')
0.1719480219512306

-Zac

On Fri, Jul 2, 2010 at 1:26 PM, Antoine Pitrou  wrote:

> On Mon, 28 Jun 2010 16:46:41 -0700
> Zac Burns  wrote:
> > In my experience it is far more expensive to allocate a lock in python
> then
> > it is the types that use them. Here are some examples:
> >
> > >>> timeit.timeit('Lock()', 'from threading import Lock')
> > 1.4449114807669048
> >
> > >>> timeit.timeit('dict()')
> > 0.2821554294221187
> >
> > >>> timeit.timeit('list()')
> > 0.17358153222312467
>
> I'm not sure what Python version on what machine you are using, but
> here (Python 2.7):
>
> >>> timeit.timeit('Lock()', 'from threading import Lock')
> 0.09944796562194824
> >>> timeit.timeit('dict()')
> 0.17817902565002441
> >>> timeit.timeit('list()')
> 0.19633007049560547
> >>> timeit.timeit('{}')
> 0.03823709487915039
> >>> timeit.timeit('[]')
> 0.05156302452087402
>
>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Download Microsoft C/C++ compiler for use with Python 2.6/2.7 ASAP

2010-07-06 Thread Thomas Jollans
On 07/06/2010 06:58 PM, Christian Heimes wrote:
> Am 06.07.2010 18:21, schrieb Thomas Jollans:
>> mingw gcc should work for building C++ extensions if it also works for C
>> extensions. There's no difference on the binding side - you simply have
>> to include everything as extern "C", which I am sure the header does for
>> you.
> 
> You need unofficial version of MinGW with gcc 4.x for several C++
> extension like PyLucene's JCC. Some project like pywin32 don't work with
> MinGW, too.

aha - why is that?

But - if you write code that builds with [whatever gcc version you
have], the compiler Python is built with shouldn't matter, should it?

> 
>> Also, VS2010 should work as well - doesn't it?
> 
> It may work, it may segfault.
> 
> The official Python binaries are build with VS 2008. Although you are
> able to build and use extensions build with other versions of VS it can
> lead to segfaults. So far every version of VS has introduced its own C
> runtime library (MSVCRT). If you try to close a FILE* from one MSVCRT
> with fclose() from another MSVCRT your program SEGFAULT. malloc() and
> free() suffer from the same problem.

Okay, you need to be careful with FILE*s. But malloc and free? You'd
normally only alloc & free something within the same module, using the
same functions (ie not mixing PyMem_Malloc and malloc), would you not?

You have to code quite defensively, true. But, IF you keep all
non-Python data structures local to your module, you should be fine?

Coming from a system where I can generally rely on the system gcc to
work for everything, I may be a bit naïve wrt certain questions ;-)

Cheers,
Thomas

PS: Windows CPython programming scares me.
-- 
http://mail.python.org/mailman/listinfo/python-list


re.sub unexpected behaviour

2010-07-06 Thread Javier Collado
Hello,

Let's imagine that we have a simple function that generates a
replacement for a regular expression:

def process(match):
return match.string

If we use that simple function with re.sub using a simple pattern and
a string we get the expected output:
re.sub('123', process, '123')
'123'

However, if the string passed to re.sub contains a trailing new line
character, then we get an extra new line character unexpectedly:
re.sub(r'123', process, '123\n')
'123\n\n'

If we try to get the same result using a replacement string, instead
of a function, the strange behaviour cannot be reproduced:
re.sub(r'123', '123', '123')
'123'

re.sub('123', '123', '123\n')
'123\n'

Is there any explanation for this? If I'm skipping something when
using a replacement function with re.sub, please let me know.

Best regards,
Javier
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Download Microsoft C/C++ compiler for use with Python 2.6/2.7 ASAP

2010-07-06 Thread Thomas Jollans
On 07/06/2010 06:49 PM, sturlamolden wrote:
> On 6 Jul, 18:21, Thomas Jollans  wrote:
> 
>> mingw gcc should work for building C++ extensions if it also works for C
>> extensions.
> 
> No, it uses an incompatible statically linked C++ runtime. We need to
> use msvcp90.dll with Python 2.6/2.7.

Python is written in C. How does the C++ runtime enter into it?


> 
>> As for amd64 - I do not know if there is a mingw64 release for windows
>> already. If there isn't, there should be ;-)
> 
> There is. But it does not have an import library for msvcr90.dll. It's
> omitted from mingw-w64. Also libpython26.a is missing from Python on
> Windows 64.
> 
> 
>> Also, VS2010 should work as well - doesn't it?
> 
> The problem with Microsoft's compilers is that they just let you pick
> between two CRTs (single- or multi-threaded). We need to specify the
> version number as well.
> 
> So no, VS2010 will not work. (At least not without some ugly hacks.)

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


Re: The real problem with Python 3 - no business case for conversion (was "I strongly dislike Python 3")

2010-07-06 Thread Terry Reedy

On 7/6/2010 11:19 AM, Giampaolo Rodolà wrote:

2010/7/6 David Cournapeau:

Or is there no change at the C level?  That would make things easy.


There are quite a few, but outside of the big pain point of
strings/byte/unicode which is present at python level as well, a lot
of the issues are not so big (and even simpler to deal with). For
example, although numpy took time to port (and is still experimental
in nature), it took me a couple of hours to get a basic scipy working
(numpy uses a lot of C api dark corners, whereas scipy is much more
straightforward in its usage of the C API).




As for this aspect, I made a port as such (C extension) for psutil,
and it hasn't been too difficult, I must admit.

For those interested here is a detailed explanation of all the steps I
faced, along with revision changes:
http://code.google.com/p/psutil/issues/detail?id=75&can=1&q=python%203&colspec=ID%20Summary%20Type%20Opsys%20Status%20Milestone%20Opened%20Owner%20Progress#c9


That post refers to
docs.python.org / dev/3.0/howto/cporting.html
[without added space] but that is currently 404 missing.

--
Terry Jan Reedy


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


Re: What is the name of the name space I am in?

2010-07-06 Thread Anthra Norell

Gregory Ewing wrote:

On 07/05/2010 11:07 AM, Anthra Norell wrote:

I try to use "new.new.classobj (name, baseclass, dict)" and have no 
clue

what the "dict" of the current name space is.


Are you sure that's what you really want to know? The
'dict' argument to classobj() defines the attributes
that you want the new class to have. It's not meant
to be the namespace in which the code creating the
class is executing.

No indeed I'm not sure. The doc explains the argument "dict" as "name 
space", a term I associated with the enclosing module's name space, 
because it is also visible from inside enclosed blocks.
 But how right you are! Passing locals () works fine inasmuch as 
the constructor doesn't complain. Looking subsequently at the class 
attributes with dir (c) or c.__dict__keys (), however, dumps the entire 
inventory of the module in addition to the attributes of the base class. 
Clearly, that can't be right.
 So, thanks to you! I very much appreciate the guidance along the 
right path.


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


Re: Plot problem.. ?? No sign at all

2010-07-06 Thread Ritchy lelis
On 6 jul, 17:29, Alan G Isaac  wrote:
> On 7/6/2010 12:11 PM, Ritchy lelis wrote:
>
> > My intention with de for loop was to iterate each point of the arrays
> > Vi and Vref at the math calculations. The V0 it's the result of the
> > math expressions between the Vi and Vref. I can't just create one V0
> > by a function set by parametters (i don't see how).
>
> Unfortunately I cannot make sense of the code you posted.
> Provide a detailed description in words (or psuedocode)
> of what you are trying to accomplish.  Be very careful
> and detailed is you want a useful response.
>
> Alan Isaac

hummm...

ok, i will try to make that detailed description. Maybe i have not
been so clear because my inglish suck's :D
However i have a tutorial and another document that my teacher gave
me, i could send you it if you allowed me. It's the 2 best document's
i've seen about ADC.

Ritchy

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


Re: SMTPHandler and Unicode

2010-07-06 Thread Vinay Sajip
norbert  gmail.com> writes:

> 
> crash with a UnicodeError. I can't see any workaround, except by
> subclassing SMTPHandler's emit method to be unicode-aware or at least
> URF-8 aware.
> 


Well, you could use an approach like the one suggested here:

http://plumberjack.blogspot.com/2010/07/using-custom-formatter-to-deal-with.html





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


Re: re.sub unexpected behaviour

2010-07-06 Thread Thomas Jollans
On 07/06/2010 07:10 PM, Javier Collado wrote:
> Hello,
> 
> Let's imagine that we have a simple function that generates a
> replacement for a regular expression:
> 
> def process(match):
> return match.string
> 
> If we use that simple function with re.sub using a simple pattern and
> a string we get the expected output:
> re.sub('123', process, '123')
> '123'
> 
> However, if the string passed to re.sub contains a trailing new line
> character, then we get an extra new line character unexpectedly:
> re.sub(r'123', process, '123\n')
> '123\n\n'

process returns match.string, which is, according to the docs:

"""The string passed to match() or search()"""

You passed "123\n" to sub(), which may not be explicitly listed here,
but there's no difference. Process correctly returns "123\n", which is
inserted. Let me demonstrate again with a longer string:

>>> import re
>>> def process(match):
... return match.string
...
>>> re.sub(r'\d+', process, "start,123,end")
'start,start,123,end,end'
>>>


> 
> If we try to get the same result using a replacement string, instead
> of a function, the strange behaviour cannot be reproduced:
> re.sub(r'123', '123', '123')
> '123'
> 
> re.sub('123', '123', '123\n')
> '123\n'

Again, the behaviour is correct: you're not asking for "whatever was
passed to sub()", but for '123', and that's what you're getting.

> 
> Is there any explanation for this? If I'm skipping something when
> using a replacement function with re.sub, please let me know.

What you want is grouping:

>>> def process(match):
... return "<<" + match.group(1) + ">>"
...
>>> re.sub(r'(\d+)', process, "start,123,end")
'start,<<123>>,end'
>>>

or better, without a function:

>>> re.sub(r'(\d+)', r'<<\1>>', "start,123,end")
'start,<<123>>,end'
>>>

Cheers,
Thomas

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


Re: re.sub unexpected behaviour

2010-07-06 Thread Steven D'Aprano
On Tue, 06 Jul 2010 19:10:17 +0200, Javier Collado wrote:

> Hello,
> 
> Let's imagine that we have a simple function that generates a
> replacement for a regular expression:
> 
> def process(match):
> return match.string
> 
> If we use that simple function with re.sub using a simple pattern and a
> string we get the expected output:
> re.sub('123', process, '123')
> '123'
> 
> However, if the string passed to re.sub contains a trailing new line
> character, then we get an extra new line character unexpectedly:
> re.sub(r'123', process, '123\n')
> '123\n\n'

I don't know why you say it is unexpected. The regex "123" matched the 
first three characters of "123\n". Those three characters are replaced by 
a copy of the string you are searching "123\n", which gives "123\n\n" 
exactly as expected.

Perhaps these examples might help:

>>> re.sub('W', process, 'Hello World')
'Hello Hello Worldorld'
>>> re.sub('o', process, 'Hello World')
'HellHello World WHello Worldrld'


Here's a simplified pure-Python equivalent of what you are doing:

def replace_with_match_string(target, s):
n = s.find(target)
if n != -1:
s = s[:n] + s + s[n+len(target):]
return s



> If we try to get the same result using a replacement string, instead of
> a function, the strange behaviour cannot be reproduced: re.sub(r'123',
> '123', '123')
> '123'
> 
> re.sub('123', '123', '123\n')
> '123\n'

The regex "123" matches the first three characters of "123\n", which is 
then replaced by "123", giving "123\n", exactly as expected.

>>> re.sub("o", "123", "Hello World")
'Hell123 W123rld'




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


Re: The real problem with Python 3 - no business case for conversion (was "I strongly dislike Python 3")

2010-07-06 Thread Thomas Jollans
On 07/06/2010 07:17 PM, Terry Reedy wrote:
> docs.python.org / dev/3.0/howto/cporting.html

http://docs.python.org/py3k/howto/cporting.html
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Download Microsoft C/C++ compiler for use with Python 2.6/2.7 ASAP

2010-07-06 Thread sturlamolden
On 6 Jul, 19:09, Thomas Jollans  wrote:

> Okay, you need to be careful with FILE*s. But malloc and free? You'd
> normally only alloc & free something within the same module, using the
> same functions (ie not mixing PyMem_Malloc and malloc), would you not?

You have to be sure PyMem_Malloc is not an preprocessor alias for
malloc (I haven't chaecked).

In general, CRT objects cannot be shared across CRT boundaries.

Also remember the C and C++ standard libraries interact. g++ from
links statically with an incompatible C++ standard library (read: it
will segfault, it's just a question of when).


> Coming from a system where I can generally rely on the system gcc to
> work for everything, I may be a bit naïve wrt certain questions ;-)

On sane operating systems you generally have one version of libc
installed.

Windows did this too (msvcrt.dll) up to the VS2003 release, which came
with msvcr71.dll in addition. Since then, M$ (pronounced Megadollar
Corp.) have published msvcr80.dll, msvcr90.dll, and msvcr100.dll (and
corresponding C++ versions) to annoy C and C++ developers into
converting to C# .NET. (And yes, programs using third-party DLL and
OCX components become unstable from this. You have to check each DLL/
OCX you use, and each DLL used by each DLL, etc. How fun...)


















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


Re: Download Microsoft C/C++ compiler for use with Python 2.6/2.7 ASAP

2010-07-06 Thread sturlamolden
On 6 Jul, 19:11, Thomas Jollans  wrote:

> Python is written in C. How does the C++ runtime enter into it?

The C and C++ runtimes interact (e.g. stdlib.h and ), malloc
and new, etc. With g++ you have a C++ standard library compiled
against msvcrt.dll, whereas Python is using msvcr90.dll.

We can use the C++ runtime msvcp90.dll used by VC++ 2008, but this DLL
is binary incompatible with g++ (GNU uses a different ABI for C++).


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


Re: Download Microsoft C/C++ compiler for use with Python 2.6/2.7 ASAP

2010-07-06 Thread Christian Heimes
>> You need unofficial version of MinGW with gcc 4.x for several C++
>> extension like PyLucene's JCC. Some project like pywin32 don't work with
>> MinGW, too.
> 
> aha - why is that?
> 
> But - if you write code that builds with [whatever gcc version you
> have], the compiler Python is built with shouldn't matter, should it?

Unless I'm mistaken, official MinGW32 packages still have GCC 3.x. Some
projects like JCC need recent C++ compilers. MinGW doesn't provide some
features that pywin32 requires.

The compiler must create ABI compatible object files and the linker
needs to support the latest CRT. Three years ago it took several months
until MinGW supported the 9.0 CRT.

> Okay, you need to be careful with FILE*s. But malloc and free? You'd
> normally only alloc & free something within the same module, using the
> same functions (ie not mixing PyMem_Malloc and malloc), would you not?
> 
> You have to code quite defensively, true. But, IF you keep all
> non-Python data structures local to your module, you should be fine?

You must be carefully with functions like PyFile_FromFile(), too. If you
expose the FILE* from the alien CRT to Python somehow you can get into
trouble. Lukely PyFile_FromFile() works around most issues but it's
still problematic. These kind of SEGFAULTs are hard to debug, too.

> Coming from a system where I can generally rely on the system gcc to
> work for everything, I may be a bit naïve wrt certain questions ;-)
>
> PS: Windows CPython programming scares me.

Yeah, it's a pain.

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


Re: Download Microsoft C/C++ compiler for use with Python 2.6/2.7 ASAP

2010-07-06 Thread Martin P. Hellwig

On 07/06/10 16:50, sturlamolden wrote:


Just a little reminder:

Microsoft has withdrawn VS2008 in favor of VS2010. The express version
is also unavailable for download.>:((


Public download that is, people like me who have a MSDN subscription can 
still download old versions like Visual Studio 2005.


So I would say that there is no particular hurry.
I would think that everyone really serious about MS development with MS 
tools should get an MSDN subscription anyway, it saves you a lot of 
money in the long run.


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


Re: Download Microsoft C/C++ compiler for use with Python 2.6/2.7 ASAP

2010-07-06 Thread Ed Keith
I downloaded the ISO, but it seems to be just a bit too big to fit on a CD!

This seems odd to me, has anyone else had this problem?

  -EdK

Ed Keith
e_...@yahoo.com

Blog: edkeith.blogspot.com


--- On Tue, 7/6/10, sturlamolden  wrote:

> From: sturlamolden 
> Subject: Download Microsoft C/C++ compiler for use with Python 2.6/2.7 ASAP
> To: python-list@python.org
> Date: Tuesday, July 6, 2010, 11:50 AM
> 
> Just a little reminder:
> 
> Microsoft has withdrawn VS2008 in favor of VS2010. The
> express version
> is also unavailable for download. >:((
> 
> We can still get a VC++ 2008 compiler required to build
> extensions for
> the official Python 2.6 and 2.7 binary installers here
> (Windows 7 SDK
> for .NET 3.5 SP1):
> 
> http://www.microsoft.com/downloads/details.aspx?familyid=71DEB800-C591-4F97-A900-BEA146E4FAE1&displaylang=en
> 
> Download today, before it goes away!
> 
> Microsoft has now published a download for Windows 7 SDK
> for .NET 4.
> It has the VC++ 2010 compiler. It can be a matter of days
> before the VC
> ++ 2008 compiler is totally unavailable.
> 
> It is possible to build C and Fortran extensions for
> official Python
> 2.6/2.7 binaries on x86 using mingw. AFAIK, Microsoft's
> compiler is
> required for C++ or amd64 though. (Intel's compiler
> requires VS2008,
> which has now perished.)
> 
> Remember Python on Windows will still require VS2008 for a
> long time.
> Just take a look at the recent Python 3 loath threads.
> 
> -- 
> http://mail.python.org/mailman/listinfo/python-list
> 


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


Re: re.sub unexpected behaviour

2010-07-06 Thread Javier Collado
Thanks for your answers. They helped me to realize that I was
mistakenly using match.string (the whole string) when I should be
using math.group(0) (the whole match).

Best regards,
Javier
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: The real problem with Python 3 - no business case for conversion (was "I strongly dislike Python 3")

2010-07-06 Thread rantingrick
On Jul 6, 12:37 am, Terry Reedy  wrote:

> In his post on this thread, Martin Loewis volunteered to list what he
> knows from psycopg2 if someone else will edit.

Now we are getting somewhere! This is the community spirit i want to
see. You don't have to give much people, every little bit counts. But
for Google's sake we need to work together to get this thing done.
Let's get a list together of 3rd party modules that are "must haves"
and start knocking on doors, evangelizing, air dropping leaflets,
spreading the word, whatever it takes! The revolution is not going to
happen whilst we sleep -- not the Python revolution that is!

Get the lead out c.l.p!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python Embedding Importing relative modules

2010-07-06 Thread Aahz
In article <8f5014f6-9aa8-44e2-afe1-a1175bcdd...@w31g2000yqb.googlegroups.com>,
moerchendiser2k3   wrote:
>
>I have a serious problem I haven't solved yet, hope one of you can
>help me. The first thing is, I embedded Python into my app and I
>execute several scripts in this environment.
>
>The problem is, the scripts don't import modules from their relative
>path. I guess this is related to the sys.path ['',...] and the current
>working directory which is set to the directory of my host
>application.
>
>I could set that path manually, but all the scripts might be stored in
>different locations. So now I try to find a way to handle that. Any
>suggestions?

Set sys.path to include each script's base dir before running it, then
restore after each script.
-- 
Aahz (a...@pythoncraft.com)   <*> http://www.pythoncraft.com/

"If you don't know what your program is supposed to do, you'd better not
start writing it."  --Dijkstra
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python GUI for C program [was: ]

2010-07-06 Thread sturlamolden
On 6 Jul, 13:45, Thomas Jollans  wrote:

> 1. Turn your C program into a library, and write a Python extension

Note that using ctypes, Cython or Boost.Python is much less painful
than using Python's C API directly.

> It might, however, be best to simply write the GUI in C as well, which
> would avoid the overhead of loading Python and isn't all that difficult
> either. If you know C++, check out wxWidgets and Qt4. To stick with
> plain C, have a look at GTK+.

You will hardly notice the overhead of loading Python. (It's not
Java...)

Also a good GUI builder is far more important than language when it
comes to making a GUI. Depending on toolkit my preferences are
wxFormBuilder, Qt Designer, GLADE or MS Visual Studio.

- wxFormBuilder are beginning to be ok for wxPython development
without XRC, finally.

- PyQt has licensing issues, although Qt is LGPL. PySide is still
incomplete.

- GLADE/PyGTK has issues on Windows (e.g. need to supply a GTK+ run-
time).

- Visual Studio can be used for IronPython .NET and native MFC
(pywin32 has MFC bindings).

- tkinter generally sucks (tedious to use, looks bad).





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


Re: Download Microsoft C/C++ compiler for use with Python 2.6/2.7 ASAP

2010-07-06 Thread Stephen Hansen
On 7/6/10 10:52 AM, Ed Keith wrote:
> I downloaded the ISO, but it seems to be just a bit too big to fit on a CD!

The website says its a DVD iso.

-- 

   Stephen Hansen
   ... Also: Ixokai
   ... Mail: me+list/python (AT) ixokai (DOT) io
   ... Blog: http://meh.ixokai.io/



signature.asc
Description: OpenPGP digital signature
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Download Microsoft C/C++ compiler for use with Python 2.6/2.7 ASAP

2010-07-06 Thread sturlamolden
On 6 Jul, 19:52, Ed Keith  wrote:

> This seems odd to me, has anyone else had this problem?

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


Re: Python GUI for C program [was: ]

2010-07-06 Thread rantingrick
On Jul 6, 1:14 pm, sturlamolden  wrote:

> Also a good GUI builder is far more important than language when it
> comes to making a GUI. Depending on toolkit my preferences are
> wxFormBuilder, Qt Designer, GLADE or MS Visual Studio.

Thats only true when using any language EXCEPT Python. With Python,
Python is all you need. Python GUI builders are for pansies.

However when using the redundantly asinine C, C++, and Java... well
your already getting bent over, might as well bring some lubrication
to ease the pain!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Download Microsoft C/C++ compiler for use with Python 2.6/2.7 ASAP

2010-07-06 Thread Robert Kern

On 7/6/10 1:52 PM, Ed Keith wrote:

I downloaded the ISO, but it seems to be just a bit too big to fit on a CD!

This seems odd to me, has anyone else had this problem?


These days, ISOs are destined for DVD-Rs. :-)

There are also utilities for mounting ISOs directly without burning them to a 
physical disk. Here is a decent list:


  http://www.techsupportalert.com/best-free-cd-emulator.htm

--
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 Embedding Importing relative modules

2010-07-06 Thread moerchendiser2k3
>Set sys.path to include each script's base dir before running it, then
>restore after each script.

That works, but doesnt solve the problem.

ScriptA.py has a module in its directory called 'bar.py'
ScriptB.py has a module in its directory called 'bar.py'

Imagine the 'bar.py' modules dont have the same content, so
they are not equal.

Now when the first bar.py is imported, the second import for
a "import bar" imports the first one, because its already
stored in sys.modules.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: A question about the posibility of raise-yield in Python

2010-07-06 Thread Дамјан Георгиевски
>> > I'm writing this as a complete newbie (on the issue), so don't be
>> > surprised if it's the stupidest idea ever.
>>
>> > I was wondering if there was ever a discusision in the python
>> > community on a 'raise-yield' kind-of combined expression. I'd like
>> > to know if it was proposed/rejected/discussed/not-decided yet??
>>
>> Recently (ok, several hours ago) I've come up to Greenlets [1] and it
>> seems they implement exactly what I was asking for, in a C
>> extension!!
>>
>> It's too bad that Python doesn't support this by default and many
>> libraries won't make use of it by default. Gevent [2] for example,
>> has to monkey-patch Python's socket, time.sleep and other modules so
>> that things like urllib work with it.
>>
>> I'll continue to read now.
> 
> Ah, if I had seen your original post I probably could have pointed you
> to some good reading right away.  What you've described is called a
> continuation, and is natively supported by some languages (like
> Scheme).  It's usually not done with exceptions, though.  In Scheme
> it's a special form that looks like an ordinary function call, but you
> can "return" from the call any number of times.

I thought they were called coroutines?

Anyway, here's the Lua implementation of coroutines. It's basically a 
yield but it will return back several frames.

http://lua-users.org/wiki/CoroutinesTutorial


-- 
дамјан ((( http://damjan.softver.org.mk/ )))

Today we create the legacy of tomorrow.

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


Re: Python Embedding Importing relative modules

2010-07-06 Thread Aahz
In article <4a3f0ca7-fef0-4f9c-b265-5370e61ed...@d8g2000yqf.googlegroups.com>,
moerchendiser2k3   wrote:
>Aahz:
>>
>>Set sys.path to include each script's base dir before running it, then
>>restore after each script.
>
>That works, but doesnt solve the problem.
>
>ScriptA.py has a module in its directory called 'bar.py'
>ScriptB.py has a module in its directory called 'bar.py'
>
>Imagine the 'bar.py' modules dont have the same content, so they are
>not equal.
>
>Now when the first bar.py is imported, the second import for a "import
>bar" imports the first one, because its already stored in sys.modules.

Good point, you'll need to save/restore sys.modules, too.  That gets you
90-95% of complete namespace separation; if you need more than that, your
best bet is to use separate processes.  Full-blown namepace isolation is
a *hard* problem, just look at all the past attempts to create secure
Python (and what you're trying to do is roughly equivalent).
-- 
Aahz (a...@pythoncraft.com)   <*> http://www.pythoncraft.com/

"If you don't know what your program is supposed to do, you'd better not
start writing it."  --Dijkstra
-- 
http://mail.python.org/mailman/listinfo/python-list


Recommend a MySQLdb Forum

2010-07-06 Thread Tim Johnson
Greetings:
I would appreciate it if some could recommend a MySQLdb forum.
thanks
tim
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Download Microsoft C/C++ compiler for use with Python 2.6/2.7 ASAP

2010-07-06 Thread sturlamolden
On 6 Jul, 19:46, "Martin P. Hellwig" 
wrote:

> Public download that is, people like me who have a MSDN subscription can
> still download old versions like Visual Studio 2005.

That's nice to know, but I personally don't have an MSDN subscription.
Many scientists don't have access to development tools like VS2008.
Many hobby developers don't have access expensive MSDN subscriptions.
Many don't develop C personally, but just "needs a compiler" to build
an extension with distutils. And for all of us not subscribing to
MSDN, this is the only remaining source.




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


Re: Download Microsoft C/C++ compiler for use with Python 2.6/2.7 ASAP

2010-07-06 Thread David Robinow
On Tue, Jul 6, 2010 at 1:46 PM, Martin P. Hellwig
 wrote:
> Public download that is, people like me who have a MSDN subscription can
> still download old versions like Visual Studio 2005.
>
> So I would say that there is no particular hurry.
> I would think that everyone really serious about MS development with MS
> tools should get an MSDN subscription anyway, it saves you a lot of money in
> the long run.
Amazing!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Download Microsoft C/C++ compiler for use with Python 2.6/2.7 ASAP

2010-07-06 Thread Christian Heimes
> That's nice to know, but I personally don't have an MSDN subscription.
> Many scientists don't have access to development tools like VS2008.
> Many hobby developers don't have access expensive MSDN subscriptions.
> Many don't develop C personally, but just "needs a compiler" to build
> an extension with distutils. And for all of us not subscribing to
> MSDN, this is the only remaining source.

I agree, the situation isn't ideal. I see if I can get in contact with
Microsoft's open source team. Perhaps they can keep the download link to
VS 2008 EE working.

By the way lot's of universities participate in the MSDN Academy
Alliance program. Students, scientists and employees of the university
can get most MSDN packages.

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


Re: Download Microsoft C/C++ compiler for use with Python 2.6/2.7 ASAP

2010-07-06 Thread casevh
On Jul 6, 9:21 am, Thomas Jollans  wrote:
> On 07/06/2010 05:50 PM, sturlamolden wrote:
>
> > It is possible to build C and Fortran extensions for official Python
> > 2.6/2.7 binaries on x86 using mingw. AFAIK, Microsoft's compiler is
> > required for C++ or amd64 though. (Intel's compiler requires VS2008,
> > which has now perished.)
>
> mingw gcc should work for building C++ extensions if it also works for C
> extensions. There's no difference on the binding side - you simply have
> to include everything as extern "C", which I am sure the header does for
> you.
>
> As for amd64 - I do not know if there is a mingw64 release for windows
> already. If there isn't, there should be ;-) But that doesn't really
> change anything: the express edition of Microsoft's VC++ doesn't include
> an amd64 compiler anyway, AFAIK.

The original version of the Windows 7 SDK includes the command line
version of the VS 2008 amd64 compiler. I've used it compile MPIR and
GMPY successfully. The GMPY source includes a text file describing the
build process using the SDK tools.

casevh
>
> Also, VS2010 should work as well - doesn't it?
>
>
>
>
>
> > Remember Python on Windows will still require VS2008 for a long time.
> > Just take a look at the recent Python 3 loath threads.- Hide quoted text -
>
> - Show quoted text -

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


Re: Python Embedding Importing relative modules

2010-07-06 Thread moerchendiser2k3
Good idea. Just one thing I thought about:

Imagine I load them parallel so the GIL might
interrupt the save-process of sys.modules,

[ENSURE GIL]
Load Script
Save sys.modules
[interrupt]
Load Script
Save sys.modules
...

so this might run into several other problems.

But maybe I change that so I load the scripts in a row.
Thanks for your shoulder I can cry on ;)

Bye,

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


Re: Download Microsoft C/C++ compiler for use with Python 2.6/2.7 ASAP

2010-07-06 Thread sturlamolden
On 6 Jul, 21:49, Christian Heimes  wrote:

> I agree, the situation isn't ideal. I see if I can get in contact with
> Microsoft's open source team. Perhaps they can keep the download link to
> VS 2008 EE working.

It seems the MSDN subscription required to get VS 2008 costs one
dollar less than $1200. So it does not fit within everyone's budget.


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


Re: Python as a scripting language. Alternative to bash script?

2010-07-06 Thread member thudfoo
On Tue, Jul 6, 2010 at 6:40 AM, Michael Torrie  wrote:
> On 07/06/2010 04:12 AM, sturlamolden wrote:
>> On 28 Jun, 19:39, Michael Torrie  wrote:
>>
>>> In python I could simply take the output of "ps ax" and use python's
>>> own, superior, cutting routines (using my module):
>>>
>>> (err, stdout, stderr) = runcmd.run( [ 'ps', 'ax' ] )
>>> for x in stdout.split('\n'):
>>>     print x.strip().split()[0]
>>
>> Or you just pass the stdout of one command as stdin to another. That
>> is equivalent of piping with bash.
>
> Consider this contrived example:
>
> tail -f /var/log/messages | grep openvpn
>
> While it's possible to set up pipes and spawn programs in parallel to
> operate on the pipes, in practice it's simpler to tell subprocess.Popen
> to use a shell and then just rely on Bash's very nice syntax for setting
> up the pipeline.  Then just read the final output in python.  If you set
> the stdout descriptor to non-blocking, you could read output as it came.
> --
> http://mail.python.org/mailman/listinfo/python-list
>

Is this a discussion about the pipes module in the std library?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Download Microsoft C/C++ compiler for use with Python 2.6/2.7 ASAP

2010-07-06 Thread sturlamolden
On 6 Jul, 21:52, casevh  wrote:

> On Jul 6, 9:21 am, Thomas Jollans  wrote:
> > But that doesn't really
> > change anything: the express edition of Microsoft's VC++ doesn't include
> > an amd64 compiler anyway, AFAIK.

See here:
http://jenshuebel.wordpress.com/2009/02/12/visual-c-2008-express-edition-and-64-bit-targets/

The express edition can be used as is for x86 though (it might not
have an optimizing compiler). It can also be used for C++, unlike g++
(at least VC++ is safer).


> The original version of the Windows 7 SDK includes the command line
> version of the VS 2008 amd64 compiler.


C:\Program Files\Microsoft SDKs\Windows\v7.0>cl
Microsoft (R) C/C++ Optimizing Compiler Version 15.00.30729.01 for x64
Copyright (C) Microsoft Corporation.  All rights reserved.

usage: cl [ option... ] filename... [ /link linkoption... ]

C:\Program Files\Microsoft SDKs\Windows\v7.0>


Need any more proof? :D


Also note that the Windows 7 SDK can still be used with IDEs, like Qt
Creator, KDEvelop (yes there is a Windows version), Eclipse, Visual
Studio, and even Visual C++ Express (a little PITA for amd64, but
possible too).

I'm still fan of a tiny text editor for typing (Kate from KDE tends to
be my favorite) and a Python script for building, though.



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


Python install has difficulties with accented characters in path

2010-07-06 Thread Pierre Thibault
I am building from the source and installing Python on my machine.

I added these tests failed:

test_doctest
test_httpservers
test_logging

But I moved the Python installation folder on another directory and
the failed tests vanished when I tried again. The difference? The new
directory does not have any accented characters in its name while the
other one was having one.

Should I flag this has a bug?

I am installing Python 2.6.5. I am running OpenSuse 11.2 AMD64.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python Embedding Importing relative modules

2010-07-06 Thread Aahz
In article <33affa14-ded1-4742-a98f-c478df353...@w31g2000yqb.googlegroups.com>,
moerchendiser2k3   wrote:
>
>Imagine I load them parallel so the GIL might interrupt the
>save-process of sys.modules,
>
>[ENSURE GIL]
>Load Script
>Save sys.modules
>[interrupt]
>Load Script
>Save sys.modules
>...
>
>so this might run into several other problems.

Very yes; if you're trying to maintain script independence, you should
either run them sequentially (so you can safely save/restore the
environment) or use processes.
-- 
Aahz (a...@pythoncraft.com)   <*> http://www.pythoncraft.com/

"If you don't know what your program is supposed to do, you'd better not
start writing it."  --Dijkstra
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python Embedding Importing relative modules

2010-07-06 Thread Thomas Jollans
On 07/06/2010 09:11 PM, Aahz wrote:
> In article <4a3f0ca7-fef0-4f9c-b265-5370e61ed...@d8g2000yqf.googlegroups.com>,
> moerchendiser2k3   wrote:
>> Aahz:
>>>
>>> Set sys.path to include each script's base dir before running it, then
>>> restore after each script.
>>
>> That works, but doesnt solve the problem.
>>
>> ScriptA.py has a module in its directory called 'bar.py'
>> ScriptB.py has a module in its directory called 'bar.py'
>>
>> Imagine the 'bar.py' modules dont have the same content, so they are
>> not equal.
>>
>> Now when the first bar.py is imported, the second import for a "import
>> bar" imports the first one, because its already stored in sys.modules.
> 
> Good point, you'll need to save/restore sys.modules, too.  That gets you
> 90-95% of complete namespace separation; if you need more than that, your
> best bet is to use separate processes.  Full-blown namepace isolation is
> a *hard* problem, just look at all the past attempts to create secure
> Python (and what you're trying to do is roughly equivalent).

I believe Python (at least in the 3.x series) supports multiple
interpreter instances per process.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python install has difficulties with accented characters in path

2010-07-06 Thread Thomas Jollans
On 07/06/2010 11:17 PM, Pierre Thibault wrote:
> I am building from the source and installing Python on my machine.
> 
> I added these tests failed:
> 
> test_doctest
> test_httpservers
> test_logging
> 
> But I moved the Python installation folder on another directory and
> the failed tests vanished when I tried again. The difference? The new
> directory does not have any accented characters in its name while the
> other one was having one.
> 
> Should I flag this has a bug?
> 
> I am installing Python 2.6.5. I am running OpenSuse 11.2 AMD64.

Before filing a bug, best test it with Python 2.7 (just released), 3.1,
and, if possible, py3k trunk.

I just tried to reproduce this with a current py3k checkout, where it
worked. Probably not an issue in Python 3.x due to the changed unicode
handling, but it might be a bug that has been fixed since 2.6.











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


Re: delegation pattern via descriptor

2010-07-06 Thread Bruno Desthuilliers
Gregory Ewing a écrit :
> Bruno Desthuilliers wrote:
>> kedra marbun a écrit :
>>
>>> if we limit our discussion to py:
>>> why __{get|set|delete}__ don't receive the 'name' & 'class' from
>>> __{getattribute|{set|del}attr}__
>>> 'name' is the name that is searched
>>
>>
>> While it would have been technically possible, I fail to imagine any use
>> case for this.
> 
> I think he wants to have generic descriptors that are
> shared between multiple attributes, but have them do
> different things based on the attribute name.

I already understood this, but thanks !-)

What I dont understand is what problem it could solve that couldn't be
solved more simply using the either _getattr__ hook or hand-coded
delegation, since such a descriptor would be so tightly coupled to the
host class that it just doesn't make sense writing a descriptor for this.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: A question about the posibility of raise-yield in Python

2010-07-06 Thread Thomas Jollans
On 07/06/2010 08:56 PM, Дамјан Георгиевски wrote:
 I'm writing this as a complete newbie (on the issue), so don't be
 surprised if it's the stupidest idea ever.
>>>
 I was wondering if there was ever a discusision in the python
 community on a 'raise-yield' kind-of combined expression. I'd like
 to know if it was proposed/rejected/discussed/not-decided yet??
>>>
>>> Recently (ok, several hours ago) I've come up to Greenlets [1] and it
>>> seems they implement exactly what I was asking for, in a C
>>> extension!!
>>>
>>> It's too bad that Python doesn't support this by default and many
>>> libraries won't make use of it by default. Gevent [2] for example,
>>> has to monkey-patch Python's socket, time.sleep and other modules so
>>> that things like urllib work with it.
>>>
>>> I'll continue to read now.
>>
>> Ah, if I had seen your original post I probably could have pointed you
>> to some good reading right away.  What you've described is called a
>> continuation, and is natively supported by some languages (like
>> Scheme).  It's usually not done with exceptions, though.  In Scheme
>> it's a special form that looks like an ordinary function call, but you
>> can "return" from the call any number of times.
> 
> I thought they were called coroutines?

The scheme call-with-current-continuation facility is a lot more
powerful than python generator-coroutines or, I expect, than whatever it
is that Lua has.

In Python, you can return to a "yield" expression exactly once, then the
code continues, and the state is lost. In Scheme, you can pass the state
around, save it, and return there as often as you want. Kind of
"go-back-to-this-particular-frame-state" as opposed to
"go-back-into-that-(co)routine"

Everything that you can do with the coroutine facilities in languages
like Python, Ruby, and Lua, Scheme's call/cc allows you to do as well.

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


Re: Python Embedding Importing relative modules

2010-07-06 Thread Aahz
In article ,
Thomas Jollans   wrote:
>On 07/06/2010 09:11 PM, Aahz wrote:
>> In article 
>> <4a3f0ca7-fef0-4f9c-b265-5370e61ed...@d8g2000yqf.googlegroups.com>,
>> moerchendiser2k3   wrote:
>>> Aahz:

 Set sys.path to include each script's base dir before running it, then
 restore after each script.
>>>
>>> That works, but doesnt solve the problem.
>>>
>>> ScriptA.py has a module in its directory called 'bar.py'
>>> ScriptB.py has a module in its directory called 'bar.py'
>>>
>>> Imagine the 'bar.py' modules dont have the same content, so they are
>>> not equal.
>>>
>>> Now when the first bar.py is imported, the second import for a "import
>>> bar" imports the first one, because its already stored in sys.modules.
>> 
>> Good point, you'll need to save/restore sys.modules, too.  That gets you
>> 90-95% of complete namespace separation; if you need more than that, your
>> best bet is to use separate processes.  Full-blown namepace isolation is
>> a *hard* problem, just look at all the past attempts to create secure
>> Python (and what you're trying to do is roughly equivalent).
>
>I believe Python (at least in the 3.x series) supports multiple
>interpreter instances per process.

Perhaps things have changed in 3.x, but although 2.x supposedly supported
multiple interpreter instances per process, the impression I got was that
most people would rather poke their eyes out with a dull stick than try
to make multiple interpreters per process actually work.

Multiple processes are easy, OTOH.
-- 
Aahz (a...@pythoncraft.com)   <*> http://www.pythoncraft.com/

"If you don't know what your program is supposed to do, you'd better not
start writing it."  --Dijkstra
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Download Microsoft C/C++ compiler for use with Python 2.6/2.7 ASAP

2010-07-06 Thread David Cournapeau
On Tue, Jul 6, 2010 at 6:00 PM, Alf P. Steinbach /Usenet
 wrote:
> * sturlamolden, on 06.07.2010 17:50:
>>
>> Just a little reminder:
>>
>> Microsoft has withdrawn VS2008 in favor of VS2010. The express version
>> is also unavailable for download.>:((
>>
>> We can still get a VC++ 2008 compiler required to build extensions for
>> the official Python 2.6 and 2.7 binary installers here (Windows 7 SDK
>> for .NET 3.5 SP1):
>>
>>
>> http://www.microsoft.com/downloads/details.aspx?familyid=71DEB800-C591-4F97-A900-BEA146E4FAE1&displaylang=en
>>
>> Download today, before it goes away!
>>
>> Microsoft has now published a download for Windows 7 SDK for .NET 4.
>> It has the VC++ 2010 compiler. It can be a matter of days before the VC
>> ++ 2008 compiler is totally unavailable.
>>
>> It is possible to build C and Fortran extensions for official Python
>> 2.6/2.7 binaries on x86 using mingw. AFAIK, Microsoft's compiler is
>> required for C++ or amd64 though. (Intel's compiler requires VS2008,
>> which has now perished.)
>>
>> Remember Python on Windows will still require VS2008 for a long time.
>> Just take a look at the recent Python 3 loath threads.
>
> Perhaps this all for the good.
>
> There is no *technical* problem creating a compiler-independent C/C++
> language binding.

It is quite hard, though, or would require changes in the API to be
entirely safe. When I asked the question a few months ago to see if we
could fix those issues once and for all for numpy, the most common
answer I got was to pass all the related functions in a structure:
http://stackoverflow.com/questions/1052491/c-runtime-objects-dll-boundaries.

The problem is not compiler, but really C runtimes. By itself, the
issues are not windows specific (using malloc from one C library and
one free from another one is trouble everywhere), but on windows:
 - multiple C runtimes are *very* common on windows
 - many things which are runtime independent on unix are not on
windows (file descriptor: AFAIK, a file descriptor as returned from
open can be dealt with in any C runtime on unix)
 - the MS standard C library is clearly not a priority: win32 specific
objects can be shared across runtimes, but standard C rarely can.
 - the recent manifest concept (which can improve or worsen the
issues)  is incredibly convoluted, and poorly documented (they expect
you to use MS tool and not to try to understand how it works).

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


Re: Download Microsoft C/C++ compiler for use with Python 2.6/2.7 ASAP

2010-07-06 Thread Thomas Jollans
On 07/07/2010 12:08 AM, David Cournapeau wrote:
> On Tue, Jul 6, 2010 at 6:00 PM, Alf P. Steinbach /Usenet
>  wrote:
>> There is no *technical* problem creating a compiler-independent C/C++
>> language binding.
> 
> It is quite hard, though, or would require changes in the API to be
> entirely safe. When I asked the question a few months ago to see if we
> could fix those issues once and for all for numpy, the most common
> answer I got was to pass all the related functions in a structure:
> http://stackoverflow.com/questions/1052491/c-runtime-objects-dll-boundaries.
> 
> The problem is not compiler, but really C runtimes. By itself, the
> issues are not windows specific (using malloc from one C library and
> one free from another one is trouble everywhere), but on windows:
>  - multiple C runtimes are *very* common on windows

I'm also rather sure that it's pretty much impossible to have multiple C
libraries in one process on UNIX, but it's obviously quite possible on
Windows.

>  - many things which are runtime independent on unix are not on
> windows (file descriptor: AFAIK, a file descriptor as returned from
> open can be dealt with in any C runtime on unix)

Are you telling me that file descriptors (it's a flippin int!) can't be
passed around universally on Windows??

Now Windows programming *really* scares me.

>  - the MS standard C library is clearly not a priority: win32 specific
> objects can be shared across runtimes, but standard C rarely can.

And, as has already been said in this thread, this does not concern the
.net developer, or any developer that sticks to managed code, be it
.net, CPython, or something-else based.

>  - the recent manifest concept (which can improve or worsen the
> issues)  is incredibly convoluted, and poorly documented (they expect
> you to use MS tool and not to try to understand how it works).


Cheers,

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


Re: Download Microsoft C/C++ compiler for use with Python 2.6/2.7 ASAP

2010-07-06 Thread Martin v. Loewis
>>  - many things which are runtime independent on unix are not on
>> windows (file descriptor: AFAIK, a file descriptor as returned from
>> open can be dealt with in any C runtime on unix)
> 
> Are you telling me that file descriptors (it's a flippin int!) can't be
> passed around universally on Windows??

There are really three things of concern here:
a) operating system file handles, of type HANDLE (which is an unsigned
   32-bit value); they are not contiguous, and stdin/stdout/stderr may
   have arbitrary numbers
b) C runtime file handles, of type int. They are contiguous, and
   stdin/stdout/stderr are 0/1/2.
c) C FILE*.

OS handles can be passed around freely within a process; across
processes, they lose their meaning

It's the data of types b) and c) that cause problems: the CRT handle 4
means different things depending on what copy of the CRT is interpreting it.

It's worse with FILE*: passing a FILE* of one CRT to the fread()
implementation of a different CRT will cause a segfault.

> And, as has already been said in this thread, this does not concern the
> .net developer, or any developer that sticks to managed code, be it
> .net, CPython, or something-else based.

Since when is CPython managed code?

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


Re: Download Microsoft C/C++ compiler for use with Python 2.6/2.7 ASAP

2010-07-06 Thread sturlamolden
On 6 Jul, 21:52, casevh  wrote:

> The original version of the Windows 7 SDK includes the command line
> version of the VS 2008 amd64 compiler. I've used it compile MPIR and
> GMPY successfully. The GMPY source includes a text file describing the
> build process using the SDK tools.

It should also be mentioned that the Windows 7 SDK includes
vcbuild.exe, so it can be used to compile Visual Studio 2008 projects
(I'm going to try Python).

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


Re: Download Microsoft C/C++ compiler for use with Python 2.6/2.7 ASAP

2010-07-06 Thread Martin P. Hellwig

On 07/06/10 21:19, sturlamolden wrote:

On 6 Jul, 21:49, Christian Heimes  wrote:


I agree, the situation isn't ideal. I see if I can get in contact with
Microsoft's open source team. Perhaps they can keep the download link to
VS 2008 EE working.


It seems the MSDN subscription required to get VS 2008 costs one
dollar less than $1200. So it does not fit within everyone's budget.


Take in the cost of your operating system, and the ones you want to test 
against, perhaps you also like to use office.
Although I am not a windows developer per se, I do use windows XP, 2000 
2003, 2008, Vista and 7 for testing. I also use office for all those 
clients who think that this is the only format.


1200 USD is actually quite cheap, but then again I didn't pay that 
because I am either always been in an academic license (about 70 EUR a 
year) or like now in a program for businesses who just start up (free 
with my bank as supporting agent). When this 3 year subscription is over 
I fall anyway in the cheaper renewals and if not I am sure that there is 
some other brand new scheme like they did for the last decade.


Anyway, if you want to provide tools for platforms that are closed 
source that means that there are costs for the developer and the client.
Although the cost for MS platforms are reasonable (as a developer and 
you know you way around, that means go a couple of times to those free 
MS events and it is quite likely you get an MSDN subscription for being 
such a good loyal puppy), there are always costs.


If you don't like that better convince your target audience about an 
open source operating system, whichever that may be.


--
mph


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


Help with movie module

2010-07-06 Thread Jose Ángel Quintanar Morales
Hi, I'm sorry by my bad english.

I have a little problem with pygame.movie module when I try work whit him
show this problem

[josean...@qumax reproductor]$ python packbox.py
packbox.py:64: RuntimeWarning: use mixer: No module named mixer
(ImportError: No module named mixer)
  pygame.mixer.quit()
Traceback (most recent call last):
  File "packbox.py", line 98, in 
main()
  File "packbox.py", line 95, in main
publicidad_show(screen)
  File "packbox.py", line 64, in publicidad_show
pygame.mixer.quit()
  File "/usr/lib/python2.6/site-packages/pygame/__init__.py", line 70, in
__getattr__
raise NotImplementedError(MissingPygameModule)
NotImplementedError: mixer module not available
(ImportError: No module named mixer)


anybody help me please, I'm search in the web and I found this email list.

thanks

José angel
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Download Microsoft C/C++ compiler for use with Python 2.6/2.7 ASAP

2010-07-06 Thread sturlamolden
On 7 Jul, 00:41, sturlamolden  wrote:

> It should also be mentioned that the Windows 7 SDK includes
> vcbuild.exe, so it can be used to compile Visual Studio 2008 projects
> (I'm going to try Python).

Not sure why I forgot to mention, but we can (or even should?) use
CMake to generate these project files. We don't need Visual Studio for
that.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Download Microsoft C/C++ compiler for use with Python 2.6/2.7 ASAP

2010-07-06 Thread Thomas Jollans
On 07/07/2010 12:38 AM, Martin v. Loewis wrote:
>>>  - many things which are runtime independent on unix are not on
>>> windows (file descriptor: AFAIK, a file descriptor as returned from
>>> open can be dealt with in any C runtime on unix)
>>
>> Are you telling me that file descriptors (it's a flippin int!) can't be
>> passed around universally on Windows??
> 
> There are really three things of concern here:
> a) operating system file handles, of type HANDLE (which is an unsigned
>32-bit value); they are not contiguous, and stdin/stdout/stderr may
>have arbitrary numbers
> b) C runtime file handles, of type int. They are contiguous, and
>stdin/stdout/stderr are 0/1/2.
> c) C FILE*.
> 
> OS handles can be passed around freely within a process; across
> processes, they lose their meaning
> 
> It's the data of types b) and c) that cause problems: the CRT handle 4
> means different things depending on what copy of the CRT is interpreting it.

Ah, okay. On UNIX systems, of course, a) and b) are identical.

> 
> It's worse with FILE*: passing a FILE* of one CRT to the fread()
> implementation of a different CRT will cause a segfault.
> 
>> And, as has already been said in this thread, this does not concern the
>> .net developer, or any developer that sticks to managed code, be it
>> .net, CPython, or something-else based.
> 
> Since when is CPython managed code?

It's not managed code in the "runs on .net" sense, but in principle, it
is managed, in that garbage collection is managed for you.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Download Microsoft C/C++ compiler for use with Python 2.6/2.7 ASAP

2010-07-06 Thread sturlamolden
On 7 Jul, 01:07, Thomas Jollans  wrote:

> It's not managed code in the "runs on .net" sense, but in principle, it
> is managed, in that garbage collection is managed for you.

I think you are confusing Python and C code.


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


Re: Download Microsoft C/C++ compiler for use with Python 2.6/2.7 ASAP

2010-07-06 Thread Thomas Jollans
On 07/07/2010 01:14 AM, sturlamolden wrote:
> On 7 Jul, 01:07, Thomas Jollans  wrote:
> 
>> It's not managed code in the "runs on .net" sense, but in principle, it
>> is managed, in that garbage collection is managed for you.
> 
> I think you are confusing Python and C code.

Or somebody's confusing something anyway

I meant "CPython based", which, in hindsight, might have not have been
clear from the grammatically obfuscated sentence I posted.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Help with movie module

2010-07-06 Thread Rodrick Brown
Did you try emailing the author of this application?

2010/7/6 Jose Ángel Quintanar Morales 

> Hi, I'm sorry by my bad english.
>
> I have a little problem with pygame.movie module when I try work whit him
> show this problem
>
> [josean...@qumax reproductor]$ python packbox.py
> packbox.py:64: RuntimeWarning: use mixer: No module named mixer
> (ImportError: No module named mixer)
>   pygame.mixer.quit()
> Traceback (most recent call last):
>   File "packbox.py", line 98, in 
> main()
>   File "packbox.py", line 95, in main
> publicidad_show(screen)
>   File "packbox.py", line 64, in publicidad_show
> pygame.mixer.quit()
>   File "/usr/lib/python2.6/site-packages/pygame/__init__.py", line 70, in
> __getattr__
> raise NotImplementedError(MissingPygameModule)
> NotImplementedError: mixer module not available
> (ImportError: No module named mixer)
>
>
> anybody help me please, I'm search in the web and I found this email list.
>
> thanks
>
> José angel
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
>


-- 
[ Rodrick R. Brown ]
http://www.rodrickbrown.com http://www.linkedin.com/in/rodrickbrown
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python as a scripting language. Alternative to bash script?

2010-07-06 Thread Chris Rebert
On Tue, Jul 6, 2010 at 1:35 PM, member thudfoo  wrote:
> On Tue, Jul 6, 2010 at 6:40 AM, Michael Torrie  wrote:
>> On 07/06/2010 04:12 AM, sturlamolden wrote:
>>> On 28 Jun, 19:39, Michael Torrie  wrote:
 In python I could simply take the output of "ps ax" and use python's
 own, superior, cutting routines (using my module):

 (err, stdout, stderr) = runcmd.run( [ 'ps', 'ax' ] )
 for x in stdout.split('\n'):
     print x.strip().split()[0]
>>>
>>> Or you just pass the stdout of one command as stdin to another. That
>>> is equivalent of piping with bash.
>>
>> Consider this contrived example:
>>
>> tail -f /var/log/messages | grep openvpn
>>
>> While it's possible to set up pipes and spawn programs in parallel to
>> operate on the pipes, in practice it's simpler to tell subprocess.Popen
>> to use a shell and then just rely on Bash's very nice syntax for setting
>> up the pipeline.  Then just read the final output in python.  If you set
>> the stdout descriptor to non-blocking, you could read output as it came.
>
> Is this a discussion about the pipes module in the std library?   

No, though that module is not irrelevant to Mr. Torrie's argument.

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


Re: Python install has difficulties with accented characters in path

2010-07-06 Thread Pierre Thibault
On 6 juil, 17:37, Thomas Jollans  wrote:
> Before filing a bug, best test it with Python 2.7 (just released), 3.1,
> and, if possible, py3k trunk.
>
> I just tried to reproduce this with a current py3k checkout, where it
> worked. Probably not an issue in Python 3.x due to the changed unicode
> handling, but it might be a bug that has been fixed since 2.6.

I've tested with the version 2.7 and the issue is gone.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: The real problem with Python 3 - no business case for conversion (was "I strongly dislike Python 3")

2010-07-06 Thread Luis M . González
On Jul 2, 4:07 pm, John Nagle  wrote:
> David Cournapeau  wrote:
> > I think one point which needs to be emphasized more is what does
> > python 3 bring to people. The" what's new in python 3 page" gives
> > the impression that python 3 is about removing cruft. That's a very
> > poor argument to push people to switch.
>
>     That's the real issue, not parentheses on the "print" statement.
> Where's the business case for moving to Python 3?   It's not faster.
> It doesn't do anything you can't do in Python 2.6.  There's no
> "killer app" for it. End of life for Python 2.x is many years away;
> most server Linux distros aren't even shipping with 2.6 yet. How can a
> business justify spending money on conversion to Python 3?
>
>     If Python 3 came with Unladen Swallow, and ran several times
> faster than Python 2.x, there'd be a strong business case for
> conversion.  Especially for large sites with racks of servers
> grinding through slow CPython code.  But it looks like Unladen
> Swallow will be available for 2.6 before it's available for 3.x.
> So that's not a selling point for 3.x.
>
>     Python 3 is a nice cleanup of some legacy syntax issues.  But
> that's just not enough.  Perl 6 is a nice cleanup of Perl 5, and
> look how that went.  Ten years on, it's not even mainstream, let
> alone dominant.
>
>     This has all been said before. See "Python 3.0: What s The Point?"
> from December 2008:
>
> http://jens.mooseyard.com/2008/12/python-30-whats-the-point/
>
>     Not much has changed since then.
>
>     What I'm not seeing is a deployment plan along these lines:
>
>     1.  Identify key modules which must be converted before Python 3
>         can be used in production environments.
>
>     2.  Get those modules converted to Python 3.
>
>     3.  Put together a distribution for the major platforms (at least
>         Linux and Windows) with builds of those modules.  This
>         could be done on PyPi, which is at present is mostly a link
>         farm, not a repository.
>
>     4.  Get some major distros, like Debian and ActiveState, to
>         include Python 3, as "python3", not as the primary Python,
>         so there are no conflicts.  (Debian already has a formal
>         policy to keep Python versions separate.)
>
>     5.  Get at least two major hosting services to put up Python 3.
>
>     6.  Get at least two popular end-user programs (not modules) to
>         support Python 3.
>
>     7.  Publicize some success stories.
>
> Unless the Python 3 enthusiasts get their act together and work much
> harder on providing an easy transition experience, it's not going to
> happen.
>
>                                 John Nagle

What's the problem?
Python 2.xx will he around for a long time. It will be supported and
you can use it for your existing projects for as long a you want.
On the other hand, if you have a new project and you plan to make it
successful and usable for many years to come, you should seriously
consider using Python 3.
-- 
http://mail.python.org/mailman/listinfo/python-list


Argh! Name collision!

2010-07-06 Thread Alf P. Steinbach /Usenet
Donald Knuth once remarked (I think it was him) that what matters for a program 
is the name, and that he'd come up with a really good name, now all he'd had to 
do was figure out what it should be all about.


And so considering Sturla Molden's recent posting about unavailability of MSVC 
9.0 (aka Visual C++ 2008) for creating Python extensions in Windows, and my 
unimaginative reply proposing names like "pni" and "pynacoin" for a compiler 
independent Python native code interface, suddenly, as if out of thin air, or 
perhaps out of fish pudding, the name "pyni" occurred to me.


"pyni"! Pronounced like "tiny"! Yay!

I sat down and made my first Python extension module, following the tutorial in 
the docs. It worked!


But, wait, perhaps some other extension is already named "piny"?

Google.

http://code.google.com/p/pyni/>, "PyNI is [a] config file reader/writer".

Argh!


- Alf

--
blog at http://alfps.wordpress.com>
--
http://mail.python.org/mailman/listinfo/python-list


Re: Argh! Name collision!

2010-07-06 Thread Richard Thomas
On Jul 7, 3:11 am, "Alf P. Steinbach /Usenet"  wrote:
> Donald Knuth once remarked (I think it was him) that what matters for a 
> program
> is the name, and that he'd come up with a really good name, now all he'd had 
> to
> do was figure out what it should be all about.
>
> And so considering Sturla Molden's recent posting about unavailability of MSVC
> 9.0 (aka Visual C++ 2008) for creating Python extensions in Windows, and my
> unimaginative reply proposing names like "pni" and "pynacoin" for a compiler
> independent Python native code interface, suddenly, as if out of thin air, or
> perhaps out of fish pudding, the name "pyni" occurred to me.
>
> "pyni"! Pronounced like "tiny"! Yay!
>
> I sat down and made my first Python extension module, following the tutorial 
> in
> the docs. It worked!
>
> But, wait, perhaps some other extension is already named "piny"?
>
> Google.
>
> http://code.google.com/p/pyni/>, "PyNI is [a] config file reader/writer".
>
> Argh!
>
> - Alf
>
> --
> blog at http://alfps.wordpress.com>

PyNI seems to perform the same function as ConfigParser. I prefer the
pronunciation like tiny to Py-N-I. The latter seems clunky.

On a possibly related note I was disappointed to discover that
Python's QT bindings are called PyQT not QTPy. :-)

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


Re: Argh! Name collision!

2010-07-06 Thread Shashwat Anand
On Wed, Jul 7, 2010 at 8:21 AM, Richard Thomas  wrote:

> On Jul 7, 3:11 am, "Alf P. Steinbach /Usenet"  +use...@gmail.com> wrote:
> > Donald Knuth once remarked (I think it was him) that what matters for a
> program
> > is the name, and that he'd come up with a really good name, now all he'd
> had to
> > do was figure out what it should be all about.
> >
> > And so considering Sturla Molden's recent posting about unavailability of
> MSVC
> > 9.0 (aka Visual C++ 2008) for creating Python extensions in Windows, and
> my
> > unimaginative reply proposing names like "pni" and "pynacoin" for a
> compiler
> > independent Python native code interface, suddenly, as if out of thin
> air, or
> > perhaps out of fish pudding, the name "pyni" occurred to me.
> >
> > "pyni"! Pronounced like "tiny"! Yay!
> >
> > I sat down and made my first Python extension module, following the
> tutorial in
> > the docs. It worked!
> >
> > But, wait, perhaps some other extension is already named "piny"?
> >
> > Google.
> >
> > http://code.google.com/p/pyni/>, "PyNI is [a] config file
> reader/writer".
> >
> > Argh!
> >
> > - Alf
> >
> > --
> > blog at http://alfps.wordpress.com>
>
> PyNI seems to perform the same function as ConfigParser. I prefer the
> pronunciation like tiny to Py-N-I. The latter seems clunky.
>
> On a possibly related note I was disappointed to discover that
> Python's QT bindings are called PyQT not QTPy. :-)
>

Isn't this the standard.
Qt -> PyQt
crypto -> pycrypto
MT -> PyMT
.
and the list goes on and on .. :)

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


Re: Python as a scripting language. Alternative to bash script?

2010-07-06 Thread Chris Rebert
On Tue, Jul 6, 2010 at 6:40 AM, Michael Torrie  wrote:
> On 07/06/2010 04:12 AM, sturlamolden wrote:
>> On 28 Jun, 19:39, Michael Torrie  wrote:
>>> In python I could simply take the output of "ps ax" and use python's
>>> own, superior, cutting routines (using my module):
>>>
>>> (err, stdout, stderr) = runcmd.run( [ 'ps', 'ax' ] )
>>> for x in stdout.split('\n'):
>>>     print x.strip().split()[0]
>>
>> Or you just pass the stdout of one command as stdin to another. That
>> is equivalent of piping with bash.
>
> Consider this contrived example:
>
> tail -f /var/log/messages | grep openvpn
>
> While it's possible to set up pipes and spawn programs in parallel to
> operate on the pipes, in practice it's simpler to tell subprocess.Popen
> to use a shell and then just rely on Bash's very nice syntax for setting
> up the pipeline.

Until there's a Python variable involved that is, unless you want to
overlook all the edge cases or do the escaping all by yourself (and
then pray you did it right).

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


Re: Argh! Name collision!

2010-07-06 Thread Stephen Hansen
On 7/6/10 8:25 PM, Shashwat Anand wrote:
> On Wed, Jul 7, 2010 at 8:21 AM, Richard Thomas  > wrote:
> On a possibly related note I was disappointed to discover that
> Python's QT bindings are called PyQT not QTPy. :-)
> Isn't this the standard.
> Qt -> PyQt
> crypto -> pycrypto
> MT -> PyMT

I think the point is QTPy would be pronounced "cutie pie" :)

-- 

   Stephen Hansen
   ... Also: Ixokai
   ... Mail: me+list/python (AT) ixokai (DOT) io
   ... Blog: http://meh.ixokai.io/



signature.asc
Description: OpenPGP digital signature
-- 
http://mail.python.org/mailman/listinfo/python-list


  1   2   >