Re: Most "active" coroutine library project?

2009-08-23 Thread Matthew Woodcraft
Phillip B Oldham writes: > I've been taking a look at the multitude of coroutine libraries > available for Python, but from the looks of the projects they all seem > to be rather "quiet". I'd like to pick one up to use on a current > project but can't deduce which is the most popular/has the larg

Re: Annoying octal notation

2009-08-23 Thread Matthew Woodcraft
Dennis Lee Bieber writes: > About the only place one commonly sees leading zeros on decimal > numbers, in my experience, is zero-filled COBOL data decks (and since > classic COBOL stores in BCD anyway... binary (usage is > computational/comp-1) was a later add-on to the data specification mo

Re: better way?

2009-08-11 Thread Matthew Woodcraft
"Rami Chowdhury" writes: > IIRC Postgres has had ON DUPLICATE KEY UPDATE functionality longer than > MySQL... PostgreSQL does not have ON DUPLICATE KEY UPDATE. The SQL standard way to do what the OP wants is MERGE. PostgreSQL doesn't have that either. -M- -- http://mail.python.org/mailman/lis

Re: mailbox.mbox.add() sets access time as well as modification time

2009-05-01 Thread Matthew Woodcraft
Chris Green wrote: > Currently I run mutt on a remote server where I have to use maildir > because their file systems are mounted noatime. I am moving to reading > mail on my own Linux box just because I want to get back to mbox, [...] For what it's worth, setting 'check_mbox_size = yes' is usuall

Re: How to do this in Python?

2009-03-17 Thread Matthew Woodcraft
Jim Garrison writes: > buf = f.read(1) > while len(buf) > 0 > # do something > buf = f.read(1) I think it's more usual to use a 'break' rather than duplicate the read. That is, something more like while True: buf = f.read(1)

Re: Style question - defining immutable class data members

2009-03-15 Thread Matthew Woodcraft
"Rhodri James" writes: > But do you, though? The only occasion I can think of that I'd want > the search to go past the instance is this "auto-initialisation", > and frankly I'd rather do that in an __init__ anyway. Perhaps > static methods or class methods work that way, I don't know how > the

Re: Style question - defining immutable class data members

2009-03-15 Thread Matthew Woodcraft
John Posner writes: > My question is ... WHY does the interpreter silently create the > instance attribute at this point, causing a "surprising decoupling" > from the class attribute? WHY doesn't the interpreter behave as it > would with a simple, non-instance variable: > > python > Python 2

Re: Style question - defining immutable class data members

2009-03-15 Thread Matthew Woodcraft
"Rhodri James" writes: > On Sun, 15 Mar 2009 13:26:17 -0000, Matthew Woodcraft >> It seems clear to me that Maxim understood all this when he asked his >> original question (you need to understand this subtlety to know why >> the trick he was asking about

Re: Style question - defining immutable class data members

2009-03-15 Thread Matthew Woodcraft
Gary Herron writes: > Gary Herron wrote: > No, you are still misinterpreting your results. But you can be forgiven > because this is quite a subtle point about Python's attribute access. > > Here's how it works: > > On access, self.count (or self.anything) attempts to find "count" in > the inst

Re: Style question - defining immutable class data members

2009-03-14 Thread Matthew Woodcraft
Gary Herron writes: > But now you are not listening to what people are telling you. It has > *nothing* to do with the mutability/immutability of the integer and the list > your two classes create. No! Did you run the code he posted? The immutability makes all the difference. > The difference

Re: "Byte" type?

2009-02-22 Thread Matthew Woodcraft
"Hendrik van Rooyen" writes: > "Christian Heimes" wrote: > on the surface JN has a point - If you have to go through two > conversions, then 2.6 does not achieve what it appears to set out to > do. So the issue is simple: > - do you have to convert twice? > - If yes - why? - as he says - there

Re: What encoding does u'...' syntax use?

2009-02-20 Thread Matthew Woodcraft
Ron Garret writes: > Put this another way: I would have thought that when the Python parser > parses "u'\xb5'" it would produce the same result as calling > unicode('\xb5'), but it doesn't. Instead it seems to produce the same > result as calling unicode('\xb5', 'latin-1'). But my default encoding

Re: are there some special about '\x1a' symbol

2009-01-16 Thread Matthew Woodcraft
Steve Holden writes: > Unknown wrote: >> On 2009-01-12, John Machin wrote: >> >>> I didn't think your question was stupid. Stupid was (a) CP/M recording >>> file size as number of 128-byte sectors, forcing the use of an in-band >>> EOF marker for text files (b) MS continuing to regard Ctrl-Z as

Re: Python svn bindings for Subversion?

2008-08-28 Thread Matthew Woodcraft
Mike B writes: > I'm trying to get Subversion 'hook scripts' working on an Ubuntu box and the > following fails. > > from svn import fs, repos, core, delta [...] > 'svn' appears to be a SWIG wrapper and could be what I'm looking for, but I > cannot find it anywhere. > > Can anyone point me in the r

Re: filter in for loop

2008-08-28 Thread Matthew Woodcraft
GHZ <[EMAIL PROTECTED]> writes: > I would like to say something like: > > for filename in os.listdir(DIR) if filename[-4:] == '.xml': > > > > instead of having to say: > > for filename in os.listdir(DIR): > if filename[-4:] == '.xml': > If the reason you don't like this one is t

Re: Fastest way to store ints and floats on disk

2008-08-09 Thread Matthew Woodcraft
Laszlo Nagy <[EMAIL PROTECTED]> writes: > The facts table cannot be kept in memory because it is too big. I need to > store it on disk, be able to read incrementally, and make statistics. In most > cases, the "statistic" will be simple sum of the measures, and counting the > number of facts affect

Re: Redirecting stderr and stdout to syslog

2008-08-05 Thread Matthew Woodcraft
In article <[EMAIL PROTECTED]>, > How do I redirect ALL stderr stuff to syslog, even stderr from > external programs that don't explicitly change their own stderr? Sending messages to syslog involves more than writing to a file descriptor, so there's no way to make this happen without having som

Re: URLs and ampersands

2008-08-05 Thread Matthew Woodcraft
Gabriel Genellina wrote: > Steven D'Aprano wrote: >> I have searched for, but been unable to find, standard library >> functions that escapes or unescapes URLs. Are there any such >> functions? > Yes: cgi.escape/unescape, and xml.sax.saxutils.escape/unescape. I don't see a cgi.unescape in the st

Re: URLs and ampersands

2008-08-05 Thread Matthew Woodcraft
Steven D'Aprano wrote: > I'm using urllib.urlretrieve() to download HTML pages, and I've hit a > snag with URLs containing ampersands: > > http://www.example.com/parrot.php?x=1&y=2 > > Somewhere in the process, urls like the above are escaped to: > > http://www.example.com/parrot.php?x=1&y=2 > > w

Re: Difference between type and class

2008-08-01 Thread Matthew Woodcraft
Thomas Troeger <[EMAIL PROTECTED]> wrote: > Will this disappear in Python 3.0., i.e. can you again simply write > > class A: > > and inherit from object automagically? Short answer: yes. -M- -- http://mail.python.org/mailman/listinfo/python-list

Re: Boolean tests [was Re: Attack a sacred Python Cow]

2008-07-31 Thread Matthew Woodcraft
Steven D'Aprano wrote: >On Thu, 31 Jul 2008 22:01:48 +0100, Matthew Woodcraft wrote: >> The point is that if you tell people that "if x" is the standard way to >> check for emptiness, and also support a general principle along the >> lines of "write your

Re: Boolean tests [was Re: Attack a sacred Python Cow]

2008-07-31 Thread Matthew Woodcraft
Steven D'Aprano wrote: >On Wed, 30 Jul 2008 20:55:03 +0100, Matthew Woodcraft wrote: >> On the other hand, iterators provide a clear example of problems with >> "if x": __nonzero__ for iterators (in general) returns True even if they >> are 'empty&#

Re: Function References

2008-07-31 Thread Matthew Woodcraft
>> Ctypes is a since python2.5 built-in module that allows to declare >> interfaces to C-libraries in pure python. You declare datatypes and >> function prototypes, load a DLL/SO and then happily work with it. No C, no >> compiler, no refcounts, no nothing. >> >> And you can pass python-functions a

Re: Boolean tests [was Re: Attack a sacred Python Cow]

2008-07-30 Thread Matthew Woodcraft
Terry Reedy <[EMAIL PROTECTED]> wrote: >Carl Banks wrote: >> That's not what I was asking for. I was asking for a use case for "if >> x" that can't be replaced by a simple explicit test. Your example >> didn't satisfy that. > But I believe my example of an iterator with __bool__ but not with

Re: Boolean tests

2008-07-29 Thread Matthew Woodcraft
Steven D'Aprano <[EMAIL PROTECTED]> wrote: >Anders wrote: >> "But then you decide to name the method "__nonzero__", instead of some >> nice descriptive name?" > That suggests to me that Anders imagined that __nonzero__ is something I > just made up, instead of a standard Python method. What do

Re: Build tool for Python

2008-07-29 Thread Matthew Woodcraft
Paul Boddie <[EMAIL PROTECTED]> wrote: > I do understand that it can be awkward to work out which object files > need recompiling due to changes in source files, for example, and > that one doesn't want to see the logic involved reproduced all over > the place, but I do wonder whether the machiner

Re: Boolean tests

2008-07-29 Thread Matthew Woodcraft
Ben Finney <[EMAIL PROTECTED]> wrote: > No, he retracted the *insult* and restated the *advice* as a distinct > statement. I think it's quite worthwhile to help people see the > difference. Ben, it was quite clear from Anders' post that he knows about __nonzero__ . That's why the so-called advice

Re: Boolean tests [was Re: Attack a sacred Python Cow]

2008-07-29 Thread Matthew Woodcraft
Steven D'Aprano <[EMAIL PROTECTED]> wrote: > "if x" is completely type agnostic. You can pass an object of any type to > it, and it will work. (Excluding objects with buggy methods, naturally.) There are many circumstances where if a parameter is None I'd rather get an exception than have the co

Re: Where is the documentation for psycopg2?

2008-07-29 Thread Matthew Woodcraft
kj <[EMAIL PROTECTED]> wrote: > Hi. I can't find any documentation for psycopg2. > > I'm a noob, so I'm sure I'm just not looking in the right place... > > Anybody know where it is? For basic use, psycopg2 follows the dbapi, which is described in http://www.python.org/dev/peps/pep-0249/ Additi

Re: Python Written in C?

2008-07-21 Thread Matthew Woodcraft
Roy Smith <[EMAIL PROTECTED]> wrote: > C is the highest level assembler language I've ever used. And I've used a > few. It really is cool that you can add two 32-bit integers and not have > to worry about all those carry bits. I was ever so pleased when I found out that the LLVM people have l

Re: x, = y (???)

2008-07-17 Thread Matthew Woodcraft
kj wrote: > I still don't get it. If we write > > y = 'Y' > x, = y > > what's the difference now between x and y? And if there's no > difference, what's the point of performing such "unpacking"? If y really is is a string, I think it's likely that the line you came across was a typo. In the

Re: py2exe & application add-ons

2008-06-19 Thread Matthew Woodcraft
Alex Gusarov <[EMAIL PROTECTED]> wrote: > Hello, I've met a problem - I want my program working without Python > installation but I have some add-on mechanism (add-ons represented by > separate .py files, and application auto-recognize such files on > start). > So, if I will using py2exe for main

Re: Function argument conformity check

2008-06-18 Thread Matthew Woodcraft
In article <[EMAIL PROTECTED]>, > The problem is that using these attributes, I would essentially have > to re-write the logic python uses when calling a function with a > given set of arguments. I was hoping there is a way to get at that > logic without rewriting it. I don't think there is. I end

Re: Getting Python exit code when calling Python script from Java program

2008-06-18 Thread Matthew Woodcraft
In article <[EMAIL PROTECTED]>, > I tried using the sys.exit() method in my script and passed non -zero > values. However the value wasn't picked up the by Java > Process.exitValue() method - it kept picking up 0. On investigation > it turned out that the exit value being read is from python.exe >

Re: Code correctness, and testing strategies

2008-05-25 Thread Matthew Woodcraft
David <[EMAIL PROTECTED]> wrote: > Might be a difference in project size/complexity then, rather than > company size. Most of my works projects are fairly small (a few > thousand lines each), very modular, and each is usually written and > maintained by one developer. A lot of the programs will be

Re: unittest: Calling tests in liner number order

2008-05-25 Thread Matthew Woodcraft
Diez B. Roggisch <[EMAIL PROTECTED]> wrote: >I don't see this as something that can be solved by ordering tests - >*especially* not on a per-method-level as the OP suggested, because I >tend to have test suites that span several files. unittest already runs multiple test suites in the order you

Re: need some help in serving static files inside a wsgi apps

2008-05-25 Thread Matthew Woodcraft
Diez B. Roggisch <[EMAIL PROTECTED]> wrote: >Sebastian 'lunar' Wiesner schrieb: >> I guess, Apache does some kind of memory caching for files, which are often >> requested and small enough to fit into the system memory. May be, that's >> what the OP is referring to ... > I'm not aware of that, an

Re: Code correctness, and testing strategies

2008-05-25 Thread Matthew Woodcraft
Michael L Torrie <[EMAIL PROTECTED]> wrote: > Watch your programmers then. They do have to write and debug the > code. And they will spend at least as much or more time debugging as > writing the code. It's a fact. I have several programmers working > for me on several projects. What you have

Re: Relationship between GUI and logic?

2008-05-24 Thread Matthew Woodcraft
David C. Ullrich <[EMAIL PROTECTED]> wrote: > Matthew Woodcraft <[EMAIL PROTECTED]> wrote: >> For example, if you were writing the 'logic' for a chess program you >> might choose a way of modelling the board that can't represent a >> position with

Re: Relationship between GUI and logic?

2008-05-23 Thread Matthew Woodcraft
John Salerno <[EMAIL PROTECTED]> wrote: > Basically, the question is this: can you write the logic behind a > program (whether it be a game, an email client, a text editor, etc.) > without having any idea of how you will implement the GUI? You probably could, but it's best not to unless you're

Re: Python and Flaming Thunder

2008-05-22 Thread Matthew Woodcraft
<[EMAIL PROTECTED]> wrote: > So it seems like you're designing a language for non-programmers. > That's good, I've never heard about anyone so interested in teaching > programming for kids and non-programmers. But in that case, you > shouldn't even be comparing it to Python. At one time, Guido was

Re: Running programs under a python program...

2008-05-21 Thread Matthew Woodcraft
[EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > So I have a python program that runs a bunch of other programsit > then loops forever, occasionally executing other programs. > > To run each of these programs my python code executes: > subprocess.Popen(command_line, shell=True, stdout=fd, > stder

Re: Purpose of operator package

2008-05-14 Thread Matthew Woodcraft
I V <[EMAIL PROTECTED]> wrote: > I hadn't heard of operator.truth before. Does it do anything different > from bool(x) ? Not really. It was occasionally useful before the bool type existed; now it's just a leftover. -M- -- http://mail.python.org/mailman/listinfo/python-list

Re: do you fail at FizzBuzz? simple prog test

2008-05-13 Thread Matthew Woodcraft
Gabriel Genellina <[EMAIL PROTECTED]> wrote: > I would like to write a similar problem without this non-programming > distracting issues (that is, a problem simple enough to be answered in a > few minutes, that requires only programming skills to be solved, and > leaving out any domain-specif

Re: Learning Python for no reason

2008-05-12 Thread Matthew Woodcraft
John Salerno <[EMAIL PROTECTED]> wrote: > Just something that crosses my mind every time I delve into "Learning > Python" each night. Does anyone see any value in learning Python when you > don't need to for school, work, or any other reason? I mean, sure, there's > value in learning anything at

Re: Any reliable obfurscator for Python 2.5

2008-04-21 Thread Matthew Woodcraft
Terry Reedy <[EMAIL PROTECTED]> wrote: > Such requests happen about once a month or so. If all the code-hiders were > to have gotten together to openly share their obfuscation ideas and code, I > suspect there would have been something pretty good by now. But in 10 > years of my watching, this

Re: Alternate indent proposal for python 3000

2008-04-21 Thread Matthew Woodcraft
Terry Reedy <[EMAIL PROTECTED]> wrote: > Off the top of my head: copy C and use {} to demarcate blocks and ';' to > end statements, so that '\n' is not needed and is just whitespace when > present. So, repeatedly scan for the next one of '{};'. That would break if those characters appear in str

Re: Alternate indent proposal for python 3000

2008-04-20 Thread Matthew Woodcraft
Terry Reedy <[EMAIL PROTECTED]> wrote: > But you do not really need a variant. Just define a preprocessor > function 'blockify' which converts code in an alternate syntax to > regular indented block syntax. Then > > exec(blockify(alt_code_string)) You can do it like that, but if it were to beco

Re: Alternate indent proposal for python 3000

2008-04-20 Thread Matthew Woodcraft
Arnaud Delobelle <[EMAIL PROTECTED]> wrote: > By 'eval', I guess you mean 'exec' :) Yes. Shows how often I use either. -M- -- http://mail.python.org/mailman/listinfo/python-list

Re: Alternate indent proposal for python 3000

2008-04-20 Thread Matthew Woodcraft
Christian Heimes <[EMAIL PROTECTED]> wrote: >> I feel that including some optional means to block code would be a big >> step in getting wider adoption of the language in web development and >> in general. I do understand though, that the current strict indenting >> is part of the core of the lan

Re: How to have unittest tests to be executed in the order they appear?

2008-04-16 Thread Matthew Woodcraft
Ben Finney <[EMAIL PROTECTED]> wrote: > Surely, since "suddenly" implies you changed one small area of the > code, that area of the code is the best place to look for what caused > the failure. Imagine that "suddenly" immediately follows "I upgraded to etch". -M- -- http://mail.python.org/mailm

Re: How to have unittest tests to be executed in the order they appear?

2008-04-16 Thread Matthew Woodcraft
Ben Finney <[EMAIL PROTECTED]> wrote: >"Giampaolo Rodola'" <[EMAIL PROTECTED]> writes: >> Is there a way to force unittest to run test methods in the order >> they appear? > No, and this is a good thing. > Your test cases should *not* depend on any state from other test > cases; they should func

Re: urllib working differently when run from crontab

2008-04-14 Thread Matthew Woodcraft
In article <[EMAIL PROTECTED]>, VictorMiller <[EMAIL PROTECTED]> wrote: > I've written a python script which, using urllib, and urllib2 will > fetch a number of files that that I'm interested in from various > websites (they're updated everyday). When I run the script from my > command line every

Re: plpythonu+postgrs anybody using it?

2008-04-02 Thread Matthew Woodcraft
Martin Marcher <[EMAIL PROTECTED]> wrote: > My main concern is that when things start getting more complicated > that everytime a SP is called an instance of the interpreter ist > started which would be a huge slowdown, so does plpythonu run > continiously a python process or does it start one ever

Re: object-relational mappers

2008-04-01 Thread Matthew Woodcraft
Aaron Watters <[EMAIL PROTECTED]> wrote: > I've been poking around the world of object-relational > mappers and it inspired me to coin a corellary to the > the famous quote on regular expressions: > "You have objects and a database: that's 2 problems. > So: get an object-relational mapper: > now

Re: Immutable and Mutable Types

2008-03-17 Thread Matthew Woodcraft
In article <[EMAIL PROTECTED]>, Duncan Booth <[EMAIL PROTECTED]> wrote: > I don't have a copy of 1.4 to check so I'll believe you, but you can > certainly get the output I asked for with much more recent versions. > For the answer I actually want each asterisk substitutes for exactly one > char

Re: Why """, not '''?

2008-03-05 Thread Matthew Woodcraft
Steven D'Aprano <[EMAIL PROTECTED]> wrote: >On Wed, 05 Mar 2008 19:19:08 +, Matthew Woodcraft wrote: >> One advantage is that a dumb syntax highlighter is more likely to cope >> well if the content includes an apostrophe. > But if the content contains double-

Re: documenting formal operational semantics of Python

2008-03-05 Thread Matthew Woodcraft
gideon <[EMAIL PROTECTED]> wrote: > In the context of a master's thesis I'm currently looking into > Python's operational semantics. Even after extensive searching on the > web, I have not found any formal model of Python. Therefore I am > considering to write one myself. To make a more informed d

Re: Why """, not '''?

2008-03-05 Thread Matthew Woodcraft
<[EMAIL PROTECTED]> wrote: > Why is """ the preferred delimiter for multi-line strings? One advantage is that a dumb syntax highlighter is more likely to cope well if the content includes an apostrophe. -M- -- http://mail.python.org/mailman/listinfo/python-list

Re: Nested module import clutters package namespace?

2008-02-29 Thread Matthew Woodcraft
<[EMAIL PROTECTED]> wrote: > I'd be grateful for help with a problem of package and module=20 > namespaces. The behaviour I observe is unexpected (to me), and I=20 > couldn't find the answer in the docs, the tutorial, or the mailing=20 > list archive. So here we go: > I have a package named 'pack'

Re: Article of interest: Python pros/cons for the enterprise

2008-02-26 Thread Matthew Woodcraft
Nicola Musatti <[EMAIL PROTECTED]> wrote: > Sebastian Kaliszewski <[EMAIL PROTECTED]> wrote: >> 3. You can't handle clean-up errors in reasonable way in C++ish approach, so >> anything more complex should not by handled that way anyway. > So it's okay for a Python mechanism to deal with 95% of th

Re: Article of interest: Python pros/cons for the enterprise

2008-02-24 Thread Matthew Woodcraft
Jeff Schwab <[EMAIL PROTECTED]> wrote: > Matthew Woodcraft wrote: >> I see. Then, unless you don't care about data loss passing silently, >> this 'most traditional' way to open a file is unsuitable for files >> opened for writing. > No, why would yo

Re: Article of interest: Python pros/cons for the enterprise

2008-02-23 Thread Matthew Woodcraft
Jeff Schwab <[EMAIL PROTECTED]> wrote: >Matthew Woodcraft wrote: >> Jeff Schwab <[EMAIL PROTECTED]> wrote: >>> The most traditional, easiest way to open a file in C++ is to use an >>> fstream object, so the file is guaranteed to be closed when the fstr

Re: Article of interest: Python pros/cons for the enterprise

2008-02-23 Thread Matthew Woodcraft
Jeff Schwab <[EMAIL PROTECTED]> wrote: > The most traditional, easiest way to open a file in C++ is to use an > fstream object, so the file is guaranteed to be closed when the fstream > goes out of scope. Out of interest, what is the usual way to manage errors that the operating system reports

Re: linux disc space

2008-02-15 Thread Matthew Woodcraft
In article <[EMAIL PROTECTED]>, Jeff Schwab <[EMAIL PROTECTED]> wrote: > Available space is how much you can actually access as a non-root user. > Apparently (thank you Jean-Paul), space can be reserved for superuser > use only; such space is "free," but not "available." > I'm not sure how su

Re: I'm searching for Python style guidelines

2008-01-08 Thread Matthew Woodcraft
<[EMAIL PROTECTED]> wrote: > A quick look (thorough analysis still required) shows that OLPC and > PyPy are, indeed, extensive standards. > one-laptop-per-child.html > (olpc),74.3,,http://wiki.laptop.org/go/Python_Style_Guide I think that's mostly PEP 8, with some notes added. -M- -- http://m

Re: I'm searching for Python style guidelines

2008-01-08 Thread Matthew Woodcraft
Paul McGuire <[EMAIL PROTECTED]> wrote: > While not required by any means, you will also find it handy to follow > *every* entry in the list with a comma, even the last one in the list > (this is legal Python). That is, in your example: > > foo =3D [ > 'too long', > 'too long too', >

Re: Hiding tracebacks from end-users

2007-10-24 Thread Matthew Woodcraft
Steven D'Aprano <[EMAIL PROTECTED]> wrote: > I'm writing a command-line application that is meant to be relatively > user friendly to non-technical users. > Consequently, I'd like to suppress Python's tracebacks if an error does > occur, replacing it with a more friendly error message. I'm doin

Re: Would Anonymous Functions Help in Learning Programming/Python?

2007-09-22 Thread Matthew Woodcraft
Cristian <[EMAIL PROTECTED]> wrote: > To me, the biggest setback for new programmers is the different > syntax Python has for creating functions. Instead of the common (and > easy to grasp) syntax of foo = bar Python has the def foo(): syntax. [...] > in a program like Python there doesn't seem

Re: An Editor that Skips to the End of a Def

2007-09-21 Thread Matthew Woodcraft
Lawrence D'Oliveiro <[EMAIL PROTECTED]> wrote: >In message <[EMAIL PROTECTED]>, John J. Lee wrote: >> Seriously for a moment, I read something recently (maybe here?) about >> an Apple study that claimed to show that people who perceived keyboard >> bindings as being much faster than mouseing did

Re: Modul (%) in python not like in C?

2007-09-11 Thread Matthew Woodcraft
J. Cliff Dyer <[EMAIL PROTECTED]> wrote: >Bryan Olson wrote: >> Not true. Here it is again: >> >> When integers are divided, the result of the / operator is >> the algebraic quotient with any fractional part discarded.(87) >> If the quotient a/b is representable, the expression >>

Re: Eval and raw string ??

2007-08-22 Thread Matthew Woodcraft
Mark <[EMAIL PROTECTED]> wrote: > Eval() doesn't seem to recognize the r'string' format. Is there a way > around this. > Example: > If I input: -> eval("r'C:\tklll\ndfd\bll'") > I get the output: > > Traceback (most recent call last): > File "", line 1, in > eval("r'C:\tklll\ndfd\bl

Re: Semantics of file.close()

2007-07-17 Thread Matthew Woodcraft
Donn Cave <[EMAIL PROTECTED]> wrote: > I don't think there's any remedy for it, other than the obvious - > either always flush, or wrap an explicit close in its own exception > handler. Even if you have flushed, close() can give an error with some filesystems. -M- -- http://mail.python.org/mai

Re: os.wait() losing child?

2007-07-12 Thread Matthew Woodcraft
Jason Zheng <[EMAIL PROTECTED]> wrote: >Hrvoje Niksic wrote: >> Actually, it's not that bad. _cleanup only polls the instances that >> are no longer referenced by user code, but still running. If you hang >> on to Popen instances, they won't be added to _active, and __init__ >> won't reap them (

Re: profiling a C++ python extension

2007-07-12 Thread Matthew Woodcraft
rasmus <[EMAIL PROTECTED]> wrote: > I have used gprof to profile stand alone C++ programs. I am also > aware of pure python profilers. However, is there a way to get > profile information on my C++ functions when they are compiled in a > shared library (python extension module) and called from p

Re: os.wait() losing child?

2007-07-11 Thread Matthew Woodcraft
greg <[EMAIL PROTECTED]> wrote: > I've figured out what's going on. The Popen class has a > __del__ method which does a non-blocking wait of its own. > So you need to keep the Popen instance for each subprocess > alive until your wait call has cleaned it up. I don't think this will be enough for

Re: Python memory handling

2007-05-31 Thread Matthew Woodcraft
Josh Bloom <[EMAIL PROTECTED]> wrote: > If the memory usage is that important to you, you could break this out > into 2 programs, one that starts the jobs when needed, the other that > does the processing and then quits. > As long as the python startup time isn't an issue for you. And if python st

Re: PEP 3131: Supporting Non-ASCII Identifiers

2007-05-16 Thread Matthew Woodcraft
Eric Brunel <[EMAIL PROTECTED]> wrote: > Joke aside, this just means that I won't ever be able to program math in > ADA, because I have absolutely no idea on how to do a 'pi' character on my > keyboard. Just in case it wasn't clear: you could of course continue to use the old name 'Pi' instead

Re: PEP 3131: Supporting Non-ASCII Identifiers

2007-05-15 Thread Matthew Woodcraft
Thorsten Kampe <[EMAIL PROTECTED]> wrote: >* René Fleschenberg (Tue, 15 May 2007 14:35:33 +0200) >> I am talking about the stdlib, not about the very few keywords Python >> has. Are you going to re-write the standard library in your native >> language so you can have a consistent use of natural la

Re: 2 new comment-like characters in Python to aid development?

2007-03-09 Thread Matthew Woodcraft
Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: Nick Craig-Wood a ecrit : > I use # FIXME for this purpose or /* FIXME */ in C etc. > > I have an emacs macro which shows it up in bright red / yellow text > so it is easy to see > Thanks you both. For what it's worth, sufficien

Re: Project organization and import

2007-03-06 Thread Matthew Woodcraft
Martin Unsal <[EMAIL PROTECTED]> wrote: > We could discuss this till we're blue in the face but it's beside the > point. For any given project, architecture, and workflow, the > developers are going to have a preference for how to organize the > code structurally into files, directories, packages,

Re: Synchronous shutil.copyfile()

2007-01-30 Thread Matthew Woodcraft
Hugo Ferreira <[EMAIL PROTECTED]> wrote: > I have a problem. I'm using calling shutil.copyfile() followed by > open(). The thing is that most of the times open() is called before > the actual file is copied. I don't have this problem when doing a > step-by-step debug, since I give enough time for t

Re: assertions to validate function parameters

2007-01-26 Thread Matthew Woodcraft
Steven D'Aprano <[EMAIL PROTECTED]> wrote: > The less your function does, the more constrained it is, the less > testing you have to do -- but the less useful it is, and the more work > you put onto the users of your function. Instead of saying something > like > a = MyNumericClass(1) > b = MyNum

Re: Thoughts on using isinstance

2007-01-25 Thread Matthew Woodcraft
Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: > Matthew Woodcraft a écrit : >> Adding the validation code can make your code more readable, in that >> it can be clearer to the readers what kind of values are being >> handled. > This is better expressed in the

Re: Thoughts on using isinstance

2007-01-24 Thread Matthew Woodcraft
abcd <[EMAIL PROTECTED]> wrote: > Well my example function was simply taking a string and printing, but > most of my cases would be expecting a list, dictionary or some other > custom object. Still propose not to validate the type of data being > passed in? There are many people here who will in

Re: for: else: - any practical uses for the else clause?

2006-09-29 Thread Matthew Woodcraft
[EMAIL PROTECTED] wrote: > And so on. For every use of the for/else clause there exists a better > alternative. Which sums up my opinion about the construct -- if you > are using it, there's something wrong with your code. How do you transform this? height = 0 for block in stack: if block.is_

Re: optparse docs

2006-09-27 Thread Matthew Woodcraft
tobiah <[EMAIL PROTECTED]> wrote: > In > http://docs.python.org/lib/optparse-terminology.html > > The GNU project introduced "-" followed by a series of hyphen-separated > words, e.g. "-file" or "-dry-run". These are the only two option > syntaxes provided by optparse. [...] > So my ques

Re: python extension modules within packages not loading

2006-09-07 Thread Matthew Woodcraft
tyler <[EMAIL PROTECTED]> wrote: > I've written a small python extension but I'm having difficulty loading > it at runtime. The source for my extension is a module which is a > member of a package is organized as follows. > > test/setup.py > test/myutils/__init__.py > test/myutils/netmodule.c [..

Re: Name of the file associated with sys.std*

2006-08-30 Thread Matthew Woodcraft
Henryk Modzelewski <[EMAIL PROTECTED]> wrote: >It might be a trivial question, but I seem to be lost. > >Is there a way to get names of the files associated with stdin/out/ >err if those are redirected to the files at the shell command-line? I doubt there is a portable way. On most linux-based s

Re: Allowing ref counting to close file items bad style?

2006-08-30 Thread Matthew Woodcraft
Dan <[EMAIL PROTECTED]> wrote: > Is this discouraged?: > > for line in open(filename): > > > That is, should I do this instead?: > > fileptr = open(filename) > for line in fileptr: > > fileptr.close() One reason to use close() explicitly is to make sure tha