comp.lang.python - 25 new messages in 16 topics - digest
comp.lang.python
http://groups.google.com/group/comp.lang.python?hl=en
comp.lang.python@googlegroups.com
Today's topics:
* OSSCamp Chandigarh April 2010 - Open Source Is The Future - 1 messages, 1
author
http://groups.google.com/group/comp.lang.python/t/0a276e6f881729e9?hl=en
* How to find an COM object in using of pywin32 - 1 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/3e8bfcf59aa39c4d?hl=en
* Method / Functions - What are the differences? - 2 messages, 2 authors
http://groups.google.com/group/comp.lang.python/t/72ab93ba395822ed?hl=en
* - python list into a sql query - 1 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/bff5c603be63854e?hl=en
* Py2exe - Bad File Descriptor - 1 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/da53bce38fcf95b6?hl=en
* python socket service related question! - 1 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/5f8b7349b101fa9b?hl=en
* Draft PEP on RSON configuration file format - 1 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/09ce33197b330e90?hl=en
* Adding to a module's __dict__? - 8 messages, 5 authors
http://groups.google.com/group/comp.lang.python/t/40837c4567d64745?hl=en
* (and about tests) Re: Pedantic pickling error after reload? - 1 messages, 1
author
http://groups.google.com/group/comp.lang.python/t/6d1d3bb3bcc68fe7?hl=en
* Call Signtool using python - 2 messages, 2 authors
http://groups.google.com/group/comp.lang.python/t/2a6d7daff19d7360?hl=en
* Verifying My Troublesome Linkage Claim between Python and Win7 - 1 messages,
1 author
http://groups.google.com/group/comp.lang.python/t/ba27d93256f5c275?hl=en
* How to use python to register a service (an existing .exe file) - 1 messages,
1 author
http://groups.google.com/group/comp.lang.python/t/87b6405cd9ba5a32?hl=en
* os.fdopen() issue in Python 3.1? - 1 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/49a2ca4c1f9e7a59?hl=en
* Python training in Florida, April 27-29 - 1 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/f8626b0a1899b27a?hl=en
* taking python enterprise level?... - 1 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/3dca28b82d10655c?hl=en
* Queue peek? - 1 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/ba3cb62c81d4cb7a?hl=en
==============================================================================
TOPIC: OSSCamp Chandigarh April 2010 - Open Source Is The Future
http://groups.google.com/group/comp.lang.python/t/0a276e6f881729e9?hl=en
==============================================================================
== 1 of 1 ==
Date: Mon, Mar 1 2010 11:58 pm
From: Rishabh Verma
Hello All,
OSSCamp is again being organized in Chandigarh on April 10, 2010. This
is another step ahead to foster the open source community in the city
beautiful. This event is a purely community organized event by some of
the open source evangelists of Chandigarh and it would be great if you
guys join us to make this event a great success. At a Camp, we love to
cross-talk, huddle together, raise some noise, celebrate technology,
argue over the coolest OS, fight on our fav programming languages,
discuss stuff, and what not!
OSScamp Chandigarh April 2010
April 10, 2009
Venue: To Be Decided
Time: 10AM - 6PM
You can register for the event at : http://chd.osscamp.in/
Follow Us on Twitter : http://twitter.com/osscamp
Facebook Event Page : http://www.facebook.com/event.php?eid=247304090115&ref=ts
==============================================================================
TOPIC: How to find an COM object in using of pywin32
http://groups.google.com/group/comp.lang.python/t/3e8bfcf59aa39c4d?hl=en
==============================================================================
== 1 of 1 ==
Date: Tues, Mar 2 2010 12:42 am
From: "Alf P. Steinbach"
* Steven Woody:
> Hi,
>
> I want to interactive with an OLE application with pywin32. The
> problem is I get totally no idea how to find the object in OLEView and
> how to figure out it's interface.
>
> With pywin32's example, I even don't understand that in the below statement,
>
> win32com.client.Dispatch('Excel.Application')
>
> that where the name 'Excel.Application' comes from? In OLEView
> (Microsoft's COM brower), I cannot find this name.
It's a "programmatic identifier" a.k.a. "progid".
It identifies a COM class and it's used as a readable but more
name-collision-prone alternative to the 128-bit UUID.
You can find the programmatic identifiers in the Windows registry (use e.g.
regedit); often they're not documented.
Cheers,
- Alf
==============================================================================
TOPIC: Method / Functions - What are the differences?
http://groups.google.com/group/comp.lang.python/t/72ab93ba395822ed?hl=en
==============================================================================
== 1 of 2 ==
Date: Tues, Mar 2 2010 12:57 am
From: Bruno Desthuilliers
John Posner a écrit :
> On 3/1/2010 2:59 PM, Bruno Desthuilliers wrote:
>
>> Answer here:
>>
>> http://groups.google.com/group/comp.lang.python/tree/browse_frm/thread/bd71264b6022765c/3a77541bf9d6617d#doc_89d608d0854dada0
>>
>>
>> I really have to put this in the wiki :-/
>
>
> Bruno, I performed a light copy-edit of your writeup and put in some
> reStructuredText (reST) markup. The result is at:
>
> http://cl1p.net/bruno_0301.rst/
Cool.
>
> The only sentence that I think needs work is:
>
> Having access to itself (of course), the
> instance (if there's one) and the class, it's easy for it
> to wrap all this into a **method** object.
>
> Maybe this?
>
> With the instance object (if any) and class object available,
> it's easy to create a method object that wraps the function object.
That's perfect.
But there's also a typo to fix in the Python implementation of the
Method object: in the call method, it should inject self.im_self as
first arg, not self.im_func. This had been spotted by someone named John
Posner, IIRC !-)
>
> Begging pardon for my presumptuousness,
Begging pardon for my laziness :-/
== 2 of 2 ==
Date: Tues, Mar 2 2010 6:17 am
From: John Posner
On 3/2/2010 3:57 AM, Bruno Desthuilliers wrote:
>>
>> With the instance object (if any) and class object available,
>> it's easy to create a method object that wraps the function object.
>
> That's perfect.
Fixed.
> But there's also a typo to fix in the Python implementation of the
> Method object: in the call method, it should inject self.im_self as
> first arg, not self.im_func. This had been spotted by someone named John
> Posner, IIRC !-)
Fixed (oops!).
I've updated the text at this location:
> http://cl1p.net/bruno_0301.rst/
I think the ball is back in your court, Bruno. I'd be happy to help more
-- feel free to contact me off-list, at jjposner@optimum.net.
Best,
John
==============================================================================
TOPIC: - python list into a sql query
http://groups.google.com/group/comp.lang.python/t/bff5c603be63854e?hl=en
==============================================================================
== 1 of 1 ==
Date: Tues, Mar 2 2010 1:04 am
From: Dennis Lee Bieber
On Mon, 1 Mar 2010 09:54:20 -0800 (PST), Jo�o <joaopcf@gmail.com>
declaimed the following in gmane.comp.python.general:
>
> I'm failing miserably in,
>
> sql = '''SELECT ip, host, dns FROM zabbix_tst_db.hosts WHERE hostid IN
> (
> select hostid from hosts_groups WHERE groupid IN (' +
> ','.join(map(str, %s)) + ')''' % grp_range
>
One: it is always best to use parameterized queries for the data
values.
Two: as mentioned by others, your join() clause is part of the
string literal... which makes no sense as SQL.
sql = """select ip, host, dns from zabbix_tst_db.hosts
where hostid in (%s)""" % ", ".join(["%s"] * len(grp_range))
Here, the .join() creates a string of (MySQLdb) placeholders for
each item in grp_range.
cursor.execute(sql, grp_range)
Here, the db-api adapter replaces each placeholder with the escaped
value of that item.
--
Wulfraed Dennis Lee Bieber KD6MOG
wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/
==============================================================================
TOPIC: Py2exe - Bad File Descriptor
http://groups.google.com/group/comp.lang.python/t/da53bce38fcf95b6?hl=en
==============================================================================
== 1 of 1 ==
Date: Tues, Mar 2 2010 1:04 am
From: Dennis Lee Bieber
On Mon, 1 Mar 2010 16:41:57 -0800 (PST), T <misceverything@gmail.com>
declaimed the following in gmane.comp.python.general:
> So how would that work..would the program buffer all the "print"
> output, then send it to the client when it connects? Do you happen to
> know of any available code that utilizes this method, or something
> similar? Thanks for your help.
No... /nothing/ would be "output" unless a client were connected.
The other approach is to use a log file of some sort (or the system
log for the OS).
If you need interactive access (output and input) to a service, the
service will need to be written with a communication protocol to pass
data both ways. If all you need is output, the best means would be via a
logging scheme that doesn't depend upon consoles or log-ins.
--
Wulfraed Dennis Lee Bieber KD6MOG
wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/
==============================================================================
TOPIC: python socket service related question!
http://groups.google.com/group/comp.lang.python/t/5f8b7349b101fa9b?hl=en
==============================================================================
== 1 of 1 ==
Date: Tues, Mar 2 2010 1:04 am
From: Dennis Lee Bieber
On Mon, 1 Mar 2010 05:49:06 -0800 (PST), elca <highcar@gmail.com>
declaimed the following in gmane.comp.python.general:
> i was captured with wireshark, some process to send login info to server.
>
> and i was found port number is 5300 and server ip is 58.225.56.152
>
> and i was send id is 'aaaaaaa' and password 'bbbbbbb' and i was received
>
> 'USER NOT FOUND' result from server.
>
> how can i make this kind of process with python socket ?
>
I've usually found the best way to debug such a connection is to use
TELNET
Telnet to (in your example) 58.225.56.152 5300 and see how it
responds to the data you are sending.
When you can get a proper session using plain telnet, THEN translate
that session into Python socket I/O.
--
Wulfraed Dennis Lee Bieber KD6MOG
wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/
==============================================================================
TOPIC: Draft PEP on RSON configuration file format
http://groups.google.com/group/comp.lang.python/t/09ce33197b330e90?hl=en
==============================================================================
== 1 of 1 ==
Date: Tues, Mar 2 2010 2:09 am
From: Daniel Fetchinson
>> > But you are working on a solution in search of a problem. The really
>> > smart thing to do would be pick something more useful to work on. We
>> > don't need another configuration language. I can't even say "yet
>> > another" because there's already a "yet another" called yaml.
>>
>> And in case you are new here let me assure you that Paul is saying
>> this with his full intention of being helpful to you. I also would
>> think that working on such a project might be fun and educational for
>> you but completely useless if you have users other than yourself in
>> mind. Again, I'm trying to be helpful here, so you can focus on a
>> project that is both fun/educational for you and also potentially
>> useful for others. This RSON business is not one of them.
>
> OK, but I am a bit unclear on what you and/or Paul are claiming. It
> could be one of a number of things. For example:
>
> - There is a preexisting file format suitable for my needs, so I
> should not invent another one.
I suspect this to be true, if we mean the same thing by "configuration
file format". Especially if RSON will be a superset of JSON.
> - If I invent a file format suitable for my needs, it couldn't
> possibly be general enough for anybody else.
Quite possibly, the reason is that the already existing file formats
have an ecosystem around them that make them attractive. Your file
format will have to cope with this barrier to attract new users which
I think will be very difficult, given the wide range of already
existing formats, covering just about any use case.
> - Even if it was general enough for somebody else, there would only be
> two of them.
See above.
> I've been known to waste time (or be accused of wasting time) on
> various endeavors, but I like to know exactly *why* it is perceived to
> be a waste.
Don't get me wrong, I also waste lot of time on hobby/fun/educational
projects ("waste" in this case is only meant as "useless for others",
not "useless for me") because it's, well, hobby and fun and
educational :) It's just good to know if a given project is in this
category or outside.
Cheers,
Daniel
--
Psss, psss, put it down! - http://www.cafepress.com/putitdown
==============================================================================
TOPIC: Adding to a module's __dict__?
http://groups.google.com/group/comp.lang.python/t/40837c4567d64745?hl=en
==============================================================================
== 1 of 8 ==
Date: Tues, Mar 2 2010 2:29 am
From: Jean-Michel Pichavant
Roy Smith wrote:
> >From inside a module, I want to add a key-value pair to the module's
> __dict__. I know I can just do:
>
> FOO = 'bar'
>
> at the module top-level, but I've got 'FOO' as a string and what I
> really need to do is
>
> __dict__['Foo'] = 'bar'
>
> When I do that, I get "NameError: name '__dict__' is not defined". Is
> it possible to do what I'm trying to do?
>
test.py:
import sys
varName= 'foo'
setattr(sys.modules[__name__], varName, 42)
in a shell:
import test
print test.foo
>>> 42
JM
== 2 of 8 ==
Date: Tues, Mar 2 2010 5:21 am
From: Roy Smith
In article <mailman.96.1267508316.23598.python-list@python.org>,
Chris Rebert <clp2@rebertia.com> wrote:
> On Mon, Mar 1, 2010 at 8:27 PM, Roy Smith <roy@panix.com> wrote:
> > >From inside a module, I want to add a key-value pair to the module's
> > __dict__. I know I can just do:
> >
> > FOO = 'bar'
> >
> > at the module top-level, but I've got 'FOO' as a string and what I
> > really need to do is
> >
> > __dict__['Foo'] = 'bar'
> >
> > When I do that, I get "NameError: name '__dict__' is not defined". Is
> > it possible to do what I'm trying to do?
>
> Yes; just modify the dict returned by the globals() built-in function
> instead.
Ah, cool. Thanks.
> It's usually not wise to do this and is better to use a
> separate dict instead, but I'll assume you know what you're doing and
> have good reasons to disregard the standard advice due to your
> use-case.
Why is it unwise?
The use case is I'm importing a bunch of #define constants from a C header
file. I've got triples that I want to associate; the constant name, the
value, and a string describing it. The idea is I want to put in the
beginning of the module:
declare('XYZ_FOO', 0, "The foo property")
declare('XYZ_BAR', 1, "The bar property")
declare('XYZ_BAZ', 2, "reserved for future use")
and so on. I'm going to have hundreds of these, so ease of use, ease of
maintenance, and niceness of presentation are important.
My declare() function will not just set XYZ_FOO = 1 at module global scope,
but also insert entries in a variety of dicts so I can look up the
description string, map from a value back to the constant name, etc.
I *could* do this in a separate dict, but the notational convenience of
being able to have the original constant names globally available is pretty
important.
== 3 of 8 ==
Date: Tues, Mar 2 2010 5:33 am
From: Steve Holden
Roy Smith wrote:
> In article <mailman.96.1267508316.23598.python-list@python.org>,
> Chris Rebert <clp2@rebertia.com> wrote:
>
>> On Mon, Mar 1, 2010 at 8:27 PM, Roy Smith <roy@panix.com> wrote:
>>> >From inside a module, I want to add a key-value pair to the module's
>>> __dict__. Â I know I can just do:
>>>
>>> FOO = 'bar'
>>>
>>> at the module top-level, but I've got 'FOO' as a string and what I
>>> really need to do is
>>>
>>> __dict__['Foo'] = 'bar'
>>>
>>> When I do that, I get "NameError: name '__dict__' is not defined". Â Is
>>> it possible to do what I'm trying to do?
>> Yes; just modify the dict returned by the globals() built-in function
>> instead.
>
> Ah, cool. Thanks.
>
>> It's usually not wise to do this and is better to use a
>> separate dict instead, but I'll assume you know what you're doing and
>> have good reasons to disregard the standard advice due to your
>> use-case.
>
> Why is it unwise?
>
> The use case is I'm importing a bunch of #define constants from a C header
> file. I've got triples that I want to associate; the constant name, the
> value, and a string describing it. The idea is I want to put in the
> beginning of the module:
>
> declare('XYZ_FOO', 0, "The foo property")
> declare('XYZ_BAR', 1, "The bar property")
> declare('XYZ_BAZ', 2, "reserved for future use")
>
> and so on. I'm going to have hundreds of these, so ease of use, ease of
> maintenance, and niceness of presentation are important.
>
> My declare() function will not just set XYZ_FOO = 1 at module global scope,
> but also insert entries in a variety of dicts so I can look up the
> description string, map from a value back to the constant name, etc.
>
> I *could* do this in a separate dict, but the notational convenience of
> being able to have the original constant names globally available is pretty
> important.
>
And how important is it to make sure that whatever data your program
processes doesn't overwrite the actual variable names you want to use to
program the processing?
If you use this technique you are effectively making your program a
hostage to fortune, as you no longer control the namespace you are using
for the programming.
regards
Steve
--
Steve Holden +1 571 484 6266 +1 800 494 3119
PyCon is coming! Atlanta, Feb 2010 http://us.pycon.org/
Holden Web LLC http://www.holdenweb.com/
UPCOMING EVENTS: http://holdenweb.eventbrite.com/
== 4 of 8 ==
Date: Tues, Mar 2 2010 5:33 am
From: Steve Holden
Roy Smith wrote:
> In article <mailman.96.1267508316.23598.python-list@python.org>,
> Chris Rebert <clp2@rebertia.com> wrote:
>
>> On Mon, Mar 1, 2010 at 8:27 PM, Roy Smith <roy@panix.com> wrote:
>>> >From inside a module, I want to add a key-value pair to the module's
>>> __dict__. Â I know I can just do:
>>>
>>> FOO = 'bar'
>>>
>>> at the module top-level, but I've got 'FOO' as a string and what I
>>> really need to do is
>>>
>>> __dict__['Foo'] = 'bar'
>>>
>>> When I do that, I get "NameError: name '__dict__' is not defined". Â Is
>>> it possible to do what I'm trying to do?
>> Yes; just modify the dict returned by the globals() built-in function
>> instead.
>
> Ah, cool. Thanks.
>
>> It's usually not wise to do this and is better to use a
>> separate dict instead, but I'll assume you know what you're doing and
>> have good reasons to disregard the standard advice due to your
>> use-case.
>
> Why is it unwise?
>
> The use case is I'm importing a bunch of #define constants from a C header
> file. I've got triples that I want to associate; the constant name, the
> value, and a string describing it. The idea is I want to put in the
> beginning of the module:
>
> declare('XYZ_FOO', 0, "The foo property")
> declare('XYZ_BAR', 1, "The bar property")
> declare('XYZ_BAZ', 2, "reserved for future use")
>
> and so on. I'm going to have hundreds of these, so ease of use, ease of
> maintenance, and niceness of presentation are important.
>
> My declare() function will not just set XYZ_FOO = 1 at module global scope,
> but also insert entries in a variety of dicts so I can look up the
> description string, map from a value back to the constant name, etc.
>
> I *could* do this in a separate dict, but the notational convenience of
> being able to have the original constant names globally available is pretty
> important.
>
And how important is it to make sure that whatever data your program
processes doesn't overwrite the actual variable names you want to use to
program the processing?
If you use this technique you are effectively making your program a
hostage to fortune, as you no longer control the namespace you are using
for the programming.
regards
Steve
--
Steve Holden +1 571 484 6266 +1 800 494 3119
PyCon is coming! Atlanta, Feb 2010 http://us.pycon.org/
Holden Web LLC http://www.holdenweb.com/
UPCOMING EVENTS: http://holdenweb.eventbrite.com/
== 5 of 8 ==
Date: Tues, Mar 2 2010 6:26 am
From: Mel
Roy Smith wrote:
[ ... ]
> Why is it unwise?
>
> The use case is I'm importing a bunch of #define constants from a C header
> file. I've got triples that I want to associate; the constant name, the
> value, and a string describing it. The idea is I want to put in the
> beginning of the module:
>
> declare('XYZ_FOO', 0, "The foo property")
> declare('XYZ_BAR', 1, "The bar property")
> declare('XYZ_BAZ', 2, "reserved for future use")
>
> and so on. I'm going to have hundreds of these, so ease of use, ease of
> maintenance, and niceness of presentation are important.
As long as the header file says what you think it says, you're fine. If you
encounter a file that does "#define sys", then the sys module is forever
masked, and your module can't invoke it. A header file that contains
"#define declare" will be fun.
Mel.
== 6 of 8 ==
Date: Tues, Mar 2 2010 7:19 am
From: Roy Smith
On Mar 2, 8:33 am, Steve Holden <st...@holdenweb.com> wrote:
> And how important is it to make sure that whatever data your program
> processes doesn't overwrite the actual variable names you want to use to
> program the processing?
Oh, I see what you're saying. You're thinking I was going to machine-
process the C header file and pattern-match the #define statements?
Actually, I was just hand-copying the values, and was looking for a
way to reduce typing.
But, I suppose if I were to machine-process the header files, that
would be a concern. I suppose in that case I would make sure I only
inserted variables which matched a particular pattern (ie, "[A-Z]+_[A-
Z][A-Z0-9]+"). In fact, now that you got me thinking in that
direction...
Somewhat sadly, in my case, I can't even machine process the header
file. I don't, strictly speaking, have a header file. What I have is
a PDF which documents what's in the header file, and I'm manually re-
typing the data out of that. Sigh.
== 7 of 8 ==
Date: Tues, Mar 2 2010 8:14 am
From: Steve Holden
Roy Smith wrote:
> On Mar 2, 8:33 am, Steve Holden <st...@holdenweb.com> wrote:
>
>> And how important is it to make sure that whatever data your program
>> processes doesn't overwrite the actual variable names you want to use to
>> program the processing?
>
> Oh, I see what you're saying. You're thinking I was going to machine-
> process the C header file and pattern-match the #define statements?
> Actually, I was just hand-copying the values, and was looking for a
> way to reduce typing.
>
> But, I suppose if I were to machine-process the header files, that
> would be a concern. I suppose in that case I would make sure I only
> inserted variables which matched a particular pattern (ie, "[A-Z]+_[A-
> Z][A-Z0-9]+"). In fact, now that you got me thinking in that
> direction...
>
> Somewhat sadly, in my case, I can't even machine process the header
> file. I don't, strictly speaking, have a header file. What I have is
> a PDF which documents what's in the header file, and I'm manually re-
> typing the data out of that. Sigh.
>
Don't worry. Now you have revealed the *real* problem you may well find
there are c.l.py readers who can help! Python can read PDFs ...
regards
Steve
--
Steve Holden +1 571 484 6266 +1 800 494 3119
PyCon is coming! Atlanta, Feb 2010 http://us.pycon.org/
Holden Web LLC http://www.holdenweb.com/
UPCOMING EVENTS: http://holdenweb.eventbrite.com/
== 8 of 8 ==
Date: Tues, Mar 2 2010 8:18 am
From: John Posner
On 3/2/2010 10:19 AM, Roy Smith wrote:
>
> Somewhat sadly, in my case, I can't even machine process the header
> file. I don't, strictly speaking, have a header file. What I have is
> a PDF which documents what's in the header file, and I'm manually re-
> typing the data out of that. Sigh.
Here's an idea, perhaps too obvious, to minimize your keystrokes:
1. Create a text file with the essential data:
XYZ_FOO 0 The foo property
XYZ_BAR 1 The bar property
XYZ_BAZ 2 reserved for future use
2. Use a Python script to convert this into the desired code:
declare('XYZ_FOO', 0, "The foo property")
declare('XYZ_BAR', 1, "The bar property")
declare('XYZ_BAZ', 2, "reserved for future use")
Note:
>>> s
'XYZ_FOO 0 The foo property'
>>> s.split(None, 2)
['XYZ_FOO', '0', 'The foo property']
HTH,
John
==============================================================================
TOPIC: (and about tests) Re: Pedantic pickling error after reload?
http://groups.google.com/group/comp.lang.python/t/6d1d3bb3bcc68fe7?hl=en
==============================================================================
== 1 of 1 ==
Date: Tues, Mar 2 2010 3:11 am
From: Robert
>> well, reloading is the thing which I do most in coding practice :-)
>> For me its a basic thing like cell proliferation in biology.
>
> I simply never do it. It has subtle issues, one of them you found,
> others you say you work around by introducing actual frameworks. But you
> might well forget some corner-cases & suddently chase a chimera you deem
> a bug, that in fact is just an unwanted side-effect of reloading.
well, at dev time there is a different rule: the more bugs, the better
(they can raise/indicate certain design and coding weaknesses)
>
> And all this extra complexity is only good for the process of actually
> changing the code. It doesn't help you maintaining code quality.
neither does a improved editor, interactive/debugging/reload
scheme replace tests, nor do tests replace them the other way
around. different dimensions. just the benefactions on all levels
radiate recursively of course ...
e.g. by a good reload scheme one can even work the tests out
better (and debug more efficiently when the tests bump).
that little reload support code is a rather constant small stub
compared to the app size (unless with trivial 1-day apps maybe).
Most 'utility' modules don't need extra care at all.
Plus maybe 1 .. 5 extra lines per few frequently changed GUI
classes (when well organized) and some 5..10 lines for
preserving/re-fixing the few application data anchors. Thats all.
No need to get it fully consistent, as serves its purpose when
editing during runtime is possible in 'most cases'. And most edit
cases during debug sessions are typically just small fixes and
touches of function code. One fix revealing the next follow-up bug
.. beautifying things .. as it is.
critical data structure changes are very rare occasions.
A general reload scheme ("edit at runtime") zeroes out most
effectively a core time consumer while exploring, iterating,
debugging, smoothing ..
On the time scale of these tasks, this effect can in my opinion by
far not be matched equivalently by setup code of whatever kind in
non-trivial apps. (As I did/do this before or with less dynamic
programming languages)
>> I typically need just 1 full app reboot on 20..50 edit-run-cycles I
>> guess. And just few unit test runs per release. Even for
>> Cython/pyximport things I added support for this reload edit-run-cycle,
>> because I cannot imagine to dev without this.
>
> Let me assure you - it works :)
>
> for example yesterday, I create a full CRUD-interface for a web-app
> (which is the thing I work on mostly these days) without *once* taking a
> look at the browser. I wrote actions, forms, HTML, and tests along,
> developed the thing ready, asserted certain constraints and error-cases,
> and once finished, fired up the browser - and he saw, it worked!
>
> Yes, I could have written that code on the fly, hitting F5 every few
> seconds/minutes to see if things work out (instead of just running the
> specific tests through nose) - and once I'd be finished, I didn't have
> anything permanent that ensured the functionality over time.
well in this 1-day example you coded a thing which obviously you
had already done similarly several times. still I guess, you had
some debug session too. some exploration of new things and new
aspects. profiting e.g. particularly from the Python interactive /
interactive debugger, post mortem etc. ..
unless you type so perfect from scratch as that guy in Genesis 1 :-)
>> this is a comfortable quasi religious theory raised often and easily
>> here and there - impracticable and very slow on that fine grained code
>> evolution level however. an interesting issue.
>
> To me, that's as much as an religious statement often heard by people
> that aren't (really) into test-driven development. By which I personally
> don't mean the variant where one writes tests first, and then code. I
> always develop both in lock-step, sometimes introducing a new feauter
> first in my test as e.g. new arguments, or new calls, and then
> implementing them, but as often the other way round.
>
> The argument is always a variation of "my problem is to complicated, the
> code-base to interviened to make it possible to test this".
well, nothing against preaching about tests ;-) , unless its too
much.
like with every extreme there is also a threshold where you don't
draw anymore at the bottom line by adding more tests. there are
costs too. other bottle necks ...
its not against test writing for testing/validating/stabilizing
and other indirect high-level benefactions. there are simply other
dimensions too, which are worth a thought or two. the question
about a good reload scheme is more oriented towards the
debugging/interactive/exploration/editing level. things, where
particularly Python opens new dimensions by its superior dynamic
and self-introspective nature.
> I call this a bluff. You might work with a code-base that makes it
> harder than needed to write tests for new functionality. But then, most
> of the time this is a sign of lack of design. Writing with testability
> in mind makes you think twice about how to proper componentize your
> application, clearly separate logic from presentation, validates
> API-design because using the API is immediatly done when writing the
> tests you need, and so forth.
yes, tests writing can also induce a better code modularization.
a good editor, good debugging/reload scheme etc also radiate...
the test runner can be connected to the post mortem
debugger/interactive and so on.
>> "Reload > pychecker/pylint > tests" works most effectively with Python
>> in my opinion.
>> And for GUI-development the difference is max.
>> (min for math algorithms which are well away from data structures/OO)
>
> As I said, I mainly do web these days. Which can be considered GUIs as
> well. Testing the HTTP-interface is obviously easier & possible, and
> what I described earlier.
>
> But we also use selenium to test JS-driven interfaces, as now the
> complexity of the interface rises, with all the bells & whistles of
> ajaxiness and whatnot.
(the CRUD approach on 'form handling IO level' as it is typically
more simple regarding tests writing than GUI programming - because
of the atomic operations and straight interface. similar like alg
and I/O testing.
While test writing for a flattery JS/CSS-heavy multi-language
multi-state web GUIs (with subtle user interactions) is perhaps
similar complex than doing it for a desktop GUI app I think.
)
>> A rule that unit tests are used only near a release or a milestone is
>> healthy in that sense I think.
>> (And a quick edit-(real)run-interact cycle is good for speed)
>
> Nope, not in my opinion. Making tests an afterthought may well lead to
> them being written carelessly, not capturing corner-cases you
Anyway one can formulate/write tests on each error/problem/design
question which one thinks is worth a test.
A interesting question may be however: if the tests (both: unit
tests and auto code checks) should be _run_ permanently - in order
to lets say have a 'zero test dump status' overall every few
minutes, at the time scale of editing/exploring/debugging ?
I think that one doesn't loose on the savety net effect, but one
wins on overall validation power of the tests, when one _uses_ the
(new and old) tests not too often: more rarely/later/before the
'release'. because after many things are rewired in the code
(incl. test code) for a milestone/release step or, each bump which
arises fresh, lets you think/cure about the network effects and
deeper effect of errors in common, similar contexts etc.
While when one makes the code fit against the 'few artificial
tests' (which are always very/too few!) too fast on the wrong time
scale, its like in that example of quick antibiotica
application/abuse: the cure for the bumps then tend to be too
short sighted. symptom curing. while the clever bugs arise in
background ...
having fresh written tests unused for some time is no problem,
because they will induce there own debug session sooner or later ..
> Testing is no silver bullet. But it's a rather mighte sword.. :)
>
I'd say testing has its place amongst other things and dimensions
like (incomplete):
Editor: type, browse
Language: formulate
Interactive: inspect, try
Debug: inspect, fix
Reload: fix, iterate, explore, clean
Design: organize
Code checks: stabilize
Unit tests: stabilize
Feedback: realize
Each issue can be improved. effective in overall speed. He saw:
If you have no good editor there is some 1.5 .. 2 x less dev
speed. If you have no Python (Ruby, Groovy...) there is some 1.5
.. 2 x less dev speed. If you have no good Interactive/Debugging
there is some 1.5 .. 2 x less dev speed. If you have no improved
reload scheme there is another 1.5 .. 2 x less dev speed. If you
have no good design scheme there is another 1.5 .. 2 x less dev
speed. If you have no good code checks there is another 1.5 .. 2 x
less dev speed. If you have no good test scheme there is another
1.5 .. 2 x less dev speed. If you have no good bug report scheme
there is another 1.5 .. 2 x less dev speed. ...
A improved reload scheme may even speed up at the center of the
development wheel: iteration. I guess I underrated...
Robert
==============================================================================
TOPIC: Call Signtool using python
http://groups.google.com/group/comp.lang.python/t/2a6d7daff19d7360?hl=en
==============================================================================
== 1 of 2 ==
Date: Tues, Mar 2 2010 3:34 am
From: enda man
Hi,
I want to call the Windows signtool to sign a binary from a python
script.
Here is my script:
//
os.chdir('./Install/activex/cab')
subprocess.call(["signtool", "sign", "/v", "/f", "webph.pfx", "/t",
"http://timestamp.verisign.com/scripts/timstamp.dll", "WebPh.exe" ])
//
But I am getting this error:
////
SignTool Error: The specified PFX password is not correct.
Number of files successfully Signed: 0
Number of warnings: 0
Number of errors: 1
Finished building plugin installer
scons: done building targets.
////
This python script is called as part of a scons build, which is also
python code.
Anyone seen this before or can pass on any ideas.
Tks,
EM
== 2 of 2 ==
Date: Tues, Mar 2 2010 6:46 am
From: "Matt Mitchell"
I think you need to use the /p switch to pass signtool.exe a password
when using the /f switch.
Check out
http://msdn.microsoft.com/en-us/library/8s9b9yaz%28VS.80%29.aspx for
more info.
-----------------------------------
The information contained in this electronic message and any attached document(s) is intended only for the personal and confidential use of the designated recipients named above. This message may be confidential. If the reader of this message is not the intended recipient, you are hereby notified that you have received this document in error, and that any review, dissemination, distribution, or copying of this message is strictly prohibited. If you have received this communication in error, please notify sender immediately by telephone (603) 262-6300 or by electronic mail immediately. Thank you.
-----Original Message-----
From: python-list-bounces+mmitchell=transparent.com@python.org
[mailto:python-list-bounces+mmitchell=transparent.com@python.org] On
Behalf Of enda man
Sent: Tuesday, March 02, 2010 6:34 AM
To: python-list@python.org
Subject: Call Signtool using python
Hi,
I want to call the Windows signtool to sign a binary from a python
script.
Here is my script:
//
os.chdir('./Install/activex/cab')
subprocess.call(["signtool", "sign", "/v", "/f", "webph.pfx", "/t",
"http://timestamp.verisign.com/scripts/timstamp.dll", "WebPh.exe" ])
//
But I am getting this error:
////
SignTool Error: The specified PFX password is not correct.
Number of files successfully Signed: 0
Number of warnings: 0
Number of errors: 1
Finished building plugin installer
scons: done building targets.
////
This python script is called as part of a scons build, which is also
python code.
Anyone seen this before or can pass on any ideas.
Tks,
EM
--
http://mail.python.org/mailman/listinfo/python-list
==============================================================================
TOPIC: Verifying My Troublesome Linkage Claim between Python and Win7
http://groups.google.com/group/comp.lang.python/t/ba27d93256f5c275?hl=en
==============================================================================
== 1 of 1 ==
Date: Tues, Mar 2 2010 4:50 am
From: alex23
"W. eWatson" <wolftra...@invalid.com> wrote:
> My claim is that if one creates a program in a folder that reads a file
> in the folder it and then copies it to another folder, it will read the
> data file in the first folder, and not a changed file in the new folder.
> I'd appreciate it if some w7 users could try this, and let me know what
> they find.
On a fresh install of Win7 Ultimate, I created your program & the text
file in one folder, then copied the program both using ctrl-c/ctrl-v
and later ctrl-drag-&-drop. In both cases, the copied program *did
not* refer to the text file when executed:
D:\projects>a
Traceback (most recent call last):
File "D:\projects\a.py", line 1, in <module>
track_file = open("verify.txt")
IOError: [Errno 2] No such file or directory: 'verify.txt'
Whatever you seem to think you did, you didn't, or you're not
providing enough detail on what you did to repeat the behaviour.
I do agree with the sentiment that this isn't a Python issue.
==============================================================================
TOPIC: How to use python to register a service (an existing .exe file)
http://groups.google.com/group/comp.lang.python/t/87b6405cd9ba5a32?hl=en
==============================================================================
== 1 of 1 ==
Date: Tues, Mar 2 2010 5:12 am
From: coldpizza
instsrv.exe does not come with Windows by default, but I guess it
should be possible to add a service using the win32 built-in `sc`
command line tool.
Try `sc create` from a console.
The app you want to install as a service will still have to be
compliant with the win32 service interface, otherwise it will throw an
error, although the app will still be started.
On Feb 16, 2:10 am, News123 <news...@free.fr> wrote:
> Hi,
>
> Is there a python way to register new windows services.
>
> I am aware of the
> instsrv.exe program, which can be used to install services.
> I could use subprocess.Popen to call
>
> instsrv.exe "service_name" program.exe
>
> but wondered, whether there's already an existing function.
>
> Thans in advance and bye
>
> N
==============================================================================
TOPIC: os.fdopen() issue in Python 3.1?
http://groups.google.com/group/comp.lang.python/t/49a2ca4c1f9e7a59?hl=en
==============================================================================
== 1 of 1 ==
Date: Tues, Mar 2 2010 6:24 am
From: Albert Hopkins
I have a snippet of code that looks like this:
pid, fd = os.forkpty()
if pid == 0:
subprocess.call(args)
else:
input = os.fdopen(fd).read()
...
This seems to work find for CPython 2.5 and 2.6 on my Linux system.
However, with CPython 3.1 I get:
input = os.fdopen(fd).read()
IOError: [Errno 5] Input/output error
Is there something wrong in Python 3.1? Is this the correct way to do
this (run a process in a pseudo-tty and read it's output) or is there
another way I should/could be doing this?
-a
==============================================================================
TOPIC: Python training in Florida, April 27-29
http://groups.google.com/group/comp.lang.python/t/f8626b0a1899b27a?hl=en
==============================================================================
== 1 of 1 ==
Date: Tues, Mar 2 2010 7:11 am
From: Mark Lutz
Tired of the Winter weather? Make your plans now to
attend our upcoming Florida Python training seminar
in April. This 3-day public class will be held on
April 27-29, in Sarasota, Florida. It is open to
both individual and group enrollments.
For more details on the class, as well as registration
instructions, please visit the class web page:
http://learning-python.com/2010-public-classes.html
Note that we have moved to a new domain name. If you
are unable to attend in April, our next Sarasota class
is already scheduled for July 13-15.
Thanks, and we hope to see you at a Python class in
sunny and warm Florida soon.
--Mark Lutz at learning-python.com
==============================================================================
TOPIC: taking python enterprise level?...
http://groups.google.com/group/comp.lang.python/t/3dca28b82d10655c?hl=en
==============================================================================
== 1 of 1 ==
Date: Tues, Mar 2 2010 8:22 am
From: aahz@pythoncraft.com (Aahz)
In article <mailman.99.1267513003.23598.python-list@python.org>,
D'Arcy J.M. Cain <darcy@druid.net> wrote:
>
>Put as much memory as you can afford/fit into your database server.
>It's the cheapest performance boost you can get. If you have a serious
>application put at least 4GB into your dedicated database server.
>Swapping is your enemy.
Also, put your log/journal files on a different spindle from the database
files. That makes a *huge* difference.
--
Aahz (aahz@pythoncraft.com) <*> http://www.pythoncraft.com/
"Many customs in this life persist because they ease friction and promote
productivity as a result of universal agreement, and whether they are
precisely the optimal choices is much less important." --Henry Spencer
==============================================================================
TOPIC: Queue peek?
http://groups.google.com/group/comp.lang.python/t/ba3cb62c81d4cb7a?hl=en
==============================================================================
== 1 of 1 ==
Date: Tues, Mar 2 2010 8:29 am
From: Veloz
Hi all
I'm looking for a queue that I can use with multiprocessing, which has
a peek method.
I've seen some discussion about queue.peek but don't see anything in
the docs about it.
Does python have a queue class with peek semantics?
Michael
==============================================================================
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