Re: Popen Question

2010-11-08 Thread Lawrence D'Oliveiro
In message , Chris Torek wrote:

> ['/bin/sh', '-c', 'echo', '$MYVAR']
> 
> (with arguments expressed as a Python list).  /bin/sh takes the
> string after '-c' as a command, and the remaining argument(s) if
> any are assigned to positional parameters ($0, $1, etc).

Doesn’t work. I don’t know what happens to the extra arguments, but they 
just seem to be ignored if -c is specified.

sh -c 'echo hi'

echoes “hi”, while

sh -c echo hi

just outputs a blank line.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: functions, list, default parameters

2010-11-08 Thread John Ladasky
On Nov 1, 7:30 pm, Lawrence D'Oliveiro  wrote:
> In message <20101021235138.609fe...@geekmail.invalid>, Andreas Waldenburger
> wrote:
>
> > While not very commonly needed, why should a shared default argument be
> > forbidden?
>
> Because it’s safer to disallow it than to allow it.

That's why Java is the way that it is, right?  It tries -- too hard,
some would say -- to "protect" the programmer from making "mistakes."
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why "flat is better than nested"?

2010-11-08 Thread Lawrence D'Oliveiro
In message
, rustom 
wrote:

> If you take zen seriously you dont get it
> If you dont take zen seriously you dont get it
> That -- seriously -- is zen

I don’t get it.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Cross compiling (i386 from amd64) with distutils

2010-11-08 Thread Martin v. Loewis
>> You can solve some of the
>> problems by editing the Makefile which it uses to learn the compiler
>> options from.
> 
> I don't understand this - do you mean I should edit the Makefile in
> the actual distutils package, and somehow use that in my project
> instead of setup.py?

No. A python *installation* has a Makefile, in config/Makefile. If
you want distutils to use different options, you could edit this
Makefile.

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


Re: Why "flat is better than nested"?

2010-11-08 Thread Rustom Mody
On Oct 26, 12:11 am, kj  wrote:
> In  Steve Holden 
>  writes:
>
>
>
> >And everyone taking the Zen too seriously should remember that it was
> >written by Tim Peters one night during the commercial breaks between
> >rounds of wrestling on television. So while it can give useful guidance,
> >it's nether prescriptive nor a bible ...
>
> Well, it's pretty *enshrined*, wouldn't you say?  After all, it is
> part of the standard distribution, has an easy-to-remember invocation,
> etc.  *Someone* must have taken it seriously enough to go through
> all this bother.  If it is as trivial as you suggest (and for all
> I know you're absolutely right), then let's knock it off its pedestal
> once and for all, and remove it from the standard distribution.
>
> ~kj

If you take zen seriously you dont get it
If you dont take zen seriously you dont get it
That -- seriously -- is zen
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Deditor 0.2.2

2010-11-08 Thread Trevor J. Christensen
I really like that editor!  Great work!!  Great ideas!!

On Sat, 2010-11-06 at 06:06 -0700, Kruptein wrote:
> Hey,
> 
> I released version 0.2.2 of my pythonic text-editor  Deditor.
> It adds the use of projects, a project is a set of files which you can
> open all at once to make development much faster and easier.
> 
> For more information visit launchpad: http://launchpad.net/deditor
> 
> I also uploaded a video to introduce you to deditor:
> http://www.youtube.com/watch?v=hS8xBu-39VI
> (note: youtube is still processing the file so you might have to wait
> a bit to see it)


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


suds: how to set proxy?

2010-11-08 Thread Johann Spies
According to the suds documentation I can set the proxy setting like this:

d = dict(http='host:80', https='host:443', ...)
client.set_options(proxy=d)

My problem is that you can only do that after 'client' was initiated like this:

client = Client(url)

And I need the proxy to reach the url.

I have tried the following ending in a SYN_SENT each time - ignoring
the proxy settings:

proxy = dict(http='proxy.sun.ac.za:3128', https='proxy.sun.ac.za:3128')

url = 'url_of_wdsl'
t = HttpAuthenticated()
client = Client(url, proxy = proxy, transport = t,
username='myusername', password='pw')

or

url = 'url_of_wdsl'
t = HttpAuthenticated()
client = Client(url, transport = t, username='myusername', password='pw')
client.set_options(proxy=proxy)

So how do I get suds to respect the proxy setting?

Regards
Johann
-- 
 May grace and peace be yours in abundance through the full knowledge
of God and of Jesus our Lord!  His divine power has given us
everything we need for life and godliness through the full knowledge
of the one who called us by his own glory and excellence.
                                                    2 Pet. 1:2b,3a
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Cross compiling (i386 from amd64) with distutils

2010-11-08 Thread Jason
On Nov 8, 4:16 pm, "Martin v. Loewis"  wrote:
> No. A python *installation* has a Makefile, in config/Makefile. If
> you want distutils to use different options, you could edit this
> Makefile.

Oh, I see what you mean. But then it would affect *everything* I build
on that machine, so I'll stick with the "separate 32-bit installation"
approach.

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


Re: Popen Question

2010-11-08 Thread Mark Wooding
Lawrence D'Oliveiro  writes:

> In message , Chris Torek wrote:
>
> > ['/bin/sh', '-c', 'echo', '$MYVAR']
> > 
> > (with arguments expressed as a Python list).  /bin/sh takes the
> > string after '-c' as a command, and the remaining argument(s) if
> > any are assigned to positional parameters ($0, $1, etc).
>
> Doesn’t work.

What doesn't work?  You were being given an explanation, not a solution.

> I don’t know what happens to the extra arguments, but they just seem
> to be ignored if -c is specified.

The argument to -c is taken as a shell script; the remaining arguments
are made available as positional parameters to the script as usual (only
starting with $0 rather than $1, for some unknown reason).

-- [mdw]
-- 
http://mail.python.org/mailman/listinfo/python-list


YAMI4 v. 1.2.0 released

2010-11-08 Thread Maciej Sobczak
Hello,

I am pleased to announce that the new version of YAMI4, 1.2.0, has
been just released and is available for download:

http://www.inspirel.com/yami4/

The most important addition for Python programmers is the Python 2.5+
module that complements the already existing Python 3.x library.
Thanks to this, both branches of the language are now properly
supported.

The following functional improvements were added in all modules:

- Keepalive option for TCP/IP.

- Propagation of events related to connection management.

- Ability to customize the management of slow (overflowing) receivers
in the publish-subscribe scenario.

Please see the changelog.txt file for the detailed list of
improvements.

--
Maciej Sobczak * http://www.inspirel.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Python 2.7

2010-11-08 Thread Antonio de Haro Millan
I can not install "*Python Imaging Library 1.1.7 for Python 2.6* (Windows
only)"
because I have the *Python 2.7. *A solution please...

___
Antonio de Haro Millan
www.de-haro.es
Tf.34.639.972.872
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python 2.7

2010-11-08 Thread Felipe Bastos Nunes
Install the python 2.6.x :-)

2010/11/8, Antonio de Haro Millan :
> I can not install "*Python Imaging Library 1.1.7 for Python 2.6* (Windows
> only)"
> because I have the *Python 2.7. *A solution please...
>
> ___
> Antonio de Haro Millan
> www.de-haro.es
> Tf.34.639.972.872
>


-- 
Felipe Bastos Nunes
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Deditor 0.2.2

2010-11-08 Thread TheSeeker
On Nov 6, 7:06 am, Kruptein  wrote:
> Hey,
>
> I released version 0.2.2 of my pythonic text-editor  Deditor.
> It adds the use of projects, a project is a set of files which you can
> open all at once to make development much faster and easier.
>
> For more information visit launchpad:http://launchpad.net/deditor
>
> I also uploaded a video to introduce you to 
> deditor:http://www.youtube.com/watch?v=hS8xBu-39VI
> (note: youtube is still processing the file so you might have to wait
> a bit to see it)

Hi,
I might have missed this, but it seems deditor requires Python above
2.5?

It would be nice to mention the requirements on the home page
somewhere.

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


Re: Python 2.7

2010-11-08 Thread brf256
use python 2.6 :]

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


Re: Python 2.7

2010-11-08 Thread David Robinow
On Mon, Nov 8, 2010 at 6:22 AM, Antonio de Haro Millan
 wrote:
> I can not install "Python Imaging Library 1.1.7 for Python 2.6 (Windows
> only)"
> because I have the Python 2.7. A solution please...
download http://effbot.org/media/downloads/PIL-1.1.7/win32-py2.7.exe
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: functions, list, default parameters

2010-11-08 Thread Roy Smith
In article ,
 Lawrence D'Oliveiro  wrote:

> In message <20101021235138.609fe...@geekmail.invalid>, Andreas Waldenburger 
> wrote:
> 
> > While not very commonly needed, why should a shared default argument be
> > forbidden?
> 
> Because it’s safer to disallow it than to allow it.

The best way to deal with this is to have some kind of knob you can turn 
to enable or disable warnings about these sorts of things.  Could be a 
command-line flag, a stand-alone tool (i.e. pylint), or even something 
in-line (like perl' 'use strict' directive).

Good engineering practice would be use enable "debug mode" during 
testing and review all the warnings to see which ones surprise you.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: A question about yield

2010-11-08 Thread Simon Brunning
On 7 November 2010 18:14, Chris Rebert  wrote:
> On Sun, Nov 7, 2010 at 9:56 AM, chad  wrote:
>> But what happens if the input file is say 250MB? Will all 250MB be
>> loaded into memory at once?
>
> No. As I said, the file will be read from 1 line at a time, on an
> as-needed basis; which is to say, "line-by-line".

IIRC, it's somewhere in between. Python will read the file in blocks.
If only *looks* like it's reading the file line by line.

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


Re: Allowing comments after the line continuation backslash

2010-11-08 Thread Neil Cerutti
On 2010-11-06, Steven D'Aprano  wrote:
>>> styles = [
>>> ("normal",  "image", MainWindow.ColorsNormalList),
>>> ("highlighted", "highlight", MainWindow.ColorsHighlightedList),
>>> ("selected","select",MainWindow.ColorsSelectedList)]
>>
>> Code should be utilitarian rather than ornate, Shaker rather
>> than Victorian.
>
> Perhaps, but lining up the columns in a 3x3 table is hardly
> "ornate". 
>
> I have mixed feelings here. On the one hand, there's no doubt
> in my mind that the extra whitespace and aligned columns make
> the data easier to read for me. On the other hand, I know that
> it is easy to fall into the trap of spending hours carefully
> aligning code that doesn't need to be aligned.

Some sort of comprehension test is probably required to know for
sure, but I doubt the code benefits much at all from the columns.

   styles = [
   ("normal", "image", MainWindow.ColorsNormalList),
   ("highlighted", "highlight", MainWindow.ColorsHighlightedList),
   ("selected", "select", MainWindow.ColorsSelectedList)]

Moreover, I jump the gun early on tables like this.

   styles = [csv.reader(open("styles.csv", newlines=''))]

Maybe too early. ;)

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


Re: Compare source code

2010-11-08 Thread Neil Cerutti
On 2010-11-07, Lawrence D'Oliveiro  wrote:
> In message <8jftftfel...@mid.individual.net>, Neil Cerutti wrote:
>
>> The handsome ':' terminator of if/elif/if statements allows us to
>> omit a newline, conserving vertical space. This improves the
>> readability of certain constructs.
>> 
>> if x: print(x)
>> elif y: print(y)
>> else: print()
>
> I would never do that. ???Conserving vertical space??? seems a
> stupid reason for doing it. In C, I even go the opposite way:
>
> if (x)
>   {
> printf(..., x);
>   }
> else if (y)
>   {
> printf(..., y);
>   }
> else
>   {
> printf(...);
>   } /*if*/

Interesting. I find conserving vertical space to be a big win. I
understand why you'd enforce braces for virtually all code bodies
in C. In C, I'm giving up the most obvious form of expression for
something obviously more robust. In Python, there's no such
trade-off. Forbidding one-line conditional statements in Python
would sacrifice succinctness for nothing.

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


Re: Deditor 0.2.2

2010-11-08 Thread Jean-Michel Pichavant

TheSeeker wrote:

On Nov 6, 7:06 am, Kruptein  wrote:
  

Hey,

I released version 0.2.2 of my pythonic text-editor  Deditor.
It adds the use of projects, a project is a set of files which you can
open all at once to make development much faster and easier.

For more information visit launchpad:http://launchpad.net/deditor

I also uploaded a video to introduce you to 
deditor:http://www.youtube.com/watch?v=hS8xBu-39VI
(note: youtube is still processing the file so you might have to wait
a bit to see it)



Hi,
I might have missed this, but it seems deditor requires Python above
2.5?

It would be nice to mention the requirements on the home page
somewhere.

Thanks,
Duane
  
I already point that on the last release. You should really just 
consider writing the requirements (python & wx).


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


Re: Compare source code

2010-11-08 Thread Grant Edwards
On 2010-11-08, Roy Smith  wrote:
> In article ,
>  Grant Edwards  wrote:
>
>> It's getting really hard to find high-DPI displays on laptops any
>> more.  1600x1200 used to be available on 16" laptop displays, and that
>> looked great.  Even my old 15" thinkpad at 1400x1050 wasn't bad.
>
> My 15" MacBook Pro is 1680 x 1050.

Yep, Apple is one of the holdouts that still offers 16:10 high
resolution displays.  That's the same format/resolution that Lenovo
used to offer before they switched to 16:9.

-- 
Grant Edwards   grant.b.edwardsYow! Boy, am I glad it's
  at   only 1971...
  gmail.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Compare source code

2010-11-08 Thread Steve Holden
On 11/8/2010 8:50 AM, Neil Cerutti wrote:
[...]
> Interesting. I find conserving vertical space to be a big win. I
> understand why you'd enforce braces for virtually all code bodies
> in C. In C, I'm giving up the most obvious form of expression for
> something obviously more robust. In Python, there's no such
> trade-off. Forbidding one-line conditional statements in Python
> would sacrifice succinctness for nothing.

One-line conditional statements aren't "forbidden" or they would not be
grammatically correct. Many stylists (and the PEP 8 style guide) eschew
the single-line form as less readable because the guarded suites (in
this case, simple statements) are not flagged as clearly by indentation
or a trailing colon, and are therefore more likely to be missed by the
casual reader.

regards
 Steve
-- 
Steve Holden   +1 571 484 6266   +1 800 494 3119
PyCon 2011 Atlanta March 9-17   http://us.pycon.org/
See Python Video!   http://python.mirocommunity.org/
Holden Web LLC http://www.holdenweb.com/

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


Question about expression evaluation

2010-11-08 Thread Scott Gould
Hi folks,

This is a head-scratcher to me. I occasionally get this error:

---
  File "/var/www/myproj/account/views.py", line 54, in account
if request.account.is_instructor and request.account.contact and
request.account.contact.relationship.institution_party_number:

AttributeError: 'NoneType' object has no attribute 'relationship'
---

I'm leaving out all the supporting code deliberately. My question is
simple: if python short-circuits evaluation and
"request.account.contact" is None, how is it even getting as far as
"request.account.contact.relationship.institution_party_number"?

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


Re: Question about expression evaluation

2010-11-08 Thread nn
On Nov 8, 11:17 am, Scott Gould  wrote:
> Hi folks,
>
> This is a head-scratcher to me. I occasionally get this error:
>
> ---
>   File "/var/www/myproj/account/views.py", line 54, in account
>     if request.account.is_instructor and request.account.contact and
> request.account.contact.relationship.institution_party_number:
>
> AttributeError: 'NoneType' object has no attribute 'relationship'
> ---
>
> I'm leaving out all the supporting code deliberately. My question is
> simple: if python short-circuits evaluation and
> "request.account.contact" is None, how is it even getting as far as
> "request.account.contact.relationship.institution_party_number"?
>
> Thanks!

Hard to tell without details. Maybe request.account.contact is an
impure property with side effects?

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


Re: Question about expression evaluation

2010-11-08 Thread Jerry Hill
On Mon, Nov 8, 2010 at 11:17 AM, Scott Gould  wrote:
> ---
>  File "/var/www/myproj/account/views.py", line 54, in account
>    if request.account.is_instructor and request.account.contact and
> request.account.contact.relationship.institution_party_number:
>
> AttributeError: 'NoneType' object has no attribute 'relationship'
> ---
>
> I'm leaving out all the supporting code deliberately.

Perhaps request.account is being mutated in another thread?

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


Re: How to get dynamically-created fxn's source?

2010-11-08 Thread gb345
In  Peter Otten <__pete...@web.de> writes:

>gb345 wrote:

>> For a project I'm working on I need a way to retrieve the source
>> code of dynamically generated Python functions.  (These functions
>> are implemented dynamically in order to simulate "partial application"
>> in Python.[1])

>Are you aware of functools.partial?

 from functools import partial
 def f(a, b, c, x, y, z):
>... return a*x + b*y*y + c*z*z*z
>...
 fstar = partial(f, x=1, y=2, z=3)
 fstar(1, 0, 0)
>1
 fstar(0, 1, 0)
>4
 fstar(0, 0, 1)
>27
 fstar.args, fstar.keywords
>((), {'y': 2, 'x': 1, 'z': 3})
 fstar.func
>

I was not aware of functools.partial.  This makes the problem a
lot easier.  Thanks!

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


Re: Question about expression evaluation

2010-11-08 Thread Peter Otten
Scott Gould wrote:

> Hi folks,
> 
> This is a head-scratcher to me. I occasionally get this error:
> 
> ---
>   File "/var/www/myproj/account/views.py", line 54, in account
> if request.account.is_instructor and request.account.contact and
> request.account.contact.relationship.institution_party_number:
> 
> AttributeError: 'NoneType' object has no attribute 'relationship'
> ---
> 
> I'm leaving out all the supporting code deliberately. My question is
> simple: if python short-circuits evaluation and
> "request.account.contact" is None, how is it even getting as far as
> "request.account.contact.relationship.institution_party_number"?

Probably a race condition: contact is set to None after

request.account.contact

is evaluated, but before

request.account.contact.relationship

is evaluated. This may happen in your case because the underlying database 
was modified by a different user (I'm speculating). Here's a simulation:

>>> class Contact:
... relationship = "SUCCESS"
...
>>> class Account(object):
... def __init__(self):
... self._contact = Contact()
... @property
... def contact(self):
... try: return self._contact
... finally: self._contact = None
...
>>> account = Account()
>>> account.contact and account.contact.relationship
Traceback (most recent call last):
  File "", line 1, in 
AttributeError: 'NoneType' object has no attribute 'relationship'

You can avoid the problem with a different coding style:

>>> account = Account()
>>> try:
... print account.contact.relationship
... except AttributeError:
... print "failed"
...
SUCCESS

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


Re: Question about expression evaluation

2010-11-08 Thread Scott Gould
Thanks for the ideas, everyone. It's probably obvious that this is in
a Django context, and while I do have WSGI configured to multi-thread
its processes, there is nothing explicitly shared -- via threading, a
multi-user situation, or otherwise -- about this data. It is entirely
local to the request so I can't figure out how the "contact" object
could change in a single line of code.

But obviously there must be something going on like what you all
suggest. I just can't figure out how. This is the entirety of the
contact-producing code within Account:

@property
def contact(self):
if not hasattr(self, '_contact'):
self._contact = get_contact_for_id(self.profile.id) if 
self.profile
and self.profile.id else None
return self._contact

As you can see, it's essentially read-only so once a self._contact
always a self._contact. (Unless I'm misunderstanding something
fundamental, which as an admitted amateur I could well be!)

On Nov 8, 11:17 am, Scott Gould  wrote:
> Hi folks,
>
> This is a head-scratcher to me. I occasionally get this error:
>
> ---
>   File "/var/www/myproj/account/views.py", line 54, in account
>     if request.account.is_instructor and request.account.contact and
> request.account.contact.relationship.institution_party_number:
>
> AttributeError: 'NoneType' object has no attribute 'relationship'
> ---
>
> I'm leaving out all the supporting code deliberately. My question is
> simple: if python short-circuits evaluation and
> "request.account.contact" is None, how is it even getting as far as
> "request.account.contact.relationship.institution_party_number"?
>
> Thanks!

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


Re: Python 2.7

2010-11-08 Thread Jeff Hobbs
On Nov 8, 3:50 am, Felipe Bastos Nunes 
wrote:
> Install the python 2.6.x :-)
>
> 2010/11/8, Antonio de Haro Millan :
>
> > I can not install "*Python Imaging Library 1.1.7 for Python 2.6* (Windows
> > only)"
> > because I have the *Python 2.7. *A solution please...

If you need Python 2.7, PIL is available via pypm for ActivePython
2.7:
http://code.activestate.com/pypm/pil/

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


Re: Popen Question

2010-11-08 Thread Ian
On Nov 8, 2:43 am, m...@distorted.org.uk (Mark Wooding) wrote:
> > I don’t know what happens to the extra arguments, but they just seem
> > to be ignored if -c is specified.
>
> The argument to -c is taken as a shell script; the remaining arguments
> are made available as positional parameters to the script as usual (only
> starting with $0 rather than $1, for some unknown reason).

Perhaps this example better demonstrates what is going on:

>>> p = subprocess.Popen(['echo one $0 three $1 five', 'two', 'four'],
...  shell=True)
one two three four five

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


Re: Question about expression evaluation

2010-11-08 Thread Peter Otten
Scott Gould wrote:

> Thanks for the ideas, everyone. It's probably obvious that this is in
> a Django context, and while I do have WSGI configured to multi-thread
> its processes, there is nothing explicitly shared -- via threading, a
> multi-user situation, or otherwise -- about this data. It is entirely
> local to the request so I can't figure out how the "contact" object
> could change in a single line of code.
> 
> But obviously there must be something going on like what you all
> suggest. I just can't figure out how. This is the entirety of the
> contact-producing code within Account:
> 
> @property
> def contact(self):
> if not hasattr(self, '_contact'):

If one thread stops this point the _contact attribute is not yet set and 
another thread may trigger the if-suite, too.

> self._contact = 
get_contact_for_id(self.profile.id) if self.profile
> and self.profile.id else None
> return self._contact
> 
> As you can see, it's essentially read-only so once a self._contact
> always a self._contact. (Unless I'm misunderstanding something
> fundamental, which as an admitted amateur I could well be!)

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


Re: Question about expression evaluation

2010-11-08 Thread Peter Otten
Scott Gould wrote:

> Thanks for the ideas, everyone. It's probably obvious that this is in
> a Django context, and while I do have WSGI configured to multi-thread
> its processes, there is nothing explicitly shared -- via threading, a
> multi-user situation, or otherwise -- about this data. It is entirely
> local to the request so I can't figure out how the "contact" object
> could change in a single line of code.
> 
> But obviously there must be something going on like what you all
> suggest. I just can't figure out how. This is the entirety of the
> contact-producing code within Account:
> 
> @property
> def contact(self):
> if not hasattr(self, '_contact'):

If one thread stops at this point the _contact attribute is not yet set and 
another thread may trigger the if-suite, too.

> self._contact = 
get_contact_for_id(self.profile.id) if self.profile
> and self.profile.id else None
> return self._contact
> 
> As you can see, it's essentially read-only so once a self._contact
> always a self._contact. (Unless I'm misunderstanding something
> fundamental, which as an admitted amateur I could well be!)

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


Re: Making ActivePython and Python co-exist on Windows

2010-11-08 Thread Sridhar Ratnakumar

On 2010-11-07, at 12:34 PM, Benjamin Kaplan wrote:

> On Sun, Nov 7, 2010 at 2:25 PM, CWC  wrote:
>> I'm new to Python.  Is it possible to make ActivePython 3.12 and
>> Python 3.12 co-exist on Windows?  I've got an app which requires the
>> former, but I want to stay with the latter, since I'm interested in
>> getting into development.  The main area of collision appears to be
>> the Registry.
>> --
> 
> ActivePython is the same thing as the "normal" Python. They just
> bundle the standard Python 3.1.2 distribution with a couple of extra
> packages in a convenient installer for you.

Yup. And as the documentation details, 
http://docs.activestate.com/activepython/3.1/whatsincluded.html
ActivePython includes PyWin32, Tkinter based on Tk 8.5 ... and PyPM for easy 
package management,
http://code.activestate.com/pypm/

-srid

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


python dpx module

2010-11-08 Thread Brian Krusic
Hi all,

Kind of at a loss here.

trying to debug some old code belonging to some one else and I keep seeing an 
error;

import dpx
no module named dpx

Would any one happen to know how I can get a hold if this elusive dpx Python 
module?

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


Intel C Compiler

2010-11-08 Thread Drake
Hello,

I'm an engineer who has access to the Intel C/C++ compiler (icc), and
for the heck of it I compiled Python2.7 with it.

Unsurprisingly, it compiled fine and functions correctly as far as I
know. However, I was interested to discover that the icc compile
printed literally thousands of various warnings and remarks.

Examples:
Parser/node.c(13): remark #2259: non-pointer conversion from "int" to
"short" may lose significant bits
  n->n_type = type;

Parser/metagrammar.c(156): warning #1418: external function definition
with no prior declaration
  Py_meta_grammar(void)

I was just wondering if anyone from the Python development team uses
icc, or finds any value in the icc compilation info. Similarly, I
would be interested to know if they use icc for benchmarking
comparisons (yes, I know that Intel has been accused of crippling amd
processors so let's not have a flame war please).

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


Re: Intel C Compiler

2010-11-08 Thread Stefan Krah
Drake  wrote:
> I'm an engineer who has access to the Intel C/C++ compiler (icc), and
> for the heck of it I compiled Python2.7 with it.
> 
> Unsurprisingly, it compiled fine and functions correctly as far as I
> know. However, I was interested to discover that the icc compile
> printed literally thousands of various warnings and remarks.
> 
> Examples:
> Parser/node.c(13): remark #2259: non-pointer conversion from "int" to
> "short" may lose significant bits
>   n->n_type = type;


I sometimes use icc. This is one of the most annoying warnings of the
Intel compiler. See:

http://software.intel.com/en-us/forums/showthread.php?t=62308


The problem is that the compiler issues this warning even when there is
no way that significant bits could be lost.

 
Stefan Krah


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


Re: python dpx module

2010-11-08 Thread Robert Kern

On 11/8/10 12:42 PM, Brian Krusic wrote:

Hi all,

Kind of at a loss here.

trying to debug some old code belonging to some one else and I keep seeing an 
error;

import dpx
no module named dpx

Would any one happen to know how I can get a hold if this elusive dpx Python 
module?


You'll have to ask them. I've never heard of it. I assume you have already 
checked Google. It might not be a publicly available module.


--
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


populating a doubly-subscripted array

2010-11-08 Thread ghw
What am I missing?  I am using Python 3.1.2.

ff = [[0.0]*5]*5
ff#(lists 5x5 array of 0.0)
for i in range(5):
  for j in range(3):
ff[i][j] = i*10+j
print (i,j,ff[i][j])  # correctly prints ff array values

ff# try this and see what happens!

result of first print of ff
[[0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0], 
[0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0], 
[0.0, 0.0, 0.0, 0.0, 0.0]]

result of second print of ff
0 0 0
0 1 1
0 2 2
1 0 10
1 1 11
1 2 12
2 0 20
2 1 21
2 2 22
3 0 30
3 1 31
3 2 32
4 0 40
4 1 41
4 2 42

result of third print of ff
[[40, 41, 42, 0.0, 0.0], [40, 41, 42, 0.0, 0.0], 
[40, 41, 42, 0.0, 0.0], [40, 41, 42, 0.0, 0.0], 
[40, 41, 42, 0.0, 0.0]]

Obviously there is something missing in my understanding of 
how array values are populated.  Why do all "rows" get 
populated with the same set of values (40, 41, 42)?  

Thanks for your help,
Hamilton Woods

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


Re: populating a doubly-subscripted array

2010-11-08 Thread Robert Kern

On 11/8/10 3:56 PM, g...@accutrol.com wrote:

What am I missing?  I am using Python 3.1.2.

ff = [[0.0]*5]*5


http://docs.python.org/faq/programming.html#how-do-i-create-a-multidimensional-list

--
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: Popen Question

2010-11-08 Thread Hans Mulder

Ian wrote:

On Nov 8, 2:43 am, m...@distorted.org.uk (Mark Wooding) wrote:

I don’t know what happens to the extra arguments, but they just seem
to be ignored if -c is specified.

The argument to -c is taken as a shell script; the remaining arguments
are made available as positional parameters to the script as usual (only
starting with $0 rather than $1, for some unknown reason).


Perhaps this example better demonstrates what is going on:


p = subprocess.Popen(['echo one $0 three $1 five', 'two', 'four'],

...  shell=True)
one two three four five


Maybe I'm thick, but I still don't understand.  If I run a shell script,
then the name of the script is in $0 and the first positional arguments
is in $1, similar to how Python sets up sys.argv.

But in this case the first positional argument is in $0.  Why is that?

Puzzled,

-- HansM


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


Re: Compare source code

2010-11-08 Thread Michael Torrie
On 11/06/2010 02:27 AM, Seebs wrote:
> On 2010-11-06, Steve Holden  wrote:
>> If someone were to use a text editor which had always historically
>> mangled whitespace I would find myself wondering why they found it
>> necessary to restrict themselves to such stone-age tools.
> 
> I have yet to find an editor that allows me to, well, *edit*, more
> comfortably than vi.

Indeed vi (or in my case, vim) works wonderfully well with python.  I
always use the following vim settings on python files:


set sw=4
set ts=8
set softtabstop=4
set expandtab
set ai

If you set up a conditional thing in your vimrc to enable these settings
for python files, you shouldn't have any more tab problems.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: functions, list, default parameters

2010-11-08 Thread Lawrence D'Oliveiro
In message , Robert Kern 
wrote:

> On 11/4/10 2:07 AM, Lawrence D'Oliveiro wrote:
>
>> In message, Robert
>> Kern wrote:
>>
>>> On 11/2/10 2:12 AM, Lawrence D'Oliveiro wrote:
>>>
 In message, Robert
 Kern wrote:

> "Immutable objects" are just those without an obvious API for
> modifying them.

 They are ones with NO legal language constructs for modifying them.
 Hint: if a selector of some part of such an object were to occur on the
 LHS of an assignment, and that would raise an error, then the object is
 immutable. The interpreter already knows all this.
>>>
>>> Incorrect. RHS method calls can often modify objects.
>>
>> So bloody what?
> 
> So examining LHS "selectors" is not sufficient for determining
> immutability.

Yes it is. All your attempts at counterexamples showed is that it is not 
necessary, not that it is not sufficient.

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


Re: populating a doubly-subscripted array

2010-11-08 Thread Ben Finney
g...@accutrol.com writes:

> What am I missing?

You're missing the fact that Python doesn't have a built-in “array”
type, nor really “subscripts” for them.

> ff = [[0.0]*5]*5

This creates a float object, ‘0.0’. It then creates a list containing
five references to that same object. It then creates a new list
containing five references to the first list. It then binds the name
‘ff’ to the outer list.

ff --+
 |
 V

+---+---+---+---+---+
| . | . | . | . | . |
+-|-+-|-+-|-+-|-+-|-+
  |   |   |   |   |
  +---+---+---+---+---+
  |
  V

+---+---+---+---+---+
| . | . | . | . | . |
+-|-+-|-+-|-+-|-+-|-+
  |   |   |   |   |
  +---+---+---+---+---+
  |
  V

  0.0

> ff#(lists 5x5 array of 0.0)

Nope. It outputs the structure described above, serialised. There is no
distinction in that output between objects that are different but have
the same value, versus the same object displayed several times. Try the
‘is’ (identity) and ‘==’ (equality) operators to see the difference.

> for i in range(5):
>   for j in range(3):
> ff[i][j] = i*10+j

This binds different integer values at some of the references in the
inner list. As the loops continue, the reference used to get at the
inner list is different; but it's always the same list.

> print (i,j,ff[i][j])  # correctly prints ff array values

It prints the values in the inner list immediately after they're
assigned. As the loops continue, the references are re-bound to other
integer values.

> ff# try this and see what happens!

After all the changes, the only references which have actually been
re-bound are the first three items in the inner list.

ff --+
 |
 V

+---+---+---+---+---+
| . | . | . | . | . |
+-|-+-|-+-|-+-|-+-|-+
  |   |   |   |   |
  +---+---+---+---+---+
  |
  V

+---+---+---+---+---+
| . | . | . | . | . |
+-|-+-|-+-|-+-|-+-|-+
  |   |   |   |   |
  |   |   |   +---+---+
  |   |   |   |
  V   V   V   V

  40  41  42  0.0

> result of third print of ff
> [[40, 41, 42, 0.0, 0.0], [40, 41, 42, 0.0, 0.0], 
> [40, 41, 42, 0.0, 0.0], [40, 41, 42, 0.0, 0.0], 
> [40, 41, 42, 0.0, 0.0]]
>
> Obviously there is something missing in my understanding of how array
> values are populated. Why do all "rows" get populated with the same
> set of values (40, 41, 42)?

Because, as the above diagram hopefully clarifies, a list isn't an
array, and its references aren't rows.

If you actually want an array, there isn't a built-in type for it.
Instead, use the standard library ‘array’ module
http://docs.python.org/library/array.html>, or (for more powerful
numeric processing) the types in the third-party NumPy library
http://numpy.scipy.org/>.

-- 
 \“When you go in for a job interview, I think a good thing to |
  `\  ask is if they ever press charges.” —Jack Handey |
_o__)  |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Allowing comments after the line continuation backslash

2010-11-08 Thread Lawrence D'Oliveiro
In message <87fwvdb69k.fsf@metalzone.distorted.org.uk>, Mark Wooding
wrote:

> Lawrence D'Oliveiro  writes:
> 
>> for \
>> Description, Attr, ColorList \
>> in \
>> (
>> ("normal", "image", MainWindow.ColorsNormalList),
>> ("highlighted", "highlight",MainWindow.ColorsHighlightedList),
>> ("selected", "select", MainWindow.ColorsSelectedList),
>> ) \
>> :
>>...
>> #end for
>>
>> Does this make more sense now?
> 
> Ugh, no!
> 
> for descr, attr, colours in [
> ('normal',  'image','Normal'),
> ('highlighted', 'highlight','Highlighted'),
> ('selected','select',   'Selected')]:
>   colourlist = getattr(MainWindow, 'Colors%sList' % colours)
>   ## ...

But then you lose the ability to match up the bracketing symbols. That’s why
I put them on lines by themselves.

> To be honest, there's so much regularity in that table that I'd consider
> generating it from a shorter list.  This would obviously involve
> refactoring something else to eliminate the image/normal asymmetry.  I'd
> also consider making the ColorsMumbleList attribute collection into a
> dictionary.

Maybe you should look at the code in context
, then you can express some more
opinions on how to improve it.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: populating a doubly-subscripted array

2010-11-08 Thread Mark Wooding
g...@accutrol.com writes:

> What am I missing?  I am using Python 3.1.2.
>
> ff = [[0.0]*5]*5
> ff#(lists 5x5 array of 0.0)
> for i in range(5):
>   for j in range(3):
> ff[i][j] = i*10+j
> print (i,j,ff[i][j])  # correctly prints ff array values
>
> ff# try this and see what happens!
>
> result of third print of ff
> [[40, 41, 42, 0.0, 0.0], [40, 41, 42, 0.0, 0.0], 
> [40, 41, 42, 0.0, 0.0], [40, 41, 42, 0.0, 0.0], 
> [40, 41, 42, 0.0, 0.0]]
>
> Obviously there is something missing in my understanding of 
> how array values are populated.  Why do all "rows" get 
> populated with the same set of values (40, 41, 42)?  

[I suppose that the trailing 0.0 entries aren't in question: they're
because the individual rows have width 5 -- from `[0.0]*5' -- but only
the first three items of each is initialzed -- because j iterates only
over range(3).]

So, why do they all come out the same?  The answer is because in fact
there are only two lists involved.  You probably thought that you were
building something like the thing on the left.  In fact, you have the
thing on the right.  (Try to forgive the rubbish ASCII art.)

.--..--.--.--.--.--..--.
| ->|  |  |  |  |  || --.
|__|`--^--^--^--^--'|__| \
|  |.--.--.--.--.--.|  |  \
| ->|  |  |  |  |  || ---. \
|__|`--^--^--^--^--'|__|  \v 
|  |.--.--.--.--.--.|  |   \.--.--.--.--.--.
| ->|  |  |  |  |  || ->|  |  |  |  |  |
|__|`--^--^--^--^--'|__|   /`--^--^--^--^--'
|  |.--.--.--.--.--.|  | /  ^
| ->|  |  |  |  |  || --'  /
|__|`--^--^--^--^--'|__|  /
|  |.--.--.--.--.--.|  | /
| ->|  |  |  |  |  || --'
`--'`--^--^--^--^--'`--'

What [x] * n does is make a list, whose length is n, and all of whose
entries are precisely the value x.  If x itself is a list, then you get
an outer list all of whose entries are the /same/ inner list -- not
copies of it.  So when you appear to change entries in one of the inner
lists, all the other inner lists seem to change too -- because they're
actually the same list.

-- [mdw]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Popen Question

2010-11-08 Thread Lawrence D'Oliveiro
In message <4cd87b24$0$81481$e4fe5...@news.xs4all.nl>, Hans Mulder wrote:

> But in this case the first positional argument is in $0.

That’s what confused me.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Compare source code

2010-11-08 Thread Lawrence D'Oliveiro
In message <87oca1b8ba.fsf@metalzone.distorted.org.uk>, Mark Wooding 
wrote:

> Vertical space is a limiting factor on how much code one can see at a
> time.

One thing that helps me is that Emacs has commands for quickly jumping 
between matching brackets.

Of course, this only works for languages that have brackets.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Compare source code

2010-11-08 Thread Lawrence D'Oliveiro
In message , Grant Edwards wrote:

> IOW, editing a loop or other control structure where you couldn't see both
> ends was problematic. Conserving vertical space avoids that problem.

No it doesn’t. It just moves it to a different, arbitrary, point a few 
percent away—not enough to be worth bothering about.
-- 
http://mail.python.org/mailman/listinfo/python-list


Pythonic/idiomatic?

2010-11-08 Thread Seebs
I have an existing hunk of Makefile code:
CPPFLAGS = "$(filter -D* -I* -i* -U*,$(TARGET_CFLAGS))"
For those not familiar with GNU makeisms, this means "assemble a string
which consists of all the words in $(TARGET_CFLAGS) which start with one
of -D, -I, -i, or -U".  So if you give it
foo -Ibar baz
it'll say
-Ibar

I have a similar situation in a Python context, and I am wondering
whether this is an idiomatic spelling:

' '.join([x for x in target_cflags.split() if re.match('^-[DIiU]', x)])

This appears to do the same thing, but is it an idiomatic use of list
comprehensions, or should I be breaking it out into more bits?

You will note that of course, I have carefully made it a one-liner so I
don't have to worry about indentation*.

-s
[*] Kidding, I just thought this seemed like a pretty clear expression.
-- 
Copyright 2010, all wrongs reversed.  Peter Seebach / usenet-nos...@seebs.net
http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures
http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!
I am not speaking for my employer, although they do rent some of my opinions.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Compare source code

2010-11-08 Thread Lawrence D'Oliveiro
In message , Grant Edwards wrote:

> ... though I'd still prefer a 4:3.

4:3 still seems to be the best. It gives you a landscape A3-proportional 
view (or two A4-proportioned portrait pages side by side), and the little 
bit of space left over at the top or bottom can be used for toolbars, 
titlebars, that sort of thing.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: functions, list, default parameters

2010-11-08 Thread Robert Kern

On 11/8/10 5:24 PM, Lawrence D'Oliveiro wrote:

In message, Robert Kern
wrote:


On 11/4/10 2:07 AM, Lawrence D'Oliveiro wrote:


In message, Robert
Kern wrote:


On 11/2/10 2:12 AM, Lawrence D'Oliveiro wrote:


In message, Robert
Kern wrote:


"Immutable objects" are just those without an obvious API for
modifying them.


They are ones with NO legal language constructs for modifying them.
Hint: if a selector of some part of such an object were to occur on the
LHS of an assignment, and that would raise an error, then the object is
immutable. The interpreter already knows all this.


Incorrect. RHS method calls can often modify objects.


So bloody what?


So examining LHS "selectors" is not sufficient for determining
immutability.


Yes it is. All your attempts at counterexamples showed is that it is not
necessary, not that it is not sufficient.


file objects. hashlib hash objects. weakref.ref objects.

Again, I ask you to point out a piece of code in the interpreter that makes this 
determination. You have repeatedly claimed that they exist, but you have not 
produced a single example.


--
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: Pythonic/idiomatic?

2010-11-08 Thread geremy condra
On Mon, Nov 8, 2010 at 6:32 PM, Seebs  wrote:
> I have an existing hunk of Makefile code:
>        CPPFLAGS = "$(filter -D* -I* -i* -U*,$(TARGET_CFLAGS))"
> For those not familiar with GNU makeisms, this means "assemble a string
> which consists of all the words in $(TARGET_CFLAGS) which start with one
> of -D, -I, -i, or -U".  So if you give it
>        foo -Ibar baz
> it'll say
>        -Ibar
>
> I have a similar situation in a Python context, and I am wondering
> whether this is an idiomatic spelling:
>
>        ' '.join([x for x in target_cflags.split() if re.match('^-[DIiU]', x)])
>
> This appears to do the same thing, but is it an idiomatic use of list
> comprehensions, or should I be breaking it out into more bits?
>
> You will note that of course, I have carefully made it a one-liner so I
> don't have to worry about indentation*.
>
> -s
> [*] Kidding, I just thought this seemed like a pretty clear expression.

I believe this is correct, but I may be wrong. Try and see.

CPPFLAGS = ' '.join(filter(lambda x: x.startswith(('-D', '-I', '-i',
'-U')), cflags))

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


Commercial or Famous Applicattions.?

2010-11-08 Thread Jorge Biquez

Hello all.

Newbie question. Sorry.

Can you mention applications/systems/solutions made with Python that 
are well known and used by public in general? ANd that maybe we do 
not know they are done with Python?


I had a talk with a friend, "PHP-Only-Fan", and he said (you know the 
schema of those talks) that "his" language is better and that "just 
to prove it" there are not too many applications done with Python 
than the ones done with PHP and that "that of course is for 
something". That conversation , that by the way I guess is useless at 
all , makes me thing the idea of ask of applications done with 
Python. Not for debate the argument of that guy BUT to learn what can 
be done with Python. In grphical interface, schemas of jobs, etc. I 
know that there are tons of solutions but would like to hear of 
possible about the ones you have used most or recommend the most.


As an example, I love and have used in the last years MAILMAN, never 
crashed, always works even on my small and old Intel Pentium III with 
a 10GB hard disk and 640KB of RAM. Still working and will work for 
sure (running under FreeBsd by the way).


Thanks in advance for your comments.

Jorge Biquez

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


Re: python test frameworks

2010-11-08 Thread Kev Dwyer
On Sun, 07 Nov 2010 09:01:42 -0800, rustom wrote:

> On Nov 7, 7:09 pm, Kev Dwyer  wrote:
>> On Sun, 07 Nov 2010 10:56:46 +0530, Rustom Mody wrote:
>> > There are a large number of test frameworks in/for python.  Apart
>> > from what comes builtin with python there seems to be nose, staf,
>> > qmtest etc etc.
>>
>> > Is there any central place where these are listed with short
>> > descriptions? 'Test framework' means widely different things in
>> > different contexts. Any explanations/tutorials around?
>>
>> > [Disclaimer: I was educated a couple of decades before the TDD rage]
>>
>> Hello,
>>
>> You could start
>> withhttp://pycheesecake.org/wiki/PythonTestingToolsTaxonomy
>>
>> Kev
> 
> Thanks -- that looks like a comprehensive resource.  But it does not
> have staf
> http://staf.sourceforge.net/current/STAFPython.htm. Is that merely an
> item missing or a category?

I'm afraid I couldn't say with any certainty - I'd throw that question 
at the python testing newsgroup, to whom I am cross-posting in the hope 
that they can help.

Kev

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


Re: Pythonic/idiomatic?

2010-11-08 Thread Ben Finney
Seebs  writes:

> I have a similar situation in a Python context, and I am wondering
> whether this is an idiomatic spelling:
>
>   ' '.join([x for x in target_cflags.split() if re.match('^-[DIiU]', x)])
>
> This appears to do the same thing, but is it an idiomatic use of list
> comprehensions, or should I be breaking it out into more bits?

One thing to know is that, if you want to create a sequence whose only
purpose is to feed to something else and then throw away, a generator
will be cleaner and (probably) better performing than a list.

For this purpose, there is a generator expression syntax
http://docs.python.org/reference/expressions.html#generator-expressions>,
almost identical to a list comprehension except without the enclosing
brackets.

' '.join(x for x in target_cflags.split() if re.match('^-[DIiU]', x))

The regex is less clear for the purpose than I'd prefer. For a simple
“is it a member of this small set”, I'd find it more readable to use a
simple list of the actual strings::

' '.join(
x for x in target_cflags.split()
if x in ['-D', '-I', '-i', '-U'])

or even an actual set::

' '.join(
x for x in target_cflags.split()
if x in {'-D', '-I', '-i', '-U'})

The latter works only in Python with set literals (Python 2.7 or later).

-- 
 \  “I find the whole business of religion profoundly interesting. |
  `\ But it does mystify me that otherwise intelligent people take |
_o__)it seriously.” —Douglas Adams |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Commercial or Famous Applicattions.?

2010-11-08 Thread alex23
Jorge Biquez  wrote:
> Can you mention applications/systems/solutions made with Python that
> are well known and used by public in general? ANd that maybe we do
> not know they are done with Python?

http://python.org/about/success/

This comes up semi-regularly so you might be able to find more
examples in past threads.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Commercial or Famous Applicattions.?

2010-11-08 Thread rantingrick

Commenting on which language is better than "this one" or which
language boasts the most achievements is nothing more than time very
poorly spent. Some people will find Python to be the best thing since
sliced bread (and i am one of them!), however others will find Python
to be the worst language they ever used (thankfully very few!). These
are nothing more than personal opinions and you must leave them at
that level. Because as they say...

"Opinions are like sphincters -- everybody has at least one"

... or something like that i suppose :)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Compare source code

2010-11-08 Thread Seebs
On 2010-11-08, Michael Torrie  wrote:
> On 11/06/2010 02:27 AM, Seebs wrote:
>> I have yet to find an editor that allows me to, well, *edit*, more
>> comfortably than vi.

> Indeed vi (or in my case, vim) works wonderfully well with python.  I
> always use the following vim settings on python files:

Ahh, but I use nvi, not vim.

> If you set up a conditional thing in your vimrc to enable these settings
> for python files, you shouldn't have any more tab problems.

And I don't think I can do that in nvi -- I don't think it has conditionals.

Although.

You've just caused me to remember something which is in context both
amusing and funny.  Which is that I believe nvi has support for some
embedded scripting functionality, at least as an optional build choice.

Which I've never used, on the grounds that I don't know Python...

So that may actually be possible.  I'll look into it, for sure.  Thanks
for nudging my memory.

-s
-- 
Copyright 2010, all wrongs reversed.  Peter Seebach / usenet-nos...@seebs.net
http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures
http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!
I am not speaking for my employer, although they do rent some of my opinions.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Compare source code

2010-11-08 Thread Seebs
On 2010-11-08, Lawrence D'Oliveiro  wrote:
> In message <87oca1b8ba.fsf@metalzone.distorted.org.uk>, Mark Wooding 
> wrote:
>> Vertical space is a limiting factor on how much code one can see at a
>> time.

> One thing that helps me is that Emacs has commands for quickly jumping 
> between matching brackets.

> Of course, this only works for languages that have brackets.

Yes.  One of the things I find frustrating about the Ruby idiom of
preferring do/end for multiline blocks is that you can't fence-match
them.

-s
-- 
Copyright 2010, all wrongs reversed.  Peter Seebach / usenet-nos...@seebs.net
http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures
http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!
I am not speaking for my employer, although they do rent some of my opinions.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Pythonic/idiomatic?

2010-11-08 Thread Seebs
On 2010-11-09, Ben Finney  wrote:
> For this purpose, there is a generator expression syntax
>http://docs.python.org/reference/expressions.html#generator-expressions>,
> almost identical to a list comprehension except without the enclosing
> brackets.
>
> ' '.join(x for x in target_cflags.split() if re.match('^-[DIiU]', x))

Ahh, handy.

I am torn very much on the generator/comprehension syntax, because on the
one hand, I really prefer to have the structure first, but on the other hand,
I can't easily figure out a way to make the syntax work for that.

> The regex is less clear for the purpose than I'd prefer. For a simple
> ???is it a member of this small set???, I'd find it more readable to use a
> simple list of the actual strings::

> ' '.join(
> x for x in target_cflags.split()
> if x in ['-D', '-I', '-i', '-U'])

The regex is intentionally not anchored with a $, because I'm looking
for "starts with", not "is".

> The latter works only in Python with set literals (Python 2.7 or later).

I think we're stuck with backwards compatibility at least as far as 2.4.

No, I'm not kidding.  *sigh*

-s
-- 
Copyright 2010, all wrongs reversed.  Peter Seebach / usenet-nos...@seebs.net
http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures
http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!
I am not speaking for my employer, although they do rent some of my opinions.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Commercial or Famous Applicattions.?

2010-11-08 Thread brf256
Mailman is of course. As well as redhats anaconda installer and google uses 
python internally for many of there "medium sized" projects. Also, calibre, 
gwibber, portage pms, ubuntu software center, YUM pms and many others including 
YouTube. Moral is many big companies do both for products and internally. 

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


Re: Commercial or Famous Applicattions.?

2010-11-08 Thread Seebs
On 2010-11-09, rantingrick  wrote:
> Commenting on which language is better than "this one" or which
> language boasts the most achievements is nothing more than time very
> poorly spent.

This is mostly true, but I don't think it's entirely true.

It is certainly possible for someone else's language choices to
affect me (if I get called in to fix their code).  And as a result, I do
try to do at least a little language advocacy.  Specifically, I try to
steer people away from PHP.  I can live with just about everything else.

-s
-- 
Copyright 2010, all wrongs reversed.  Peter Seebach / usenet-nos...@seebs.net
http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures
http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!
I am not speaking for my employer, although they do rent some of my opinions.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Popen Question

2010-11-08 Thread Ian
On Nov 8, 3:35 pm, Hans Mulder  wrote:
> > Perhaps this example better demonstrates what is going on:
>
>  p = subprocess.Popen(['echo one $0 three $1 five', 'two', 'four'],
> > ...                      shell=True)
> > one two three four five
>
> Maybe I'm thick, but I still don't understand.  If I run a shell script,
> then the name of the script is in $0 and the first positional arguments
> is in $1, similar to how Python sets up sys.argv.
>
> But in this case the first positional argument is in $0.  Why is that?

It's just a quirk in the way the shell handles the -c option.  The
syntax for the shell invocation boils down to something like this:

sh [-c command_string] command_name arg1 arg2 arg3 ...

Without the -c option, sh runs the file indicated by command_name,
setting $0 to command_name, $1 to arg1, $2 to arg2, etc.

With the -c option, it does the same thing; it just runs the
command_string instead of a file pointed to by command_name.  The
latter still conceptually exists as an argument, however, which is why
it still gets stored in $0 instead of $1.

We could argue about whether this approach is correct or not, but it's
what the shell does, and that's not likely to change.

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


Re: Commercial or Famous Applicattions.?

2010-11-08 Thread John Nagle

On 11/8/2010 4:47 PM, brf...@gmail.com wrote:

Mailman is of course. As well as redhats anaconda installer and
google uses python internally for many of there "medium sized"
projects. Also, calibre, gwibber, portage pms, ubuntu software
center, YUM pms and many others including YouTube. Moral is many big
companies do both for products and internally.

Cheers, - Braden Faulkner


   YouTube was rewritten a few years ago, as it was scaled up.
Not sure what it's written in now.

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


Re: Pythonic/idiomatic?

2010-11-08 Thread Ben Finney
Seebs  writes:

> On 2010-11-09, Ben Finney  wrote:
> > The regex is less clear for the purpose than I'd prefer. For a
> > simple ???is it a member of this small set???, I'd find it more
> > readable to use a simple list of the actual strings::
>
> > ' '.join(
> > x for x in target_cflags.split()
> > if x in ['-D', '-I', '-i', '-U'])
>
> The regex is intentionally not anchored with a $, because I'm looking
> for "starts with", not "is".

Ah, okay. Strings have a built-in ‘startswith’ method, but it may be
less convenient for the current case compared to a regex. Here's an
attempt::

' '.join(
x for x in target_cflags.split()
if any(
x.startswith(opt_name)
for opt_name in ['-D', '-I', '-i', '-U']))

I still find that more readable than the version using a regex, but
it's pushing the boundaries of verbosity.

Better would be to use the fact that ‘str.startswith’ can do the same as
above with a tuple of prefix strings::

' '.join(
x for x in target_cflags.split()
if x.startswith(('-D', '-I', '-i', '-U')))

> I think we're stuck with backwards compatibility at least as far as
> 2.4.

Then you don't yet have the ‘any’ and ‘all’ built-in functions, or the
tuple-of-prefixes feature of ‘str.startswith’ either. Bummer.

At which point, the Pythonic thing to do is to convince your
organisation to use a version of Python that's at least officially
supported by the PSF :-)

-- 
 \ “Teach a man to make fire, and he will be warm for a day. Set a |
  `\   man on fire, and he will be warm for the rest of his life.” |
_o__) —John A. Hrastar |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Commercial or Famous Applicattions.?

2010-11-08 Thread Alan Gauld


"Jorge Biquez"  wrote

Can you mention applications/systems/solutions made with Python that 
are well known and used by public in general? ANd that maybe we do 
not know they are done with Python?


The Python web site has an advocacy section, you will find several
success stories  there.

HTH,


--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/



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


Re: Pythonic/idiomatic?

2010-11-08 Thread Tim Chase

On 11/08/10 18:34, Seebs wrote:

On 2010-11-09, Ben Finney  wrote:

 ' '.join(x for x in target_cflags.split() if re.match('^-[DIiU]', x))


Ahh, handy.

...

The latter works only in Python with set literals (Python
2.7 or later).


I think we're stuck with backwards compatibility at least as
far as 2.4.

No, I'm not kidding. *sigh*


I feel your pain :)  At least be glad you don't have to go back 
to 2.3 where Ben's suggested generator-syntax isn't available.



The regex is less clear for the purpose than I'd prefer. For a simple
???is it a member of this small set???, I'd find it more readable to use a
simple list of the actual strings::



 ' '.join(
 x for x in target_cflags.split()
 if x in ['-D', '-I', '-i', '-U'])


The regex is intentionally not anchored with a $, because I'm looking
for "starts with", not "is".


I suppose you could do

  ' '.join(
  x for x in target_cflags.split()
  if x[:2] in ['-D', '-I', '-i', '-U']
  )

or

  ' '.join(
  x for x in target_cflags.split()
  if x.startswith(('-D', '-I', '-i', '-U'))
  )

or even

  ' '.join(
  x for x in target_cflags.split()
  if x[:1] == '-' and x[1:2] in 'DIiU'
  )

-tkc




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


Re: Commercial or Famous Applicattions.?

2010-11-08 Thread rantingrick
On Nov 8, 6:43 pm, Seebs  wrote:
> On 2010-11-09, rantingrick  wrote:

> It is certainly possible for someone else's language choices to
> affect me (if I get called in to fix their code).  And as a result, I do
> try to do at least a little language advocacy.  Specifically, I try to
> steer people away from PHP.  I can live with just about everything else.

True and i agree with your statements however i was alluding more to
the fact that there exist no true winner in the battle of languages.
Just as there exists no winners in the battle of composers. You can
say "Hey this of group of talented fellows really shines above the
rest". However you can NEVER say that "This specific fellow shines
above the group of talented fellows". Can you compare the expansive
depth and melodic genius of Chopin to the explosive (almost vengeful!)
energy of Ludwig van Beethoven? How how about Rachmaninoff to Liszt?
But yea i must agree... PHP... :-P"
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [Tutor] Commercial or Famous Applicattions.?

2010-11-08 Thread Luke Paireepinart
just off the top of my head...
NASA uses it.  Lots of games use Python as their game logic/scripting
language (how many use PHP? probably approaching 0.  LUA is more
popular than Python but Python is much  more popular than PHP).  The
first ever bittorrent client (the official one) was written in Python.
 The game Eve Online is written completely in Python.  Youtube uses
lots of Python, Facebook uses some.  Reddit is written in Python as
well.  Google App Engine has both Python and Java interfaces.  They
don't have a PHP interface; I wonder why?

Lots of jobs at Google (even Java jobs and such) require Python
experience; they don't tend to require PHP experience too.  Because
PHP doesn't really teach you much.  The syntax is not nearly as
elegant.  It's buggy and rough around the edges.  They have gross
workarounds for a lot of things that should be language features.

That's not to say that Python's the only language that is better than
PHP for most things.  Ruby is also a good option.  But these languages
are both infinitely more flexible _right now_ (not based almost solely
for web apps) and better to use for almost everything than PHP.

PHP has its place, and part of the reason it still has that place is
because a lot of web hosts haven't started hosting Python and Ruby
frameworks in a scalable, fast way.  But it's not the frameworks'
fault.

That's just my 2c.

On Mon, Nov 8, 2010 at 6:18 PM, Jorge Biquez  wrote:
> Hello all.
>
> Newbie question. Sorry.
>
> Can you mention applications/systems/solutions made with Python that are
> well known and used by public in general? ANd that maybe we do not know they
> are done with Python?
>
> I had a talk with a friend, "PHP-Only-Fan", and he said (you know the schema
> of those talks) that "his" language is better and that "just to prove it"
> there are not too many applications done with Python than the ones done with
> PHP and that "that of course is for something". That conversation , that by
> the way I guess is useless at all , makes me thing the idea of ask of
> applications done with Python. Not for debate the argument of that guy BUT
> to learn what can be done with Python. In grphical interface, schemas of
> jobs, etc. I know that there are tons of solutions but would like to hear of
> possible about the ones you have used most or recommend the most.
>
> As an example, I love and have used in the last years MAILMAN, never
> crashed, always works even on my small and old Intel Pentium III with a 10GB
> hard disk and 640KB of RAM. Still working and will work for sure (running
> under FreeBsd by the way).
>
> Thanks in advance for your comments.
>
> Jorge Biquez
>
> ___
> Tutor maillist  -  tu...@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Define macro when invoking setup.py

2010-11-08 Thread Jason
I'd like to be able switch between building my C extension with a
certain preprocessor macro defined or not defined. I'm using the
rudimentary distutils setup.py example given here:

http://docs.python.org/extending/building.html

Is there a command line option that distutils.core.setup() will
interpret for me, like the "-D" option for gcc? Or do I need to do
something more complicated? (I had a brief look at the
distutils.command.build_* docs... but they're pretty sparse.)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: http error 301 for urlopen

2010-11-08 Thread Lawrence D'Oliveiro
In message <4cd7987e$0$1674$742ec...@news.sonic.net>, John Nagle wrote:

>It's the New York Times' paywall.  They're trying to set a cookie,
> and will redirect the URL until you store and return the cookie.

And if they find out you’re acessing them from a script, they’ll probably 
try to find a way to block that as well.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Silly newbie question - Carrot character (^)

2010-11-08 Thread Lawrence D'Oliveiro
In message , Dennis Lee 
Bieber wrote:

> On Sat, 6 Nov 2010 10:22:47 -0400, Philip Semanchuk
>  declaimed the following in
> gmane.comp.python.general:
>  
>> Some people might think the language ref> is a fine place to direct
>> newcomers to Python. I don't. It's not awful, but it's dense and
>> unfriendly for those just starting out.
>>
> Have you ever looked at the reference manual for Ada?

Or even worse, the annotated reference. I thought annotations were supposed 
to clarify things; in this case they seemed to have the opposite effect...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: subclassing str

2010-11-08 Thread Lawrence D'Oliveiro
In message <5dlbo.1024$w8@twister2.libero.it>, not1xor1 (Alessandro) 
wrote:

> I'm already using plain functions, but thought that wrapping most of
> them in a str subclass would let me save some time and yield cleaner
> and more manageable code

How exactly does

   a.f(b, c)

save time over

f(a, b, c)

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


Re: Pythonic/idiomatic?

2010-11-08 Thread Seebs
On 2010-11-09, Ben Finney  wrote:
> Seebs  writes:
>> I think we're stuck with backwards compatibility at least as far as
>> 2.4.

> Then you don't yet have the ???any??? and ???all??? built-in functions, or the
> tuple-of-prefixes feature of ???str.startswith??? either. Bummer.

Eww.

> At which point, the Pythonic thing to do is to convince your
> organisation to use a version of Python that's at least officially
> supported by the PSF :-)

Unfortunately, we're selling something to people who will explode if
we tell them to upgrade their RHEL4 systems, so we have to work on those.
(There is some tiny hope that we'll be able to move the baseline to RHEL5
within another two years.)

If it were only a matter of internal use, my job would be orders of
magnitude easier.  (I'm maintaining something that intercepts and wraps
large hunks of the standard C library; if you think dealing with
Python 2.4 is a burden, you ain't seen *nothing* compared to that.)

-s
-- 
Copyright 2010, all wrongs reversed.  Peter Seebach / usenet-nos...@seebs.net
http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures
http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!
I am not speaking for my employer, although they do rent some of my opinions.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Silly newbie question - Carrot character (^)

2010-11-08 Thread Seebs
On 2010-11-09, Lawrence D'Oliveiro  wrote:
> In message , Dennis Lee 
> Bieber wrote:
>> Have you ever looked at the reference manual for Ada?

> Or even worse, the annotated reference. I thought annotations were supposed 
> to clarify things; in this case they seemed to have the opposite effect...

Clearly, you've never seen Schildt's infamous "Annotated ANSI C Standard".

-s
-- 
Copyright 2010, all wrongs reversed.  Peter Seebach / usenet-nos...@seebs.net
http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures
http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!
I am not speaking for my employer, although they do rent some of my opinions.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Define macro when invoking setup.py

2010-11-08 Thread Christian Heimes
Am 09.11.2010 03:09, schrieb Jason:
> I'd like to be able switch between building my C extension with a
> certain preprocessor macro defined or not defined. I'm using the
> rudimentary distutils setup.py example given here:
> 
> http://docs.python.org/extending/building.html
> 
> Is there a command line option that distutils.core.setup() will
> interpret for me, like the "-D" option for gcc? Or do I need to do
> something more complicated? (I had a brief look at the
> distutils.command.build_* docs... but they're pretty sparse.)

You were looking at the wrong manual. Read
http://docs.python.org/distutils/setupscript.html#preprocessor-options

Extension(...,
  define_macros=[('NDEBUG', '1'),
 ('HAVE_STRFTIME', None)],
  undef_macros=['HAVE_FOO', 'HAVE_BAR'])

Note that define_macros requires a list of tuples each having two members.

Christian

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


Re: subclassing str

2010-11-08 Thread rantingrick
On Nov 8, 8:18 pm, Lawrence D'Oliveiro  wrote:
> In message <5dlbo.1024$w8@twister2.libero.it>, not1xor1 (Alessandro)
> wrote:
>
> > I'm already using plain functions, but thought that wrapping most of
> > them in a str subclass would let me save some time and yield cleaner
> > and more manageable code
>
> How exactly does
>
>    a.f(b, c)
>
> save time over
>
>     f(a, b, c)
>
> ?

I think if you'll re-read the OP's statements (specifically the ones
you quoted!) then you will see it's not an issue of time, its an issue
of form and structure. Its an issue of paradigm. The OP wishes to keep
his code as true to OOP as possible and what is wrong with that?
Nothing in my book!

One thing i love about Python is the fact that it can please almost
all the "religious paradigm zealots" with it's multiple choice
approach to programming. However some of the features that OOP
fundamentalists hold dear in their heart are not always achievable in
a clean manner with Python. Yes you could use a function but that is
not the OOP way. Yes you could use UserString but that also seems too
excessive. Ruby allows redefining everything. However this can open a
REAL can of worms in group environment greater than one!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Define macro when invoking setup.py

2010-11-08 Thread Jason
On Nov 9, 10:48 am, Christian Heimes  wrote:
> You were looking at the wrong manual. 
> Readhttp://docs.python.org/distutils/setupscript.html#preprocessor-options
>
> Extension(...,
>           define_macros=[('NDEBUG', '1'),
>                          ('HAVE_STRFTIME', None)],
>           undef_macros=['HAVE_FOO', 'HAVE_BAR'])
>
> Note that define_macros requires a list of tuples each having two members.

But can they be selected or set from the command line, so I can do,
say, "setup.py build -DDEBUG=1"?

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


Re: Define macro when invoking setup.py

2010-11-08 Thread Jason
On Nov 9, 10:56 am, Jason  wrote:
> But can they be selected or set from the command line, so I can do,
> say, "setup.py build -DDEBUG=1"?

Just answered my own question: there's an option for "build_ext" (NOT
"build") that allows this.

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


Re: Is there a way to pring a list object in Python?

2010-11-08 Thread Zeynel
On Oct 31, 2:44 pm, Benjamin Kaplan  wrote:

> Rep() = Rep object
> Rep.all() = Query object
> list(Rep.all()) = List of Rep objects.
> list(Rep.all())[0] = A single Rep object
> list(Rep.all())[0].replist = A list
>

Thanks! This was very helpful.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Commercial or Famous Applicattions.?

2010-11-08 Thread John Bond

On 9/11/2010 12:18 AM, Jorge Biquez wrote:

Hello all.

Newbie question. Sorry.

Can you mention applications/systems/solutions made with Python that 
are well known and used by public in general? ANd that maybe we do not 
know they are done with Python?


...
Jorge Biquez



Keep in mind that Python is also popular in frameworks such as Zope and 
Twisted, and things based on them are based on Python. It's also been 
reasonably popular and well supported on Symbian smartphones.


The Wing IDE is a good example of a commercial Python app on the desktop.

I once got asked to write a list things that I'd make different in the 
technology world if I could, to make it better for everyone. Number 3 
was "everywhere you now see Javascript or PHP, you'd see Python 
instead". If only...


Cheers, JB






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


Re: Commercial or Famous Applicattions.?

2010-11-08 Thread Lawrence D'Oliveiro
In message , John Bond 
wrote:

> I once got asked to write a list things that I'd make different in the
> technology world if I could, to make it better for everyone. Number 3
> was "everywhere you now see Javascript or PHP, you'd see Python
> instead". If only...

PHP yes, JavaScript no.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Commercial or Famous Applicattions.?

2010-11-08 Thread Lawrence D'Oliveiro
In message , Jorge 
Biquez wrote:

> ... there are not too many applications done with Python
> than the ones done with PHP ...

PHP is only used for server-side Web applications, nothing else. Python is 
used for lots of things, on and off the Web.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Silly newbie question - Caret character (^)

2010-11-08 Thread Lawrence D'Oliveiro
In message , Seebs wrote:

> On 2010-11-09, Lawrence D'Oliveiro 
> wrote:
>
>> In message , Dennis
>> Lee Bieber wrote:
>>>
>>> Have you ever looked at the reference manual for Ada?
> 
>> Or even worse, the annotated reference. I thought annotations were
>> supposed to clarify things; in this case they seemed to have the opposite
>> effect...
> 
> Clearly, you've never seen Schildt's infamous "Annotated ANSI C Standard".

There absolutely no chance (or at least no way I can imagine) that anyone 
could annotate a concise language like C up to the level of turgidity of the 
Ada spec.

Hang on, is this Herb Schildt? I bought a couple of his books, back when I 
was trying to get to grips with C++ (I have the edition of “C++ The Complete 
Reference” which proudly proclaims it “Covers the New International Standard 
for C+”). Not as useful as I thought they would be; I ended up referring to 
the libstdc++ sources to clarify things.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Commercial or Famous Applicattions.?

2010-11-08 Thread John Bond

On 9/11/2010 5:54 AM, Lawrence D'Oliveiro wrote:

In message, John Bond
wrote:


I once got asked to write a list things that I'd make different in the
technology world if I could, to make it better for everyone. Number 3
was "everywhere you now see Javascript or PHP, you'd see Python
instead". If only...

PHP yes, JavaScript no.

Without wanting to go too far o/t, why?

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


Re: JavaScript vs Python (was Re: Commercial or Famous Applicattions.?)

2010-11-08 Thread Lawrence D'Oliveiro
In message , John Bond 
wrote:

> On 9/11/2010 5:54 AM, Lawrence D'Oliveiro wrote:
>
>> In message, John Bond
>> wrote:
>>
>>> I once got asked to write a list things that I'd make different in the
>>> technology world if I could, to make it better for everyone. Number 3
>>> was "everywhere you now see Javascript or PHP, you'd see Python
>>> instead". If only...
>>
>> PHP yes, JavaScript no.
>>
> ... why?

Because JavaScript is actually a decent language in its own right.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Silly newbie question - Caret character (^)

2010-11-08 Thread Seebs
On 2010-11-09, Lawrence D'Oliveiro  wrote:
> In message , Seebs wrote:
>> On 2010-11-09, Lawrence D'Oliveiro 
>> wrote:
>>> Or even worse, the annotated reference. I thought annotations were
>>> supposed to clarify things; in this case they seemed to have the opposite
>>> effect...

>> Clearly, you've never seen Schildt's infamous "Annotated ANSI C Standard".

> There absolutely no chance (or at least no way I can imagine) that anyone 
> could annotate a concise language like C up to the level of turgidity of the 
> Ada spec.

Not so much turgidity as being WRONG.  Consistently and often.

> Hang on, is this Herb Schildt? I bought a couple of his books, back when I 
> was trying to get to grips with C++ (I have the edition of ???C++ The 
> Complete 
> Reference??? which proudly proclaims it ???Covers the New International 
> Standard 
> for C+???). Not as useful as I thought they would be; I ended up referring to 
> the libstdc++ sources to clarify things.

Yes, Herb Schildt:
http://www.seebs.net/c/c_tcn4e.html

(I know too little about C++ to criticize is writings about it, but people have
told me they're comparable.)

-s
-- 
Copyright 2010, all wrongs reversed.  Peter Seebach / usenet-nos...@seebs.net
http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures
http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!
I am not speaking for my employer, although they do rent some of my opinions.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Compare source code

2010-11-08 Thread Arnaud Delobelle
Lawrence D'Oliveiro  writes:

> In message <87oca1b8ba.fsf@metalzone.distorted.org.uk>, Mark Wooding 
> wrote:
>
>> Vertical space is a limiting factor on how much code one can see at a
>> time.
>
> One thing that helps me is that Emacs has commands for quickly jumping 
> between matching brackets.
>
> Of course, this only works for languages that have brackets.

python-mode has python-beginning-of-block (C-c C-u) and
python-end-of-block.

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


How to Write a Winning Dissertation

2010-11-08 Thread Karis Lee
Writing a Dissertation requires mastery of research methods for valid
and reliable data collection, availability of all the resources and
perfection of dissertation format, structure and citation styles. This
article offers some guiltiness about how to write a winning
dissertation.

Dissertation Writing certainly is very challenging and time consuming
task. Writing a dissertation requires to set before clear aims and
objectives, define the research approach and methods and achieve the
objectives with valid and reliable results.

Dissertation Writing is the most vital and exigent task for students.
It is in fact a real test of their academic learning, mastery of the
language, and command of expression. For students, dissertation
writing has become an adamant task because of countless reasons. The
most obvious reason why students fail in writing a good dissertation
is that they don’t give due attention to its format, structure and the
citation style.

The proper format of masters dissertation is very important and it
should be consistent throughout to offer a professional look. Mostly,
universities prefer times new roman 12 font size with 1.5” margin on
both sides to allow binding.

The proper structure of any acceptable dissertation is:

1.  Dissertation title

2.  Dissertation acknowledgment

3.  Dissertation abstract

4.  Table of contents

5.  Dissertation Introduction

6.  Dissertation Literature review

7.  Dissertation methodology

8.  Dissertation results

9.  Dissertation conclusion

Some universities prefer to break the dissertation even to six or
seven chapters. For this purpose, the results are presented in fourth
chapter while a critical analysis of these results is presented in
fifth chapter. Then conclusion is offered in chapter six and in the
seventh chapter dissertation recommendation and limitations are
offered.

Finally, the citation style is also very important and if students
fail to follow the given citation style by the university they are
sure to fail and lose their valuable degree. Citation is must for any
academic writing and every reference to any research of the author
must be quoted using the required citation style. For example, in UK
universities Harvard citation style and APA citation style are mostly
used. In order to be familiar with these citation styles, there is a
lot of material on internet and APA citation examples as well as
Harvard citation examples can be found easily.

Besides the format, structure and the citation style, choosing the
proper research methodology is very critical for data collection
process. There are two kinds of data collected for academic research:
primary and the secondary. The secondary data comes from the already
written sources like books, articles, journals and information
available from web. On the other hand, the primary data is collected
personally through interviews, case study, and surveys.

Dissertation Master is the best place to get help for writing a
perfect dissertation as we have hired masters of dissertation writing
who are well aware of the dissertation format, dissertation structure
and the dissertation data collection. Besides, our prices are very
affordable, competitive and we offer attractive discounts. For more
detail, visit http://www.dissertationmaster.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: JavaScript vs Python (was Re: Commercial or Famous Applicattions.?)

2010-11-08 Thread Chris Rebert
On Mon, Nov 8, 2010 at 10:52 PM, Lawrence D'Oliveiro
 wrote:
> In message , John Bond
> wrote:
>
>> On 9/11/2010 5:54 AM, Lawrence D'Oliveiro wrote:
>>> In message, John Bond
>>> wrote:
>>>
 I once got asked to write a list things that I'd make different in the
 technology world if I could, to make it better for everyone. Number 3
 was "everywhere you now see Javascript or PHP, you'd see Python
 instead". If only...
>>>
>>> PHP yes, JavaScript no.
>>>
>> ... why?
>
> Because JavaScript is actually a decent language in its own right.

"The Good Parts" of it anyway.

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


Re: Silly newbie question - Caret character (^)

2010-11-08 Thread Lawrence D'Oliveiro
In message , Seebs wrote:

> Not so much turgidity as being WRONG.  Consistently and often.

Wow. And the guy’s written so many books; how does he get away with it?

> (I know too little about C++ to criticize is writings about it, but people
> have told me they're comparable.)

I suppose seeing that “Covers the New International Standard for C+” should 
have set off my alarm bells...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Pythonic/idiomatic?

2010-11-08 Thread Arnaud Delobelle
Seebs  writes:

> I have an existing hunk of Makefile code:
>   CPPFLAGS = "$(filter -D* -I* -i* -U*,$(TARGET_CFLAGS))"
> For those not familiar with GNU makeisms, this means "assemble a string
> which consists of all the words in $(TARGET_CFLAGS) which start with one
> of -D, -I, -i, or -U".  So if you give it
>   foo -Ibar baz
> it'll say
>   -Ibar
>
> I have a similar situation in a Python context, and I am wondering
> whether this is an idiomatic spelling:
>
>   ' '.join([x for x in target_cflags.split() if re.match('^-[DIiU]', x)])

You can also use the (less favoured) filter:
>>> target_cflags="-ifoo -abar -U -Dbaz".split()
>>> def matches_flags(flags):
... return re.compile("^-[%s]" % flags).match
... 
>>> ' '.join(filter(matches_flags("DiIU"), target_cflags))
'-ifoo -U -Dbaz'

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


Re: How to test if a module exists?

2010-11-08 Thread Lawrence D'Oliveiro
In message , Roy Smith wrote:

> On the other hand, if your module's bug is that it in turn imports some
> other module, which doesn't exist, you'll also get an ImportError.

Does it really matter? Either way, the module is unusable.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: JavaScript vs Python (was Re: Commercial or Famous Applicattions.?)

2010-11-08 Thread Ian Kelly
On Tue, Nov 9, 2010 at 12:30 AM, Chris Rebert  wrote:

> "The Good Parts" of it anyway.
>
>
All hail William Goldman!

Wait, what were talking about?

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