[issue39232] asyncio crashes when tearing down the proactor event loop

2020-09-12 Thread Caleb Hattingh
Change by Caleb Hattingh : -- nosy: +cjrh ___ Python tracker <https://bugs.python.org/issue39232> ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue41505] asyncio.gather of large streams with limited resources

2020-08-23 Thread Caleb Hattingh
Caleb Hattingh added the comment: The traditional way this done is with a finite number of workers pulling work off a queue. This is straightforward to set up with builtins: from uuid import uuid4 import asyncio, random async def worker(q: asyncio.Queue): while job := await q.get

[issue40894] asyncio.gather() cancelled() always False

2020-06-12 Thread Caleb Hattingh
Caleb Hattingh added the comment: Kyle is correct. By analogy with Kyle's example, the following example has no gather, only two nested futures: ``` # childfut.py import asyncio async def f(fut): await fut async def g(t): await asyncio.sleep(t) async def main(): fut_g

[issue39839] Non-working error handler when creating a task with assigning a variable

2020-03-15 Thread Caleb Hattingh
Caleb Hattingh added the comment: Can reproduce also on 3.8. Another version that "works" (raises the exception) is task = loop.create_task(test()) del task Suggests there's something going on with reference counting or garbage collection. In the version that &qu

[issue39857] subprocess.run: add an extra_env kwarg to complement existing env kwarg

2020-03-10 Thread Caleb Hattingh
Caleb Hattingh added the comment: The dict unpacking generalizations that I posted were added in Python 3.5, which is pretty old by now. (But, true, is in Python 3 and not Python 2). This is the PEP: https://www.python.org/dev/peps/pep-0448/ The new syntax that Brandt posted will indeed

[issue39857] subprocess.run: add an extra_env kwarg to complement existing env kwarg

2020-03-07 Thread Caleb Hattingh
Caleb Hattingh added the comment: dict syntax tools make it fairy easy to compose new dicts from old ones with overrides: subprocess.run(..., env={**os.environ, 'FOO': ..., 'BAR', ...}, ...) Would this be sufficient to avoid the copy/pasting boilerplate? -- nosy: +cjrh

[issue39609] Set the thread_name_prefix for asyncio's default executor ThreadPoolExecutor

2020-02-17 Thread Caleb Hattingh
Caleb Hattingh added the comment: This change seems fine. Markus, I'm curious if there is a specific reason you prefer to use the default executor rather than replacing it with your own? Is it just convenience or are there other reasons? -- nosy: +cjrh

[issue38988] Killing asyncio subprocesses on timeout?

2020-02-01 Thread Caleb Hattingh
Caleb Hattingh added the comment: @dontbugme This is a very old problem with threads and sub-processes. In the general case (cross-platform, etc) it is difficult to kill threads and sub-processes from the outside. The traditional solution is to somehow send a message to the thread

[issue39483] Proposial add loop parametr to run in asyncio

2020-02-01 Thread Caleb Hattingh
Caleb Hattingh added the comment: Hmm, my recent comment looks rude but I didn't intend it to be that way. What I mean is: there are many, many more users of asyncio.run than there are of teleton, so any change made to asyncio.run is going to affect more people than the other way round. So

[issue39483] Proposial add loop parametr to run in asyncio

2020-02-01 Thread Caleb Hattingh
Caleb Hattingh added the comment: @heckad You should instead ask the maintainers of teleton how to use their library with asyncio.run, not the other way round. -- nosy: +cjrh ___ Python tracker <https://bugs.python.org/issue39

[issue39010] ProactorEventLoop raises unhandled ConnectionResetError

2020-02-01 Thread Caleb Hattingh
Change by Caleb Hattingh : -- nosy: +cjrh ___ Python tracker <https://bugs.python.org/issue39010> ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue37334] Add a cancel method to asyncio Queues

2019-11-22 Thread Caleb Hattingh
Caleb Hattingh added the comment: Ok, I see now. The improvement with only a single producer/consumer might be marginal, but the proposition that `queue.cancel()` might simplify the situation with multiple producers and/or consumers is more compelling. Usually, assuming M producers and N

[issue38529] Python 3.8 improperly warns about closing properly closed streams

2019-10-19 Thread Caleb Hattingh
Change by Caleb Hattingh : -- nosy: +cjrh ___ Python tracker <https://bugs.python.org/issue38529> ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue38501] multiprocessing.Pool hangs atexit (and garbage collection sometimes)

2019-10-19 Thread Caleb Hattingh
Change by Caleb Hattingh : -- nosy: +cjrh ___ Python tracker <https://bugs.python.org/issue38501> ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue38306] High level API for loop.run_in_executor(None, ...)?

2019-10-12 Thread Caleb Hattingh
Caleb Hattingh added the comment: We can't allow both an `executor=` kwarg, as well as **kwargs for the target func, unfortunately. If we do `executor=`, we'll again have to force users to use functools.partial to wrap their functions that take kwargs

[issue38306] High level API for loop.run_in_executor(None, ...)?

2019-10-12 Thread Caleb Hattingh
Caleb Hattingh added the comment: Even before task groups land, this API can be easily improved by adding asyncio.run_in_executor(func, *args, **kwargs) - Only valid inside a coro or async context (uses get_running_loop internally) - Analogous to how `loop.create_task` became

[issue37736] asyncio.wait_for is still confusing

2019-10-05 Thread Caleb Hattingh
Caleb Hattingh added the comment: > asyncio.wait_for is still confusing Perhaps the confusion can be fixed with improvements to the docs? To me, these specific docs seem pretty clear now, but I might not be a good judge of that. > However, we still have the case where a misbehaving Ta

[issue38164] polishing asyncio Streams API

2019-09-29 Thread Caleb Hattingh
Change by Caleb Hattingh : -- nosy: +cjrh ___ Python tracker <https://bugs.python.org/issue38164> ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue38242] Revert the new asyncio Streams API

2019-09-29 Thread Caleb Hattingh
Change by Caleb Hattingh : -- nosy: +cjrh ___ Python tracker <https://bugs.python.org/issue38242> ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue34037] asyncio: BaseEventLoop.close() shutdowns the executor without waiting causing leak of dangling threads

2019-09-11 Thread Caleb Hattingh
Change by Caleb Hattingh : -- nosy: +cjrh ___ Python tracker <https://bugs.python.org/issue34037> ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue37334] Add a cancel method to asyncio Queues

2019-06-21 Thread Caleb Hattingh
Caleb Hattingh added the comment: I'm interested in how this change would affect the pattern of shutting down a queue-processing task. How would one decide between whether to cancel the queue or the task? (I'm asking for real, this is not an objection to the PR). For example, looking

[issue34831] Asyncio Tutorial

2019-06-19 Thread Caleb Hattingh
Caleb Hattingh added the comment: I'm removing the GUI section of the chat case study. Yury was right, it's not going to add anything useful. The CLI chat client will work well because prompt-toolkit has actual support for asyncio. Tkinter does not, and I think it'll be better to add a GUI

[issue34831] Asyncio Tutorial

2019-06-16 Thread Caleb Hattingh
Caleb Hattingh added the comment: FYI I'm going to be using the 3rd-party prompt-toolkit for the chat client. (The server depends only on asyncio only). I put several hours research into finding a way for the CLI chat client to be not terrible, but it gets very complicated trying to manage

[issue34831] Asyncio Tutorial

2019-06-15 Thread Caleb Hattingh
Caleb Hattingh added the comment: That was an long two months, apologies. I've made some fixes based on review comments and cleaned up some more of the code samples. The primary outstanding pieces are the client component of the chat application case study, and the GUI integration section

[issue19495] context manager for measuring duration of blocks of code

2019-03-25 Thread Caleb Hattingh
Caleb Hattingh added the comment: Somehow I missed that there's been an open issue on this. Like others I've written a bunch of different incarnations of an "elapsed" context manager over the years. Always for the more crude "how long did this take" reason like Da

[issue34831] Asyncio Tutorial

2019-01-05 Thread Caleb Hattingh
Caleb Hattingh added the comment: A quick note to say I have not abandoned this, it's just that life got complicated for me in late 2018. I intend to pick up progress again within the next month or two. -- ___ Python tracker <ht

[issue30487] DOC: automatically create a venv and install Sphinx when running make

2019-01-05 Thread Caleb Hattingh
Caleb Hattingh added the comment: @cheryl.sabella I am ok with closing this, but the original motivation for this work was from @zack.ware so he should weigh in. I am not going to work on this any further for the forseeable future (I've got my hands full already with the asyncio docs I'm

[issue34831] Asyncio Tutorial

2018-10-21 Thread Caleb Hattingh
Caleb Hattingh added the comment: I've added a few ideas for items in the "cookbook" page, which you'll see in the PR. If anyone has suggestions for more or better cookbook entries (recipes?), feel free to mention here or in the PR, I check both places. I expect to get more ti

[issue35036] logger failure in suspicious.py

2018-10-21 Thread Caleb Hattingh
Change by Caleb Hattingh : -- nosy: +cjrh ___ Python tracker <https://bugs.python.org/issue35036> ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue34831] Asyncio Tutorial

2018-10-07 Thread Caleb Hattingh
Caleb Hattingh added the comment: I tested the Python 3.7.0 release version for Mac, the download called "macOS 64-bit installer" with checksum ae0717a02efea3b0eb34aadc680dc498 on this page: https://www.python.org/downloads/release/python-370/ I downloaded, installed tha

[issue34831] Asyncio Tutorial

2018-10-07 Thread Caleb Hattingh
Caleb Hattingh added the comment: I set up a basic structure under "Doc/library/asyncio-tutorial" as suggested, and opened a PR to show you how that looks. When I make more progress on a section, I'll post an update here. -- ___ Pyth

[issue34831] Asyncio Tutorial

2018-10-07 Thread Caleb Hattingh
Change by Caleb Hattingh : -- keywords: +patch pull_requests: +9134 stage: -> patch review ___ Python tracker <https://bugs.python.org/issue34831> ___ ___ Py

[issue34831] Asyncio Tutorial

2018-10-06 Thread Caleb Hattingh
Caleb Hattingh added the comment: A CLI client is a necessary step along the way anyway, so that sounds good by me. You suggested: > I'd organize the tutorial in a dedicated directory like > "Doc/library/asyncio-tutorial/" I had a look at the source tree, there is an

[issue34831] Asyncio Tutorial

2018-10-01 Thread Caleb Hattingh
Caleb Hattingh added the comment: > * I think we should stick to your structure and push things to > docs.python.org as soon as every next section is somewhat ready. Ok. I'll get a PR going for the start page of the tutorial. > * Every big section should probably have its own page

[issue34831] Asyncio Tutorial

2018-09-28 Thread Caleb Hattingh
New submission from Caleb Hattingh : Hi Yury, As discussed, below is a very rough outline of a proposed TOC for an asyncio tutorial. No content has been written yet (only what you see below). I think we should nail down the TOC first. Asyncio Tutorial Proposed Table

[issue30487] DOC: automatically create a venv and install Sphinx when running make

2017-11-27 Thread Caleb Hattingh
Caleb Hattingh <caleb.hatti...@gmail.com> added the comment: Yep, sounds good. -- ___ Python tracker <rep...@bugs.python.org> <https://bugs.python

[issue30487] DOC: automatically create a venv and install Sphinx when running make

2017-11-27 Thread Caleb Hattingh
Caleb Hattingh <caleb.hatti...@gmail.com> added the comment: It looks like the check for an existing sphinx-build passes, and so no new venv is made, but this also means that blurb doesn't get installed. I was concerned about this, but figured that at least the buildbots would create ne

[issue30487] DOC: automatically create a venv and install Sphinx when running make

2017-11-27 Thread Caleb Hattingh
Caleb Hattingh <caleb.hatti...@gmail.com> added the comment: Hi Ned It's still supposed to allow both. It sounds like it's not working properly. I'll have a look. FYI, I worked on this for Zach Ware who is the primary stakeholder for this feature. Rgds Caleb > On 28 Nov 2017, a

[issue30487] DOC: automatically create a venv and install Sphinx when running make

2017-11-09 Thread Caleb Hattingh
Caleb Hattingh <caleb.hatti...@gmail.com> added the comment: No worries. I've made a new PR 4346. The old one was unsalvagable I'm afraid. Too many other people got added to the notifications list as a result of my incorrect rebase. The new one i

[issue30487] DOC: automatically create a venv and install Sphinx when running make

2017-11-09 Thread Caleb Hattingh
Change by Caleb Hattingh <caleb.hatti...@gmail.com>: -- keywords: +patch pull_requests: +4303 ___ Python tracker <rep...@bugs.python.org> <https://bugs.python

[issue30487] DOC: automatically create a venv and install Sphinx when running make

2017-11-08 Thread Caleb Hattingh
Caleb Hattingh <caleb.hatti...@gmail.com> added the comment: I messed up the PR through a failed rebase (trying to rebase my PR on top of upstream). I closed the PR as a result. I have now fixed up my feature branch, but I have not resubmitted the PR. Since the PR was left alone fo

[issue31620] asyncio.Queue leaks memory if the queue is empty and consumers poll it frequently

2017-09-29 Thread Caleb Hattingh
Caleb Hattingh <caleb.hatti...@gmail.com> added the comment: This looks like a dupe, or at least quite closely related to https://bugs.python.org/issue26259. If the PR resolves both issues that one should be closed too. -- nosy: +cjrh ___

[issue30487] DOC: automatically create a venv and install Sphinx when running make

2017-05-26 Thread Caleb Hattingh
New submission from Caleb Hattingh: Under guidance from zware during Pycon sprints, I've changed the Doc/ Makefile to automatically create a virtual environment and install Sphinx, all as part of the `make html` command. -- assignee: docs@python components: Documentation messages

[issue30433] Devguide lacks instructions for building docs

2017-05-26 Thread Caleb Hattingh
Caleb Hattingh added the comment: The PR has been merged by Mariatta so I think this can be closed. -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/i

[issue30433] Devguide lacks instructions for building docs

2017-05-22 Thread Caleb Hattingh
Caleb Hattingh added the comment: Oops, sorry! The PR was wrong because it auto-assumes the main cpython repo, but my PR is in the devguide repo. This is the URL for the PR: https://github.com/python/devguide/pull/206 -- ___ Python tracker <

[issue30433] Devguide lacks instructions for building docs

2017-05-22 Thread Caleb Hattingh
Changes by Caleb Hattingh <caleb.hatti...@gmail.com>: -- pull_requests: -1812 ___ Python tracker <rep...@bugs.python.org> <http://bugs.python

[issue30433] Devguide lacks instructions for building docs

2017-05-22 Thread Caleb Hattingh
New submission from Caleb Hattingh: The official devguide at https://github.com/python/devguide does not include instructions on exactly how to build the docs! If, after cloning, you simply type `make`, you get some helpful output: $ make Please use `make ' where is one of html

[issue15663] Investigate providing Tcl/Tk 8.6 with OS X installers

2016-09-01 Thread Caleb Hattingh
Changes by Caleb Hattingh <caleb.hatti...@gmail.com>: -- nosy: +cjrh ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue15663> ___ _

[issue12294] multiprocessing.Pool: Need a way to find out if work are finished.

2016-08-19 Thread Caleb Hattingh
Changes by Caleb Hattingh <caleb.hatti...@gmail.com>: -- nosy: +cjrh ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue12294> ___ _

[issue12982] Document that importing .pyo files needs python -O

2016-08-19 Thread Caleb Hattingh
Caleb Hattingh added the comment: Presumably PEP488 (and the 4 years of inactivity) means that this issue could be closed? -- nosy: +cjrh ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/i

[issue11602] python-config code should be in sysconfig

2016-08-19 Thread Caleb Hattingh
Changes by Caleb Hattingh <caleb.hatti...@gmail.com>: -- nosy: +cjrh ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue11602> ___ _

[issue25572] _ssl doesn't build on OSX 10.11

2016-06-23 Thread Caleb Hattingh
Caleb Hattingh added the comment: I struggled with this issue, and eventually found the recommendations about linking with homebrew's OpenSSL on StackOverflow or similar, and then only later found this issue here (and with it the link to the devguide); but the *first* places I looked were

[issue25572] _ssl doesn't build on OSX 10.11

2016-06-15 Thread Caleb Hattingh
Changes by Caleb Hattingh <caleb.hatti...@gmail.com>: -- nosy: +cjrh ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue25572> ___ _

Re: Lambda alternative?

2009-04-15 Thread Caleb Hattingh
On Wed, 15 Apr 2009 15:47:05 +0200, mousem...@gmail.com wrote: But, lambda functions can't be pickled. I would like to pickle my objects, and i would really like to use parallel python (which requires pickling). If you are fixated on using lambda, you could probably use Recipe 7.6: Pickling

Re: No speedup on multi-processor machine?

2007-04-21 Thread Caleb Hattingh
On Apr 21, 11:02 pm, [EMAIL PROTECTED] wrote: Hi, I am using Python Thread library for my parallel processing course project. I am doing matrix convolution on a multi-processor machine running Solaris. I just found out that no speed-up is obtained with threading. It is probably because of

Re: I need suggests

2007-01-23 Thread Caleb Hattingh
Pat wrote: I have to do a big programm. Could someone give me some suggests about IDE (on Linux) and books to learn. http://groups.google.com/groups/search?q=python+ideqt_s=Search Lots and lots to read :) Caleb -- http://mail.python.org/mailman/listinfo/python-list

Re: rsync for python?

2006-12-22 Thread Caleb Hattingh
I want to build rsync server that can run in linux and windows, and configure by python. So I'm looking for something like rsync for python. I find rsync.py and pysync. But rsync.py looks like a client mode, it can't be a rsync server, is it? Can pysync be a rsync server? Hi nienfeng

Re: Is there a way to push data into Microsoft Excel Word from Python ?

2006-12-21 Thread Caleb Hattingh
Hi Paul Thanks for the kind words! No, thank _you_ for taking the time to write such a useful document. regards Caleb -- http://mail.python.org/mailman/listinfo/python-list

Re: Is there a way to push data into Microsoft Excel Word from Python ?

2006-12-16 Thread Caleb Hattingh
The Night Blogger wrote: Is there a way to push data to Microsoft Excel Word from a Python Application On Windows, it's easy after you install the win32 extensions. For example, for python: import win32com.client xl = win32com.client.Dispatch('Excel.Application') after which you can

Re: Dictionary, iterate update objects

2006-12-16 Thread Caleb Hattingh
jansenh wrote: hi comp.lang.python. I need some newbe advice on idiomatic use of Python dictionaries. I have service with a dictionary which holds a bunch of objects as values, and an ID as key to each object. Then I want to change an objects state based on its key. The way I am doing this

Re: automatically grading small programming assignments

2006-12-15 Thread Caleb Hattingh
Hi Brian You could make great use of XML-RPC here. XML-RPC is /really/ easy to use. Here is a simple example: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/81549 You put procedures on the server that will check the args against a the required result, and report back to the student

Re: Writing and reading variables to/from flat file

2006-12-15 Thread Caleb Hattingh
Hi Kevin The other posters helped you with configParser, which is what you wanted, i.e. text file access. However, you can also get persistance really cheaply with pickling, if you don't need the saved data to be text-editable: (from memory) verboseSettings = {} verboseSettings['Detailed'] =

Re: concatenating strings

2006-12-15 Thread Caleb Hattingh
Hi Erich If you're going to be doing a lot of string substitution, you should look at the Templating support in the library: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/304005 and (a little bit fancier): http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/335308 Regards Caleb

And now for something completely different...

2006-12-12 Thread Caleb Hattingh
I spent way too much time reading the recent massive 500-messages thread, and then spent even more time (perhaps better spent) reading wider on some aspects of the debate. This recently-found link sets out (from one possibly-biased POV, I guess) how the rift between GNU Emacs and XEmacs occurred:

Re: looking for a simple way to load a program from another python program..

2006-08-13 Thread Caleb Hattingh
Hi Eric Check that .py and .pyw are in your PATHEXT environment variable (are you using Windows?). Then, if the folder that cabel is in is in your PATH environment variable, and the correct association for .py files is set up (i.e. they get run by python.exe), either os.system('cabel') or

Re: ConfigParser and multiple option names

2006-05-03 Thread Caleb Hattingh
I have had this same problem before, and what I ended up doing was writing my own far more limited config parser that would create lists for repeated named assignments. Who is the maintainer of ConfigParser? Perhaps a keyword option can be added so that this kind of behaviour can be added at

Re: Can one query full name (or version) of selected packages at pypi?

2006-04-25 Thread Caleb Hattingh
Hi Martin Pretty much exactly what I wanted :) How up-to-date does Debian keep its package list for python addons, or are you running Unstable? My big problem, being in South Africa, is that I have to get any distros on cover CDs or order from distro-resellers, and they never have Testing or

Can one query full name (or version) of selected packages at pypi?

2006-04-20 Thread Caleb Hattingh
Hi everyone I suspect this has come up before, but google and group searches for python package index query or pypi query and the like haven't turned anything up. I want to monitor the versions of the list of packages I like having around, and I expect that the python package index might be a

Re: Python 2.5 licensing: stop this change

2006-04-01 Thread Caleb Hattingh
Steve I agree with you. If my vote means anything, I vote against it. The Board realises that this change will be contentious. There are many advantages to making it, however, which we feel will benefit the Python community at large and the PSF membership in particular. Users who wish to

Re: Python 2.5 licensing: stop this change

2006-04-01 Thread Caleb Hattingh
WAIT- Did I just get caught by an April Fools Joke? I have a nasty feeling about this :)) C -- http://mail.python.org/mailman/listinfo/python-list

Re: python challenge question (string manipulation)

2006-03-30 Thread Caleb Hattingh
Felipe I get the same results as you. You make a good point about not iterating when it's not needed. I played around with your test code and found some interesting things: 1. enumerate vs. range(len()) has very little overhead (something I have wondered about) In my code, making the change

Matplotlib: How to set number of ticks on an axis?

2006-03-30 Thread Caleb Hattingh
Hi I tried several Google searches to no avail. I read through pretty much most of the online docs at the matplotlib sourceforge site, but didn't find what I was looking for. I went through the axis.py and ticker.py code today, trying to find out how to set the number of points (ticks) on an

Re: Convert Word .doc to Acrobat .pdf files

2006-03-30 Thread Caleb Hattingh
If you can find some API documentation for PDFMWord.dll, you can call its methods with the ctypes python module. Caleb -- http://mail.python.org/mailman/listinfo/python-list

Re: Simple py script to calc folder sizes

2006-03-30 Thread Caleb Hattingh
Ben, Thank you. Caleb -- http://mail.python.org/mailman/listinfo/python-list

Re: Matplotlib: How to set number of ticks on an axis?

2006-03-30 Thread Caleb Hattingh
John, Thank you. Caleb -- http://mail.python.org/mailman/listinfo/python-list

Re: Multiplying sequences with floats

2006-03-29 Thread Caleb Hattingh
Hi Dennis Sure, I get it. I do most of my work in Delphi, which is, shall we say, not lax about floating-point types. Thinking about this more, I realise my initial interest was in looking at the // operator as something new, whereas I now see it probably just wraps math.floor(); obviously

Re: operation complexities of lists and dictionaries

2006-03-29 Thread Caleb Hattingh
Hi Use the timeit module, like so: from timeit import Timer t = Timer('[i for i in range(1)]') # The string is code to execute (for timing) print t.timeit(100) # execute it 100 times and print the result 0.222389936447 I would appreciate it if you could present your results in this

Re: Free Python IDE ?

2006-03-29 Thread Caleb Hattingh
Hi Ernesto SPE, or Stani's python editor is actually a decent IDE that can lauch the winpdb debugger to step through code, with side windows for locals, and watches and so on. It's not exactly integrated debugging a la Delphi, but in general my need for debugging is much less with python; the

Re: python challenge question (string manipulation)

2006-03-29 Thread Caleb Hattingh
John In python, strings are immutable - you have to create a new string no matter what you do. Also, I suspect you meant to say: alphabet = string.ascii_lowercase code = alphabet[2:] + alphabet[:2] I had a similar need recently for a guitar chord generator program I've been working on. Here

Re: python challenge question (string manipulation)

2006-03-29 Thread Caleb Hattingh
Terry That is very succint. Rewriting my shift function given earlier: import string alpha = string.ascii_lowercase print alpha abcdefghijklmnopqrstuvwxyz def shift(lst, n): return [lst[(i+len(lst)-n)%len(lst)] for i,item in enumerate(lst)] print shift(alpha,2) ['y', 'z', 'a',

Re: Simple py script to calc folder sizes

2006-03-29 Thread Caleb Hattingh
Hi John Your code works on some folders but not others. For example, it works on my /usr/lib/python2.4 (the example you gave), but on other folders it terminates early with StopIteration exception on the os.walk().next() step. I haven't really looked at this closely enough yet, but it looks as

Re: Simple py script to calc folder sizes

2006-03-28 Thread Caleb Hattingh
Thanks John I will use your code :) 30% improvement is not insignificant, and that's what I was looking for. I find the log function a little harder to read, but I guess that is a limitation of me, not your code. Caleb -- http://mail.python.org/mailman/listinfo/python-list

Re: Multiplying sequences with floats

2006-03-28 Thread Caleb Hattingh
Hi Fredrik Fair enough; I wasn't precise. Upon further reflection, I actually meant floor division, via the // operator. In the following snippet: 4/2 2 4//2 2 4.0/2.0 2.0 4.0//2 2.0 4.0//2.0 2.0 We know the last two operations can only return what are effectively integer numbers (or

Re: Multiplying sequences with floats

2006-03-28 Thread Caleb Hattingh
Christoph I understand the explanation regarding the underlying math.floor() call. Were I using this functionality in my code, int(a//b)* some_list would not be something I consider a big deal. However, I see what you're saying: The multiplcation by list can only work with an int, and you

Re: New development windows, IronPython or PythonWin

2006-03-24 Thread Caleb Hattingh
Hi Dan Pythonwin just adds support for specifically MS Windows features, most prominently COM; writing Excel scripts in python is so cool. The standard python distribution for windows runs perfectly on windows. I'm not sure whether this was clear to you or not. Also, Thomas ctypes and comtypes

Re: Multiplying sequences with floats

2006-03-24 Thread Caleb Hattingh
Hi Christoph On my linux py-2.4.1: 4.0//2 # Integer division, but still returns a float. 2.0 4.0//2 == 2 True 4.0//2 doesn't return an integer, but the equality against an integer still holds. I agree that integer division should return an integer, because using the operator at all means

Re: Python vs. Java gzip performance

2006-03-21 Thread Caleb Hattingh
Hi Peter Clearly I misunderstood what Martin was saying :)I was comparing operations on lines via the file generator against first loading the file's lines into memory, and then performing the concatenation. What does .readlines() do differently that makes it so much slower than

Simple py script to calc folder sizes

2006-03-21 Thread Caleb Hattingh
Hi everyone [Short version: I put a some code below: what changes can make it run faster?] Unless you have a nice tool handy, calculating many folder sizes for clearing disk space can be a click-fest nightmare. Looking around, I found Baobab (gui tool); the du linux/unix command-line tool; the

Re: Python vs. Java gzip performance

2006-03-17 Thread Caleb Hattingh
I tried this: from timeit import * #Try readlines print Timer('import gzip;lines=gzip.GzipFile(gztest.txt.gz).readlines();[i+1 for i in lines]').timeit(200) # This is one line # Try file object - uses buffering? print Timer('import gzip;[i+1 for i in gzip.GzipFile(gztest.txt.gz)]').timeit(200)

Re: Use of Python with GDAL. How to speed up ?

2006-03-17 Thread Caleb Hattingh
Hi The documentation for the python profiler in the python library reference is extremely readable (well done James Roskin!?). Profile your code, and when you find where the speed problem occurs, try pitching just that section of code in comp.lang.python. You will likely get much feedback.

Binary python extensions with Free Pascal Compiler

2006-03-16 Thread Caleb Hattingh
Hi all I want to write python extensions with FPC (Free Pascal Compiler, http://www.freepascal.org). In Delphi, this is trivially easy due to the great work of the P4D (Python-for-Delphi, http://mmm-experts.com/) guys; however, when aiming for cross-platform binary extensions, that strategy

Re: Counting nested loop iterations

2006-03-16 Thread Caleb Hattingh
Hi Derek I went for an embarrassingly long time without knowing about enumerate(). It doesn't directly answer your question about counting *within* nests, but I am going to tell you this on the off chance you don't know yet (and apologies if you do): This: count = 0 for animal in zoo: a =

Re: Binary python extensions with Free Pascal Compiler

2006-03-16 Thread Caleb Hattingh
Well, there it is: * Added support for Free Pascal Compiler (http://www.freepascal.org/) and Lazarus Project (http://www.lazarus.freepascal.org/) Thanks to Michiel du Toit ([EMAIL PROTECTED]) That was easy. I just saw the new support for D2k6 recently. thx Ravi Caleb --

Re: Is this possible in Python?

2006-03-13 Thread Caleb Hattingh
Hi I don't think this is what you want (a string representation of the argument passed to a function as that argument is at runtime is way beyond my abilities), but this can retrieve the literal text in the function call as it appears in the .py file, assuming you have the .py file available

Re: Python IDE: great headache....

2006-03-13 Thread Caleb Hattingh
Hi Being a Delphi user at work, I know what you mean :) The best python IDE I have found is Stani's Python Editor (SPE), and I think Stani himself replied to your message as well. It integrates wxGlade, which is nice for form-building, although I don't really do much of that with the python

Re: very high-level IO functions?

2005-09-19 Thread Caleb Hattingh
York Short answer: yes We use python and R at work, and in general you will find python syntax a little cleaner for functionality they have in common. R is better for some of the more hard-wired stats stuff, though. On Mon, 19 Sep 2005 20:04:37 +0200, York [EMAIL PROTECTED] wrote: Hi,

Re: p2exe using wine/cxoffice

2005-09-19 Thread Caleb Hattingh
The other thing (and this is always true) is that better needs definition. On purely technical grounds, on average, MSOffice is better than OO. However, holistically, OO is probably better (no lock-in, open standards, multiplatform and so on). Those soft issues do matter. On Mon, 19 Sep

Re: Is this Pythonic?

2005-08-01 Thread Caleb Hattingh
Peter To my mind, this kind of setup (interface class, or abstact class) is more usually used in static languages to benefit polymorphism - but python is dynamically typed, so in which situations would this setup be useful in a python program? You see, I expected your post to say that it

Re: Python IDE's

2005-08-01 Thread Caleb Hattingh
You know, for several years I was one of those people who simply ignored posts like this about Vi/Vim because I happened to come across it once on a sparc machine and thought it was ridiculous that I couldn't figure out how to type a simple note. I thought that Vi (Vim) was some kind of

Re: GUI - Windows: Where to get started

2005-07-26 Thread Caleb Hattingh
Probably, the best place for learning how to build GUI's for Windows, in general, is to get hold the personal edition of Delphi from the Borland website. If you want something more specific to Python, it is likely to be much tougher. You would, for example, have to decide which widget

  1   2   >