Re: why does list's .remove() does not return an object?

2018-05-17 Thread David Stanek
On 17-May-2018 12:37, Ned Batchelder wrote:
> On 5/17/18 12:28 PM, Dan Strohl via Python-list wrote:
> > On 2018-05-17 11:26 AM, Abdur-Rahmaan Janhangeer wrote:
> > > I don't understand what this would return? x? You already have x.  Is
> > > it meant to make a copy? x has been mutated, so I don't understand the
> > > benefit of making a copy of the 1-less x.  Can you elaborate on the
> > > problem you are trying to solve?
> > >
> > > --Ned.
> > >
> > >
> > > assignment to another var
> > >
> > Though I don’t know what the OP was specifically looking for I could see a 
> > benefit to returning the item deleted.
>
> Notice that this is not the thing the OP wanted returned.  I believe they
> are looking to return the list, not the item.
>

I'm guessing that they want to be able to do some sort of method
chaining like:

  the_list.remove(x).remove(y)

Although the clarifying example was contrived and confusing. A more
concrete example would be greatly appreciated.

-- 
david stanek
web: https://dstanek.com
twitter: https://twitter.com/dstanek
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Tips or strategies to understanding how CPython works under the hood

2018-01-09 Thread David Stanek
On 09-Jan 15:21, Robert O'Shea wrote:
> 
> Been subscribed to this thread for a while but haven't contributed much.

+1. I'm a lurker too.


> So besides just grabbing a chunk of CPython source code and digesting it, I
> was wondering if those of you have read and understood the source code, do
> you have any tips or good starting points?
> 

There are a ton of videos on Youtube that talk about Python internals. I
liked https://www.youtube.com/playlist?list=PLzV58Zm8FuBL6OAv1Yu6AwXZrnsFbbR0S
quite a bit. Even though I knew a good portion of the material, there
was still a lot of new stuff.

-- 
david stanek
web: https://dstanek.com
twitter: https://twitter.com/dstanek
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Application and package of the same name

2017-10-21 Thread David Stanek
On 19-Oct 19:34, Paul Moore wrote:
> On 19 October 2017 at 19:18, Skip Montanaro <skip.montan...@gmail.com> wrote:
> >
> > This is in Python 2.7, FWIW. What am I missing?
> 
> My immediate reaction is "you shouldn't name your main program and
> your package the same". It's not a pattern I've seen commonly used.
> 

This is actually a common pattern I see when teaching the language. For
example, when a student wants to test out a package like requests many
seem to initially want to create a requests.py module. Then they become
very confused when they get an AttributeError on requests.get().

-- 
david stanek
web: https://dstanek.com
twitter: https://twitter.com/dstanek
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue2445] Use The CygwinCCompiler Under Cygwin

2016-08-30 Thread David Stanek

Changes by David Stanek <dsta...@dstanek.com>:


--
nosy:  -dstanek

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



[issue900092] hotshot.stats.load fails with AssertionError

2014-03-19 Thread David Stanek

Changes by David Stanek dsta...@dstanek.com:


--
nosy: +dstanek

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



Re: Inconsistent SMTP/Gmail connection drop

2011-08-03 Thread David Stanek
On Wed, Aug 3, 2011 at 5:46 PM, Astley Le Jasper
astley.lejas...@gmail.comwrote:


 Any ideas?



Is it possible that the first email is sent before the network connection
has been properly established?

-- 
David
blog: http://www.traceback.org
twitter: http://twitter.com/dstanek
www: http://dstanek.com
-- 
http://mail.python.org/mailman/listinfo/python-list


[issue8036] Interpreter crashes on invalid arg to spawnl on Windows

2011-01-26 Thread David Stanek

David Stanek dsta...@dstanek.com added the comment:

Should this just be resolved as a won't fix?

--
nosy: +dstanek

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



[issue6584] gzip module has no custom exception

2011-01-26 Thread David Stanek

Changes by David Stanek dsta...@dstanek.com:


--
nosy: +dstanek

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



[issue8025] TypeError: string argument expected, got 'str'

2011-01-26 Thread David Stanek

Changes by David Stanek dsta...@dstanek.com:


--
nosy: +dstanek

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



[issue7659] Attribute assignment on object() instances raises wrong exception

2011-01-26 Thread David Stanek

Changes by David Stanek dsta...@dstanek.com:


--
nosy: +dstanek

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



[issue4492] httplib code thinks it closes connection, but does not

2011-01-26 Thread David Stanek

Changes by David Stanek dsta...@dstanek.com:


--
nosy: +dstanek

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



[issue2007] cookielib lacks FileCookieJar class for Internet Explorer

2011-01-26 Thread David Stanek

Changes by David Stanek dsta...@dstanek.com:


--
nosy: +dstanek

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



[issue9233] json.load failure when C optimizations aren't built

2011-01-26 Thread David Stanek

Changes by David Stanek dsta...@dstanek.com:


--
nosy: +dstanek

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



[issue3849] FUD in documentation for urllib.urlopen()

2011-01-26 Thread David Stanek

Changes by David Stanek dsta...@dstanek.com:


--
nosy: +dstanek

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



[issue5097] asyncore.dispatcher_with_send undocumented

2011-01-26 Thread David Stanek

Changes by David Stanek dsta...@dstanek.com:


--
nosy: +dstanek

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



[issue8743] set() operators don't work with collections.Set instances

2011-01-26 Thread David Stanek

Changes by David Stanek dsta...@dstanek.com:


--
nosy: +dstanek

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



[issue7100] test_xmlrpc: global name 'stop_serving' is not defined

2011-01-26 Thread David Stanek

Changes by David Stanek dsta...@dstanek.com:


--
nosy: +dstanek

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



[issue10993] HTTPSConnection does not close when call close() method

2011-01-24 Thread David Stanek

Changes by David Stanek dsta...@dstanek.com:


--
nosy: +dstanek

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



[issue10983] Errors in http.client.HTTPConnection class (python3)

2011-01-24 Thread David Stanek

Changes by David Stanek dsta...@dstanek.com:


--
nosy: +dstanek

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



[issue5885] uuid.uuid1() is too slow

2011-01-24 Thread David Stanek

Changes by David Stanek dsta...@dstanek.com:


--
nosy: +dstanek

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



[issue10911] cgi: add more tests

2011-01-24 Thread David Stanek

Changes by David Stanek dsta...@dstanek.com:


--
nosy: +dstanek

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



[issue2193] Cookie Colon Name Bug

2010-10-18 Thread David Stanek

David Stanek dsta...@dstanek.com added the comment:

My Java may be a bit rusty, but it seems that it would filter out the colon. 
tspecials contains a colon and thus having a colon in the cookie name would 
make in invalid.

I glanced at the Perl code and couldn't find where it filtered out any 
characters.

Would it be better to file bugs against buggy implementations instead of 
changing Python's implementation to be more lenient?

--
nosy: +dstanek

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



[issue1210680] Split email headers near a space

2010-08-17 Thread David Stanek

Changes by David Stanek dsta...@dstanek.com:


--
nosy: +dstanek

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



[issue7275] CoverageResult fails to merge input file with non-empty callers in trace.py (patch)

2010-08-17 Thread David Stanek

Changes by David Stanek dsta...@dstanek.com:


--
nosy: +dstanek

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



[issue8722] Documentation for __getattr__

2010-08-17 Thread David Stanek

Changes by David Stanek dsta...@dstanek.com:


--
nosy: +dstanek

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



[issue5843] Possible normalization error in urlparse.urlunparse

2010-08-17 Thread David Stanek

Changes by David Stanek dsta...@dstanek.com:


--
nosy: +dstanek

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



[issue7159] Urllib2 authentication memory.

2010-08-17 Thread David Stanek

Changes by David Stanek dsta...@dstanek.com:


--
nosy: +dstanek

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



[issue9417] Declaring a class creates circular references

2010-08-17 Thread David Stanek

Changes by David Stanek dsta...@dstanek.com:


--
nosy: +dstanek

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



[issue1573931] WSGI, cgi.FieldStorage incompatibility

2010-08-04 Thread David Stanek

Changes by David Stanek dsta...@dstanek.com:


--
nosy: +dstanek

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



[issue5587] vars() no longer has a useful __repr__

2010-08-04 Thread David Stanek

David Stanek dsta...@dstanek.com added the comment:

A possible fix is to add a __repr__ implementation to proxydict. I've attached 
a patch and also posted it to: http://codereview.appspot.com/1908043.

--
keywords: +patch
nosy: +dstanek
Added file: http://bugs.python.org/file18376/5587.patch

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



[issue9500] urllib2: Content-Encoding

2010-08-03 Thread David Stanek

Changes by David Stanek dsta...@dstanek.com:


--
nosy: +dstanek

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



[issue7013] Httplib read routine is not tolerant to not well-formed chunked http responses.

2010-08-03 Thread David Stanek

Changes by David Stanek dsta...@dstanek.com:


--
nosy: +dstanek

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



[issue5931] Python runtime name hardcoded in wsgiref.simple_server

2010-08-03 Thread David Stanek

Changes by David Stanek dsta...@dstanek.com:


--
nosy: +dstanek

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



[issue8280] urllib2 passes fragment identifier to server

2010-08-03 Thread David Stanek

David Stanek dsta...@dstanek.com added the comment:

Added a patch to fix this behavior.

--
keywords: +patch
nosy: +dstanek
Added file: http://bugs.python.org/file18358/fragment.patch

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



[issue8280] urllib2 passes fragment identifier to server

2010-08-03 Thread David Stanek

David Stanek dsta...@dstanek.com added the comment:

I have also uploaded my patch to http://codereview.appspot.com/1918042 so 
easier viewing.

--

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



[issue754016] urlparse goes wrong with IP:port without scheme

2010-08-03 Thread David Stanek

David Stanek dsta...@dstanek.com added the comment:

I've reworked the patch so that it applied against the py3k branch. It's been 
attached to this issue and is also available here: 
http://codereview.appspot.com/1910044.

--
nosy: +dstanek
Added file: http://bugs.python.org/file18362/754016.patch

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



[issue6602] BaseHTTPServer log_message should log to sys.stdout

2010-08-03 Thread David Stanek

David Stanek dsta...@dstanek.com added the comment:

I think this is the right thing to do. To help this along I've included a 
patch. The codereview is also available: http://codereview.appspot.com/1697062.

--
keywords: +patch
nosy: +dstanek
Added file: http://bugs.python.org/file18365/6602.patch

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



[issue8757] Race condition when checking for set in set

2010-08-03 Thread David Stanek

Changes by David Stanek dsta...@dstanek.com:


--
nosy: +dstanek

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



[issue7464] circular reference in HTTPResponse by urllib2

2010-08-03 Thread David Stanek

David Stanek dsta...@dstanek.com added the comment:

Does this issue still exist? I did a little poking around at could not find the 
quoted code.

--
nosy: +dstanek

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



[issue1673007] urllib2 requests history + HEAD support

2010-08-03 Thread David Stanek

David Stanek dsta...@dstanek.com added the comment:

I have attached a patch to add support for HEAD, PUT and DELETE methods. The 
code review is available here: http://codereview.appspot.com/1696061.

I have started working on another patch that validates that the method is 
properly set. For instance, it doesn't make sense to have a HEAD or DELETE with 
post data. The problem is that the interface is so wide open that it is hard to 
catch all possible user errors. A user could call Request.__init__ correctly, 
but then set req.method to an invalid method. If there is some interest I'll 
finish up the patch.

--
nosy: +dstanek
Added file: http://bugs.python.org/file18369/1673007_methods.patch

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



[issue8150] urllib needs ability to set METHOD for HTTP requests

2010-08-03 Thread David Stanek

David Stanek dsta...@dstanek.com added the comment:

In issue #1673007 I submitted a patch that enables the programmer to create a 
Request instance and specify the method to use.

--
nosy: +dstanek

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



[issue4493] urllib2 doesn't always supply / where URI path component is empty

2010-08-01 Thread David Stanek

Changes by David Stanek dsta...@dstanek.com:


--
nosy: +dstanek

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



[issue9141] Allow objects to decide if they can be collected by GC

2010-07-31 Thread David Stanek

Changes by David Stanek dsta...@dstanek.com:


--
nosy: +dstanek

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



[issue2244] urllib and urllib2 decode userinfo multiple times

2010-07-31 Thread David Stanek

Changes by David Stanek dsta...@dstanek.com:


--
nosy: +dstanek

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



[issue2304] subprocess under windows fails to quote properly when shell=True

2010-07-31 Thread David Stanek

Changes by David Stanek dsta...@dstanek.com:


--
nosy: +dstanek

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



[issue7839] Popen should raise ValueError if pass a string when shell=False or a list when shell=True

2010-07-31 Thread David Stanek

Changes by David Stanek dsta...@dstanek.com:


--
nosy: +dstanek

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



[issue9370] Add reader redirect from test package docs to unittest module

2010-07-31 Thread David Stanek

Changes by David Stanek dsta...@dstanek.com:


--
nosy: +dstanek

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



[issue6293] Have regrtest.py echo back sys.flags

2010-07-31 Thread David Stanek

Changes by David Stanek dsta...@dstanek.com:


--
nosy: +dstanek

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



[issue8910] Write a text file explaining why Lib/test/data exists

2010-07-31 Thread David Stanek

Changes by David Stanek dsta...@dstanek.com:


--
nosy: +dstanek

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



[issue7331] Command line testing consistency between 2.x and 3.x

2010-07-31 Thread David Stanek

Changes by David Stanek dsta...@dstanek.com:


--
nosy: +dstanek

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



[issue7325] tempfile.mkdtemp() does not return absolute pathname when dir is specified

2010-07-31 Thread David Stanek

Changes by David Stanek dsta...@dstanek.com:


--
nosy: +dstanek

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



[issue8572] httplib getheader() throws error instead of default

2010-07-31 Thread David Stanek

David Stanek dsta...@dstanek.com added the comment:

I created some tests for the existing behavior and the expected behavior. One 
of my apps was passing in a tuple and the default. Since this already worked 
and there are probably others besides me expecting this behavior I changed the 
patch to handle this.

The new patch treats any non-string value as an iterable and performs a ', 
'.join() on it. This is basically the old behavior.

This patch is against the py3k branch.

--
nosy: +dstanek
Added file: http://bugs.python.org/file18299/8572.diff

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



[issue8572] httplib getheader() throws error instead of default

2010-07-31 Thread David Stanek

David Stanek dsta...@dstanek.com added the comment:

Adding a patch that includes a documentation change.

--
Added file: http://bugs.python.org/file18302/8572-with-docs.diff

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



Re: Function to apply superset of arguments to a function

2009-09-09 Thread David Stanek
On Wed, Sep 9, 2009 at 12:45 PM, Andrey Fedorovanfedo...@gmail.com wrote:
 Hi all,

 I've written a function [1] called apply_some which takes a set of
 keywords arguments, filters only those a function is expecting, and
 calls the function with only those arguments. This is meant to
 suppress TypeErrors - a way to abstract the logic which checks what
 arguments a passed-in function accepts.

 For example:

 def foo(x=1, y=2):
    return (x,y)

 apply_some(foo, y=0, z=hi) // calls foo(y=0)
 - (1,0)

 I'd like to expand this to fill undefined arguments with None, but
 before I do, does anyone know of any packages/libraries which either
 do something similar or would make this code cleaner?

 Cheers,
 Andrey

 1. http://gist.github.com/183375
 --
 http://mail.python.org/mailman/listinfo/python-list


What is your use-case for using this? It seems really odd to me.

-- 
David
blog: http://www.traceback.org
twitter: http://twitter.com/dstanek
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: HTTP POST File without cURL

2009-09-09 Thread David Stanek
On Wed, Sep 9, 2009 at 1:57 PM, John D Giottajdgio...@gmail.com wrote:
 I'm working with an API that allows me to POST a zip file via HTTP and
 the documentation uses a cURL example. cURL works, but when I try to
 POST the file via python it fails.
 I don't want to use cURL (since I'm trying to be transparent and
 dependency-less), but I can't find anything online that works.

 When I use multipart/form-data methods (found here
 http://code.activestate.com/recipes/146306/), the recipient cannot
 decipher the attached file.

 This is about the most difficult thing I've had to do with python and
 yet it is supposed to be the very basics of HTTP.

 Example cURL command:
 curl -v -u username:passwd --data-binary @/home/jdgiotta/test.zip -H
 Content-Type: application/zip https://host/selector

 Is there a valid way to do this?


Without seeing code it is hard to tell what is happening. What I would
do is capture the HTTP traffic and compare Python to cURL. Then you'll
know how to change you script.

-- 
David
blog: http://www.traceback.org
twitter: http://twitter.com/dstanek
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Function to apply superset of arguments to a function

2009-09-09 Thread David Stanek
On Wed, Sep 9, 2009 at 5:03 PM, Melmwil...@the-wire.com wrote:
 David Stanek wrote:
 On Wed, Sep 9, 2009 at 12:45 PM, Andrey Fedorovanfedo...@gmail.com
 wrote:

 I've written a function [1] called apply_some which takes a set of
 keywords arguments, filters only those a function is expecting, and
 calls the function with only those arguments. This is meant to
 suppress TypeErrors - [ ... ]

 What is your use-case for using this? It seems really odd to me.

 I may have run into one possible use.  I have a program that uses DB-API 2.0
 to work with a database, sometimes SQLite3, sometimes PostgreSQL.  Connect
 parameters are built up in a dict from a combination of defaults,
 environment values, and command-line arguments.  This dictionary has to be
 pruned down before calling connect, because sqlite3.connect doesn't take the
 wide assortment of arguments that are needed for PostgreSQL.  The existing
 program does this by hand, being programmed in advance to know which
 parameters are acceptable to which database module.


The way I would normally do it is to use the URI format and based on
the scheme choose a handler. For example: mysql://u...@host:server/db,
would translate to a mysql specific function that knows what to do.
Adding support for new schemes does mean an additional function, but I
like the control. And it's explicit.

I worry about the magic of the OP's approach. In your example generate
a dictionary in a generic way and apply it to a set of functions. What
happens if in the future if connect_mysql adds adds a parameter with
the same name as one in connect_postgres, but different semantics. Now
the magic is broken and you have an ugly special case.


-- 
David
blog: http://www.traceback.org
twitter: http://twitter.com/dstanek
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python server locks up

2009-09-09 Thread David Stanek
On Wed, Sep 9, 2009 at 4:28 PM, Zac Burnszac...@gmail.com wrote:

 How would you suggest to figure out what is the problem?


I don't think you said your OS so I'll assume Linux.

Sometimes it is more noise than value, but stracing the process may
shed light on what system calls are being made. This in turn may help
you narrow your focus. I find strace helps me a ton in some really
tough problems.

Are you watching for swapping, CPU usage, etc.?

-- 
David
blog: http://www.traceback.org
twitter: http://twitter.com/dstanek
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: hashability

2009-08-12 Thread David Stanek
On Wed, Aug 12, 2009 at 2:18 AM, Asun Friereafri...@yahoo.co.uk wrote:
 On Aug 12, 3:32 pm, James Stroud nospamjstroudmap...@mbi.ucla.edu
 wrote:

 You should be more imaginative.

 I'm by no means discounting that there might be some actual problem
 you're trying to solve here, but I honestly can't see it.

How about a cache? Hashing by id means nothing across machines or even
process runs on the same machine.

-- 
David
blog: http://www.traceback.org
twitter: http://twitter.com/dstanek
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: httplib incredibly slow :-(

2009-08-12 Thread David Stanek
On Tue, Aug 11, 2009 at 4:25 PM, Chris Withersch...@simplistix.co.uk wrote:
 Hi All,

 I'm using the following script to download a 150Mb file:

 from base64 import encodestring
 from httplib import HTTPConnection
 from datetime import datetime

 conn = HTTPSConnection('localhost')
 headers = {}
 auth = 'Basic '+encodestring('username:password').strip()
 headers['Authorization']=auth
 t = datetime.now()
 print t
 conn.request('GET','/somefile.zip',None,headers)
 print 'request:',datetime.now()-t
 response = conn.getresponse()
 print 'response:',datetime.now()-t
 data = response.read()
 print 'read:',datetime.now()-t

 The output shows it takes over 20 minutes to do this.
 However, this is on a local network, and downloading the same file in IE
 takes under 3 seconds!

 I saw this issue:

 http://bugs.python.org/issue2576

 I tried changing the buffer size to 4096 in a subclass as the issue
 suggested, but I didn't see the reported speed improvement.
 I'm using Python 2.6.2.

 Does anyone know of an alternative library for creating http requests and
 getting their responses that's faster but hopefully has a similar interface?


I tried to reproduce this, but I could not. Could you paste in the
output of your script? Also on the same box where you run this script
can you test with curl or wget?

-- 
David
blog: http://www.traceback.org
twitter: http://twitter.com/dstanek
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is feedparser deprecated?

2009-08-08 Thread David Stanek
On Fri, Aug 7, 2009 at 3:07 PM, John Naglena...@animats.com wrote:
  Feedparser requires SGMLlib, which has been removed from Python 3.0.
 Feedparser hasn't been updated since 2007. Does this mean Feedparser
 is dead?


The release is from 2007, but there are several recent commits.

http://code.google.com/p/feedparser/source/list


-- 
David
blog: http://www.traceback.org
twitter: http://twitter.com/dstanek
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: sqlite3 performance problems only in python

2009-07-23 Thread David Stanek
On Thu, Jul 23, 2009 at 9:02 AM, Stef Mientkistef.mien...@gmail.com wrote:

 btw, I don't know if it's of any importance, the SQL-statement I perform is
 select OPNAMEN.*, NAME, NAME_, SCORES.SCORE, PATIENT.*
  from OPNAMEN
   inner join POID_VLID          on OPNAMEN.POID            = POID_VLID.POID
   inner join VRAAGLST           on VRAAGLST.VLID           = POID_VLID.VLID
   inner join VLID_SSID          on VRAAGLST.VLID           = VLID_SSID.VLID
   inner join SUBSCHAAL_GEGEVENS on SUBSCHAAL_GEGEVENS.SSID = VLID_SSID.SSID
   inner join POID_SSID_SCID     on ( OPNAMEN.POID            =
 POID_SSID_SCID.POID ) and
                                    ( SUBSCHAAL_GEGEVENS.SSID =
 POID_SSID_SCID.SSID )
   inner join SCORES             on SCORES.SCID             =
 POID_SSID_SCID.SCID
   inner join PID_POID           on OPNAMEN.POID            = PID_POID.POID
   inner join PATIENT            on PATIENT.PID             = PID_POID.PID
  where substr ( lower( NAME) , 1, 6)  = 'cis20r'
   and lower ( NAME_ ) = 'fatigue'
   and TEST_COUNT in (3,4)
   and DATETIME  39814.0
   and SCORE  30

Warning: I suck at SQL and hate it with a passion...

By using lower() on the left side of the where expressions I believe
that you are table scanning. So it is not the size of the data
returned, but the size of the data that needs to be scanned.

-- 
David
blog: http://www.traceback.org
twitter: http://twitter.com/dstanek
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: sqlite3 performance problems only in python

2009-07-23 Thread David Stanek
On Thu, Jul 23, 2009 at 6:29 PM, Stef Mientkistef.mien...@gmail.com wrote:

 but because the same SQL-statement in Delphi performed well,
 I thought it was a problem with the Python implementation.

Same SQL, but were you also using Sqlite in Delphi?

-- 
David
blog: http://www.traceback.org
twitter: http://twitter.com/dstanek
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Changing the private variables content

2009-07-21 Thread David Stanek
On Tue, Jul 21, 2009 at 6:00 PM, Rhodri
Jamesrho...@wildebst.demon.co.uk wrote:
 On Tue, 21 Jul 2009 21:55:18 +0100, Ryniek90 rynie...@gmail.com wrote:

 Hi.
 I'm writing some class, and decided to use inside private method and some
 private variables. While with method i haven't got any problem's with
 variables i have.

 There is no mechanism in Python that makes attributes truly private.
 self._number is an attribute just like any other, the whole business
 with _leading_underscores is purely a matter of convention.  If you
 have an instance attribute or method with a leading underscore, you
 know that using it or calling it isn't something you're supposed
 to do outside its class, but nothing will stop you doing exactly that
 if you're rude enough to try.


Doubling the _ will give you a little more privacy. It really just
mangles the attribute name, but it close to what you want.

I just use a _single_under to tell other programmers that they
shouldn't be accessing that attribute directly. To my knowledge
nothing bad has happened because things are public and using the
__double_under makes testing a little harder.

   class C(object):
  ... def __init__(self):
  ... self.__x = 0
  ...
   c = C()
   c.__x
  Traceback (most recent call last):
File stdin, line 1, in module
  AttributeError: 'C' object has no attribute '__x'
   c._C__x
  0


-- 
David
blog: http://www.traceback.org
twitter: http://twitter.com/dstanek
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python import Error

2009-07-18 Thread David Stanek
On Sat, Jul 18, 2009 at 3:14 AM, Kalyan
Chakravarthykalyanchakravar...@hyit.com wrote:
 Hi All,
    I am using Python 2.6, MySQL 4.0 , I have successfully
 Instaled MySQLdb (MySQL-python-1.2.3c1.win32-py2.6) in my system. I tested
 through command prompt with import MySQLdb , its not shwing any errors
 (means its instaled successfully), I set Eneceranment variable for Python

 I  am running simple application with import MySQLdb to get the connection
 to MySQL, But its throwing No module named MySQLdb, Please any one tell me
 what couled be the reasion

 is there any version miss match with python and MySQL ?

 Since last 3days I am strugling on this


Off the top of my head I would say that maybe you are using one python
binary from the command-line and another in your script or possibly
your python path is foobar.

-- 
David
blog: http://www.traceback.org
twitter: http://twitter.com/dstanek
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Override a method but inherit the docstring

2009-07-17 Thread David Stanek
On Fri, Jul 17, 2009 at 2:58 AM, Peter Otten__pete...@web.de wrote:
 Ben Finney wrote:

 Howdy all,

 The following is a common idiom::

     class FooGonk(object):
         def frobnicate(self):
              Frobnicate this gonk. 
             basic_implementation(self.wobble)

     class BarGonk(FooGonk):
         def frobnicate(self):
             special_implementation(self.warble)

 The docstring for ‘FooGonk.frobnicate’ is, intentionally, perfectly
 applicable to the ‘BarGonk.frobnicate’ method also. Yet in overriding
 the method, the original docstring is not associated with it.

 Ideally there would be a way to specify that the docstring should be
 inherited. The best I can come up with is::

     class BarGonk(FooGonk):
         def frobnicate(self):
             special_implementation(self.warble)
         frobnicate.__doc__ = FooGonk.frobnicate.__doc__

 but that violates DRY (the association between BarGonk and FooGonk is
 being repeated), puts the docstring assignment awkwardly after the end
 of the method instead of at the beginning where docstrings normally go,
 and reads poorly besides.

 What is the most Pythonic, DRY-adherent, and preferably least-ugly
 approach to override a method, but have the same docstring on both
 methods?

 Just thinking aloud: Write a patch for pydoc that looks up the base-class
 documentation.

 B.f.__doc__ will continue to return None, but

 help(B.f) will show something like

    No documentation available for B.f.

    Help for A.f:
    yadda yadda


 Of course that might be misleading when A.f and B.f are up to something
 completely different...


This should never be the case. It violates LSP and would be very confusing to
readers of the code.


-- 
David
blog: http://www.traceback.org
twitter: http://twitter.com/dstanek
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Override a method but inherit the docstring

2009-07-17 Thread David Stanek
On Fri, Jul 17, 2009 at 3:52 AM, Steven
D'Apranost...@remove-this-cybersource.com.au wrote:
 On Fri, 17 Jul 2009 12:58:48 +1000, Ben Finney wrote:

 Using a decorator in this manner requires repeating the super class
 name.  Perhaps there is a way to get the bases of BarGonk, but I don't
 think so, because at the time that the decorator is called, BarGonk is
 not yet fully defined.

 Yes, I tried a few different ways, but within the decorator it seems the
 function object is quite unaware of what class it is destined for.


 When the decorator is called, the function object is just a function
 object, not a method, so there is no concept of what class it is
 destined for.

 def dec(func):
 ...     print type(func)
 ...     try:
 ...             print func.im_class
 ...     except:
 ...             print no im_class
 ...     return func
 ...
 class Test(object):
 ...     @dec
 ...     def spam(self):
 ...             pass
 ...
 type 'function'
 no im_class
 type(Test.spam)
 type 'instancemethod'
 Test.spam.im_class
 class '__main__.Test'


 I suppose you could try to determine what namespace you're currently when
 the class is created, but that's surely going to be fragile and messy.


It isn't too bad. I got the idea to use the method's enclosing
scope[1] in my decorator[2] from DecoratorTools. I am working to
remove it because it make me sad, but it does work.

[1] 
http://code.google.com/p/snake-guice/source/browse/snakeguice/decorators.py#51
[2] 
http://code.google.com/p/snake-guice/source/browse/snakeguice/decorators.py#58


-- 
David
blog: http://www.traceback.org
twitter: http://twitter.com/dstanek
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to unbuffer Python's output

2009-07-14 Thread David Stanek
2009/7/14 Lily Gao lily@autodesk.com:
 Hi, All

 I am calling a python program in perl and use redirection,

 Like :

 `python x.py  1.log 21`

Try tihs instead:
python x.py 21  1.log

-- 
David
blog: http://www.traceback.org
twitter: http://twitter.com/dstanek
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Looking for the right library for a simple HTTP client

2009-07-10 Thread David Stanek
On Fri, Jul 10, 2009 at 1:29 AM,
scriptlear...@gmail.comscriptlear...@gmail.com wrote:
 I am trying to implement a simple client that can do the following:
 1)to send the following kinds of HTTP requests and validate responses
 1.1 GET
 1.2 POST with application/x-www-form-urlencoded encoding
 1.3 POST with multipart/form-data encoding

 2)to set any number of (even duplicate) headers.  For example, I may
 intentionally add the following Cookie: headers to a request:
 Cookie: id_1=v1;Domain=sample.com;Path=/
 Cookie: id_1=v1;Domain=sample.com;Path=/ --same as the one above
 Cookie: id_2=v1;Domain=sample.com;Path=/

 3)to set proxy cfg so requests can go through a proxy server to reach
 the target server.

 4)to send multiple requests simultaneously.


 I have Python 2.4.1 on Solaris 9 and 10, and I don't have any plan to
 upgrade to latest version of Python.

 I looked around and I found httplib and urllib.  Are they sufficient
 for my tasks 1 to 3 above?  Any good sample codes will be great.
 Thanks.
 --
 http://mail.python.org/mailman/listinfo/python-list


I like urllib2. The examples[1] are pretty good.

[1] http://www.python.org/doc/2.4.1/lib/urllib2-examples.html

-- 
David
blog: http://www.traceback.org
twitter: http://twitter.com/dstanek
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Unexpected behaviour of inner functions/ decorators

2009-06-30 Thread David Stanek
On Tue, Jun 30, 2009 at 1:44 PM, Francesco Bochicchiobieff...@gmail.com wrote:


[snip]

 It looks like the decorator uses an older  instance of 'funct', which
 does not yet
 have the attribute dinamically attached to it. This seem to be
 confirmed by the fact that adding the attribute before
 rebinding the function name, the problem disappear:

The decorator is using the original function that you defined. By
decorating 'funct' you are actually rebinding that name to the
'inner_f' function. So the statement 'funct.enabled = True' is
actually creating an enabled property on the 'inner_f' function.

Take a look at this code:

 def def_f(f):
... def inner_f():
... if iam.enabled:
... f()
... iam = inner_f
... return inner_f
...
 @def_f
... def funct():
... print 'Ciao'
...
 funct.enabled = True
 funct()
Ciao


-- 
David
blog: http://www.traceback.org
twitter: http://twitter.com/dstanek
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Get name of class without instance

2009-06-24 Thread David Stanek
Try Foo.__name__ if Foo is a class object.

On 6/24/09, Bryan bryanv...@gmail.com wrote:
 Given a class:

 class Foo(object):
 pass

 How can I get the name Foo without having an instance of the class?

 str(Foo) gives me more than just the name Foo.   __main__.Account
 Foo.__class__.__name__ gives me type

 I don't want to do:
 Foo().__class__.__name__ if possible.  I would rather avoid the
 constructor.  I just want to get a string Foo

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


-- 
Sent from my mobile device

David
blog: http://www.traceback.org
twitter: http://twitter.com/dstanek
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Guidance on initialization code in a module

2009-06-16 Thread David Stanek
On Tue, Jun 16, 2009 at 4:54 PM, mrstevegrossmrstevegr...@gmail.com wrote:
 Is there a common way to initialize various stuff in a module? That
 is, I have some code in my module that I want to run whenever the
 module is imported. Currently, my module looks like this:

 === foo.py ===
 def something():
  ...

 def somethingelse():
  ...

 something()
 === EOF ===

 Is the 'something()' line at the end in an ok location? I just put it
 at the end. Maybe there's some special __init__() mechanism for
 modules? Or should I use the 'if __name__ != '__main__'' trick?


I think what you are doing is fine. The only thing that I would do
differently is rename 'something' to 'initialize'. That way your
intent is really obvious.


-- 
David
blog: http://www.traceback.org
twitter: http://twitter.com/dstanek
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Odd closure issue for generators

2009-06-08 Thread David Stanek
On Thu, Jun 4, 2009 at 7:42 PM, Scott David
Danielsscott.dani...@acm.org wrote:
 Brian Quinlan wrote:

 This is from Python built from the py3k branch:
   c = (lambda : i for i in range(11, 16))
   for q in c:
 ...     print(q())
 ...
 11
 12
 13
 14
 15
   # This is expected
   c = (lambda : i for i in range(11, 16))
   d = list(c)
   for q in d:
 ...     print(q())
 ...
 15
 15
 15
 15
 15
   # I was very surprised

 You are entitled to be surprised.  Then figure out what is going on.
 Hint: it is the moral equivalent of what is happening here:

     c = []
     for i in range(11, 16):
            c.append(lambda: i)

     i = 'Surprise!'
     print([f() for f in c])
    ['Surprise!', 'Surprise!', 'Surprise!', 'Surprise!', 'Surprise!']

     i = 0
     print([f() for f in c])
    [0, 0, 0, 0, 0]

 The body of your lambda is an un-evaluated expression with a reference,
 not an expression evaluated at the time of loading c.  TO get what you
 expected, try this:

     c = []
     for i in range(11, 16):
            c.append(lambda i=i: i)

     i = 'Surprise!'
     print([f() for f in c])
    [11, 12, 13, 14, 15]

 When you evaluate a lambda expression, the default args are evaluated,
 but the expression inside the lambda body is not.  When you apply that
 evaluated lambda expression, the expression inside the lambda body is
 is evaluated and returned.


Getting around this can be pretty easy:

  c = (lambda i=i: i for i in range(11, 16))
  for q in (list(c)):
  print(q())


-- 
David
blog: http://www.traceback.org
twitter: http://twitter.com/dstanek
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: pylint naming conventions?

2009-06-07 Thread David Stanek
On Sun, Jun 7, 2009 at 9:23 AM, Esmailebo...@hotmail.com wrote:
 Ben Finney wrote:

 Esmail ebo...@hotmail.com writes:

 I am confused by pylint's naming conventions, I don't think the are in
 tune with Python's style recommendations (PEP 8?)

 Anyone else think this?

 It's hard to know, without examples. Can you give some output of pylint
 that you think doesn't agree with PEP 8?

 Sure, I will next time I have a nice self-contained example. Perhaps not
 that
 many people are using pylint? I was expecting a bunch of messages either
 contradicting my observation or agreeing with it :-) .. but perhaps this
 indicates that there's no issue.

It is my understanding that it does check for PEP8 names. Even if it doesn't
it is really easy to change. If you run 'pylint --generate-rcfile' (i think)
it will output the configuration that it is using. You can then save this
off and customize it.


 I'll try to come up with a nice short code example in the next few days
 to demonstrate what I think the problem is and post it, thanks for the
 suggestion.

If you didn't have an example handy what prompted you to start this thread?

-- 
David
blog: http://www.traceback.org
twitter: http://twitter.com/dstanek
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: try except inside exec

2009-05-29 Thread David Stanek
On Fri, May 29, 2009 at 11:55 AM, Michele Petrazzo
michele.petra...@remove_me_unipex.it wrote:

 My goal is to execute a function received from a third-part, so I cannot
 modify as you made in your first piece of code.
 I want a clean exception with the real line code/tb so I can show a real
 error message. This means that the try/execpt has to include the passed
 function and catch every possible exception.

 Do you have any ideas on how can I figure this out?


Is the thirdparty function the entire STR or just the a_funct part?

-- 
David
blog: http://www.traceback.org
twitter: http://twitter.com/dstanek
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: strip char from list of strings

2009-05-19 Thread David Stanek
On Mon, May 18, 2009 at 3:30 PM, Laurent Luce laurentluc...@yahoo.com wrote:

 I have the following list:

 [ 'test\n', test2\n', 'test3\n' ]

 I want to remove the '\n' from each string in place, what is the most 
 efficient way to do that ?


What have you tried so far?

-- 
David
blog: http://www.traceback.org
twitter: http://twitter.com/dstanek
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Performance java vs. python

2009-05-19 Thread David Stanek
On Tue, May 19, 2009 at 5:43 PM, namekuseijin namekusei...@gmail.com wrote:
 someone said:

 If you took a look at Java, you would
 notice that the core language syntax is much simpler than Python's.

 thanks for the laughs whoever you are!


I'm no Java fan, but I do agree that the core language is a bit easier
for people to grasp. I have also heard that from other developers as
well.

-- 
David
blog: http://www.traceback.org
twitter: http://twitter.com/dstanek
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python code-bloat tool-- warning n00b stuff...

2009-05-18 Thread David Stanek
On Mon, May 18, 2009 at 12:45 PM, david wright

 I would suggest looking into TDD (test driven development).

 This technique would be a good fit to eliminate you feeling of code bloat, in 
 TDD you only write the necessary amount
 of code to make your test pass, hence you never write code that is not going 
 to be utilized.

 It takes a little while to get used to this technique ( also, it can be much 
 more difficult to apply in some situations) but it's well worth the effort. 
 :). You'll have no trouble finding tons of resources for this topic.

TDD does help cut down on code bloat, but not because you are only
coding what will actually be used. Rather because of rule #3:
 1. Red - write just enough test code to make a test fail
 2. Green - write just enough production code to make the test pass
 3. Refactor - mercilessly reduce duplication
 4. Repeat

-- 
David
blog: http://www.traceback.org
twitter: http://twitter.com/dstanek
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: object query assigned variable name?

2009-05-02 Thread David Stanek
On Fri, May 1, 2009 at 12:48 PM, Steven D'Aprano
st...@remove-this-cybersource.com.au wrote:
 On Fri, 01 May 2009 09:24:10 -0700, warpcat wrote:

 I'd like it to print, when instanced, something like this:

 s = Spam()
 I’m assigned to s!

 But it seems prohibitively hard (based on my web and forum searches) for
 an object to know what variable name is has been assigned to when
 created.

 Can't be done. Objects don't know what names they are bound to.


While objects don't know what they are assigned to, they can be made
to find out. Unless you have a good use case I don't think that you
really want to be doing it.

DecoratorTools allows you to do this. I have code that allows you to
use a a function like:

class C:
attr = inject(Customer)

The inject function does know that it is being assigned to attr. There
is tracing/frame introspection black magic involved. So much so that I
have been debating removing that feature.

The code is on Bitbucket[1]. It has a little extra complication
because inject can also be used as a decorator. The key is the
decorate_assignment call in the inject function.

Again I don't think you really want to do this.

[1] http://bitbucket.org/dstanek/snake-guice/src/tip/snakeguice/decorators.py

-- 
David
blog: http://www.traceback.org
twitter: http://twitter.com/dstanek
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python Packages : A looming problem? packages might no longer work? (well not on your platform or python version anyway)

2009-04-23 Thread David Stanek
On Thu, Apr 23, 2009 at 2:47 AM, Daniel Fetchinson
fetchin...@googlemail.com wrote:

 The OP is just thinking out loud that it would be great if developers
 could count on some help for testing various platforms and versions.
 And I agree, it would indeed be great.


I think you interpreted the OP differently. As I said before the idea
is not a bad one, but as a package developer I get to decide which
platforms and versions my code supports.

-- 
David
blog: http://www.traceback.org
twitter: http://twitter.com/dstanek
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python Packages : A looming problem? packages might no longer work? (well not on your platform or python version anyway)

2009-04-23 Thread David Stanek
On Thu, Apr 23, 2009 at 12:33 AM, David Lyon david.l...@preisshare.net wrote:
 Hi Steve,
 Why should the package developer dictacte which python version the
 package will run on ?

 Because they're the developer. Who else should decide what Python
 versions to support?
 The developer shouldn't be making such decisions at all
 What hardware or operating systems we run his/her programs on is
 up to the real world to decide.
 If you think about it logically... why are we even asking our
 developers to even build their packages for specific python
 versions in the first place?
 They should just:


You should abandon this argument. Your original idea of a huge build
infrastructure had some merit. This is just off the wall.

If I use win32com how do you expect me to support Linux? What about
the many packages on PYPI containing C? What if I decide to write only
to Python 3? Who will support the other platforms if not the
developer?

--
David
blog: http://www.traceback.org
twitter: http://twitter.com/dstanek
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python Packages : A looming problem? packages might no longer work? (well not on your platform or python version anyway)

2009-04-23 Thread David Stanek
On Thu, Apr 23, 2009 at 1:12 PM, norseman norse...@hughes.net wrote:

 BB's, User Lists, all repositories can make these required before
 acceptance.



This is open source. I volunteer my time on the projects that I
maintain. If you don't like the quality or lack of documentations,
tests, etc. Contribute. Or just don't use the software.

What maybe another option is to have a karma rating on PYPI. Maybe
based off of home much you are included in other packages or some
other factors.

-- 
David
blog: http://www.traceback.org
twitter: http://twitter.com/dstanek
--
http://mail.python.org/mailman/listinfo/python-list


Re: Configuring pylint for local conventions (was: pyflakes, pylint, pychecker - and other tools)

2009-04-23 Thread David Stanek
On Thu, Apr 23, 2009 at 12:00 PM, Aahz a...@pythoncraft.com wrote:
 In article 874owf4gky.fsf...@benfinney.id.au,
 Ben Finney  ben+pyt...@benfinney.id.au wrote:
a...@pythoncraft.com (Aahz) writes:

 Second, you can configure pylint to respect your personal style

How? I haven't seen any decent documentation on doing so.

 Actually, I don't know how, I'm just repeating what was claimed at a
 presentation on pylint.  ;-)  I've traditionally used pychecker myself
 and haven't seen any reason to switch.


I believe you just:

  pylint --generate-rcfile  ~/.pylintrc

and then customize that file.

-- 
David
blog: http://www.traceback.org
twitter: http://twitter.com/dstanek
--
http://mail.python.org/mailman/listinfo/python-list


Re: Configuring pylint for local conventions

2009-04-23 Thread David Stanek
On Thu, Apr 23, 2009 at 10:21 PM, Ben Finney ben+pyt...@benfinney.id.au wrote:
 Ben Finney ben+pyt...@benfinney.id.au writes:

 David Stanek dsta...@dstanek.com writes:

  I believe you just:
    pylint --generate-rcfile  ~/.pylintrc
  and then customize that file.

 This is the part that I'm asking how to do. What documentation is there
 on this configuration file and recommendations on how to modify it?

 For bonus points, I'm actually wanting to know how to configure it per
 *project*, and applying that configuration for all programmers of that
 project. Having one set of coding conventions per *user* seem like a
 recipe for frustration.


I find that the comments in the file it generates are enough. I
haven't needed any more documentation than that.

For project specific configuration I just keep a config file[1] in the
project's source repository. Then make my build script[2] specify that
file when I run 'paver lint'.

[1] http://bitbucket.org/dstanek/snake-guice/src/tip/pylint.cfg
[2] http://bitbucket.org/dstanek/snake-guice/src/tip/pavement.py

-- 
David
blog: http://www.traceback.org
twitter: http://twitter.com/dstanek
--
http://mail.python.org/mailman/listinfo/python-list


Re: execfile (exec?) create non consistent locals() state

2009-04-22 Thread David Stanek
 I expected exec to work the same, but apparently I was wrong. Is there is a
 way to exec a file more correctly? thus avoid the need to resort to
 awkward solutions such as using the locals() dictionary?

 I don't know personally. Perhaps a kind soul will chime in.


Why not just exec into a dictionary like this:

{{{
eee0:~% cat execme.py
a = 0

def func():
print a
eee0:~% python
Python 2.5.2 (r252:60911, Oct  5 2008, 19:24:49)
[GCC 4.3.2] on linux2
Type help, copyright, credits or license for more information.
 d = {}
 execfile('execme.py', d, d)
 d['a']
0
 d['func']()
0

}}}


-- 
David
blog: http://www.traceback.org
twitter: http://twitter.com/dstanek
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python Packages : A looming problem? packages might no longer work? (well not on your platform or python version anyway)

2009-04-22 Thread David Stanek
On Wed, Apr 22, 2009 at 7:06 PM, David Lyon david.l...@preisshare.net wrote:

 One of the big challenges for Python going forward is providing a testing
 infrastructure for Python Packages.

 There are now over 6,000 packages listed on PyPi - and this number can only
 get bigger.


Interesting ideas, but I'm not sure I see the value. As a package
developer I publish eggs for various Python versions and a source
package. In some of my newer stuff I have been thinking of using 2.6+
features, which means I don't care if it runs on any other version.

I've been fine so far in relying on my code running the same on all
platforms. I don't use any of the platform specific modules, but if I
did as a package developer I can just say too bad -you need Linux. I
have been bitten a few times by hardcoding '/' instead of os.path.sep,
but I get a bug report and make a fix. So far no big deal.

I think that if you do this or snakebite gets up and running then
projects should opt in to platform/Python versions.

-- 
David
blog: http://www.traceback.org
twitter: http://twitter.com/dstanek
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python Packages : A looming problem? packages might no longer work? (well not on your platform or python version anyway)

2009-04-22 Thread David Stanek
On Wed, Apr 22, 2009 at 10:39 PM, David Lyon david.l...@preisshare.net wrote:
 Hi David,



 Yes, I agree...

 But as an end-application-developer, I would put it to you that it is a lot
 of effort for developers to humanly contact the package developers every
 time we end-developers find a bug.
 The task (for us developers) involves:

 finding the project page for the project...
 finding their tracking system..
 sometimes finding the project is abandoned
 entering the bug
 waiting a few days


If they took the time to find the package, install the package and
learn to use it then they can file a bug report. And if it is on a
platform that I don't have access to who will submit the patch?

 Given that Python 3 is now on its way

 It strikes me that are a lot of packages that are about to break.


I think it is safe to assume that if the package maintainer didn't
port to Python 3 that it won't work.

 What I am talking about (regression testing) already exists in the Perl
 world..

 So I am hoping to have at least the same in the Python Universe

 It seems to me that from your perspective there would be no change? just

 bug reports coming sooner, rather than later.


Not really. If you are running my unit tests then you have a 50/50
chance of finding a bug. The path bug I mentioned earlier would not
have been found on Windows by running my tests. It would, however,
been caught by real usage.


-- 
David
blog: http://www.traceback.org
twitter: http://twitter.com/dstanek
--
http://mail.python.org/mailman/listinfo/python-list


Re: Passing all extra commandline arguments to python program, Optparse raises exception

2009-04-19 Thread David Stanek
On Thu, Apr 16, 2009 at 10:05 AM, sapsi saptarshi.g...@gmail.com wrote:
 Hello,
 Im using optparse and python 2.6 to parse some options, my commandline
 looks like

 prog [options] start|stop extra-args-i-will-pas-on

 The options are --b --c --d

 The extra options are varied are are passed onto another program e.g --
 quiet --no-command , my program doesnt care what these are but instead
 passes them onto another program.

 I know these will always follow start|stop.

 However optparse tries to process them and throws an exception - how
 can i prevent this without placing all the extra-args in quotes.



In Linux (maybe in Windows) you can tell an application to stop
processing args by using '--'. Given this code:
import sys
from optparse import OptionParser
op = OptionParser()
op.add_option('--a', dest='a', action='store_true', default=False)
op.add_option('--b', dest='b', action='store_true', default=False)
opts, args = op.parse_args(sys.argv)
print 'opts:', opts
print 'args:', args

Here is an example use:
eee0:~% python junk.py --a -- --c
{'a': True, 'b': False}
['junk.py', '--c']


-- 
David
blog: http://www.traceback.org
twitter: http://twitter.com/dstanek
--
http://mail.python.org/mailman/listinfo/python-list


Re: Imports in python are static, any solution?

2009-04-13 Thread David Stanek
On Mon, Apr 13, 2009 at 11:59 AM, Ravi ra.ravi@gmail.com wrote:
 foo.py :

    i = 10

   def fi():
      global i
      i = 99

 bar.py :

    import foo
    from foo import i

    print i, foo.i
    foo.fi()
    print i, foo.i

 This is problematic. Well I want i to change with foo.fi() .

Why not only import foo and using foo.i? In fi() when you set i = 99
you are creating a new object called i in foo's namespace.


-- 
David
blog: http://www.traceback.org
twitter: http://twitter.com/dstanek
--
http://mail.python.org/mailman/listinfo/python-list


Re: Spring-like IoC in python?

2009-04-05 Thread David Stanek
On Sun, Apr 5, 2009 at 5:51 AM, Giovanni Giorgi j...@objectsroot.com wrote:
 Hi all, I have just read the Thread Thoughts on language-level
 configuration support? started by jfager.
 I have worked in the past days with Java Spring.
 I found very valuable the ideas behind Inversion of Control (IoC).
 I think it should be a very nice feature to get into python too.
 In detail, I think the most important concept is the ability to auto-wire
 dependencies declared in the configuration file.
 It is the added value of such idea in my own opinion.
 Spring is heavily based on type declaration (in form of concrete class of
 interfaces) so this approach is not the preferred path in a dynamically
 language like Python.
 Do someone have tried or seen something like IoC container based on Python?


There are several projects implementing IoC in Python. The three I am
most familiar with are snake-guice[0], pinsor[1] and SpringPython[2].
I think they are all worth investigating.

I started snake-guice as a clone of the google-guice project (a Java
IoC framework.) I liked several things that I just didn't see anywhere
else:
 1. Language based configuration because XML sucks
 2. In code hints about what will be injected
 3. Not a container - the injector injects and gets out of the way

The documentation is a little lacking, but that will be changing in
the next few days. Examples of using snake-guice with CherryPy, Django
and TurboGears are just a few days off as well. The API tests[3] show
simple clear examples.

The project is going to be used on several very large websites. So you
can expect it to be maintained for quite a while.

I would encourage you to look at each project and leave feedback where
you can. It can only help each project.

0. http://code.google.com/p/snake-guice/
1. http://code.google.com/p/pinsor/
2. http://springpython.webfactional.com/
3. 
http://code.google.com/p/snake-guice/source/browse/trunk/snakeguice/tests/test_api_25.py

-- 
David
blog: http://www.traceback.org
twitter: http://twitter.com/dstanek
--
http://mail.python.org/mailman/listinfo/python-list


Re: Spring-like IoC in python?

2009-04-05 Thread David Stanek
On Sun, Apr 5, 2009 at 9:24 AM, andrew cooke and...@acooke.org wrote:
 David Stanek wrote:
 [...]
 The documentation is a little lacking, but that will be changing in
 the next few days. Examples of using snake-guice with CherryPy, Django
 and TurboGears are just a few days off as well. The API tests[3] show
 simple clear examples.
 [...]
 3.
 http://code.google.com/p/snake-guice/source/browse/trunk/snakeguice/tests/test_api_25.py

 can i make a suggestion?  add comments to those tests explaining what they
 do in fairly boring, introductory detail (ie we are injecting a value in
 ... because ...).

 also, explain ch (class hierarchy) or, if it's just a meaningless module
 name, use

 from ... import Person

 because i thought it was something important and now think it's noise and
 if its noise it wasted my time.  i know Person is the kind of class used
 in examples, but i am unsure if ch is something special your system
 needs or not.

 i was going to argue that ioc isn't needed in python because the
 motivation for it in java - that you need a more concise configuration
 language - doesn't exist.  what's the point of using xml to simulate a
 scripting language when you are already in a scripting language.  but
 maybe i have missed something, given that this stuff exists (hence me
 trying to understand it).


That is a very good point. Up until recently I had been mostly working
on getting it ready to use at work. I am only beginning my attempt to
get community involvement.


-- 
David
blog: http://www.traceback.org
twitter: http://twitter.com/dstanek
--
http://mail.python.org/mailman/listinfo/python-list


Re: Thoughts on language-level configuration support?

2009-03-31 Thread David Stanek
On Mon, Mar 30, 2009 at 9:40 AM, jfager jfa...@gmail.com wrote:
 I've written a short post on including support for configuration down
 at the language level, including a small preliminary half-functional
 example of what this might look like in Python, available at
 http://jasonfager.com/?p=440.

 The basic idea is that a language could offer syntactic support for
 declaring configurable points in the program.  The language system
 would then offer an api to allow the end user to discover a programs
 configuration service, as well as a general api for providing
 configuration values.


What value does this have over simply having a configuration file. In
your load testing application you could have easily checked for the
settings in a config object. I think that the discover-ability of
configuration can be handled with example configs and documentation.


-- 
David
blog: http://www.traceback.org
twitter: http://twitter.com/dstanek
--
http://mail.python.org/mailman/listinfo/python-list


Re: Thoughts on language-level configuration support?

2009-03-31 Thread David Stanek
On Tue, Mar 31, 2009 at 3:19 AM, jfager jfa...@gmail.com wrote:

 Simply having a configuration file - okay.  What format?  What if
 the end user wants to keep their configuration info in LDAP?  Did the
 library I'm including make the same decisions, or do I have to do some
 contortions to adapt?  Didn't I write basically this  exact same code
 for the last umpteen projects I worked on, just schlepping around
 config objects?


Ah I see your point here. During PyCon I was trying to add the ability
to inject configuration into objects that are constructed by the
snake-guice framework. The code is not yet in the Subversion
repository, but I did brain dump a little documentation[0]. It is
still very much a work in progress.

0. http://code.google.com/p/snake-guice/wiki/InjectingConfiguration

-- 
David
blog: http://www.traceback.org
twitter: http://twitter.com/dstanek
--
http://mail.python.org/mailman/listinfo/python-list


Re: Thoughts on language-level configuration support?

2009-03-31 Thread David Stanek
On Tue, Mar 31, 2009 at 10:01 AM, jfager jfa...@gmail.com wrote:
 On Mar 31, 6:02 am, David Stanek dsta...@dstanek.com wrote:
 On Tue, Mar 31, 2009 at 3:19 AM, jfager jfa...@gmail.com wrote:

  Simply having a configuration file - okay.  What format?  What if
  the end user wants to keep their configuration info in LDAP?  Did the
  library I'm including make the same decisions, or do I have to do some
  contortions to adapt?  Didn't I write basically this  exact same code
  for the last umpteen projects I worked on, just schlepping around
  config objects?

 Ah I see your point here. During PyCon I was trying to add the ability
 to inject configuration into objects that are constructed by the
 snake-guice framework. The code is not yet in the Subversion
 repository, but I did brain dump a little documentation[0]. It is
 still very much a work in progress.

 0.http://code.google.com/p/snake-guice/wiki/InjectingConfiguration

 This is getting close :)  I think it would be nice if you didn't have
 to come up with your own names (so that projects across different
 authors would share more or less the same naming structure), and if
 those names didn't encode their expectation of a particular end-user
 configuration scheme.


For my purpose I am writing the glue infrastructure that allows
components to be put together within an application. What I am missing
is a schema-like way to define configuration files. I have debated
starting a project to do that, but at this time I'm already
overextended :-)


-- 
David
blog: http://www.traceback.org
twitter: http://twitter.com/dstanek
--
http://mail.python.org/mailman/listinfo/python-list


Re: Thoughts on language-level configuration support?

2009-03-31 Thread David Stanek
On Tue, Mar 31, 2009 at 9:42 PM, Lawrence D'Oliveiro
l...@geek-central.gen.new_zealand wrote:
 In message 36148830-22c0-4f19-ab23-
 d04d8755a...@s28g2000vbp.googlegroups.com, jfager wrote:

 I've written a short post on including support for configuration down
 at the language level ...

 If you're advocating anything resembling php.ini, you deserve to die.


I am pretty sure that is uncalled for.


-- 
David
blog: http://www.traceback.org
twitter: http://twitter.com/dstanek
--
http://mail.python.org/mailman/listinfo/python-list


Re: __init__ vs. __del__

2009-03-22 Thread David Stanek
2009/3/21 Randy Turner rtms...@yahoo.com:
 There are a number of use-cases for object cleanup that are not covered by
 a generic garbage collector...

 For instance, if an object is caching data that needs to be flushed to
 some persistent resource, then the GC has
 no idea about this.

 It seems to be that for complex objects, clients of these objects will need
 to explictly call the objects cleanup routine
 in some type of finally clause, that is if the main thread of execution
 is some loop that can terminate either expectedly or
 unexpectedly

 Relying on a generic GC is only for simple object cleanup...at least based
 on what I've read so far.

 Someone mentioned a context manager earlier...I may see what this is about
 as well, since I'm new to the language.


If you add a .close method to your class you can use
contextlib.closing[0]. I have used this to clean up distributed locks
and other non-collectable resources.

0. http://docs.python.org/library/contextlib.html#contextlib.closing

-- 
David
blog: http://www.traceback.org
twitter: http://twitter.com/dstanek
--
http://mail.python.org/mailman/listinfo/python-list


Re: Style question - defining immutable class data members

2009-03-14 Thread David Stanek
On Sat, Mar 14, 2009 at 12:32 PM, Maxim Khitrov mkhit...@gmail.com wrote:
 Very simple question on the preferred coding style. I frequently write
 classes that have some data members initialized to immutable values.
 For example:

 class Test(object):
    def __init__(self):
        self.some_value = 0
        self.another_value = None

 Similar effect can be achieved by defining some_value and
 another_value for the entire class, like so:

 class Test(object):
    some_value = 0
    another_value = None

 The advantage of doing this is that the assignments are evaluated once
 and thus the creation of that class is a bit faster. Access is still
 performed through self.some_value and self.another_value. Is there a
 reason to prefer the first style over the second?


In general I think it can be fine as long as you do use immutable
values. I use this pattern when I create data transfer objects[0].
Normally these objects don't have any methods. So you want to be
careful that you are doing it for the right reason. When I create
objects that are not DTOs I don't do this.

[0] http://martinfowler.com/eaaCatalog/dataTransferObject.html

-- 
David
blog: http://www.traceback.org
twitter: http://twitter.com/dstanek
--
http://mail.python.org/mailman/listinfo/python-list


Re: Why is lambda allowed as a key in a dict?

2009-03-09 Thread David Stanek
On Mon, Mar 9, 2009 at 11:07 PM, Daniel Fetchinson
fetchin...@googlemail.com wrote:
 Python 2.5.1 (r251:54863, Oct 30 2007, 13:45:26)
 [GCC 4.1.2 20070925 (Red Hat 4.1.2-33)] on linux2
 Type help, copyright, credits or license for more information.
 x = { }
 x[lambda arg: arg] = 5
 x[lambda arg: arg]
 Traceback (most recent call last):
  File stdin, line 1, in module
 KeyError: function lambda at 0x2abaab18

 Is this a case of we are all adults here? I should only blame myself
 for making an unnamed function a dictionary key or should it be
 forbidden? Or am I missing something completely?


Each time you are using lambda to create a new anonymous function
object. It is not giving you the same object. If you save the
reference to the lambda you can easily get it back:

 l = lambda arg: arg

 d= {}
 d[l] = 5
 d[l]
5

-- 
David
blog: http://www.traceback.org
twitter: http://twitter.com/dstanek
--
http://mail.python.org/mailman/listinfo/python-list


Re: PyPI editing

2009-03-05 Thread David Stanek
On Thu, Mar 5, 2009 at 3:32 AM, andrew cooke and...@acooke.org wrote:

 Apparently not (this will probably change, but see
 http://pypi.python.org/pypi/LEPL/2.0.1 which is currently displaying
 restructured text literally)


Did you put the ReST in the description or the long_description? Take
a look at the setup.py from the example you gave:
http://code.google.com/p/pypp/source/browse/trunk/setup.py.

Warning: I have not done this myself.

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


Re: SVN/CVS and Branching

2009-02-19 Thread David Stanek
On Thu, Feb 19, 2009 at 7:10 AM, Jeff Dyke jeff.d...@gmail.com wrote:
 Fair enough.  Say my project is called foo, and it has many
 submodules.  So there are imports that may look like `import foo.bar`
 or `from foo.bar import baz`, if i change the top level directory, it
 is no longer foo and then those imports do not work as originally
 written.  The way i currently do this  is to create a branch, say
 foo2, and create a symbolic link named foo pointing at foo2, after
 renaming foo, when i want to work on the branch and remove the link
 when i want to work on the head.  This actually works fine, but
 thought there may be a better way.

 Jeff


I think that your project structure is faulty. In Subversion I do
something like:

* FooProject/trunk/foo
* FooProject/branches/TRY-foo2

TRY-foo2 is an svn cp of trunk so checking out TRY-foo2 gives you a
TRY-foo2 directory containing a foo package. My DVCS projects go
essentially the same thing.


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


Re: Code coverage to Python code

2009-01-04 Thread David Stanek
On Sun, Jan 4, 2009 at 9:26 PM, Roy Smith r...@panix.com wrote:
 In article mailman.6574.1231108877.3487.python-l...@python.org,
  Robert Kern robert.k...@gmail.com wrote:

 Hussein B wrote:
  Hey,
  What is the best code coverage tool available for Python?

 I like Titus Brown's figleaf.

 http://darcs.idyll.org/~t/projects/figleaf/doc/

 I was playing with Ned Batchelder's coverage.py module today.  Once I
 stopped screwing around trying to get the easy install stuff to work and
 just copied the danged .py file to my site-packages directory, I was up and
 running in a few minutes.

 I suppose there's a lot of bells and whistles you could add, but it ran my
 code and told me which lines had executed and which hadn't.  That pretty
 much seems like what you want a code coverage tool to do.

 http://nedbatchelder.com/code/modules/coverage.html

It will show lines as covered when they are executed by the
interpreter. Class statements, function definitions, etc. can show up
as executed. Are you seeing other code show up as covered?

shameless_self_promotion
Recently I pushed a branch of an experimental project I am calling
Barbarian[0]. It uses nose, figleaf and pylint to generate HTML for a
project. A blog post with a more detailed description will be posted
within a few days.

[0] http://code.launchpad.net/~dstanek/+junk/Barbarian
/shameless_self_promotion

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


  1   2   >