comp.lang.python - 25 new messages in 10 topics - digest
comp.lang.python
http://groups.google.com/group/comp.lang.python?hl=en
comp.lang.python@googlegroups.com
Today's topics:
* What happened to pyjamas? - 7 messages, 6 authors
http://groups.google.com/group/comp.lang.python/t/4480c0898703d657?hl=en
* string to list when the contents is a list - 5 messages, 4 authors
http://groups.google.com/group/comp.lang.python/t/d604be2eee402ced?hl=en
* How secure are temp files created via tempfile.TemporaryFile()? - 2 messages,
2 authors
http://groups.google.com/group/comp.lang.python/t/37552844fb729198?hl=en
* The future of "frozen" types as the number of CPU cores increases - 4
messages, 4 authors
http://groups.google.com/group/comp.lang.python/t/7ef75c20d1be370d?hl=en
* Few questions on SOAP - 2 messages, 2 authors
http://groups.google.com/group/comp.lang.python/t/3808b1054771aa1c?hl=en
* unit testing a routine that sends mail - 1 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/33e5d23bbb8724a3?hl=en
* LISA 2010 CFP - 1 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/71a3126d2a3d79e2?hl=en
* Executing a command from within python using the subprocess module - 1
messages, 1 author
http://groups.google.com/group/comp.lang.python/t/f9d10cb1a8deca55?hl=en
* Why this doesn't work? - 1 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/698b29e4a1bebed4?hl=en
* Interesting talk on Python vs. Ruby and how he would like Python to have
just a bit more syntactic flexibility. - 1 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/9a88c79d4043ba30?hl=en
==============================================================================
TOPIC: What happened to pyjamas?
http://groups.google.com/group/comp.lang.python/t/4480c0898703d657?hl=en
==============================================================================
== 1 of 7 ==
Date: Thurs, Feb 18 2010 10:16 am
From: Daniel Fetchinson
Does anyone know what happened to pyjs.org ?
Cheers,
Daniel
--
Psss, psss, put it down! - http://www.cafepress.com/putitdown
== 2 of 7 ==
Date: Thurs, Feb 18 2010 10:44 am
From: Mark Lawrence
Daniel Fetchinson wrote:
> Does anyone know what happened to pyjs.org ?
>
> Cheers,
> Daniel
>
>
According to google cache it was fine 13/02/2010 and it's down according
to this.
http://downforeveryoneorjustme.com/pyjs.org
HTH.
Mark Lawrence
== 3 of 7 ==
Date: Thurs, Feb 18 2010 10:47 am
From: Daniel Fetchinson
>> Does anyone know what happened to pyjs.org ?
>
> it's working for me.
That's odd, it's unpingable for me from both Europe and the US, ping
says unknown host.
Daniel
--
Psss, psss, put it down! - http://www.cafepress.com/putitdown
== 4 of 7 ==
Date: Thurs, Feb 18 2010 10:58 am
From: "ssteinerX@gmail.com"
Down from here (NH, US).
S
On Feb 18, 2010, at 1:44 PM, Chris Colbert wrote:
>
== 5 of 7 ==
Date: Thurs, Feb 18 2010 12:21 pm
From: Daniele Gondoni
On 18 Feb, 19:58, "sstein...@gmail.com" <sstein...@gmail.com> wrote:
> Down from here (NH, US).
>
> S
>
> On Feb 18, 2010, at 1:44 PM, Chris Colbert wrote:
>
>
>
>
Unreacheable from Italy as well...
== 6 of 7 ==
Date: Thurs, Feb 18 2010 12:45 pm
From: Luis M. González
On Feb 18, 5:21 pm, Daniele Gondoni <daniele.gond...@gmail.com> wrote:
> On 18 Feb, 19:58, "sstein...@gmail.com" <sstein...@gmail.com> wrote:
>
> > Down from here (NH, US).
>
> > S
>
> > On Feb 18, 2010, at 1:44 PM, Chris Colbert wrote:
>
> Unreacheable from Italy as well...
Same here (Buenos Aires, Argentina).
== 7 of 7 ==
Date: Thurs, Feb 18 2010 12:53 pm
From: Irmen de Jong
On 2/18/10 9:45 PM, Luis M. González wrote:
> On Feb 18, 5:21 pm, Daniele Gondoni<daniele.gond...@gmail.com> wrote:
>> On 18 Feb, 19:58, "sstein...@gmail.com"<sstein...@gmail.com> wrote:
>>
>>> Down from here (NH, US).
>>
>>> S
>>
>>> On Feb 18, 2010, at 1:44 PM, Chris Colbert wrote:
>>
>> Unreacheable from Italy as well...
>
> Same here (Buenos Aires, Argentina).
It ain't down till Netcraft confirms it!
http://uptime.netcraft.com/up/graph?site=www.pyjs.org
Oh wait...
-irmen
==============================================================================
TOPIC: string to list when the contents is a list
http://groups.google.com/group/comp.lang.python/t/d604be2eee402ced?hl=en
==============================================================================
== 1 of 5 ==
Date: Thurs, Feb 18 2010 11:32 am
From: Wes James
On Thu, Feb 18, 2010 at 8:18 AM, Tim Chase
<python.list@tim.thechases.com> wrote:
> Wes James wrote:
<snip>
>
> Just to add to the list of solutions I've seen, letting the built-in csv
> module do the heavy lifting:
>
> >>> s = "['a','b']"
> >>> import csv
> >>> no_brackets = s[1:-1] # s.strip(' \t[]')
> >>> c = csv.reader([no_brackets], quotechar="'")
> >>> c.next()
> ['a', 'b']
>
> This also gives you a bit of control regarding how escaping is done, and
> other knobs & dials to twiddle if you need. Additionally, if you have more
> than one string to process coming from an iterable source (such as a file),
> you can just pass that iterator to csv.reader() instead of concocting a
> one-element list.
Thx, I think this will work for what I want.
-wes
== 2 of 5 ==
Date: Thurs, Feb 18 2010 11:56 am
From: Wes James
On Thu, Feb 18, 2010 at 12:32 PM, Wes James <comptekki@gmail.com> wrote:
> On Thu, Feb 18, 2010 at 8:18 AM, Tim Chase
> <python.list@tim.thechases.com> wrote:
>> Wes James wrote:
> <snip>
>
>>
>> Just to add to the list of solutions I've seen, letting the built-in csv
>> module do the heavy lifting:
>>
>> >>> s = "['a','b']"
>> >>> import csv
>> >>> no_brackets = s[1:-1] # s.strip(' \t[]')
>> >>> c = csv.reader([no_brackets], quotechar="'")
>> >>> c.next()
>> ['a', 'b']
Hmm. When I put csv.reader in a class:
import csv
class IS_LIST():
def __init__(self, format='', error_message='must be a list!'):
self.format = format
self.error_message = error_message
def __call__(self, value):
try:
if value=='[]' or value=='':
value=[]
else:
no_brackets = value[1:-1] # s.strip(' \t[]')
c = csv.reader([no_brackets], quotechar="'")
value=c.next()
return (value, None)
except:
return (value, self.error_message)
def formatter(self, value):
return value
I get an error (when I take the "try" out):
AttributeError: 'function' object has no attribute 'reader'
Why?
-wes
== 3 of 5 ==
Date: Thurs, Feb 18 2010 12:12 pm
From: Tim Chase
> import csv
>
> class IS_LIST():
> def __init__(self, format='', error_message='must be a list!'):
> self.format = format
> self.error_message = error_message
> def __call__(self, value):
> try:
> if value=='[]' or value=='':
> value=[]
> else:
> no_brackets = value[1:-1] # s.strip(' \t[]')
> c = csv.reader([no_brackets], quotechar="'")
> value=c.next()
> return (value, None)
> except:
> return (value, self.error_message)
> def formatter(self, value):
> return value
>
> I get an error (when I take the "try" out):
>
> AttributeError: 'function' object has no attribute 'reader'
A couple ideas occur to me:
1) you haven't copy/pasted the exact (or entirety of the) code,
and something you're doing is shadowing the "csv" module
2) are you using Python 2.x or 3.x? I don't know if the csv
module has changed in 3.x but it should work in 2.x
The first thing to check would be to pull up a raw python prompt
and see if your csv module has the expected reader:
>>> import csv
>>> csv.reader
<built-in function reader>
If not, something likely changed in 3.x and you'd have to inspect
the docs to see what happened to the reader.
If you get the above evidence of an existing reader, then you're
likely shadowing it.
-tkc
== 4 of 5 ==
Date: Thurs, Feb 18 2010 12:33 pm
From: Benjamin Kaplan
On Thu, Feb 18, 2010 at 2:56 PM, Wes James <comptekki@gmail.com> wrote:
>
> I get an error (when I take the "try" out):
>
> AttributeError: 'function' object has no attribute 'reader'
>
You have a function called "csv" that's defined after the import csv
statement is executed. That function has no attribute 'reader", so you
get the error. By the way, don't use a bare except- it's bad form
because it hides any other problems you have.
== 5 of 5 ==
Date: Thurs, Feb 18 2010 1:18 pm
From: aahz@pythoncraft.com (Aahz)
In article <mailman.2736.1266522979.28905.python-list@python.org>,
Wes James <comptekki@gmail.com> wrote:
>
> try:
> if value=3D=3D'[]' or value=3D=3D'':
> value=3D[]
> else:
> no_brackets =3D value[1:-1] # s.strip(' \t[]')
> c =3D csv.reader([no_brackets], quotechar=3D"'")
> value=3Dc.next()
> return (value, None)
> except:
> return (value, self.error_message)
Two important points:
* Don't use bare except: clauses
* Put less code in the try: clause to make it easier to track down
problems
--
Aahz (aahz@pythoncraft.com) <*> http://www.pythoncraft.com/
"At Resolver we've found it useful to short-circuit any doubt and just
refer to comments in code as 'lies'. :-)"
==============================================================================
TOPIC: How secure are temp files created via tempfile.TemporaryFile()?
http://groups.google.com/group/comp.lang.python/t/37552844fb729198?hl=en
==============================================================================
== 1 of 2 ==
Date: Thurs, Feb 18 2010 11:33 am
From: MRAB
python@bdurham.com wrote:
> I'm doing a code review of an application that occassionally writes
> blocks of secure data to temp files created with tempfile.TemporaryFile(
> delete=True ).
>
> How secure are temp files created via tempfile.TemporaryFile( delete=True )?
>
> Are there OS specific nuances I should be concerned about regarding use
> of this function on Windows (XP or higher) or Linux?
>
Well, the contents of temp files aren't encrypted, if that's what you're
asking, so if you're writing unencrypted data to a temp file then other
applications could read it.
== 2 of 2 ==
Date: Thurs, Feb 18 2010 12:09 pm
From: python@bdurham.com
MRAB,
> Well, the contents of temp files aren't encrypted, if that's what you're asking
I understand the contents of temp files aren't encrypted.
> if you're writing unencrypted data to a temp file then other applications could read it.
That's my concern - can other applications really read my temp files
created with tempfile.TemporaryFile( delete=True )?
I don't think so because:
1. These files appear to be exclusively locked by my process, eg. no
other processes can read or write to these temp files except the process
that created these files.
2. As soon as my process terminates (voluntarily or involuntarily), the
temp file gets deleted.
But I want to make sure.
Thanks,
Mal
==============================================================================
TOPIC: The future of "frozen" types as the number of CPU cores increases
http://groups.google.com/group/comp.lang.python/t/7ef75c20d1be370d?hl=en
==============================================================================
== 1 of 4 ==
Date: Thurs, Feb 18 2010 11:58 am
From: John Nagle
John Nagle wrote:
> I look at this as Python's answer to multicore CPUs and "Go".
On that note, I went to a talk at Stanford yesterday by one of the
designers of Intel's Nelahem core. The four-core, eight thread
version is out now. The six-core, twelve thread version is working;
the speaker has one in his lab. The eight-core, sixteen thread version
is some months away. This isn't an expensive CPU; this is Intel's
"converged" mainstream product. (Although there will be a whole range
of "economy" and "performance" versions, all with the same core but
with some stuff turned off.)
Python isn't ready for this. Not with the GIL.
Multiple processes are not the answer. That means loading multiple
copies of the same code into different areas of memory. The cache
miss rate goes up accordingly.
John Nagle
== 2 of 4 ==
Date: Thurs, Feb 18 2010 1:19 pm
From: Ethan Furman
John Nagle wrote:
> John Nagle wrote:
>
>> I look at this as Python's answer to multicore CPUs and "Go".
>
> On that note, I went to a talk at Stanford yesterday by one of the
> designers of Intel's Nelahem core. The four-core, eight thread
> version is out now. The six-core, twelve thread version is working;
> the speaker has one in his lab. The eight-core, sixteen thread version
> is some months away. This isn't an expensive CPU; this is Intel's
> "converged" mainstream product. (Although there will be a whole range
> of "economy" and "performance" versions, all with the same core but
> with some stuff turned off.)
>
> Python isn't ready for this. Not with the GIL.
>
> Multiple processes are not the answer. That means loading multiple
> copies of the same code into different areas of memory. The cache
> miss rate goes up accordingly.
>
> John Nagle
Will the new GIL in 3.2 make this workable? It would still be one
thread at a time, though, wouldn't it.
~Ethan~
== 3 of 4 ==
Date: Thurs, Feb 18 2010 2:11 pm
From: Chris Rebert
On Thu, Feb 18, 2010 at 11:58 AM, John Nagle <nagle@animats.com> wrote:
<snip>
> On that note, I went to a talk at Stanford yesterday by one of the
> designers of Intel's Nelahem core. The four-core, eight thread
> version is out now. The six-core, twelve thread version is working;
> the speaker has one in his lab. The eight-core, sixteen thread version
> is some months away. This isn't an expensive CPU; this is Intel's
> "converged" mainstream product. (Although there will be a whole range
> of "economy" and "performance" versions, all with the same core but
> with some stuff turned off.)
>
> Python isn't ready for this. Not with the GIL.
Is any language, save perhaps Erlang, really ready for it?
Cheers,
Chris
--
http://blog.rebertia.com
== 4 of 4 ==
Date: Thurs, Feb 18 2010 2:12 pm
From: Steven D'Aprano
On Thu, 18 Feb 2010 11:58:32 -0800, John Nagle wrote:
> John Nagle wrote:
>
>> I look at this as Python's answer to multicore CPUs and "Go".
>
> On that note, I went to a talk at Stanford yesterday by one of the
> designers of Intel's Nelahem core. The four-core, eight thread version
> is out now. [...]
>
> Python isn't ready for this. Not with the GIL.
Pardon me, but Python is perfectly ready for this. Why aren't you using
Jython or IronPython, if the GIL is such a drag on your use-case?
--
Steven
==============================================================================
TOPIC: Few questions on SOAP
http://groups.google.com/group/comp.lang.python/t/3808b1054771aa1c?hl=en
==============================================================================
== 1 of 2 ==
Date: Thurs, Feb 18 2010 12:00 pm
From: Muhammad Alkarouri
Your question is borderline if not out of topic in this group. I will
make a few comments though.
On Feb 18, 3:36 pm, joy99 <subhakolkata1...@gmail.com> wrote:
> Dear Group,
>
> I was reading on SOA or Service Oriented Architecture for last few
> days and got some questions. As this is a room for the expert computer
> scientists, if you can help me solve my queries.
>
> As per I read and felt SOA is an architecture, which relies on few
> basic principles as,
> the system must be modular, the modules must be distributive, module
> interfaces must be clearly defined and documented, module that
> implements a service can be swapped out for another module that offers
> the same service and interface, service provider modules must be
> shareable.
> SOA is an architecture which is now a days governed like XML by W3C.
SOA is an architecture which can be implemented using any of a number
of different middleware choices. It is not governed or controlled by
anyone. You are mixing it up with SOAP, which is a web services
technology, currently governed by W3C.
For example, I tend to use SOA implemented using REST
(Representational State Transfer).
All of these technologies are somewhat explained in wikipedia. You
probably want to start there.
> The latest version is SOAP 1.2.
This is the latest of SOAP, not SOA.
> SOA is implemented mainly in a client/server environment, where
> applications have the use of service, thus we can say it is a service-
> oriented architecture.
> It is a step towards cloud computing with its sister WSDL and BPM.
A SOAP web service is described using WSDL. BPM is not really
connected with them, but is probably more connected with SOA as an
architecture. BPM can be implemented using SOAP/WSDL web services, as
can SOA.
>
> If both client/server are following the SOA then they can communicate
> and exchange information without worrying for platform.
You mean SOAP here.
In real life, there are interoperability issues. So various
implementations of SOAP will need a bit of work to actually work
together.
SOA is an architecture and does not help exchanging information in a
direct way.
>
> SOAP is a software implementation of Python,.NET,J2EE based on this
> principle.
SOAP is a web services protocol that was created before the concept of
SOA was developed enough for use and is largely independent of it.
SOAP has been implemented in many different languages, like
Java, .Net, C/C++, Python, etc.
> SOAPPy is a Python implementation.
SOAP implementations in Python are not of the best quality (in my
opinion, there are better ways to achieve the ends needed). SOAPpy is
currently a bit out of date. The better ones are ZSI (for client and
server) and suds (for clients).
I guess I have already answered some of your questions.
>
> My questions are:
> (i) Am I understanding correctly?
See above.
> (ii) Does SOAP has any standard architecture like UML other than the
> W3C one?
Depends on what you mean by architecture. SOAP is a standard. UML is a
way of modelling software and can be used to model web services, which
can then be implemented in SOAP.
> (iii) Can I write short programs to check the SOAP using my personal
> computer as client as well as Server?
Yes. Try ZSI examples (http://pywebsvcs.sourceforge.net/zsi.html).
> (iv) Is SOAPpy fine?
See above.
> (v) What is the difference among SOAP, WSDL and BPM.
SOAP standardise the communication between client and server. WSDL
describes the methods provided by a server to be consumed by a client
(interfaces in Java language). BPM is a management method to improve
business and is not a software protocol but an approach.
> (vi) As SOAP is for communication with a server if I pick a URL and
> start to communicate with Google/Yahoo would they allow?
To be able to talk SOAP to a server, it must understand SOAP. Some of
those companies do provide SOAP web service access, but their standard
search pages are accessible in pure HTTP (the way you browser uses
them).
To access a SOAP service you need to know the functions exported by
it, which are usually defined in a WSDL document.
> (vii) Can I design a web based robot/crawler with SOAP?
No. Web pages are accessed using simple HTTP. SOAP is usually deployed
on top of HTTP, but most web pages are not communicated using SOAP.
You can search for Python web crawling; there are a lot of examples on
the web.
Regards,
k
== 2 of 2 ==
Date: Thurs, Feb 18 2010 1:07 pm
From: Mark Lawrence
Muhammad Alkarouri wrote:
> Your question is borderline if not out of topic in this group. I will
> make a few comments though.
This might be a Python group, but threads often drift way off topic,
which added to the language itself make this a great group to read. If
you don't like the way a thread goes, you can always skip it.
>
> On Feb 18, 3:36 pm, joy99 <subhakolkata1...@gmail.com> wrote:
>> Dear Group,
>>
>> I was reading on SOA or Service Oriented Architecture for last few
>> days and got some questions. As this is a room for the expert computer
>> scientists, if you can help me solve my queries.
>>
>> As per I read and felt SOA is an architecture, which relies on few
>> basic principles as,
>> the system must be modular, the modules must be distributive, module
>> interfaces must be clearly defined and documented, module that
>> implements a service can be swapped out for another module that offers
>> the same service and interface, service provider modules must be
>> shareable.
>> SOA is an architecture which is now a days governed like XML by W3C.
>
> SOA is an architecture which can be implemented using any of a number
> of different middleware choices. It is not governed or controlled by
> anyone. You are mixing it up with SOAP, which is a web services
> technology, currently governed by W3C.
> For example, I tend to use SOA implemented using REST
> (Representational State Transfer).
>
> All of these technologies are somewhat explained in wikipedia. You
> probably want to start there.
>
>> The latest version is SOAP 1.2.
>
> This is the latest of SOAP, not SOA.
>
>> SOA is implemented mainly in a client/server environment, where
>> applications have the use of service, thus we can say it is a service-
>> oriented architecture.
>> It is a step towards cloud computing with its sister WSDL and BPM.
>
> A SOAP web service is described using WSDL. BPM is not really
> connected with them, but is probably more connected with SOA as an
> architecture. BPM can be implemented using SOAP/WSDL web services, as
> can SOA.
>
>> If both client/server are following the SOA then they can communicate
>> and exchange information without worrying for platform.
>
> You mean SOAP here.
> In real life, there are interoperability issues. So various
> implementations of SOAP will need a bit of work to actually work
> together.
>
> SOA is an architecture and does not help exchanging information in a
> direct way.
>
>> SOAP is a software implementation of Python,.NET,J2EE based on this
>> principle.
>
> SOAP is a web services protocol that was created before the concept of
> SOA was developed enough for use and is largely independent of it.
> SOAP has been implemented in many different languages, like
> Java, .Net, C/C++, Python, etc.
>
>> SOAPPy is a Python implementation.
>
> SOAP implementations in Python are not of the best quality (in my
> opinion, there are better ways to achieve the ends needed). SOAPpy is
> currently a bit out of date. The better ones are ZSI (for client and
> server) and suds (for clients).
>
> I guess I have already answered some of your questions.
>
>> My questions are:
>> (i) Am I understanding correctly?
>
> See above.
>
>> (ii) Does SOAP has any standard architecture like UML other than the
>> W3C one?
>
> Depends on what you mean by architecture. SOAP is a standard. UML is a
> way of modelling software and can be used to model web services, which
> can then be implemented in SOAP.
>
>> (iii) Can I write short programs to check the SOAP using my personal
>> computer as client as well as Server?
>
> Yes. Try ZSI examples (http://pywebsvcs.sourceforge.net/zsi.html).
>
>> (iv) Is SOAPpy fine?
>
> See above.
>
>> (v) What is the difference among SOAP, WSDL and BPM.
>
> SOAP standardise the communication between client and server. WSDL
> describes the methods provided by a server to be consumed by a client
> (interfaces in Java language). BPM is a management method to improve
> business and is not a software protocol but an approach.
>
>> (vi) As SOAP is for communication with a server if I pick a URL and
>> start to communicate with Google/Yahoo would they allow?
>
> To be able to talk SOAP to a server, it must understand SOAP. Some of
> those companies do provide SOAP web service access, but their standard
> search pages are accessible in pure HTTP (the way you browser uses
> them).
> To access a SOAP service you need to know the functions exported by
> it, which are usually defined in a WSDL document.
>
>> (vii) Can I design a web based robot/crawler with SOAP?
>
> No. Web pages are accessed using simple HTTP. SOAP is usually deployed
> on top of HTTP, but most web pages are not communicated using SOAP.
> You can search for Python web crawling; there are a lot of examples on
> the web.
>
>
> Regards,
>
> k
==============================================================================
TOPIC: unit testing a routine that sends mail
http://groups.google.com/group/comp.lang.python/t/33e5d23bbb8724a3?hl=en
==============================================================================
== 1 of 1 ==
Date: Thurs, Feb 18 2010 12:16 pm
From: Phlip
commander_coder wrote:
> I have a routine that sends an email (this is how a Django view
> notifies me that an event has happened). I want to unit test that
> routine.
Are you opening SMTP and POP3 sockets??
If you are not developing that layer itself, just use Django's built-
in mock system. Here's my favorite assertion for it:
def assert_mail(self, funk):
from django.core import mail
previous_mails = len(mail.outbox)
funk()
mails = mail.outbox[ previous_mails : ]
assert [] != mails, 'the called block should produce emails'
if len(mails) == 1: return mails[0]
return mails
You call it a little bit like this:
missive = self.assert_mail( lambda:
mark_order_as_shipped(order) )
Then you can use assert_contains on the missive.body, to see what mail
got generated. That's what you are actually developing, so your tests
should skip any irrelevant layers, and only test the layers where you
yourself might add bugs.
--
Phlip
http://penbird.tumblr.com/
==============================================================================
TOPIC: LISA 2010 CFP
http://groups.google.com/group/comp.lang.python/t/71a3126d2a3d79e2?hl=en
==============================================================================
== 1 of 1 ==
Date: Thurs, Feb 18 2010 1:34 pm
From: ntwrkd
Hello All,
The USENIX Large Installation System Administration Conference is now
accepting paper proposals.
If you are interested in submitting a paper, please check out this
blog post about submitting a paper
(http://www.usenix.org/events/lisa10/cfp/), or feel free to contact me
directly if you think you might have a topic to present.
Thank you,
Matthew
==============================================================================
TOPIC: Executing a command from within python using the subprocess module
http://groups.google.com/group/comp.lang.python/t/f9d10cb1a8deca55?hl=en
==============================================================================
== 1 of 1 ==
Date: Thurs, Feb 18 2010 1:40 pm
From: aahz@pythoncraft.com (Aahz)
In article <5YudnaFysO8HouTWnZ2dnUVZ_tidnZ2d@westnet.com.au>,
R (Chandra) Chandrasekhar <chyavana@gmail.com> wrote:
>
>---
>import subprocess
>
>width = 5
>height = 30
>colors = ['#abcdef]', '#456789']
>filename = "/tmp/image.png"
>
># I want to get the equivalent of variable interpolation in Perl
># so that the command
>#
># convert -size 5x30 gradient:#abcdef-#456789 /tmp/image.png
Here's the equivalent of Peter's cute code in simpler form:
cmd = [
'convert',
'-size',
'%sx%s' % (width, height),
'gradient:%s-%s' % tuple(colors),
# above could also be: 'gradient:%s-%s' % (colors[0], colors[1]),
filename,
]
subprocess.Popen(cmd)
--
Aahz (aahz@pythoncraft.com) <*> http://www.pythoncraft.com/
"At Resolver we've found it useful to short-circuit any doubt and just
refer to comments in code as 'lies'. :-)"
==============================================================================
TOPIC: Why this doesn't work?
http://groups.google.com/group/comp.lang.python/t/698b29e4a1bebed4?hl=en
==============================================================================
== 1 of 1 ==
Date: Thurs, Feb 18 2010 2:07 pm
From: Steven D'Aprano
On Thu, 18 Feb 2010 18:28:44 +0100, mk wrote:
> nostat.__orig_get__ = nostat.__get__
I should point out that leading-and-trailing-double-underscore names are
reserved for use by the language.
It's unlikely that Python will introduce a special method named
__orig_get__, and in truth the prohibition against using such names is
honoured more in the breach than in the observance (e.g. people often use
metadata names like __version__, __author__, etc.). But just be aware
that you are in technical breach of Python best practices, and should
consider renaming it as _orig_get or __orig_get.
--
Steven
==============================================================================
TOPIC: Interesting talk on Python vs. Ruby and how he would like Python to
have just a bit more syntactic flexibility.
http://groups.google.com/group/comp.lang.python/t/9a88c79d4043ba30?hl=en
==============================================================================
== 1 of 1 ==
Date: Thurs, Feb 18 2010 2:17 pm
From: Steven D'Aprano
On Thu, 18 Feb 2010 06:15:20 -0800, Steve Howell wrote:
> On Feb 18, 1:23 am, Duncan Booth <duncan.bo...@invalid.invalid> wrote:
>> Jonathan Gardner <jgard...@jonathangardner.net> wrote:
>> > On Feb 17, 12:02 am, Lawrence D'Oliveiro <l...@geek-
>> > central.gen.new_zealand> wrote:
>> >> In message
>> >> <8ca440b2-6094-4b35-80c5-81d000517...@v20g2000prb.googlegroups.com>,
>>
>> >> Jonathan Gardner wrote:
>> >> > I used to think anonymous functions (AKA blocks, etc...) would be
>> >> > a nice feature for Python.
>>
>> >> > Then I looked at a stack trace from a different programming
>> >> > language with lots of anonymous functions. (I believe it was
>> >> > perl.)
>>
>> >> Didn't it have source line numbers in it?
>>
>> >> What more do you need?
>>
>> > I don't know, but I tend to find the name of the function I called to
>> > be useful. It's much more memorable than line numbers, particularly
>> > when line numbers keep changing.
>>
>> > I doubt it's just me, though.
>>
>> Some problems with using just line numbers to track errors:
>>
>> In any language it isn't much use if you get a bug report from a
>> shipped program that says there was an error on line 793 but no report
>> of exactly which version of the shipped code was being run.
>>
>> Microsoft love telling you the line number: if IE gets a Javascript
>> error it reports line number but not filename, so you have to guess
>> which of the HTML page or one of many included files actually had the
>> error. Plus the line number that is reported is often slightly off.
>>
>> Javascript in particular is often sent to the browser compressed then
>> uncompressed and eval'd. That makes line numbers completely useless for
>> tracking down bugs as you'll always get the line number of the eval.
>> Also the way functions are defined in Javascript means you'll often
>> have almost every function listed in a backtrace as 'Anonymous'.
>
> If this is an argument against using anonymous functions, then it is a
> quadruple strawman.
There really ought to be a special level of Hell for people who misuse
"strawman" to mean "a weak or invalid argument" instead of what it
actually means, which is a weak or invalid argument NOT HELD by your
opponent, which you (generic you) made up specifically for the sake of
shooting down.
If you actually read what Duncan says, he prefixes his response with:
"Some problems with using just line numbers to track errors".
Duncan's post is an argument against relying on line numbers as your
main, or only, source of information about the location of bugs in
Javascript.
In fact, this post is remarkable for the sheer number of actual strawman
arguments that you (Steve Howell) use:
> Shipping buggy code is a bad idea, even with named functions.
Strawman #1: nobody said that shipping buggy code was a good idea, with
or without named functions. But shipping buggy code *happens*, no matter
how careful you are, so you need to expect bug reports back from users.
(And they will be *hard to find* bugs, because if they were easy to find
you would have found them in your own testing before shipping.)
> Obscuring line numbers is a bad idea, even with named functions.
Strawman #2: nobody said that obscuring line numbers was a good idea. But
apparently compressing Javascript is valuable for other reasons, and
obscuring the line numbers is the side-effect of doing so.
And even knowing the line numbers is not necessarily useful, because many
bugs aren't due to the line that raises the stack trace. Just because you
know the line which failed doesn't mean you know how to fix the bug.
> Having your customers stay on older versions of your software is a bad
> idea, even with named functions.
Strawman #3: nobody said that staying on older versions is a good idea.
But sometimes it happens whether you like it or not.
(Although I'd like to point out that from the end user's perspective,
sometimes we don't want your stinkin' new version with all the anti-
features and pessimations and will stick to the old version for as long
as possible. If you don't like it, then think a bit harder before adding
anti-features like fragile, easily-corrupted databases which perform
really, really badly when your home directory is mounted over the
network. I'm talking to you, Firefox developers.)
And it doesn't really matter: you either end-of-life the old version, in
which case you don't need to do anything about the bug report except say
"upgrade", or you decide to continue support, in which case it doesn't
matter whether the bug is reported for an old version or the latest
version, you still need to fix it.
> Not being able to know which version of software you're customer is
> running is a bad idea, even with named functions.
Strawman #4.
See the pattern? When you attack a position the other guy hasn't taken,
that's a strawman. When you make a weak argument, it's just a weak
argument.
--
Steven
==============================================================================
You received this message because you are subscribed to the Google Groups "comp.lang.python"
group.
To post to this group, visit http://groups.google.com/group/comp.lang.python?hl=en
To unsubscribe from this group, send email to comp.lang.python+unsubscribe@googlegroups.com
To change the way you get mail from this group, visit:
http://groups.google.com/group/comp.lang.python/subscribe?hl=en
To report abuse, send email explaining the problem to abuse@googlegroups.com
==============================================================================
Google Groups: http://groups.google.com/?hl=en
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home