Re: Reversible Debugging

2009-07-03 Thread Horace Blegg
You might consider using a VM with 'save-points'. You run the program (in a debugger/ida/what have you) to a certain point (logical point would be if/ifelse/else statements, etc) and save the VM state. Once you've saved, you continue. If you find the path you've taken isn't what you are after, you

Re: question of style

2009-07-03 Thread upwestdon
On Jul 2, 1:23 pm, Simon Forman wrote: > Hey I was hoping to get your opinions on a sort of minor stylistic > point. > These two snippets of code are functionally identical. Which would you > use and why? > The first one is easier [for me anyway] to read and understand, but > slightly less efficie

Re: Searching equivalent to C++ RAII or deterministic destructors

2009-07-03 Thread Aahz
In article , Tim Roberts wrote: >Dave Angel wrote: >> >>You're right of course. What I was trying to say was it deletes the >>reference to the object. Unlike obj = None, del obj removes the >>reference (attribute) entirely. Although I don't know what it should be >>called if it's a local

Re: question of style

2009-07-03 Thread Aahz
In article <7xhbxtjxtn@ruckus.brouhaha.com>, Paul Rubin wrote: >Simon Forman writes: >> >> (I like Haskell's Maybe, but saying A is better than B doesn't imply >> that B is therefore terrible.) > >I wouldn't say Python's None is terrible, but the programming st

Re: Reversible Debugging

2009-07-03 Thread Gabriel Genellina
En Fri, 03 Jul 2009 15:18:51 -0300, Patrick Sabin escribió: I am interested if there are any python modules, that supports reversible debugging aka stepping backwards. Any links or ideas would be helpful, because I am thinking of implementing something like that. Do you want reverse exec

Re: stringio+tarfile (or better... zipfile)

2009-07-03 Thread Gabriel Genellina
En Fri, 03 Jul 2009 17:14:22 -0300, superpollo escribió: following the excellent suggestions received, i tried to adapt the problem to zipfile, and i wrote this: zip = zipfile.ZipFile(zb , "w" , zipfile.ZIP_DEFLATED) for name , buffer in [nb1 , nb2]: zip.writestr(name, buffer.getvalue()

Re: question of style

2009-07-03 Thread Steven D'Aprano
On Fri, 03 Jul 2009 13:50:12 -0700, Paul Rubin wrote: > I wouldn't say Python's None is terrible, but the programming style in > which None is used as a marker for "absent value" is genuinely a source > of bugs, requiring care when used. Often it's easy to just avoid it and > all the bugs that co

Problems with using queue in Tkinter application

2009-07-03 Thread Icarus
I'm working on a serial protocol analyzer in python. We have an application written by someone else in MFC but we need something that is cross platform. I intended to implement the GUI portion in Tkinter but am having trouble. The idea is that I will read messages from the serial port and output

Re: Idioms and Anti-Idioms Question

2009-07-03 Thread Lawrence D'Oliveiro
In message , J. Cliff Dyer wrote: > On Wed, 2009-07-01 at 17:19 +1200, Lawrence D'Oliveiro wrote: >> >> In message , J. >> Cliff Dyer wrote: >> >> > If the lines got separated, a leading + could disappear into its line >> > without any errors showing up. A trailing + would raise a syntax >> > e

Re: Clarity vs. code reuse/generality

2009-07-03 Thread Pablo Torres N.
On Fri, Jul 3, 2009 at 09:05, kj wrote: > The context is the concept of a binary search.  In one of their > homeworks, my students will have two occasions to use a binary > search.  This seemed like a perfect opportunity to illustrate the > idea of abstracting commonalities of code into a re-usable

Re: question of style

2009-07-03 Thread John Yeung
On Jul 3, 4:50 pm, Paul Rubin wrote: > I wouldn't say Python's None is terrible, but the > programming style in which None is used as a marker > for "absent value" is genuinely a source of bugs, > requiring care when used.  Often it's easy to just > avoid it and all t

3.1 Windows Installer trashes extension registrations

2009-07-03 Thread Alan G Isaac
> Alan G Isaac wrote: >> Using the 3.1 Windows installer, I chose that I did not >> want the extensions registered, and the installer >> unregistered the .py and .pyw extensions (which I had >> wanted to keep associated with Python 2.6). >> Is this intentional? On 7/3/2009 2:57 PM Terry Reedy

Re: Compiling 64 bit python on a mac - cannot compute sizeof (int)

2009-07-03 Thread Adam
On Jul 3, 2:18 pm, Mark Dickinson wrote: > On Jul 3, 5:30 pm, Keflavich wrote: > > > I'm trying to compile a 64 bit version of python 2.6.2 on my mac (OS X > > 10.5.7), and am running into a problem during the configure stage. > > > I configure with: > > ./configure --enable-framework=/Library/Fr

Re: question of style

2009-07-03 Thread Paul Rubin
Simon Forman writes: > "...stick to the principle: NULL is wrong because it causes horrible > and tricky mistakes which appear even after the program was tested > thoroughly. You cannot introduce NULL into the language and tell the > programmer to be careful about it. The programmer is not capable

Re: Python debugger

2009-07-03 Thread Simon Forman
On Jul 3, 8:15 am, srinivasan srinivas wrote: > Hi, > Could you suggest some python debuggers? > > Thanks, > Srini > >       Love Cricket? Check out live scores, photos, video highlights and more. > Click herehttp://cricket.yahoo.com Ipython has good debugger integration. -- http://mail.python.

Re: Clarity vs. code reuse/generality

2009-07-03 Thread Terry Reedy
Steven D'Aprano wrote: On Fri, 03 Jul 2009 16:19:22 +, kj wrote: In Alan G Isaac writes: 1. Don't use assertions to test argument values! Out of curiosity, where does this come from? Assertions are disabled when you run Python with the -O (optimise) flag. If you rely on assertions t

Re: Searching equivalent to C++ RAII or deterministic destructors

2009-07-03 Thread Tim Roberts
Dave Angel wrote: > >You're right of course. What I was trying to say was it deletes the >reference to the object. Unlike obj = None, del obj removes the >reference (attribute) entirely. Although I don't know what it should be >called if it's a local variable. Perhaps it "unbinds" the nam

Re: Compiling 64 bit python on a mac - cannot compute sizeof (int)

2009-07-03 Thread Mark Dickinson
On Jul 3, 5:30 pm, Keflavich wrote: > I'm trying to compile a 64 bit version of python 2.6.2 on my mac (OS X > 10.5.7), and am running into a problem during the configure stage. > > I configure with: > ./configure --enable-framework=/Library/Frameworks --enable- > universalsdk MACOSX_DEPLOYMENT_TA

Re: question of style

2009-07-03 Thread Simon Forman
On Jul 3, 12:56 am, Paul Rubin wrote: > Simon Forman writes: > > > Yes, but the concept of null pointers is considered kludgy these days. > > Seriously? "kludgy"?  (I really AM getting old.) > >  http://math.andrej.com/2009/04/11/on-programming-language-design/ > > d

Re: stringio+tarfile (or better... zipfile)

2009-07-03 Thread superpollo
following the excellent suggestions received, i tried to adapt the problem to zipfile, and i wrote this: $ cat zip001.py import sys import zipfile import StringIO nb1 = "first.txt", StringIO.StringIO("one one\n") nb2 = "second.txt", StringIO.StringIO("two\n") zb = StringIO.StringIO() zip = zip

Re: Sequence splitting

2009-07-03 Thread MRAB
Mel wrote: Steven D'Aprano wrote: The most important difference between my suggestion and that of the OP is that he limited the key function to something which returns a truth value, while I'm looking for something more general which can split the input into an arbitrary number of collated subl

Re: question of style

2009-07-03 Thread Simon Forman
On Jul 3, 2:09 am, Lie Ryan wrote: > Simon Forman wrote: > > On Jul 2, 3:57 pm, Scott David Daniels wrote: > >> Duncan Booth wrote: > >>> Simon Forman wrote: > ... > if self.higher is self.lower is None: return > ... > >>> As a matter of style however I wouldn't use the shorthand

Re: Python implmenentation of finding process's command line parameters.

2009-07-03 Thread Giampaolo Rodola'
On 3 Lug, 21:50, Tim Golden wrote: > Sorry. Exactly what I meant. (Should have checked for > the exact post rather than trusting to my memory) No prolem. > dudeja.ra...@gmail.com wrote: > > I have had a look at psutil, however, this only works with Python 2.6.x and > > above. We are using Pytho

Re: pep 8 constants

2009-07-03 Thread Terry Reedy
Eric S. Johansson wrote: Horace Blegg wrote: I've been kinda following this. I have a cousin who is permanently wheel chair bound and doesn't have perfect control of her hands, but still manages to use a computer and interact with society. However, the idea/thought of disabled programmers was ne

Re: Python implmenentation of finding process's command line parameters.

2009-07-03 Thread Tim Golden
dudeja.ra...@gmail.com wrote: I have had a look at psutil, however, this only works with Python 2.6.x and above. We are using Python 2.5.2 and updating python could pose certain problems. So, I'm not keep on using psutils. Doesn't look as if there's anything 2.6-specific there. Maybe the mainta

Re: Python implmenentation of finding process's command line parameters.

2009-07-03 Thread Tim Golden
Giampaolo Rodola' wrote: On 3 Lug, 21:15, Tim Golden wrote: dudeja.ra...@gmail.com wrote: I'm looking for some python implementation of finding the command line parameters of a process on Windows XP SP3 machine. I found some links but they all point me to the direction of c/c++ implememtations

Re: Python implmenentation of finding process's command line parameters.

2009-07-03 Thread Tim Golden
Giampaolo Rodola' wrote: On 3 Lug, 21:15, Tim Golden wrote: dudeja.ra...@gmail.com wrote: I'm looking for some python implementation of finding the command line parameters of a process on Windows XP SP3 machine. I found some links but they all point me to the direction of c/c++ implememtations

Re: Sequence splitting

2009-07-03 Thread Paul Rubin
Terry Reedy writes: > > This isn't so attractive, since filter takes a sequence input but > > returns a list. > > In modern Python (py3), it returns an iterator. Still not much help in the proposed version that would return two iterators. -- http://mail.python.org/mailman/listinfo/python-list

Re: Python implmenentation of finding process's command line parameters.

2009-07-03 Thread dudeja . rajat
I have had a look at psutil, however, this only works with Python 2.6.x and above. We are using Python 2.5.2 and updating python could pose certain problems. So, I'm not keep on using psutils. -- Regrads, Rajat -- http://mail.python.org/mailman/listinfo/python-list

Re: Python implmenentation of finding process's command line parameters.

2009-07-03 Thread Giampaolo Rodola'
On 3 Lug, 21:15, Tim Golden wrote: > dudeja.ra...@gmail.com wrote: > > I'm looking for some python implementation of finding the command line > > parameters of a process on Windows XP SP3 machine. I found some links but > > they all point me to the direction of c/c++ implememtations. > > > I've se

Re: Sequence splitting

2009-07-03 Thread Terry Reedy
Paul Rubin wrote: Brad writes: Maybe this would be difficult to get into the core, but how about this idea: Rename the current filter function to something like "split" or "partition" (which I agree may be a better name) and modify it to return the desired true and false sequences. Then recreat

Re: Sequence splitting

2009-07-03 Thread Terry Reedy
Brad wrote: On Jul 2, 8:17 pm, "Pablo Torres N." wrote: This sounds like it belongs to the python-ideas list. I suggest posting there for better feedback, since the core developers check that list more often than this one. I tried posting on python-ideas and received a "You are not allowed t

Re: Getting input the scanf way

2009-07-03 Thread Mr.SpOOn
Thanks, I think raw_input() will work just fine for my needs. -- http://mail.python.org/mailman/listinfo/python-list

Re: [Help] Python implmenentation of finding process's command line parameters.

2009-07-03 Thread Tim Golden
dudeja.ra...@gmail.com wrote: I'm looking for some python implementation of finding the command line parameters of a process on Windows XP SP3 machine. I found some links but they all point me to the direction of c/c++ implememtations. I've seen WMI, but this takes time to load. So I just though

Re: Python debugger

2009-07-03 Thread Clovis Fabricio
2009/7/3 Kee Nethery : > It's not free but I like the debugger in Komodo IDE. > Lets me simulate a web connection, lets me step through the code and examine > the variables as it executes, can be run remotely (have not played with that > aspect yet). > Does variable inspection of the variables so y

[Help] Python implmenentation of finding process's command line parameters.

2009-07-03 Thread dudeja . rajat
I'm looking for some python implementation of finding the command line parameters of a process on Windows XP SP3 machine. I found some links but they all point me to the direction of c/c++ implememtations. I've seen WMI, but this takes time to load. So I just though if some one has done implementa

Re: Sequence splitting

2009-07-03 Thread Mel
Steven D'Aprano wrote: > The most important difference between my suggestion and that of the OP is > that he limited the key function to something which returns a truth > value, while I'm looking for something more general which can split the > input into an arbitrary number of collated sublists.

Re: Python 3.0 (pinin' for the fjords)

2009-07-03 Thread Terry Reedy
Alan G Isaac wrote: Using the 3.1 Windows installer, I chose that I did not want the extensions registered, and the installer unregistered the .py and .pyw extensions (which I had wanted to keep associated with Python 2.6). Is this intentional? I suspect not, but Martin is the one to answer. I

Re: Clarity vs. code reuse/generality

2009-07-03 Thread Charles Yeomans
On Jul 3, 2009, at 2:03 PM, Steven D'Aprano wrote: On Fri, 03 Jul 2009 16:19:22 +, kj wrote: In Alan G Isaac writes: 1. Don't use assertions to test argument values! Out of curiosity, where does this come from? Assertions are disabled when you run Python with the -O (optimise) f

Re: getting rid of —

2009-07-03 Thread Tep
On 3 Jul., 18:54, MRAB wrote: > Tep wrote: > > On 3 Jul., 16:58, "Mark Tolonen" wrote: > >> "Tep" wrote in message > > >>news:46d36544-1ea2-4391-8922-11b8127a2...@o6g2000yqj.googlegroups.com... > > >>> On 3 Jul., 06:40, Simon Forman wrote: > On Jul 2, 4:31 am, Tep wrote: > >> [snip] > >>>

Reversible Debugging

2009-07-03 Thread Patrick Sabin
Hello, I am interested if there are any python modules, that supports reversible debugging aka stepping backwards. Any links or ideas would be helpful, because I am thinking of implementing something like that. Thanks in advance, Patrick -- http://mail.python.org/mailman/listinfo/python-list

Re: Python debugger

2009-07-03 Thread Kee Nethery
It's not free but I like the debugger in Komodo IDE. Lets me simulate a web connection, lets me step through the code and examine the variables as it executes, can be run remotely (have not played with that aspect yet). Does variable inspection of the variables so you can dive into the parts

Re: Clarity vs. code reuse/generality

2009-07-03 Thread Steven D'Aprano
On Fri, 03 Jul 2009 16:19:22 +, kj wrote: > In Alan G Isaac > writes: > >>1. Don't use assertions to test argument values! > > Out of curiosity, where does this come from? Assertions are disabled when you run Python with the -O (optimise) flag. If you rely on assertions to verify data, t

Re: Clarity vs. code reuse/generality

2009-07-03 Thread Alan G Isaac
> In Alan G Isaac > writes: >> 1. Don't use assertions to test argument values! On 7/3/2009 12:19 PM kj apparently wrote: > Out of curiosity, where does this come from? http://docs.python.org/reference/simple_stmts.html#grammar-token-assert_stmt "The current code generator emits no code for

Re: PSP Caching

2009-07-03 Thread Simon Forman
On Jul 3, 5:18 am, Johnson Mpeirwe wrote: > Hello All, > > How do I stop caching of Python Server Pages (or whatever causes changes > in a page not to be noticed in a web browser)? I am new to developing > web applications in Python and after looking at implementations of PSP > like Spyce (which I

Re: stringio+tarfile

2009-07-03 Thread superpollo
Peter Otten wrote: gettarinfo() expects a real file, not a file-like object. You have to create your TarInfo manually. ok... which attributes are mandatory, and which optional? I recommend that you have a look into the tarfile module's source code. i will try... but: $ cat /usr/lib/pyt

Re: Sequence splitting

2009-07-03 Thread Scott David Daniels
Steven D'Aprano wrote: I've never needed such a split function, and I don't like the name, and the functionality isn't general enough. I'd prefer something which splits the input sequence into as many sublists as necessary, according to the output of the key function. Something like itertools.g

PyGtkSourceView / PyScintilla

2009-07-03 Thread fiafulli
Hello to all. I would have need of the recent version (possibly most recent) than one of the two controls in subject. I think that wrapper for scintilla it would be better but creed that the development for pygtk is stopped. therefore I'm more inclined for GtkSourceView (than today it is to the

Re: Sequence splitting

2009-07-03 Thread Lie Ryan
Brad wrote: > On Jul 3, 12:57 am, Steven D'Aprano cybersource.com.au> wrote: >> I've never needed such a split function, and I don't like the name, and >> the functionality isn't general enough. I'd prefer something which splits >> the input sequence into as many sublists as necessary, according t

Re: Sequence splitting

2009-07-03 Thread Paul Rubin
Brad writes: > Maybe this would be difficult to get into the core, but how about this > idea: Rename the current filter function to something like "split" or > "partition" (which I agree may be a better name) and modify it to > return the desired true and false sequences. Then recreate the > exist

Re: Sequence splitting

2009-07-03 Thread Brad
On Jul 3, 12:57 am, Steven D'Aprano wrote: > I've never needed such a split function, and I don't like the name, and > the functionality isn't general enough. I'd prefer something which splits > the input sequence into as many sublists as necessary, according to the > output of the key function.

Re: XML(JSON?)-over-HTTP: How to define API?

2009-07-03 Thread Ken Dyck
On Jul 2, 6:17 pm, Allen Fowler wrote: > Since I need to work with other platforms, pickle is out...  what are the > alternatives?  XML? JSON? Don't forget YAML (http://yaml.org). Libraries available for Python and .NET, among others. -Ken -- http://mail.python.org/mailman/listinfo/python-list

Re: getting rid of —

2009-07-03 Thread MRAB
Tep wrote: On 3 Jul., 16:58, "Mark Tolonen" wrote: "Tep" wrote in message news:46d36544-1ea2-4391-8922-11b8127a2...@o6g2000yqj.googlegroups.com... On 3 Jul., 06:40, Simon Forman wrote: On Jul 2, 4:31 am, Tep wrote: [snip] how can I replace '—' sign from string? Or do split at that

Re: Config files with different types

2009-07-03 Thread Zach Hobesh
yaml looks pretty interesting. Also, I wouldn't have to change much, I would still use the same function, and still output a dict. Thanks! -Zach On Thu, Jul 2, 2009 at 11:55 PM, Javier Collado wrote: > Hello, > > Have you considered using something that is already developed? > > You could take

Re: Why re.match()?

2009-07-03 Thread Lie Ryan
Steven D'Aprano wrote: > On Thu, 02 Jul 2009 11:19:40 +, kj wrote: > >> I'm sure that it is possible to find cases in which the *current* >> implementation of re.search() would be inefficient, but that's because >> this implementation is perverse, which, I guess, is ultimately the point >> of

Re: Is Psyco good for Python 2.6.1?

2009-07-03 Thread duncan smith
Russ P. wrote: > I need to speed up some Python code, and I discovered Psyco. However, > the Psyco web page has not been updated since December 2007. Before I > go to the trouble of installing it, does anyone know if it is still > good for Python 2.6.1? Thanks. If you look at http://psyco.sourcefo

Re: Clarity vs. code reuse/generality

2009-07-03 Thread Paul Rubin
kj writes: > sense = cmp(func(hi), func(lo)) > if sense == 0: > return None > target_plus = sense * target + epsilon > target_minus = sense * target - epsilon > ... The code looks confusing to me and in some sense incorrect. Suppose func(hi)==func(lo)==target. In thi

Compiling 64 bit python on a mac - cannot compute sizeof (int)

2009-07-03 Thread Keflavich
I'm trying to compile a 64 bit version of python 2.6.2 on my mac (OS X 10.5.7), and am running into a problem during the configure stage. I configure with: ./configure --enable-framework=/Library/Frameworks --enable- universalsdk MACOSX_DEPLOYMENT_TARGET=10.5 --with-universal-archs=all - with-read

Re: getting rid of —

2009-07-03 Thread Tep
On 3 Jul., 16:58, "Mark Tolonen" wrote: > "Tep" wrote in message > > news:46d36544-1ea2-4391-8922-11b8127a2...@o6g2000yqj.googlegroups.com... > > > > > > > On 3 Jul., 06:40, Simon Forman wrote: > > > On Jul 2, 4:31 am, Tep wrote: > [snip] > > > > > > > how can I replace '—' sign from string? Or

Re: Clarity vs. code reuse/generality

2009-07-03 Thread kj
In a...@pythoncraft.com (Aahz) writes: >First of all, cmp() is gone in Python 3, unfortunately, so I'd avoid >using it. Good to know. >Second, assuming I understand your code correctly, I'd change >"sense" to "direction" or "order". Thanks, kj -- http://mail.python.org/mailman/listinfo/pyth

Re: Clarity vs. code reuse/generality

2009-07-03 Thread kj
In Alan G Isaac writes: >1. Don't use assertions to test argument values! Out of curiosity, where does this come from? Thanks, kj -- http://mail.python.org/mailman/listinfo/python-list

Re: Clarity vs. code reuse/generality

2009-07-03 Thread Lie Ryan
kj wrote: > I'm will be teaching a programming class to novices, and I've run > into a clear conflict between two of the principles I'd like to > teach: code clarity vs. code reuse. I'd love your opinion about > it. Sometimes when the decision between clarity and generality becomes too hard; you

Re: Direct interaction with subprocess - the curse of blocking I/O

2009-07-03 Thread yam850
On 3 Jul., 17:43, Scott David Daniels wrote: > yam850 wrote: > > I made a python method/function for nonblockingread from a file > > object I am happy to see comments. > OK, here's a fairly careful set of comments with a few caveats: [snip] valuable comments > --Scott David Daniels > scott.d

Re: Clarity vs. code reuse/generality

2009-07-03 Thread Jean-Michel Pichavant
kj wrote: I'm will be teaching a programming class to novices, and I've run into a clear conflict between two of the principles I'd like to teach: code clarity vs. code reuse. I'd love your opinion about it. [...] sense = cmp(func(hi), func(lo)) if sense == 0: return None M

Re: Direct interaction with subprocess - the curse of blocking I/O

2009-07-03 Thread Scott David Daniels
yam850 wrote: I made a python method/function for non blocking read from a file object I am happy to see comments. OK, here's a fairly careful set of comments with a few caveats: Does this work on windows? The top comment should say where you know it works. Does this code correctly read

Re: Why re.match()?

2009-07-03 Thread Bruno Desthuilliers
kj a écrit : (snipo To have a special-case re.match() method in addition to a general re.search() method is antithetical to language minimalism, FWIW, Python has no pretention to minimalism. -- http://mail.python.org/mailman/listinfo/python-list

Re: Clarity vs. code reuse/generality

2009-07-03 Thread Bruno Desthuilliers
kj a écrit : I'm will be teaching a programming class to novices, and I've run into a clear conflict between two of the principles I'd like to teach: code clarity vs. code reuse. I'd love your opinion about it. (snip - others already commented on this code) Here's the rub: the code above is

Video shows vigorous Jackson before death???

2009-07-03 Thread Huynh Nhu Thuy
Video shows vigorous Jackson before death??? http://hd-family.blogspot.com/2009/07/video-shows-vigorous-jackson-before.html LOS ANGELES (AFP) – A video released Thursday showed Michael Jackson vigorously practicing a song-and-dance routine days before his death, supporting accounts he had been i

Re: getting rid of —

2009-07-03 Thread Mark Tolonen
"Tep" wrote in message news:46d36544-1ea2-4391-8922-11b8127a2...@o6g2000yqj.googlegroups.com... On 3 Jul., 06:40, Simon Forman wrote: > On Jul 2, 4:31 am, Tep wrote: [snip] > > > > > how can I replace '—' sign from string? Or do split at that > > > > > character? > > > > > Getting unicode

Custom CFLAGS with distutils

2009-07-03 Thread Rocco Rutte
Hi, I've been trying to make distutils build mercurial with custom cflags. The only way this works is to change Makefile because I don't want to put my changed CFLAGS into the environment and I tend to forget to run "make" with a CFLAGS=... option. Google brings up a special "Setup" file which sh

Re: pep 8 constants

2009-07-03 Thread MRAB
Eric S. Johansson wrote: Horace Blegg wrote: I've been kinda following this. I have a cousin who is permanently wheel chair bound and doesn't have perfect control of her hands, but still manages to use a computer and interact with society. However, the idea/thought of disabled programmers was ne

Re: Clarity vs. code reuse/generality

2009-07-03 Thread Bearophile
On 3 Lug, 16:05, kj wrote: > I'm will be teaching a programming class to novices, and I've run > into a clear conflict between two of the principles I'd like to > teach: code clarity vs. code reuse. They are both important principles, but clarity is usually more important because short code that

The TimingAnalyzer -- project to convert from Java to Python

2009-07-03 Thread chewie
Hello, This a project related to the development of an EDA CAD tool program called the TimingAnalyzer. Digital engineers could use this kind of program to analyze and document inteface timing diagrams for IC, ASIC, FPGA, and board level hardware projects. The TimingAnalyzer is licensed as free

Re: Clarity vs. code reuse/generality

2009-07-03 Thread Aahz
In article , kj wrote: > >This seemed straightforward enough, until I realized that, to be >useful to my students in their homework, this _binary_search function >had to handle the case in which the passed function was monotonically >decreasing in the specified interval... > >def _binary_search(l

Re: Clarity vs. code reuse/generality

2009-07-03 Thread Alan G Isaac
On 7/3/2009 10:05 AM kj apparently wrote: > The context is the concept of a binary search. In one of their > homeworks, my students will have two occasions to use a binary > search. This seemed like a perfect opportunity to illustrate the > idea of abstracting commonalities of code into a re-usab

Re: Is code duplication allowed in this instance?

2009-07-03 Thread Bearophile
Francesco Bochicchio: > Possibly to prepare the test data set you might need a > different - and already proven - implementation of > the algorithm. Usually a brute force or slow but short algorithm is OK (beside some hard-coded input-output pairs). Sometimes you may use the first implementation

Re: Clarity vs. code reuse/generality

2009-07-03 Thread Steven D'Aprano
On Fri, 03 Jul 2009 14:05:08 +, kj wrote: > ... I find that the processing of > abstracting out common logic often results in code that is harder to > read ... Yes. There is often a conflict between increasing abstraction and ease of understanding. [...] > The implementation is still very

Re: Why re.match()?

2009-07-03 Thread Aahz
In article , kj wrote: >In <025db0a6$0$20657$c3e8...@news.astraweb.com> Steven D'Aprano > writes: >>On Thu, 02 Jul 2009 11:19:40 +, kj wrote: >>> >>> If the concern is efficiency for such cases, then simply implement >>> optional offset and length parameters for re.search(), to specify any >

VirtualEnv

2009-07-03 Thread Ronn Ross
I'm attempting to write a bootstrap script for virtualenv. I just want to do a couple of easy_install's after the environment is created. It was fairly easy to create the script, but I can't figure out how to implement it. The documentation was not of much help. Can someone please point me in the r

Re: pep 8 constants

2009-07-03 Thread Eric S. Johansson
Horace Blegg wrote: > I've been kinda following this. I have a cousin who is permanently wheel > chair bound and doesn't have perfect control of her hands, but still > manages to use a computer and interact with society. However, the > idea/thought of disabled programmers was new to me/hadn't ever

Clarity vs. code reuse/generality

2009-07-03 Thread kj
I'm will be teaching a programming class to novices, and I've run into a clear conflict between two of the principles I'd like to teach: code clarity vs. code reuse. I'd love your opinion about it. The context is the concept of a binary search. In one of their homeworks, my students will have

Re: Why re.match()?

2009-07-03 Thread MRAB
kj wrote: In <025db0a6$0$20657$c3e8...@news.astraweb.com> Steven D'Aprano writes: On Thu, 02 Jul 2009 11:19:40 +, kj wrote: If the concern is efficiency for such cases, then simply implement optional offset and length parameters for re.search(), to specify any arbitrary substring to ap

Re: Why re.match()?

2009-07-03 Thread kj
In <025db0a6$0$20657$c3e8...@news.astraweb.com> Steven D'Aprano writes: >On Thu, 02 Jul 2009 11:19:40 +, kj wrote: >> If the concern is efficiency for such cases, then simply implement >> optional offset and length parameters for re.search(), to specify any >> arbitrary substring to apply t

Re: stringio+tarfile

2009-07-03 Thread Lie Ryan
superpollo wrote: >> First problem I see is all those numbers before the lines. That's not >> valid python. >> >> Assuming that was a transcription error > > not so. i intentionally add linenumbers to facilitare reference to the > code, but if it is a nuisance i will not include them anymore. Th

Re: Sequence splitting

2009-07-03 Thread Lie Ryan
tsangpo wrote: > Just a shorter implementation: > > from itertools import groupby > def split(lst, func): > gs = groupby(lst, func) > return list(gs[True]), list(gs[False]) > As you're replying to my post, I assume you meant a shorter implementation my function. But it doesn't do the sam

Re: Is code duplication allowed in this instance?

2009-07-03 Thread Steven D'Aprano
On Fri, 03 Jul 2009 03:46:32 -0700, Klone wrote: > Hi all. I believe in programming there is a common consensus to avoid > code duplication, I suppose such terms like 'DRY' are meant to back this > idea. Anyways, I'm working on a little project and I'm using TDD (still > trying to get a hang of th

Re: PEP 376

2009-07-03 Thread Tarek Ziadé
Ok here's my proposal for the checksum : - I'll add the "hash_type:" suffix in the record file - install will get a new option to define what hash should be used when writing the RECORD file it will default to SHA1 for 2.7/3.2 - pkgutil, that reads the RECORD files, will pick the right hash fu

Re: Python debugger

2009-07-03 Thread Clovis Fabricio
2009/7/3 srinivasan srinivas : > Could you suggest some python debuggers? Two graphical debugger frontends: http://www.gnu.org/software/emacs/ http://winpdb.org/ -- http://mail.python.org/mailman/listinfo/python-list

Re: Is code duplication allowed in this instance?

2009-07-03 Thread Lie Ryan
Klone wrote: > Hi all. I believe in programming there is a common consensus to avoid > code duplication, I suppose such terms like 'DRY' are meant to back > this idea. Anyways, I'm working on a little project and I'm using TDD > (still trying to get a hang of the process) and am trying to test the

Re: Adding an object to the global namespace through " f_globals" is that allowed ?

2009-07-03 Thread Bruno Desthuilliers
Stef Mientki a écrit : hello, I need to add an object's name to the global namespace. The reason for this is to create an environment, where you can add some kind of math environment, where no need for Python knowledge is needed. The next statement works, but I'm not sure if it will have any dr

Re: Python debugger

2009-07-03 Thread Bruno Desthuilliers
srinivasan srinivas a écrit : Hi, Could you suggest some python debuggers? http://docs.python.org/library/pdb.html#module-pdb HTH -- http://mail.python.org/mailman/listinfo/python-list

Re: Is code duplication allowed in this instance?

2009-07-03 Thread Francesco Bochicchio
On Jul 3, 12:46 pm, Klone wrote: > Hi all. I believe in programming there is a common consensus to avoid > code duplication, I suppose such terms like 'DRY' are meant to back > this idea. Anyways, I'm working on a little project and I'm using TDD > (still trying to get a hang of the process) and a

Re: Sequence splitting

2009-07-03 Thread Pablo Torres N.
On Fri, Jul 3, 2009 at 06:01, Paul Moore wrote: > 2009/7/3 Brad : >> Perhaps true, but it would be a nice convenience (for me) as a built- >> in written in either Python or C. Although the default case of a bool >> function would surely be faster. > > The chance of getting this accepted as a builti

Re: Searching equivalent to C++ RAII or deterministic destructors

2009-07-03 Thread Jack Diederich
On Thu, Jul 2, 2009 at 2:36 PM, Carl Banks wrote: > On Jul 2, 3:12 am, Ulrich Eckhardt wrote: >> Bearophile wrote: >> > Ulrich Eckhardt: >> >> a way to automatically release the resource, something >> >> which I would do in the destructor in C++. >> >> > Is this helpful? >> >http://effbot.org/pyre

Python debugger

2009-07-03 Thread srinivasan srinivas
Hi, Could you suggest some python debuggers? Thanks, Srini Love Cricket? Check out live scores, photos, video highlights and more. Click here http://cricket.yahoo.com -- http://mail.python.org/mailman/listinfo/python-list

Re: stringio+tarfile

2009-07-03 Thread Peter Otten
superpollo wrote: > thanks to the guys who bothered to answer me even using their chrystal > ball ;-) > > i'll try to be more specific. > > yes: i want to create a tar file in memory, and add some content from a > memory buffer... > > my platform: > > $ uname -a > Linux fisso 2.4.24 #1 Thu Feb

Re: Searching equivalent to C++ RAII or deterministic destructors

2009-07-03 Thread Ulrich Eckhardt
Thanks to all that answered, in particular I wasn't aware of the existence of the __del__ function. For completeness' sake, I think I have found another way to not really solve but at least circumvent the problem: weak references. If I understand correctly, those would allow me to pass out handles

Re: stringio+tarfile

2009-07-03 Thread superpollo
thanks to the guys who bothered to answer me even using their chrystal ball ;-) i'll try to be more specific. yes: i want to create a tar file in memory, and add some content from a memory buffer... my platform: $ uname -a Linux fisso 2.4.24 #1 Thu Feb 12 19:49:02 CET 2004 i686 GNU/Linux $ py

Re: Is code duplication allowed in this instance?

2009-07-03 Thread Rickard Lindberg
> Whoever it so happens to verify the > output from the method I have to employ the same algorithm within the > method to do the verification since there is no way I can determine > the output before hand. Can you clarify this scenario a bit? If you are performing black-box testing I don't see wh

Re: pep 8 constants

2009-07-03 Thread Horace Blegg
I've been kinda following this. I have a cousin who is permanently wheel chair bound and doesn't have perfect control of her hands, but still manages to use a computer and interact with society. However, the idea/thought of disabled programmers was new to me/hadn't ever occurred to me. You say tha

  1   2   >