[issue24185] Add Function for Sending File to Trash (or Recycling Bin)

2015-05-14 Thread Virgil Dupras
Virgil Dupras added the comment: For further references, there's also https://mail.python.org/pipermail/python-ideas/2014-December/030547.html which is a deeper discussion and brings even more arguments against it. Even though I'd love to have some of my code integrated into the core

[issue21643] File exists error during venv --upgrade

2014-06-03 Thread Virgil Dupras
Virgil Dupras added the comment: I could reproduce the bug on the v3.4.1 tag, on the 3.4 branch and on the default branch. I think that one of the conditions for the bug to arise is to have the lib64 symlink created (as described in #21197). I reproduced the bug on Gentoo and Arch

[issue21643] File exists error during venv --upgrade

2014-06-02 Thread Virgil Dupras
New submission from Virgil Dupras: There seems to have been a regression in Python 3.4.1 with pyvenv --upgrade, and this regression seems to be caused by #21197. It now seems impossible to use the --upgrade flag without getting a File exists error. Steps to reproduce: $ pyvenv env $ pyvenv

[issue15051] Can't compile Python 3.3a4 on OS X

2012-06-12 Thread Virgil Dupras
New submission from Virgil Dupras hs...@hardcoded.net: I try to compile Pyhton 3.3a4 on a OS X 10.7 with XCode 4.3.3 and it fails. I tried a few configuration options, but even with a basic ./configure make, I get this: ./python.exe -SE -m sysconfig --generate-posix-vars Could not find

[issue11076] Iterable argparse Namespace

2011-02-10 Thread Virgil Dupras
Virgil Dupras hs...@hardcoded.net added the comment: Here's a documentation-only patch which adds a section about using vars() to convert a namespace to a dict. If this becomes a documentation issue, can we target Python 3.2.1 instead of Python 3.3? -- Added file: http

[issue11076] Iterable argparse Namespace

2011-02-05 Thread Virgil Dupras
Virgil Dupras hs...@hardcoded.net added the comment: I didn't know about vars() (well, I knew it existed, but never was quite sure what it did). Given that I'm not a Python newbie, I'm guessing I'm not alone in this situation. Maybe that instead of making the Namespace iterable, we should

[issue11076] Iterable argparse Namespace

2011-02-02 Thread Virgil Dupras
Virgil Dupras hs...@hardcoded.net added the comment: I went ahead and created a patch (with test and doc) making argparse.Namespace iterable. -- keywords: +patch -easy Added file: http://bugs.python.org/file20648/issue11076.diff ___ Python tracker

[issue11076] Iterable argparse Namespace

2011-01-31 Thread Virgil Dupras
New submission from Virgil Dupras hs...@hardcoded.net: Currently, there is no (documented) way to easily extract arguments in an argparse Namespace as a dictionary. This way, it would me easy to interface a function taking a lot of kwargs like this: args = parser.parse_args() my_function

[issue10418] test_io hangs on 3.1.3rc1

2010-11-14 Thread Virgil Dupras
New submission from Virgil Dupras hs...@hardcoded.net: I downloaded Python 3.1.3rc1 this morning to do my civic duty of testing it. I don't know what I'm doing wrong, but for me, test_io hangs and never completed. I'm on OS X 10.6.5. I ran it with: $ ./python.exe Lib/test/regrtest.py test_io

[issue10418] test_io hangs on 3.1.3rc1

2010-11-14 Thread Virgil Dupras
Virgil Dupras hs...@hardcoded.net added the comment: I ran the test with the -v option flag. The malloc error don't happen at the same place the hang up happens. The first one happens at: test_readline (test.test_io.PyIOTest) ... ok test_unbounded_file (test.test_io.PyIOTest) ... skipped 'test

[issue10418] test_io hangs on 3.1.3rc1

2010-11-14 Thread Virgil Dupras
Virgil Dupras hs...@hardcoded.net added the comment: Nobody else can reproduce the bug? I'm not sure I can fix this (although I can try). I tried to re-compile 3.1.2 with the same flags and run test_io and it passes, so something happened between 3.1.2 and 3.1.3rc1. So, I'll give it a look

[issue10418] test_io hangs on 3.1.3rc1

2010-11-14 Thread Virgil Dupras
Virgil Dupras hs...@hardcoded.net added the comment: Ooh, darn, that was it. I installed it and afterwards, the tests passed. Sorry for the fuss, I'll keep that gotcha in mind next time. -- resolution: - invalid status: open - closed ___ Python

[issue839159] iterators broken for weak dicts

2010-07-23 Thread Virgil Dupras
Virgil Dupras hs...@hardcoded.net added the comment: It looks like this issue has been fixed in issue7105 already. Can we close this ticket? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue839159

[issue839159] iterators broken for weak dicts

2010-07-23 Thread Virgil Dupras
Virgil Dupras hs...@hardcoded.net added the comment: We might as well backport Antoine's patch rather than take this one (even if mine for 2.x already). It would be weird to have 2 wildly different patches to solve the same problem. Maybe close this ticket and flag issue7105 for backporting

[issue8392] unit tests rather light on testing __import__(..., level)

2010-07-23 Thread Virgil Dupras
Virgil Dupras hs...@hardcoded.net added the comment: If I understand the patch correctly, this patch basically add a test for relative imports. I'm pretty sure this is already testes in importlib.test. Brett, am I right? If yes, there's no point in applying this patch. -- nosy

[issue8392] unit tests rather light on testing __import__(..., level)

2010-07-23 Thread Virgil Dupras
Virgil Dupras hs...@hardcoded.net added the comment: Because importlib is already well tested and that it already has the machinery to test __import__ instead of the importlib code, I suggest that we re-use importlib's relative tests instead. Attached is a patch that does this. I made sure

[issue7830] Flatten nested functools.partial

2010-07-23 Thread Virgil Dupras
Virgil Dupras hs...@hardcoded.net added the comment: Applies cleanly on the py3k branch at r83069, the tests work correctly (fail before applying the patch, success afterwards), and, to the best of my C-API knowledge, the C code is alright. Oh, and it behaves as described... Python 3.2a0

[issue7830] Flatten nested functools.partial

2010-07-23 Thread Virgil Dupras
Virgil Dupras hs...@hardcoded.net added the comment: Oops, used it wrong (but it still works correctly). p2 = partial(p1, 2) p2.func, p2.args (function foo at 0x10051da68, (1, 2)) -- ___ Python tracker rep...@bugs.python.org http

[issue8392] unit tests rather light on testing __import__(..., level)

2010-07-23 Thread Virgil Dupras
Virgil Dupras hs...@hardcoded.net added the comment: Brett, I think there's a problem with the tweak you made to the patch. There was already a testcase called RelativeImportTests and you've hidden it (that I why I called it ImportlibRelativeImportTests initially

[issue9043] 2to3 doesn't handle byte comparison well

2010-06-21 Thread Virgil Dupras
New submission from Virgil Dupras hs...@hardcoded.net: If we run 2to3 on the following code: s = b' ' print s[0] == s we end up with this: s = b' ' print(s[0] == s) However, the first code, under python2 prints True while the converted code, under python3 prints False. Shouldn't 2to3

[issue6095] os.curdir as the default argument for os.listdir

2010-04-19 Thread Virgil Dupras
Virgil Dupras hs...@hardcoded.net added the comment: Here's another one. I hadn't realized that it was useless to target the 2.x codebase. So I re-worked this on py3k. The change is non-trivial, since the non-windows/non-os2 part of the code has significantly changed in 3k. This time, since

[issue6095] os.curdir as the default argument for os.listdir

2010-04-18 Thread Virgil Dupras
Virgil Dupras hs...@hardcoded.net added the comment: Since I last submitted this patch, my leet C skills have improved. I'm submitting another patch, without the needless PyUnicode creation this time. (Moreover, I think the previous patch was wrong to insert code before variable declaration

[issue7350] csv doesn't handle escaped characters properly

2009-11-20 Thread Virgil Dupras
Virgil Dupras hs...@hardcoded.net added the comment: You have to tell the reader how to handle escaping. In your case, you should send escapechar=\\ in reader()'s kwargs. -- nosy: +vdupras ___ Python tracker rep...@bugs.python.org http

[issue6095] os.curdir as the default argument for os.listdir

2009-06-14 Thread Virgil Dupras
Virgil Dupras hs...@hardcoded.net added the comment: 1. Yeah, I know. At first, that's what I wanted to do, but it resulted in a lot of code duplication (alloc, memerror, copy), which I didn't much like. But then again, what I ended up writing (because I realized I had to decref the new po

[issue6095] os.curdir as the default argument for os.listdir

2009-06-13 Thread Virgil Dupras
Virgil Dupras hs...@hardcoded.net added the comment: I saw this ticket as a good way to get my feet wet (I almost never touched C) with Python's C API, so I went ahead and did the part for OS X. I also did the Windows part, but I'm not setup to compile Python on Windows, so I don't even know

[issue5679] cleanUp stack for unittest

2009-04-05 Thread Virgil Dupras
Virgil Dupras hs...@hardcoded.net added the comment: So, we are talking about adding a feature that could cause problem whether cleanup is performed before tearDown or after tearDown. Don't we risk confusing developers who are not familiar with the cleanup order? Do we really want to add

[issue1741130] struct.pack(I, foo); struct.pack(L, foo) should fail

2009-04-01 Thread Virgil Dupras
Virgil Dupras hs...@hardcoded.net added the comment: While the behavior cannot be reproduced in the trunk, in can be reproduced in the 2.6 release: $ python -W ignore Python 2.6.1 (r261:67515, Dec 6 2008, 16:42:21) [GCC 4.0.1 (Apple Computer, Inc. build 5370)] on darwin Type help, copyright

[issue5345] cStringIO class name typo

2009-02-22 Thread Virgil Dupras
Virgil Dupras hs...@hardcoded.net added the comment: The documentation says: Another difference from the StringIO module is that calling StringIO() with a string parameter creates a read-only object. Unlike an object created without a string parameter, it does not have write methods

[issue839159] iterators broken for weak dicts

2009-02-14 Thread Virgil Dupras
Virgil Dupras hs...@hardcoded.net added the comment: About duplicated code and performance: When I look at the duplicated code, I don't see anything that remotely looks like a performance tweak. Just to make sure, I made a bench: #!/usr/bin/env python import sys sys.path.insert(0, 'Lib

[issue839159] iterators broken for weak dicts

2009-02-14 Thread Virgil Dupras
Virgil Dupras hs...@hardcoded.net added the comment: Oh, that's me again not correctly reading my own tests. It's the *_are_not_held_* tests that test that no reference is kept. I agree about the *_flushed_dead_items_* being an implementation detail

Re: [Python-Dev] as keyword woes

2008-12-06 Thread Virgil Dupras
On 06 Dec 2008, at 20:38, Warren DeLano wrote: Date: Fri, 05 Dec 2008 22:22:38 -0800 From: Dennis Lee Bieber [EMAIL PROTECTED] Subject: Re: as keyword woes To: python-list@python.org Message-ID: [EMAIL PROTECTED] I'm still in the dark as to what type of data could even inspire the

[issue1117601] os.path.exists returns false negatives in MAC environments.

2008-08-08 Thread Virgil Dupras
Virgil Dupras [EMAIL PROTECTED] added the comment: hsoft-dev:~ hsoft$ mkdir foobar hsoft-dev:~ hsoft$ echo baz foobar/baz hsoft-dev:~ hsoft$ chmod 000 foobar/baz hsoft-dev:~ hsoft$ python Python 2.5.2 (r252:60911, Feb 22 2008, 07:57:53) [GCC 4.0.1 (Apple Computer, Inc. build 5363)] on darwin

[issue2153] unittest.py modernization

2008-08-08 Thread Virgil Dupras
Virgil Dupras [EMAIL PROTECTED] added the comment: This patch has gone invalid due to some recent conflicting changes. I remade it and I'm resubmitting it hoping that it will get applied. Added file: http://bugs.python.org/file11086/unittest_modern2.diff

[issue3189] Py3k DeprecationWarning in difflib

2008-06-24 Thread Virgil Dupras
New submission from Virgil Dupras [EMAIL PROTECTED]: When running with the -3 flag, difflib creates DeprecationWarnings. I attach a patch fixing them. There was a note in the code saying DOES NOT WORK for x in a. However, after my changes, tests still pass, so I removed these notices

[issue3189] Py3k DeprecationWarning in difflib

2008-06-24 Thread Virgil Dupras
Virgil Dupras [EMAIL PROTECTED] added the comment: It slipped out of my mind that performance was probably important for this module, so I ditched that nested get call and went if an if..else. Added file: http://bugs.python.org/file10718/difflib_py3k_deprecation2.diff

Re: Subclassing list the right way?

2008-04-25 Thread Virgil Dupras
On Apr 25, 4:03 pm, Kirk Strauser [EMAIL PROTECTED] wrote: I want to subclass list so that each value in it is calculated at call time.  I had initially thought I could do that by defining my own __getitem__, but 1) apparently that's deprecated (although I can't find that; got a link?), and 2)

Re: Class Inheritance - What am I doing wrong?

2008-04-24 Thread Virgil Dupras
On Apr 24, 10:22 pm, Brian Munroe [EMAIL PROTECTED] wrote: My example: class A(object):         def __init__(self, name):                 self.__name = name         def getName(self):                 return self.__name class B(A):         def __init__(self,name=None):                

[issue2162] unittest.findTestCases undocumented

2008-03-18 Thread Virgil Dupras
Virgil Dupras [EMAIL PROTECTED] added the comment: Can't we close this ticket? __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue2162 __ ___ Python-bugs-list mailing list

[issue2387] cStringIO and unicode

2008-03-18 Thread Virgil Dupras
New submission from Virgil Dupras [EMAIL PROTECTED]: hsoft-dev:python hsoft$ python Python 2.5.1 (r251:54869, Apr 18 2007, 22:08:04) [GCC 4.0.1 (Apple Computer, Inc. build 5367)] on darwin Type help, copyright, credits or license for more information. from cStringIO import StringIO StringIO

[issue984219] hotspot.stats.load is very slow

2008-03-18 Thread Virgil Dupras
Virgil Dupras [EMAIL PROTECTED] added the comment: I had a 54 mb hotshot profile lying around, and it is indeed very long to load, so I ran a profiling session of hotshot.stats.load(MY_BIG_FILE) with python and stdlib of r61515, and here are the results (the resulting prof file is 27 mb

[issue2127] sqlite3 docs should mention utf8 requirement

2008-02-28 Thread Virgil Dupras
Virgil Dupras added the comment: Ok then, we need a test for this. Patch attached. However, I don't know if I applied Amaury's patch wrong or if I miss a ./configure option or something, but even with the patch, the test fails. Another thing: Why isn't the sqlite3 test suite a part

[issue2127] sqlite3 docs should mention utf8 requirement

2008-02-28 Thread Virgil Dupras
Virgil Dupras added the comment: u':memory:'? That already worked before the patch because the implicit encoding with 'ascii' does not bump into any non-ascii character. Nope, one has to call connect with a filename containing non-ascii characters. __ Tracker

[issue1738] filecmp.dircmp does exact match only

2008-02-24 Thread Virgil Dupras
Virgil Dupras added the comment: The documentation doesn't say anything about dircmp being supposed to support pattern matching. This ticket is a feature request rather than a bug. -- components: +Library (Lib) -None nosy: +vdupras type: behavior - feature request

[issue839159] iterators broken for weak dicts

2008-02-24 Thread Virgil Dupras
Virgil Dupras added the comment: I made a patch to fix the problem. The cleaning up of they weakref keys or values will be held until all references to iterators created by the weakdict are dead. I also couldn't resist removing code duplication of code in items(), keys() and values

[issue2162] unittest.findTestCases undocumented

2008-02-22 Thread Virgil Dupras
Virgil Dupras added the comment: findTestCases is an obsolete function. From the code: # Expose obsolete functions for backwards compatibility __all__.extend(['getTestCaseNames', 'makeSuite', 'findTestCases']) -- nosy: +vdupras __ Tracker [EMAIL

[issue2153] unittest.py modernization

2008-02-21 Thread Virgil Dupras
New submission from Virgil Dupras: What prompted me to do these changes is that Backward compatibility section for 2.1 and earlier. How long are we going to keep this? According to svn, no commit has been made on the 2.1 branch since 2003. Is it safe to assume no unittest change is ever going

[issue2156] TestCase.tmpdir(), TestCase.mock()

2008-02-21 Thread Virgil Dupras
New submission from Virgil Dupras: I've been using unittest for quite a while. One thing I got tired with is the code duplication for file management and mocking. A few months ago I created this nifty little TestCase subclass and I've been using it ever since. It works quite well. Am I

[issue2127] sqlite3 docs should mention utf8 requirement

2008-02-21 Thread Virgil Dupras
Virgil Dupras added the comment: Shouldn't we apply this patch directly on pysqlite? Any change made to the sqlite3 module will be overwritten in the next refresh, right? Anyway, I'm not 100% sure, but it might already be fixed: http://www.initd.org/tracker/pysqlite/changeset/452 So, maybe

[issue2153] unittest.py modernization

2008-02-21 Thread Virgil Dupras
Virgil Dupras added the comment: Isn't it why KeyboardInterrupt is a subclass of BaseException instead of Exception (along with SystemExit)? so that except Exception: doesn't catch it? __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue2153

[issue2156] TestCase.tmpdir(), TestCase.mock()

2008-02-21 Thread Virgil Dupras
Virgil Dupras added the comment: Oh, you meant hs.path? ah yeah, it's just for tmppath(), which is of no use except in my own stuff. __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue2156

[issue2156] TestCase.tmpdir(), TestCase.mock()

2008-02-21 Thread Virgil Dupras
Virgil Dupras added the comment: Well, yeah, but I'm the owner, it's not like if the copyright was a problem. I'd gladly release it (and the test unit that goes with it) under BSD. __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue2156

[issue2144] os.environ should inherit dict

2008-02-20 Thread Virgil Dupras
Virgil Dupras added the comment: The performance gain is rather good: hsoft-dev:python hsoft$ ./python.exe -m timeit -s import os os.environ['HOME'] 100 loops, best of 3: 1.16 usec per loop hsoft-dev:python hsoft$ patch -p0 environ-modern.diff patching file Lib/os.py hsoft-dev:python

[issue2127] sqlite3 docs should mention utf8 requirement

2008-02-19 Thread Virgil Dupras
Virgil Dupras added the comment: +1 I've been pulling my hair off over this one too. Try this on win32: Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit (Intel)] on win32 Type help, copyright, credits or license for more information. import os os.mkdir(u'foo\xe9') import

[issue1149798] hotshot.runctx: builtins missing

2008-02-19 Thread Virgil Dupras
Virgil Dupras added the comment: Python 2.5.1 (r251:54869, Apr 18 2007, 22:08:04) [GCC 4.0.1 (Apple Computer, Inc. build 5367)] on darwin Type help, copyright, credits or license for more information. import hotshot hotshot.Profile('/tmp/hs').runctx('print len',{'__builtins__

[issue1149798] hotshot.runctx: builtins missing

2008-02-19 Thread Virgil Dupras
Virgil Dupras added the comment: oh crap here goes my ego... pasted the wrong line. _ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1149798 _ ___ Python-bugs-list mailing

[issue1149798] hotshot.runctx: builtins missing

2008-02-19 Thread Virgil Dupras
Virgil Dupras added the comment: Well, since I brought that issue back, I might as well supply a patch. So if indeed it is decided that hotshot.Profile.runctx() should have __builtins__ in its globals by default, here is it. Added file: http://bugs.python.org/file9462

[issue2124] xml.sax and xml.dom fetch DTDs by default

2008-02-17 Thread Virgil Dupras
Virgil Dupras added the comment: -1 on the systematic warnings too, but what I was talking about is a warning that would say The server you are trying to fetch your resource from is refusing the connection. Don't cha think you misbehave? only on 5xx and 4xx responses, not on every remote

[issue2124] xml.sax and xml.dom fetch DTDs by default

2008-02-16 Thread Virgil Dupras
Virgil Dupras added the comment: The blog page talked about 503 responses. What about issuing a warning on these responses? Maybe it would be enough to make developers aware of the problem? Or what about in-memory caching of the DTDs? Sure, it wouldn't be as good as a catalog or anything

[issue1734234] Fast path for unicodedata.normalize()

2008-02-15 Thread Virgil Dupras
Virgil Dupras added the comment: It's a very interesting patch. I wonder why it fell into oblivion. stuff like unicode.normalize('NFC', u'\xe9') was more than twice as fast for me. Making sure that all unicode is normalized can be a bottleneck in a lot of applications (it somewhat is in my

[issue1777134] minidom pretty xml output improvement

2008-02-15 Thread Virgil Dupras
Virgil Dupras added the comment: If the patch would have better styling (if(onetextnode == True):), correct the test it breaks, and even better, add new ones, I guess it would be an acceptable one. -- nosy: +vdupras _ Tracker [EMAIL PROTECTED] http

[issue1390] toxml generates output that is not well formed

2008-02-12 Thread Virgil Dupras
Virgil Dupras added the comment: I wanted to start contributing to python for quite a while, so here's my very first try (cleaning out old patchless open tickets). So, whatever is the final decision on this, here's a patch. CDATASection.writexml() already raises ValueError when finding

Re: Test driven development

2008-01-24 Thread Virgil Dupras
On Jan 24, 7:37 am, [EMAIL PROTECTED] wrote: Hi Sorry if this is a bit off topic but as unit testing is such a cornerstone of python development I thought a few of you may be able to share your knowledge/experiences. I like the concept of TDD but find it difficult to put into practice most

Re: Test driven development

2008-01-24 Thread Virgil Dupras
On Jan 24, 1:30 pm, Roel Schroeven [EMAIL PROTECTED] wrote: Virgil Dupras schreef: I know what you mean by top-down vs. bottom-up and I used to have the same dilemma, but now I would tend to agree with Albert. Your issue with top-down or bottom-up is not relevant in TDD. The only thing

Re: Best way to protect my new commercial software.

2007-12-10 Thread Virgil Dupras
On Dec 10, 8:15 am, farsheed [EMAIL PROTECTED] wrote: I wrote a software and I want to protect it so can not be cracked easily. I wrote it in python and compile it using py2exe. what is the best way in your opinion? Don't. This is a fight you already lost. Besides, people who crack software

Re: a Python person's experience with Ruby

2007-12-10 Thread Virgil Dupras
On Dec 9, 1:15 am, Bruno Desthuilliers [EMAIL PROTECTED] wrote: Richard Jones a écrit : Bruno Desthuilliers wrote: class A(object): @apply def a(): def fget(self): return self._a def fset(self, val): self._a = val return property(**locals())

Re: Best way to protect my new commercial software.

2007-12-10 Thread Virgil Dupras
On Dec 10, 9:55 am, farsheed [EMAIL PROTECTED] wrote: Thanks. But I ask this question technically, I mean I know nothing is uncrackable and popular softwares are not well protected. But my software is not that type and I don't want this specific software popular. It is some kind of in house

Re: Any simpler way to do this

2007-12-07 Thread Virgil Dupras
On Dec 7, 9:37 am, Lars Johansen [EMAIL PROTECTED] wrote: I have a function that looks like this: def Chooser(color): if color == RED: x = term.RED elif color == BLUE: x = term.BLUE elif color == GREEN: x =

Re: Dictionary instantiation?

2007-12-07 Thread Virgil Dupras
On Dec 7, 9:05 am, Matt_D [EMAIL PROTECTED] wrote: Hello there, this is my first post to the list. Only been working with Python for a few days. Basically a complete newbie to programming. I'm working with csv module as an exercise to parse out a spreadsheet I use for work.(I am an editor for

Re: Can I embed Windows Python in C# or VC++?

2007-12-07 Thread Virgil Dupras
On Dec 7, 9:03 am, grbgooglefan [EMAIL PROTECTED] wrote: On Dec 7, 3:07 pm, Gabriel Genellina [EMAIL PROTECTED] wrote: En Fri, 07 Dec 2007 01:24:57 -0300, grbgooglefan [EMAIL PROTECTED] escribió: On Dec 7, 12:17 pm, Gabriel Genellina [EMAIL PROTECTED] wrote: En Thu, 06 Dec 2007

Refactoring test units after an extract method

2007-06-05 Thread Virgil Dupras
This is not strictly python related, but it's not strictly TDD related either. Anyway, here it goes. There's something that I was never quite sure how to handle with test units: How to handle the test unit refactoring after a method extraction. Let's say that you have a function foo() that does

Re: Good Python style?

2007-05-31 Thread Virgil Dupras
On May 31, 3:59 am, Andreas Beyer [EMAIL PROTECTED] wrote: Hi, I found the following quite cryptic code, which basically reads the first column of some_file into a set. In Python I am used to seeing much more verbose/explicit code. However, the example below _may_ actually be faster than the

Re: PEP 3131: Supporting Non-ASCII Identifiers

2007-05-13 Thread Virgil Dupras
On May 13, 11:44 am, Martin v. Löwis [EMAIL PROTECTED] wrote: PEP 1 specifies that PEP authors need to collect feedback from the community. As the author of PEP 3131, I'd like to encourage comments to the PEP included below, either here (comp.lang.python), or to [EMAIL PROTECTED] In summary,

Re: Decorating class member functions

2007-05-03 Thread Virgil Dupras
On May 3, 9:21 pm, Andy Terrel [EMAIL PROTECTED] wrote: Okay does anyone know how to decorate class member functions? The following code gives me an error: Traceback (most recent call last): File decorators2.py, line 33, in module s.update() File decorators2.py, line 13, in

Re: Decorating class member functions

2007-05-03 Thread Virgil Dupras
On May 3, 9:33 pm, Virgil Dupras [EMAIL PROTECTED] wrote: On May 3, 9:21 pm, Andy Terrel [EMAIL PROTECTED] wrote: Okay does anyone know how to decorate class member functions? The following code gives me an error: Traceback (most recent call last): File decorators2.py, line 33

Re: Decorating class member functions

2007-05-03 Thread Virgil Dupras
On May 3, 9:21 pm, Andy Terrel [EMAIL PROTECTED] wrote: Okay does anyone know how to decorate class member functions? The following code gives me an error: Traceback (most recent call last): File decorators2.py, line 33, in module s.update() File decorators2.py, line 13, in

Re: Python 3000 idea: reversing the order of chained assignments

2007-03-21 Thread Virgil Dupras
On Mar 21, 9:24 pm, Steve Holden [EMAIL PROTECTED] wrote: Marcin Ciura wrote: Steven D'Aprano wrote: x, y, z = 1, 2, 3 x = y = z x, y, z (3, 3, 3) I certainly wouldn't expect to get (2, 3, 3). Neither would I. I must have expressed myself not clearly enough. Currently x = y =

Re: Python 3000 idea: reversing the order of chained assignments

2007-03-21 Thread Virgil Dupras
On Mar 21, 10:05 pm, Steve Holden [EMAIL PROTECTED] wrote: Virgil Dupras wrote: On Mar 21, 9:24 pm, Steve Holden [EMAIL PROTECTED] wrote: Marcin Ciura wrote: Steven D'Aprano wrote: x, y, z = 1, 2, 3 x = y = z x, y, z (3, 3, 3) I certainly wouldn't expect to get (2, 3, 3

Re: Flatten a two-level list -- one liner?

2007-03-07 Thread Virgil Dupras
On Mar 7, 7:14 pm, Sergio Correia [EMAIL PROTECTED] wrote: Hi, I'm looking for an easy way to flatten a two level list like this spam = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]] Into something like eggs = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12] There are *no* special cases (no

Re: Nested Parameter Definitions

2007-02-25 Thread Virgil Dupras
On Feb 25, 1:00 pm, Paddy [EMAIL PROTECTED] wrote: I blogged on finding a new-to-me feature of Python, in that you are allowed to nnest parameter definitions: def x ((p0, p1), p2): ... return p0,p1,p2 ... x(('Does', 'this'), 'work') ('Does', 'this', 'work') Ruben commented that

Re: Inheriting str object

2007-02-05 Thread Virgil Dupras
On Feb 5, 5:48 am, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: I want to have a str with custom methods, but I have this problem: class myStr(str): def hello(self): return 'hello '+self s=myStr('world') print s.hello() # prints 'hello world' s=s.upper() print s.hello() #

Re: Matching Directory Names and Grouping Them

2007-01-11 Thread Virgil Dupras
From your example, if you want to group every path that has the same last 9 characters, a simple solution could be something like: groups = {} for path in paths: group = groups.setdefault(path[-9:],[]) group.append(path) I didn't actually test it, there ight be syntax errors. J wrote:

Re: About the 79 character line recommendation

2006-12-05 Thread Virgil Dupras
Steve Bergman wrote: As I study Python, I am trying to develop good, Pythonic, habits. For one thing, I am trying to keep Guido's the style guide in mind. And I know that it starts out saying that it should not be applied in an absolute fashion. However, I am finding that the 79 character

Re: reduce to be removed?

2006-11-11 Thread Virgil Dupras
Dustan wrote: According to the following page on Wikipedia: http://en.wikipedia.org/wiki/Python_%28programming_language%29#Future_development reduce is going to be removed in python 3.0. It talks of an accumulation loop; I have no idea what that's supposed to mean. So,

Re: Names changed to protect the guilty

2006-10-06 Thread Virgil Dupras
MonkeeSage wrote: On Oct 6, 6:27 pm, [EMAIL PROTECTED] (Aahz) wrote: The following line of lightly munged code was found in a publicly available Python library... Yes, this violates the Holy, Inspired, Infallible Style Guide (pbuh), which was written by the very finger of God when the

Re: Where is Python in the scheme of things?

2006-10-04 Thread Virgil Dupras
On Oct 4, 4:21 pm, gord [EMAIL PROTECTED] wrote: As a complete novice in the study of Python, I am asking myself where this language is superior or better suited than others. For example, all I see in the tutorials are lots of examples of list processing, arithmetic calculations - all in a

Re: Splitting device addresses into parts

2006-09-26 Thread Virgil Dupras
Fabian Steiner wrote: I often have to deal with strings like PCI:2:3.0 or PCI:3.4:0 and need the single numbers as tuple (2, 3, 0) or (3, 4, 0). Is there any simple way to achieve this? So far I am using regular expressions but I would like to avoid them ... Regards, Fabian Steiner I would

Re: byte count unicode string

2006-09-20 Thread Virgil Dupras
MonkeeSage wrote: OK, so the devil always loses. ;P Regards, Jordan Huh? The devil always loses? *turns TV on, watches the news, turns TV off* Nope, buddy. Quite the contrary. -- http://mail.python.org/mailman/listinfo/python-list