string questions

2007-09-15 Thread Shawn Minisall
Hi everyone, I'm a beginning programming student in Python and have a few questions regarding strings. If s1 = spam If s2 = ni! 1. Would string.ljust(string.upper(s2),4) * 3 start it at the left margin and move it 12 spaces to the right because of the 4 *3? If so, why is it in the

Re: how to join array of integers?

2007-09-15 Thread Steven D'Aprano
On Sat, 15 Sep 2007 15:56:40 +0200, Arnau Sanchez wrote: js escribió: On 9/15/07, Summercool [EMAIL PROTECTED] wrote: in Python... is the method to use ,.join() ? but then it must take a list of strings... not integers... any fast method? print ''.join([str(i) for i in [1,2,3]])

Re: string questions

2007-09-15 Thread Marc 'BlackJack' Rintsch
On Sat, 15 Sep 2007 19:52:47 -0400, Shawn Minisall wrote: Hi everyone, I'm a beginning programming student in Python and have a few questions regarding strings. If s1 = spam If s2 = ni! 1. Would string.ljust(string.upper(s2),4) * 3 start it at the left margin and move it 12 spaces

Re: Needless copying in iterations?

2007-09-15 Thread Marc 'BlackJack' Rintsch
On Sat, 15 Sep 2007 14:58:15 -0700, James Stroud wrote: I was staring at a segment of code that looked like this today: for something in stuff[x:y]: whatever(something) and was wondering if the compiler really made a copy of the slice from stuff as the code seems to suggest,

Re: Can You Program?

2007-09-15 Thread Steven D'Aprano
On Sat, 15 Sep 2007 14:15:20 +, brus stoc at gmail dot com wrote: [snip spam] Hey, thanks for spamming our group. You know, there are probably millions of people who never received the original spam because their Usenet provider does a good job of filtering out crud, and they wouldn't

RE: Python statements not forcing whitespace is messy?

2007-09-15 Thread Ryan Ginstrom
On Behalf Of J. Cliff Dyer On the other hand, this is just as bad: [ ( y ) for ( x , y ) in [ ( foo , 2 ) , ( bar , 4 ) ] if foo in ( x ) ] I think that's allowed in order to recruit C/C++ programmers. Regards, Ryan Ginstrom -- http://mail.python.org/mailman/listinfo/python-list

Re: string questions

2007-09-15 Thread J. Cliff Dyer
Marc 'BlackJack' Rintsch wrote: But please don't use the functions in `string` that are also available as methods on strings. Those functions are deprecated. Meaning (for newbie clarification): instead of string.upper(s2), just do s2.upper(). For more detail, see the docs. --

Re: how to join array of integers?

2007-09-15 Thread Steven D'Aprano
On Sat, 15 Sep 2007 16:07:07 +, Grant Edwards wrote: It's nice people have invented so many ways to spell the builting map ;) ,.join(map(str,[1,2,3])) '1,2,3' The oldest solution, and if not the fastest, at least neck-and-neck with the list comprehension. timeit.Timer(',

Re: Needless copying in iterations?

2007-09-15 Thread Steven D'Aprano
On Sun, 16 Sep 2007 00:05:58 +, Marc 'BlackJack' Rintsch wrote: On Sat, 15 Sep 2007 14:58:15 -0700, James Stroud wrote: I was staring at a segment of code that looked like this today: for something in stuff[x:y]: whatever(something) and was wondering if the compiler

Re: Latest software here!!!!!

2007-09-15 Thread pixellee
On 9 16 , 2 51 , [EMAIL PROTECTED] wrote: http://freesoftwareupgrades.blogspot.com/ what -- http://mail.python.org/mailman/listinfo/python-list

Re: Python statements not forcing whitespace is messy?

2007-09-15 Thread Steven D'Aprano
On Sun, 16 Sep 2007 09:14:57 +0900, Ryan Ginstrom wrote: On Behalf Of J. Cliff Dyer On the other hand, this is just as bad: [ ( y ) for ( x , y ) in [ ( foo , 2 ) , ( bar , 4 ) ] if foo in ( x ) ] I think that's allowed in order to recruit C/C++ programmers. Heh :) In all seriousness,

Re: How to avoid overflow errors

2007-09-15 Thread Steven D'Aprano
On Sat, 15 Sep 2007 02:45:10 -0700, James Stroud wrote: Steven D'Aprano wrote: On Fri, 14 Sep 2007 18:19:45 -0700, James Stroud wrote: How do I subclass int and/or long so that my class also auto-converts only when needed? Use __new__. The disadvantage of that is that your example code

Re: Python statements not forcing whitespace is messy?

2007-09-15 Thread Steve Holden
John Machin wrote: On 16/09/2007 8:11 AM, James Stroud wrote: Steve Holden wrote: I don't know why you have a bug up your ass about it, as the Americans say. I think most Americans say wild hare up your ass. The essence of Steve's point appears to be that the OP has ridden into town to

thanks everyone for your replies!

2007-09-15 Thread Shawn Minisall
:) -- http://mail.python.org/mailman/listinfo/python-list

Python Blend or Maya

2007-09-15 Thread pixellee
Anybody introdcing something on the subject? -- http://mail.python.org/mailman/listinfo/python-list

Re: List append

2007-09-15 Thread Rob E
On Sat, 15 Sep 2007 03:25:27 +, mouseit wrote: I'm trying to add an element to a list which is a property of an object, stored in an array. When I append to one element, all of the lists are appended! Example Code: class Test: array = [] myTests = [Test() , Test() , Test()]

Re: how to join array of integers?

2007-09-15 Thread Robert Kern
Grant Edwards wrote: On 2007-09-15, Robert Kern [EMAIL PROTECTED] wrote: Grant Edwards wrote: On 2007-09-15, Erik Jones [EMAIL PROTECTED] wrote: print ''.join([str(i) for i in [1,2,3]]) It's better to use generator comprehension instead of LC: ,.join(str(i) for i in [1, 2, 3]) Why is

Re: List append

2007-09-15 Thread Steve Holden
Rob E wrote: On Sat, 15 Sep 2007 03:25:27 +, mouseit wrote: I'm trying to add an element to a list which is a property of an object, stored in an array. When I append to one element, all of the lists are appended! Example Code: class Test: array = [] myTests = [Test() , Test()

Re: Needless copying in iterations?

2007-09-15 Thread Ben Finney
Steven D'Aprano [EMAIL PROTECTED] writes: In *general* the compiler can't tell, but in specific cases it could. A (hypothetical) optimizing compiler would tell the difference between: for item in alist[1:5]: print item # no possible side-effects The 'print' statement converts the

Re: subclass of integers

2007-09-15 Thread Roberto Bonvallet
On Sep 14, 10:30 am, Mark Morss [EMAIL PROTECTED] wrote: I would like to construct a class that includes both the integers and None. I desire that if x and y are elements of this class, and both are integers, then arithmetic operations between them, such as x+y, return the same result as

Un(der)documented bits of cgi.py

2007-09-15 Thread Bob Kline
I'm trying to detect and intelligently deal with problems created when a user of a Python CGI page uploads a file and then gets impatient and clicks on some other button or the browser's cancel button (or even closes the page). If the file is large enough, and the user is impatient enough,

[issue1164] tp_print slots don't release the GIL

2007-09-15 Thread Armin Rigo
Armin Rigo added the comment: We need to start from PyFile_WriteString() and PyFile_WriteObject() and PyObject_Print(), which are what the PRINT_* opcodes use, and make sure there is no single fprintf() or fputs() that occurs with the GIL held. It is not enough to fix a few places that could

[issue1165] Should itertools.count work for arbitrary integers?

2007-09-15 Thread Eduardo Padoan
New submission from Eduardo Padoan: Currently, itertools.count.__next__ checks wether the current value is PY_SSIZE_T_MAX and raises OverflowError if so. Shouldn't the value be stored as long, at least in Py3k? Not that I have any use case for it, so it is minor. -- components: Library

[issue1165] Should itertools.count work for arbitrary integers?

2007-09-15 Thread Eric S. R-eyyyy-mond
Eric S. R-e-mond added the comment: Hi guys. -- assignee: - esr nosy: +esr __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1165 __ ___ Python-bugs-list mailing list

[issue1165] Should itertools.count work for arbitrary integers?

2007-09-15 Thread Eric S. R-eyyyy-mond
Changes by Eric S. R-e-mond: -- severity: minor - critical __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1165 __ ___ Python-bugs-list mailing list Unsubscribe:

[issue1165] Should itertools.count work for arbitrary integers?

2007-09-15 Thread Eric S. R-eyyyy-mond
Changes by Eric S. R-e-mond: -- keywords: +r-eyyy-mond __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1165 __ ___ Python-bugs-list mailing list Unsubscribe:

[issue1165] Should itertools.count work for arbitrary integers?

2007-09-15 Thread Eric S. R-eyyyy-mond
Changes by Eric S. R-e-mond: -- versions: +3rd party, Python 2.1.1, Python 2.1.2, Python 2.2, Python 2.2.1, Python 2.2.2, Python 2.2.3, Python 2.3, Python 2.4, Python 2.5, Python 2.6 __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1165

[issue1165] Should itertools.count work for arbitrary integers?

2007-09-15 Thread Eric S. R-eyyyy-mond
Changes by Eric S. R-e-mond: -- type: behavior - compile error __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1165 __ ___ Python-bugs-list mailing list

[issue1165] Should itertools.count work for arbitrary integers?

2007-09-15 Thread Eric S. R-eyyyy-mond
Changes by Eric S. R-e-mond: -- dependencies: +--install-base not honored on win32 type: compile error - behavior versions: -3rd party, Python 2.1.1, Python 2.1.2, Python 2.2, Python 2.2.1, Python 2.2.2, Python 2.2.3, Python 2.3, Python 2.4, Python 2.5, Python 2.6

[issue1165] Should itertools.count work for arbitrary integers?

2007-09-15 Thread Eric S. R-eyyyy-mond
Changes by Eric S. R-e-mond: -- dependencies: + Elemental Security contribution - pgen2 package __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1165 __ ___

[issue1166] NameError when calling malloc

2007-09-15 Thread Eric S. R-eyyyy-mond
New submission from Eric S. R-e-mond: I tried this code, and it blew up in my face. foo = malloc(4096) NameError: name 'malloc' is not defined Why? -- components: Library (Lib) keywords: r-eyyy-mond messages: 55929 nosy: esr priority: high severity: normal status: open title:

[issue1164] tp_print slots don't release the GIL

2007-09-15 Thread Guido van Rossum
Guido van Rossum added the comment: Plese do submit a patch. FWIW I think it's solved in Py3k, the tp_print slot is dead (as is any use of the C stdio library). -- nosy: +gvanrossum __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1164

[issue1164] tp_print slots don't release the GIL

2007-09-15 Thread Brett Cannon
Changes by Brett Cannon: -- versions: +Python 2.6 __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1164 __ ___ Python-bugs-list mailing list Unsubscribe:

[issue1164] tp_print slots don't release the GIL

2007-09-15 Thread Brett Cannon
Brett Cannon added the comment: Since I already did this once I just did a more thorough job; patch is attached. PyObject_WriteString() just calls PyFile_WriteObject() which ends up using PyObject_Print(), so it is was simple to handle those cases. I then released the GIL for strings, lists,

[issue1164] tp_print slots don't release the GIL

2007-09-15 Thread Brett Cannon
Changes by Brett Cannon: -- keywords: +patch __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1164 __ ___ Python-bugs-list mailing list Unsubscribe:

[issue1134] Parsing a simple script eats all of your memory

2007-09-15 Thread Alexey Suda-Chen
Alexey Suda-Chen added the comment: --- tokenizer.c (revision 58161) +++ tokenizer.c (working copy) @@ -402,6 +402,8 @@ if (allocated) { Py_DECREF(bufobj); } + Py_XDECREF(tok-decoding_buffer); + tok-decoding_buffer = 0; return s; -- nosy:

[issue1165] Should itertools.count work for arbitrary integers?

2007-09-15 Thread Martin v. Löwis
Changes by Martin v. Löwis: -- assignee: esr - __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1165 __ ___ Python-bugs-list mailing list Unsubscribe:

[issue1165] Should itertools.count work for arbitrary integers?

2007-09-15 Thread Martin v. Löwis
Changes by Martin v. Löwis: -- keywords: +patch -r-eyyy-mond __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1165 __ ___ Python-bugs-list mailing list Unsubscribe:

[issue1165] Should itertools.count work for arbitrary integers?

2007-09-15 Thread Martin v. Löwis
Changes by Martin v. Löwis: -- dependencies: - Elemental Security contribution - pgen2 package, --install-base not honored on win32 __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1165 __

[issue1165] Should itertools.count work for arbitrary integers?

2007-09-15 Thread Martin v. Löwis
Changes by Martin v. Löwis: -- keywords: +py3k -patch __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1165 __ ___ Python-bugs-list mailing list Unsubscribe:

[issue1166] NameError when calling malloc

2007-09-15 Thread Martin v. Löwis
Martin v. Löwis added the comment: I doubt you are esr, although I'm uncertain how you hijacked his account. Please stop spamming this tracker. -- nosy: +loewis resolution: - invalid status: open - closed __ Tracker [EMAIL PROTECTED]

[issue1134] Parsing a simple script eats all of your memory

2007-09-15 Thread Brett Cannon
Brett Cannon added the comment: Note the patch is inlined in a message. -- keywords: +patch, py3k nosy: +brett.cannon __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1134 __

[issue1164] tp_print slots don't release the GIL

2007-09-15 Thread Guido van Rossum
Guido van Rossum added the comment: Looks Good, except I think it's a bad idea to release/acquire the GIL for each character when writing the repr() of a string. Given that the string is immutable and its refcount kept alive by the caller I don't see a reason why you can't just reference the

[issue1165] Should itertools.count work for arbitrary integers?

2007-09-15 Thread Paul F. Dubois
Changes by Paul F. Dubois: __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1165 __ ___ Python-bugs-list mailing list Unsubscribe:

[issue1165] Should itertools.count work for arbitrary integers?

2007-09-15 Thread Paul F. Dubois
Changes by Paul F. Dubois: -- nosy: -esr __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1165 __ ___ Python-bugs-list mailing list Unsubscribe:

[issue1164] tp_print slots don't release the GIL

2007-09-15 Thread Brett Cannon
Brett Cannon added the comment: Good point. I changed it on my machine and it cut that whole section down to a single release/acquire. I will go ahead and do this for the other types and then upload another patch to be reviewed when it's ready. __ Tracker

[issue1164] tp_print slots don't release the GIL

2007-09-15 Thread Brett Cannon
Brett Cannon added the comment: OK, every PyTypeObject in Objects and Modules has its tp_print release the GIL. Once someone OKs the patch I will apply it. __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1164 __

[issue1727780] 64/32-bit issue when unpickling random.Random

2007-09-15 Thread sligocki
Changes by sligocki: -- versions: +Python 2.5 -Python 2.4 _ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1727780 _ ___ Python-bugs-list mailing list

[issue1727780] 64/32-bit issue when unpickling random.Random

2007-09-15 Thread sligocki
sligocki added the comment: I've had this same problem with 2.5.1 Pickling random.getstate() on 64bit and then loading it back with random.setstate() on 32bit does not work (crashes because of trying cast 64bit ints to 32bit). The other way around is even worse. It loads but is in a faulty

[issue1167] gdbm/ndbm 1.8.1+ needs libgdbm_compat.so

2007-09-15 Thread Ian Kelly
New submission from Ian Kelly: The ndbm functions in gdbm 1.8.1+ require the gdbm_compat library in addition to gdbm. -- components: Build, Extension Modules files: gdbm_ndbm.diff messages: 55939 nosy: ikelly severity: normal status: open title: gdbm/ndbm 1.8.1+ needs libgdbm_compat.so

<    1   2