Re: set using alternative hash function?

2009-10-16 Thread OKB (not okblacke)
Austin Bingham wrote: > To put it in code, I want this: > > s = set(hash_func = lambda obj: hash(obj.name), eq_func = ...) > ... > x.name = 'foo' > y.name = 'foo' > s.add(x) > s.add(y) # no-op because of uniqueness criteria > assert len(s) == 1 The part of this that seems i

Re: optparse, allowing both --foo and foo=99?

2009-10-16 Thread Carl Banks
On Oct 15, 10:29 pm, Mark Harrison wrote: > What's the magic to allow this?  If the value is not specified I > would like to use the default value of 1. > > import optparse > p=optparse.OptionParser() > p.add_option("--debug") > > (opts, args) = p.parse_args(['--debug=22']); print opts > (opts, ar

Re: How about adding slice notation to iterators/generators?

2009-10-16 Thread Terry Reedy
Eloff wrote: I was just working with a generator for a tree that I wanted to skip the first result (root node.) There is already an obvious standard way to do this. it = next(it) #toss first item for item in it: And it occurs to me, why do we need to do: import sys from itertools im

optparse, allowing both --foo and foo=99?

2009-10-16 Thread Mark Harrison
What's the magic to allow this? If the value is not specified I would like to use the default value of 1. import optparse p=optparse.OptionParser() p.add_option("--debug") (opts, args) = p.parse_args(['--debug=22']); print opts (opts, args) = p.parse_args(['--debug']);print opts Many TIA! M

Re: How about adding slice notation to iterators/generators?

2009-10-16 Thread Bearophile
Terry Reedy: > 1. islice works with any iterator; generator method would only work with > generators A slice syntax that's syntactic sugar for islice(some_iter,1,None) may be added to all iterators. >2. iterator protocol is intentionally simple.< Slice syntax is already available for lists, tu

Re: Object Relational Mappers are evil (a meditation)

2009-10-16 Thread Tim Wintle
On Fri, 2009-10-16 at 01:01 +0200, Mick Krippendorf wrote: > Maybe my English (and my memory) is just not so good. I'm german, and > here "abnormal" and "anormal" are both negations of "normal", but with > a slight difference in meaning. "anormal" means just "not normal", > whereas the meaning of "

ANN: GUI2Exe 0.5.0

2009-10-16 Thread Andrea Gavana
Hi All, I am happy to announce a new release of GUI2Exe (0.5.0). What is it? = GUI2Exe is my first attempt to unify all the available "executable builders" for Python in a single and simple to use graphical user interface. At the moment the supported executable builders are: -

Re: optparse, allowing both --foo and foo=99?

2009-10-16 Thread Jean-Michel Pichavant
Carl Banks wrote: On Oct 15, 10:29 pm, Mark Harrison wrote: What's the magic to allow this? If the value is not specified I would like to use the default value of 1. import optparse p=optparse.OptionParser() p.add_option("--debug") (opts, args) = p.parse_args(['--debug=22']); print opts (

Re: optparse, allowing both --foo and foo=99?

2009-10-16 Thread Jean-Michel Pichavant
Jean-Michel Pichavant wrote: Carl Banks wrote: On Oct 15, 10:29 pm, Mark Harrison wrote: What's the magic to allow this? If the value is not specified I would like to use the default value of 1. import optparse p=optparse.OptionParser() p.add_option("--debug") (opts, args) = p.parse_args(

Re: struct curiosity

2009-10-16 Thread Richard Brodie
"pjcoup" wrote in message news:b1537079-6e3a-43e1-814b-7ccf185fb...@v15g2000prn.googlegroups.com... > I would have expected calcsize('BB') to be either 10 or 12 > (padding), but 11? Is there a simple explanation of what is going > on here? The purpose of the padding is to align the words

Re: How to schedule system calls with Python

2009-10-16 Thread Christian Heimes
MRAB wrote: > You could use multithreading: put the commands into a queue; start the > same number of worker threads as there are processors; each worker > thread repeatedly gets a command from the queue and then runs it using > os.system(); if a worker thread finds that the queue is empty when it

Iterators

2009-10-16 Thread Kelson Folkvard Braaten ZAWACK
Recently I was iterating through both a list and a file and I noticed a difference in behavior. When I create an iterator for a list by calling iter(list_name) and then call the iterators next method I get the first element in the list. When I then create another iterator over the same list and

Re: ANN: ActivePython 2.6.3.7 (and PyPM) is now available

2009-10-16 Thread denis
On Oct 7, 2:16 am, "Sridhar Ratnakumar" wrote: > ... > This release includes a new packaging tool by activestate called Python > Package Manager (PyPM).PyPM- currently in beta - is the package Sridhar, folks, the ActivePython FAQ says "While you can install most packages registered in PyPI usin

Re: Iterators

2009-10-16 Thread Chris Rebert
On Fri, Oct 16, 2009 at 2:24 AM, Kelson Folkvard Braaten ZAWACK wrote: > Recently I was iterating through both a list and a file and I noticed a > difference in behavior.  When I create an iterator for a list by calling > iter(list_name) and then call the iterators  next method I get the first > e

Re: how to write a unicode string to a file ?

2009-10-16 Thread Niklas Norrthon
On 16 Okt, 06:10, Donn wrote: > On Friday 16 October 2009 01:59:43 Stephen Hansen wrote: > > Just to say, thanks for that post. I am an old ascii dog and this notion of > encoding and decoding is taking such a lng time to penetrate my thick > skull. Little snippets like your post are valuable

Re: struct curiosity

2009-10-16 Thread Peter Otten
Richard Brodie wrote: > "pjcoup" wrote in message > news:b1537079-6e3a-43e1-814b-7ccf185fb...@v15g2000prn.googlegroups.com... > > >> I would have expected calcsize('BB') to be either 10 or 12 >> (padding), but 11? Is there a simple explanation of what is going >> on here? > > The purpose

Re: set using alternative hash function?

2009-10-16 Thread Dave Angel
Austin Bingham wrote: On Thu, Oct 15, 2009 at 7:49 PM, Ethan Furman wrote: Austin Bingham wrote: I'm feeling really dense about now... What am I missing? What you're missing is the entire discussion up to this point. I was looking for a way to use an alternative uniqueness criteria in

Re: how to write a unicode string to a file ?

2009-10-16 Thread Paul Boddie
On 16 Okt, 01:49, Benjamin Kaplan wrote: > > Unicode is an abstract concept, and as such can't actually be written > to a file. To write Unicode to a file, you have to specify an encoding > so Python has actual bytes to write. If Python doesn't know what > encoding it should use, it defaults to pl

Re: Iterators

2009-10-16 Thread Duncan Booth
Chris Rebert wrote: > Essentially, file iterators are dumb and don't keep track of where in > the file the next line starts, instead relying on their associated > file object to keep track of the current position in the file; the > iterator's state is little more than a reference to its associate

Re: ANN: ActivePython 2.6.3.7 (and PyPM) is now available

2009-10-16 Thread srid
On Oct 16, 3:30 pm, denis wrote: > On Oct 7, 2:16 am, "Sridhar Ratnakumar" > wrote: > > > ... > > This release includes a new packaging tool by activestate called Python > > Package Manager (PyPM).PyPM- currently in beta - is the package > > Sridhar, folks, >   the ActivePython FAQ says > "While

Re: windows side-by-side configuration woes on windows HPC

2009-10-16 Thread M.-A. Lemburg
Nick Touran wrote: > I've made enough progress to get my setup working! I attempted to apply the > patch and recompile the packages that complained but got in too deep while > compiling matplotlib on windows (I don't have admin privileges and can't > install the prereqs) so I dug deeper. > > I fou

Re: id( ) function question

2009-10-16 Thread Mel
Erik Max Francis wrote: > Mel wrote: >> My poster-child use of `is` is a MUDD game where >> >> `reference1_to_player is reference2_to_player` >> >> , if True, means that both refer to the same in-game player. Even that >> might not last. > > Well, that usage is fine; I can't see any circumstan

Re: ANN: ActivePython 2.6.3.7 (and PyPM) is now available

2009-10-16 Thread denis
On Oct 16, 2:23 pm, srid wrote: > > Does that mean that PyPM installs ONLY from the activestate repository > > and not from url or .tar.gz or dir/ ? > > This is correct. Although it may change in the future. Note that Sridhar, activestate folks, if you want people to switch to PyPM, make it UN

Re: struct curiosity

2009-10-16 Thread Mark Dickinson
On Oct 15, 7:07 pm, pjcoup wrote: > I was fooling around with python's struct lib, looking on how we'd > unpack some data.  I was a little confused by its behavior: > Python 2.5.2 (r252:60911, Jul 22 2009, 15:33:10) > [GCC 4.2.4 (Ubuntu 4.2.4-1ubuntu3)] on linux2 > Type "help", "copyright", "credi

Re: Object Relational Mappers are evil (a meditation)

2009-10-16 Thread mario ruggier
On Oct 5, 4:25 pm, Aaron Watters wrote: > Occasionally I fantasize about making a non-trivial change > to one of these programs, but I strongly resist going further > than that because the ORM meatgrinder makes it somewhere > between extremely unpleasant and impossible to make any > non-trivial c

Re: how to write a unicode string to a file ?

2009-10-16 Thread Donn
On Friday 16 October 2009 13:08:38 Niklas Norrthon wrote: > that made me think I understand > Lol, I know the feeling! :D I have read that page a few times, and I always emerge thinking 'now I've got it'. Then a week passes... \d -- http://mail.python.org/mailman/listinfo/python-list

Re: struct curiosity

2009-10-16 Thread Gabriel Genellina
En Thu, 15 Oct 2009 15:07:04 -0300, pjcoup escribió: import struct struct.calcsize('BB') 11 struct.calcsize('@BB') 11 struct.calcsize(' 10 struct.calcsize('>BB') 10 I would have expected calcsize('BB') to be either 10 or 12 (padding), but 11? There are no pad bytes foll

Re: struct curiosity

2009-10-16 Thread Gabriel Genellina
En Thu, 15 Oct 2009 15:07:04 -0300, pjcoup escribió: import struct struct.calcsize('BB') 11 struct.calcsize('@BB') 11 struct.calcsize(' 10 struct.calcsize('>BB') 10 I would have expected calcsize('BB') to be either 10 or 12 (padding), but 11? There are no pad bytes foll

Re: a splitting headache

2009-10-16 Thread John Posner
Mensenator said: c = '001110' c.split('0') ['', '', '1', '', '', '', '11', ''] Ok, the consecutive delimiters appear as empty strings for reasons unknown (except for the first one). Except when they start or end the string in which case the first one is included. Maybe there's a r

Re: How about adding slice notation to iterators/generators?

2009-10-16 Thread Stephen Hansen
On Fri, Oct 16, 2009 at 2:02 AM, Bearophile wrote: > Terry Reedy: > >2. iterator protocol is intentionally simple.< > > Slice syntax is already available for lists, tuples, strings, arrays, > numpy, etc, so adding it to iterators too doesn't look like adding > that large amount of information to t

restriction on sum: intentional bug?

2009-10-16 Thread Alan G Isaac
I expected this to be fixed in Python 3: sum(['ab','cd'],'') Traceback (most recent call last): File "", line 1, in TypeError: sum() can't sum strings [use ''.join(seq) instead] Of course it is not a good way to join strings, but it should work, should it not? Naturally, '' + 'ab' + 'cd'

Re: Iterators

2009-10-16 Thread Stephen Hansen
On Fri, Oct 16, 2009 at 5:22 AM, Duncan Booth wrote: > Chris Rebert wrote: > > > Essentially, file iterators are dumb and don't keep track of where in > > the file the next line starts, > [snip] > > Nothing 'dumb' or 'smart' about it: it is simply that a file object is > already an iterator. Tr

Re: restriction on sum: intentional bug?

2009-10-16 Thread Christian Heimes
Alan G Isaac schrieb: > I expected this to be fixed in Python 3: > sum(['ab','cd'],'') > Traceback (most recent call last): >File "", line 1, in > TypeError: sum() can't sum strings [use ''.join(seq) instead] > > Of course it is not a good way to join strings, > but it should work, shou

Re: restriction on sum: intentional bug?

2009-10-16 Thread Stephen Hansen
On Fri, Oct 16, 2009 at 8:39 AM, Alan G Isaac wrote: > I expected this to be fixed in Python 3: > > sum(['ab','cd'],'') >>> Traceback (most recent call last): > File "", line 1, in > TypeError: sum() can't sum strings [use ''.join(seq) instead] > > Of course it is not a good way to join s

Re: HTMLgen???

2009-10-16 Thread Walter Dörwald
On 16.10.09 05:44, alex23 wrote: > On Oct 15, 6:58 pm, [email protected] wrote: >> Does HTMLgen (Robin Friedrich's) still exsist?? And, if so, where can it >> be found? > > If you're after an easy to use html generator, I highly recommend > Richard Jones' html[1] lib. It's new, supported

Re: windows side-by-side configuration woes on windows HPC

2009-10-16 Thread Nick Touran
Yes, I'll add the report to the bug ticket. As for the msvcr71.dll, the particular module I'm using was apparently compiled with VS2005, but I'm currently unable to rebuild it with VS2008 because I don't have the MSSQL developer headers, etc. So, in an ideal world, I'd compile the module myself and

Re: restriction on sum: intentional bug?

2009-10-16 Thread Alan G Isaac
Alan G Isaac schrieb: I expected this to be fixed in Python 3: sum(['ab','cd'],'') Traceback (most recent call last): File "", line 1, in TypeError: sum() can't sum strings [use ''.join(seq) instead] Of course it is not a good way to join strings, but it should work, should it not? Natur

Re: Iterators

2009-10-16 Thread Aahz
In article , Duncan Booth wrote: >Chris Rebert wrote: >> >> Essentially, file iterators are dumb and don't keep track of where in >> the file the next line starts, instead relying on their associated >> file object to keep track of the current position in the file; the >> iterator's state is lit

Re: restriction on sum: intentional bug?

2009-10-16 Thread Peter Otten
Alan G Isaac wrote: > I expected this to be fixed in Python 3: > sum(['ab','cd'],'') > Traceback (most recent call last): >File "", line 1, in > TypeError: sum() can't sum strings [use ''.join(seq) instead] > > Of course it is not a good way to join strings, > but it should work, shoul

Re: Iterators

2009-10-16 Thread Harald Kraemer
Stephen Hansen wrote: On Fri, Oct 16, 2009 at 5:22 AM, Duncan Booth wrote: Chris Rebert wrote: > Essentially, file iterators are dumb and don't keep track of where in > the file the next line starts, [snip] Nothing 'dumb' or 'smart' about it: it is simply that a file object is alread

Re: restriction on sum: intentional bug?

2009-10-16 Thread MRAB
Stephen Hansen wrote: On Fri, Oct 16, 2009 at 8:39 AM, Alan G Isaac > wrote: I expected this to be fixed in Python 3: sum(['ab','cd'],'') Traceback (most recent call last): File "", line 1, in TypeError: sum() can't sum strings

re.sub question (regular expressions)

2009-10-16 Thread Chris Seberino
What does this line do?... input_ = re.sub("([a-zA-Z]+)", '"\\1"', input_) Does it remove parentheses from words? e.g. (foo) -> foo ??? I'd like to replace [a-zA-Z] with \w but \w makes it blow up. In other words, re.sub("(\w+)", '"\\1"', input_) blows up. Why? cs -- http://mail.python.org/m

Re: struct curiosity

2009-10-16 Thread pjcoup
Yes, this is basically what I expected as well. I would have expected some size that you can coax gcc to give, either 12 (as here), or 10 (with directives). Thanks to everyone for the responses! Pete On Oct 16, 4:30 am, Peter Otten <[email protected]> wrote: > > I would have expected "native size

Re: Iterators

2009-10-16 Thread Stephen Hansen
On Fri, Oct 16, 2009 at 9:24 AM, Harald Kraemer wrote: > Stephen Hansen wrote: > Nothing 'dumb' or 'smart' about it: it is simply that a file object is > >> already an iterator. Trying to create an iterator from an existing >>> iterator >>> in Python never duplicates the iterator. >>> >>> >>> f

Re: a splitting headache

2009-10-16 Thread Mensanator
On Oct 16, 10:30�am, John Posner wrote: > Mensenator said: > > c = '001110' > c.split('0') > > > ['', '', '1', '', '', '', '11', ''] > > > Ok, the consecutive delimiters appear as empty strings for > > reasons unknown (except for the first one). Except when they > > start or end the

Re: re.sub question (regular expressions)

2009-10-16 Thread Jean-Michel Pichavant
Chris Seberino wrote: What does this line do?... input_ = re.sub("([a-zA-Z]+)", '"\\1"', input_) Does it remove parentheses from words? e.g. (foo) -> foo ??? I'd like to replace [a-zA-Z] with \w but \w makes it blow up. In other words, re.sub("(\w+)", '"\\1"', input_) blows up. Why? cs

Re: re.sub question (regular expressions)

2009-10-16 Thread MRAB
Chris Seberino wrote: What does this line do?... input_ = re.sub("([a-zA-Z]+)", '"\\1"', input_) Why don't you try it? Does it remove parentheses from words? e.g. (foo) -> foo ??? No, it puts quotes around them. I'd like to replace [a-zA-Z] with \w but \w makes it blow up. In other word

SQL user function returning list for IN clause

2009-10-16 Thread Felix
I am using the Python SQLite3 interface, but the question is probably general to python and SQL. I want to run a query like select * from table a, table b where a.foo IN foobar(b.bar) where foobar is a user function (registered by create_function in pysqlite3) returning a list of integers. Howev

Re: Yet Another Pic Problem

2009-10-16 Thread Victor Subervi
Well, I've spent the last 2 days chasing my tail just to discover that there was some screwy python deal going on. The following code works: sql = "update productsX set Name='%s', Title='%s', Description='%s', Price='%s', Bedrooms='%s', Bathrooms='%s', Conditions='%s', Acreage='%s', Construc

Re: restriction on sum: intentional bug?

2009-10-16 Thread Tim Chase
Stephen Hansen wrote: Why doesn't duck typing apply to `sum`? Because it would be so hideously slow and inefficient that it'd be way too easy a way for people to program something they think should work fine but really doesn't... alternatively, the function would have to do two /completely/ dif

Re: restriction on sum: intentional bug?

2009-10-16 Thread Benjamin Peterson
MRAB mrabarnett.plus.com> writes: > It checks to see whether you're trying to sum strings, so it's already > treating them as a special case. Why can't it just use str.join > internally instead in that case instead of raising an exception? Because that violates explicit is better than implicit.

Re: restriction on sum: intentional bug?

2009-10-16 Thread Benjamin Peterson
Alan G Isaac gmail.com> writes: > So of course join is better, as originally noted, > but that does not constitute a reason to intentionally > violate duck typing. As Stephen pointed out, duck typing is not an absolute. -- http://mail.python.org/mailman/listinfo/python-list

Re: SQL user function returning list for IN clause

2009-10-16 Thread Peter Otten
Felix wrote: > I am using the Python SQLite3 interface, but the question is probably > general to python and SQL. > > I want to run a query like > > select * from table a, table b where a.foo IN foobar(b.bar) > > where foobar is a user function (registered by create_function in > pysqlite3) ret

Re: SQL user function returning list for IN clause

2009-10-16 Thread Felix
> > Rewriting the query to say > > select * from table a, table b where foobar_predicate(a.foo, b.bar) > > would work (foobar_predicate checks if a.foo is in foobar(b.bar). But > > it does not allow to use an index on a.foo > Define a function foobar_contains() as follows: > > def foobar_contains(

Re: The rap against "while True:" loops

2009-10-16 Thread Tim Rowe
2009/10/15 Steven D'Aprano : >> And with enough static analysis to guarantee that the break will be >> reached? I think it would be a bit much to expect Python to solve the >> halting problem! Not to what I thought was being proposed -- it seemed to make the break mandatory, not merely the only c

Re: set using alternative hash function?

2009-10-16 Thread Ethan Furman
Austin Bingham wrote: On Thu, Oct 15, 2009 at 7:49 PM, Ethan Furman wrote: Austin Bingham wrote: I'm feeling really dense about now... What am I missing? What you're missing is the entire discussion up to this point. I was looking for a way to use an alternative uniqueness criteria in a set

Re: SQL user function returning list for IN clause

2009-10-16 Thread Peter Otten
Felix wrote: >> Define a function foobar_contains() as follows: >> >> def foobar_contains(foo, bar): >> return foo in foobar(bar) >> >> and change the query to >> >> select * from table a, table b where foobar_contains(a.foo, b.bar) > > I thought about that (see above), but it would not use an in

Re: The rap against "while True:" loops

2009-10-16 Thread Tim Rowe
2009/10/15 Steven D'Aprano : > Setting up a try...except block is cheap in Python. According to my > tests, the overhead is little more than that of a single pass statement. > > But actually raising and catching the exception is not cheap. If you use > a lot of exceptions for flow control, perform

Re: restriction on sum: intentional bug?

2009-10-16 Thread Stephen Hansen
On Fri, Oct 16, 2009 at 9:59 AM, Tim Chase wrote: > Stephen Hansen wrote: > >> Why doesn't duck typing apply to `sum`? >>> >> >> Because it would be so hideously slow and inefficient that it'd be way too >> easy a way for people to program something they think should work fine but >> really doesn'

Re: restriction on sum: intentional bug?

2009-10-16 Thread Jon Clements
On Oct 16, 5:59 pm, Tim Chase wrote: > Stephen Hansen wrote: > >> Why doesn't duck typing apply to `sum`? > > > Because it would be so hideously slow and inefficient that it'd be way too > > easy a way for people to program something they think should work fine but > > really doesn't... alternativ

Re: set using alternative hash function?

2009-10-16 Thread Anthony Tolle
On Oct 16, 12:24 pm, Ethan Furman wrote: > [snip] > As for what you want:  No, it's not currently possible.  If it's so big > a deal that the various methods presented don't meet with your approval, > break out the C and write your own.  Then you could give that back to > the community instead of

Re: restriction on sum: intentional bug?

2009-10-16 Thread Ethan Furman
Jon Clements wrote: On Oct 16, 5:59 pm, Tim Chase wrote: Stephen Hansen wrote: Why doesn't duck typing apply to `sum`? Because it would be so hideously slow and inefficient that it'd be way too easy a way for people to program something they think should work fine but really doesn't... al

cx_freeze install_exe error

2009-10-16 Thread james27
hello im currently installed cx_freeze on linux. and want to make win32 exe file on linux by use cx_freeze. and then will distribute on widows platform. one of my problem is ,i can build with no problem. but whenever i run,it something weird error message was show. follow is my log file. anybody c

putchar(8)

2009-10-16 Thread gervaz
Hi all, is there a pythonic way to have the -- http://mail.python.org/mailman/listinfo/python-list

putchar(8)

2009-10-16 Thread gervaz
Hi all, is there in python the equivalent of the C function int putchar (int c)? I need to print putchar(8). Thanks, Mattia -- http://mail.python.org/mailman/listinfo/python-list

Re: The rap against "while True:" loops

2009-10-16 Thread Aahz
In article , Tim Rowe wrote: > >The understood meaning of throwing an exception is to say "something >happened that shouldn't have". If one uses it when something has >happened that *should* have, because it happens to have the right >behaviour (even if the overhead doesn't matter), then one is >

Re: putchar(8)

2009-10-16 Thread Jason Tackaberry
On Fri, 2009-10-16 at 12:01 -0700, gervaz wrote: > Hi all, is there in python the equivalent of the C function int putchar > (int c)? I need to print putchar(8). >>> print '\x08' or: >>> print chr(8) -- http://mail.python.org/mailman/listinfo/python-list

More & More Fun w/ Pics & MySQL

2009-10-16 Thread Victor Subervi
Hi; Okay, here's the code: #! /usr/bin/python import cgitb; cgitb.enable() import MySQLdb import cgi import sys,os sys.path.append(os.getcwd()) from login import login def pic(): user, passwd, db, host = login() form = cgi.FieldStorage() db = MySQLdb.connect(host, user, passwd, db) cursor=

Rename file if it exists.

2009-10-16 Thread Stephen Reese
The script below uploads files to a web server. Currently it overwrites a file if it already exists. I'm instead trying to rename the old file with an appended date/timestamp before the new file is uploaded. I *think* I have the idea down but it's not be implemented in the script correctly. Any hin

Re: An assessment of Tkinter and IDLE

2009-10-16 Thread Aahz
In article <[email protected]>, Ben Finney wrote: >TerryP writes: >> >> One thing you should also learn about me, is I do not deal in >> absolutes. > >What, *never*? Well, hardly ever. -- Aahz ([email protected]) <*> http://www.pythoncraft.com/ "To me vi is

Re: restriction on sum: intentional bug?

2009-10-16 Thread Tim Chase
Stephen Hansen wrote: There really is just a right way verses a wrong way to join strings together; using + is always the wrong way. Sometimes that level of 'wrong' is so tiny that no one cares, like if you are using it to join together two small strings. But when joining together a sequence of s

Re: The rap against "while True:" loops

2009-10-16 Thread Bearophile
Paul Rubin: >  http://scholar.google.com/scholar?cluster=17368311454828547380 > > Keep in mind that the article is 35 years old though, and is purely > imperative.  Lots of stuff done with cockamamie looping constructs is > more cleanly done with Python generators, itertools, higher-order > functi

Spawning Cmd Window via Subprocess

2009-10-16 Thread D
Hello, I would like to be able to spawn a new CMD window (specifing size, color and placement of the window), and write to it separately. Specifically, I have a backup program that displays each file backed up in the main window, and I would like to spawn and continually update a second CMD windo

Re: restriction on sum: intentional bug?

2009-10-16 Thread Alan G Isaac
On 10/16/2009 3:40 PM, Tim Chase wrote: What's always wrong is giving me an *error* when the semantics are perfectly valid. Exactly. Which is why I expected this to be fixed in Python 3. Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list

Re: id( ) function question

2009-10-16 Thread Erik Max Francis
Mel wrote: True, I don't see that exact expression going wrong. The actual poster, trimmed for that post, used to go: def broadcast (self, message): for p in players: if p is not self: p.send (message) This use of `is` is fine. For my fears to come tr

Re: Rename file if it exists.

2009-10-16 Thread Diez B. Roggisch
Stephen Reese schrieb: The script below uploads files to a web server. Currently it overwrites a file if it already exists. I'm instead trying to rename the old file with an appended date/timestamp before the new file is uploaded. I *think* I have the idea down but it's not be implemented in the

Re: how to write a unicode string to a file ?

2009-10-16 Thread Stephen Fairchild
Stef Mientki wrote: > hello, > > By writing the following unicode string (I hope it can be send on this > mailing list) > > Bücken > > to a file > > fh.write ( line ) > > I get the following error: > > UnicodeEncodeError: 'ascii' codec can't encode character u'\xfc' in > position

Re: More & More Fun w/ Pics & MySQL

2009-10-16 Thread Carsten Haese
Victor Subervi wrote: > [snip...] > > print 'Content-type: image/jpeg' > print 'Content-Encoding: base64' > print > print pic().encode('base64') > print '' > > [snip...] Why are you printing "" at the end of a page that is supposed to be a base64-encoded JPEG file? -- Carsten Haese http://informi

Re: restriction on sum: intentional bug?

2009-10-16 Thread Christian Heimes
Alan G Isaac schrieb: > On 10/16/2009 3:40 PM, Tim Chase wrote: >> What's always wrong is giving me an *error* when the semantics are >> perfectly valid. > > > Exactly. > Which is why I expected this to be fixed in Python 3. It's not going to happen. Christian -- http://mail.python.org/mailma

Re: Tracking down DLL load errors in Windows ?

2009-10-16 Thread Fred Pacquier
Christian Heimes said : > Fred P wrote: >> Is there any tool and/or methodology I could use to at least pinpoint >> the exact DLL that libpyexiv2 is failing to load, and ideally also >> the reason why ?... > > The depencency walker http://www.dependencywalker.com/ works fine for > me. I'd neve

print()

2009-10-16 Thread mattia
Is there a way to print to an unbuffered output (like stdout)? I've seen that something like sys.stdout.write("hello") works but it also prints the number of characters! -- http://mail.python.org/mailman/listinfo/python-list

Re: Rename file if it exists.

2009-10-16 Thread Stephen Reese
> This isn't working because the else: is dangling. And I think your logic is > flawed (I might be wrong of course) because you rename the *existing* file > instead of giving the new one a new data. > > Thus e.g. a link to the file (if it's a webserver) will suddenly deliver a > different file. I d

Re: print()

2009-10-16 Thread Chris Rebert
On Fri, Oct 16, 2009 at 2:04 PM, mattia wrote: > Is there a way to print to an unbuffered output (like stdout)? Just follow your prints or stdout.write()s with calls to stdout.flush() to flush the buffer. You could alternatively use the -u option to the python interpreter to make the standard st

Re: The rap against "while True:" loops

2009-10-16 Thread Russ P.
On Oct 10, 1:15 pm, kj wrote: > I'm coaching a group of biologists on basic Python scripting.  One > of my charges mentioned that he had come across the advice never > to use loops beginning with "while True".  Of course, that's one > way to start an infinite loop, but this seems hardly a sufficie

Re: Spawning Cmd Window via Subprocess

2009-10-16 Thread TerryP
On Oct 16, 8:15 pm, D wrote: > Hello, > > I would like to be able to spawn a new CMD window (specifing size, > color and placement of the window),  and write to it separately. > Specifically, I have a backup program that displays each file backed > up in the main window, and I would like to spawn

Re: How about adding slice notation to iterators/generators?

2009-10-16 Thread Eloff
On Oct 16, 3:54 am, Terry Reedy wrote: > There is already an obvious standard way to do this. > > it = > next(it) #toss first item > for item in it: >   > That fails if there is no first item. You're taking one corner case and saying there's an easy way to do it, which is more or less true,

Re: print()

2009-10-16 Thread TerryP
On Oct 16, 9:04 pm, mattia wrote: > Is there a way to print to an unbuffered output (like stdout)? I've seen > that something like sys.stdout.write("hello") works but it also prints > the number of characters! http://docs.python.org/3.1/library/functions.html#print a suitable object passed that

Re: More & More Fun w/ Pics & MySQL

2009-10-16 Thread Victor Subervi
I was trying all sorts of crap. I tried it without, too. Still didn't work :( V On Fri, Oct 16, 2009 at 4:42 PM, Carsten Haese wrote: > Victor Subervi wrote: > > [snip...] > > > > print 'Content-type: image/jpeg' > > print 'Content-Encoding: base64' > > print > > print pic().encode('base64') > >

Re: restriction on sum: intentional bug?

2009-10-16 Thread Alan G Isaac
On 10/16/2009 5:03 PM, Christian Heimes wrote: It's not going to happen. That's a prediction, not a justification. As Tim explained in detail, and as Peter explained with brevity, whether it will happen or not, it should happen. This conversation has confirmed that current behavior is a wart:

Re: restriction on sum: intentional bug?

2009-10-16 Thread ryles
On Oct 16, 11:39 am, Alan G Isaac wrote: > I expected this to be fixed in Python 3: > > >>> sum(['ab','cd'],'') > > Traceback (most recent call last): >    File "", line 1, in > TypeError: sum() can't sum strings [use ''.join(seq) instead] Then you probably haven't read through these discussions

Re: restriction on sum: intentional bug?

2009-10-16 Thread Carl Banks
On Oct 16, 9:59 am, Tim Chase wrote: > So I agree with Alan & Peter that this creates an unfortunate > language wart among (as Peter aptly puts it) "consenting adults". Perhaps, BUT... If, say, you were to accept that Python is going to guard against a small number of especially bad cases, this

One class one file?

2009-10-16 Thread Someone Something
I'm trying write a program that's going to be more than 100 lines or so but I need it all in one class. Is there a painless way to have one class in two files? -- http://mail.python.org/mailman/listinfo/python-list

ftplib connection fails with multiple nics

2009-10-16 Thread Sean DiZazzo
Hi all, I'm trying to connect to an ftp site from a windows machine with two nics going to two different networks, but I keep getting the below exception: Traceback (most recent call last): File "ftp.pyo", line 70, in connect File "ftp.pyo", line 17, in __init__ File "ftplib.pyo", line 131,

Re: restriction on sum: intentional bug?

2009-10-16 Thread Carl Banks
On Oct 16, 12:40 pm, Tim Chase wrote: > Then I'm fine with sum() being smart enough to recognize this > horrid case and do the "right" thing by returning ''.join() > instead. You don't want Python to get into this business. Trust me. Just don't go there. If you want sum to call ''.join transpa

Re: More & More Fun w/ Pics & MySQL

2009-10-16 Thread Carsten Haese
Victor Subervi wrote: > I was trying all sorts of crap. I tried it without, too. Still didn't > work :( Please help us help you. "Still didn't work" tells us nothing. See http://catb.org/~esr/faqs/smart-questions.html for hints on how you can ask a questions in a way that makes them more likely to

Re: restriction on sum: intentional bug?

2009-10-16 Thread Carl Banks
On Oct 16, 8:39 am, Alan G Isaac wrote: > I expected this to be fixed in Python 3: A word of advice: the Python maintainers don't regard anything that behaves as it is documented to as a "bug", no matter how wrong it seems. This is taken a lot more seriously than you would think. In future com

Re: One class one file?

2009-10-16 Thread MRAB
Someone Something wrote: I'm trying write a program that's going to be more than 100 lines or so but I need it all in one class. Is there a painless way to have one class in two files? Python won't complain if you have more than 100 lines in one file, or even in one class in one file. There a

Re: how to write a unicode string to a file ?

2009-10-16 Thread Stef Mientki
Stephen Hansen wrote: On Thu, Oct 15, 2009 at 4:43 PM, Stef Mientki > wrote: hello, By writing the following unicode string (I hope it can be send on this mailing list) Bücken to a file fh.write ( line ) I get the following err

Re: restriction on sum: intentional bug?

2009-10-16 Thread Terry Reedy
Alan G Isaac wrote: As Tim explained in detail, and as Peter explained with brevity, whether it will happen or not, it should happen. This conversation has confirmed that current behavior is a wart: an error is raised despite correct semantics. Ugly! The fact that two or three people who agre

Re: More & More Fun w/ Pics & MySQL

2009-10-16 Thread Victor Subervi
I'm sorry. These scripts worked fine before and should have been plug-and-play. I have wasted 2 frustrating weeks trying to figure out why they don't work only to discover things that make no sense at all that do the trick. I thought programming was straight-forward and "logical"...boy, am I disapp

  1   2   >