Re: Mathematica 7 compares to other languages

2008-12-14 Thread the . brown . dragon . blog
On Dec 12, 12:12 am, Xah Lee wrote: > On Dec 11, 6:50 am, the.brown.dragon.b...@gmail.com wrote: > ;; Chicken Scheme. By the.brown.dragon...@gmail.com > (require 'srfi-1) > (define (normalize vec) >   (map (cute / <> (sqrt (reduce + 0 (map (cute expt <> 2) vec > vec)) > > Is it possible to mak

Re: Python is slow

2008-12-14 Thread Andreas Kostyrka
Am Sun, 14 Dec 2008 20:38:58 -0800 (PST) schrieb cm_gui : > > hahaha, do you know how much money they are spending on hardware to > make > youtube.com fast??? yeah, as they do for basically all big sites, no matter what language is used for implementation. Next is the fact that it's rather simp

Re: mod_python and files directory

2008-12-14 Thread mete
On Monday 08 December 2008 10:31:28 Gabriel Genellina wrote: > os.path.dirname(os.path.abspath(__file__)) thanks a lot it's working. -- http://mail.python.org/mailman/listinfo/python-list

Re: Removing None objects from a sequence

2008-12-14 Thread Arnaud Delobelle
Lie Ryan writes: > I was just expressing the preference that operators should be > composed of a single word, especially since none of the other > operators are multi-words (Special cases aren't special enough to > break the rules). The only advantage of using 'is not' over 'isnot' is > that we

Re: Bidirectional Networking

2008-12-14 Thread Bryan Olson
Brian Allen Vanderburg II wrote: As for the backlog (5), this doesn't mean that you can only have a maximum of 5 established connections. Each established connection gets a new socket object. But what I think it means is that during the listen for an incoming connection on the listening sock

HTTPConnection Sending Cookies to server

2008-12-14 Thread Lamonte Harris
Right now I can login to www.phpbb.com's forums import httplib, urllib params = urllib.urlencode({'username':'TheInfernoSin','password':'PASSWORD','login':1,'sid':'','redirect':'index.php','autologin':1}) headers = {"Content-type": "application/x-www-form-urlencoded","Accept": "text/plain"} con =

Re: Bidirectional Networking

2008-12-14 Thread Bryan Olson
Emanuele D'Arrigo wrote: Bryan Olson wrote: Software firewalls will often simply refuse incoming connections. The basic protection of the garden-variety home router comes from "network address translation" (NAT), in which case TCP connections initiated from the inside will generally work, regard

Re: Looking for the best way to translate an idiom

2008-12-14 Thread James Stroud
I V wrote: On Sun, 14 Dec 2008 21:08:33 -0800, James Stroud wrote: Yes. I think it was the British who decided that the apostrophe rule for "it" would be reversed from normal usage relative to just about every other noun. I'm not sure the purpose--maybe it was to give compulsive proofreaders a r

Re: alt.possessive.its.has.no.apostrophe

2008-12-14 Thread James Stroud
Ben Finney wrote: James Stroud writes: Yes. I think it was the British who decided that the apostrophe rule for "it" would be reversed from normal usage relative to just about every other noun. Remember that “it” is a pronoun. I see no reversal: Ok. Pronouns are reversed. Bob's Its -- htt

Re: [OT] stable algorithm with complexity O(n)

2008-12-14 Thread Lie Ryan
On Mon, 15 Dec 2008 01:48:43 +, Steven D'Aprano wrote: > Some things really don't have a solution, no matter how much power of > positive thinking you apply to it. Some may, only not with the current understanding of the universe. Well, I agree that there are a few things that is straight ou

Re: [OT] stable algorithm with complexity O(n)

2008-12-14 Thread Steven D'Aprano
On Sun, 14 Dec 2008 21:18:03 -0500, Roy Smith wrote: > Steven D'Aprano wrote: > >> All the positive thinking in the world won't help you: >> >> * make a four-sided triangle; >> >> * split a magnet into two individual poles; > > These two are fundamentally different problems. > > The first is

Re: stable algorithm with complexity O(n)

2008-12-14 Thread David Cournapeau
On Mon, Dec 15, 2008 at 2:12 PM, Aaron Brady wrote: > > I agree. Most of his examples were tautologies. The magnet one was > the exception. A proof is nothing more than a tautology :) The fact that pi is not rational is not trivial (but certainly has been proved for some time now). cheers, D

alt.possessive.its.has.no.apostrophe (was: Looking for the best way to translate an idiom)

2008-12-14 Thread Ben Finney
James Stroud writes: > Yes. I think it was the British who decided that the apostrophe rule > for "it" would be reversed from normal usage relative to just about > every other noun. Remember that “it” is a pronoun. I see no reversal: he she we theyme you it

Re: Looking for the best way to translate an idiom

2008-12-14 Thread I V
On Sun, 14 Dec 2008 21:08:33 -0800, James Stroud wrote: > Yes. I think it was the British who decided that the apostrophe rule for > "it" would be reversed from normal usage relative to just about every > other noun. I'm not sure the purpose--maybe it was to give compulsive > proofreaders a raison

Re: Removing None objects from a sequence

2008-12-14 Thread Lie Ryan
On Mon, 15 Dec 2008 03:21:21 +, Steven D'Aprano wrote: > On Mon, 15 Dec 2008 02:11:10 +, Lie Ryan wrote: > >>> So given the normal precedence rules of Python, there is no ambiguity. >>> True, you have to learn the rules, but that's no hardship. >> >> *I* know about the precedence rule, b

Unit tests / build tools

2008-12-14 Thread tleeuwenb...@gmail.com
Hi all, I don't know if there is an equivalent to Maven for Python, or whether Maven could be used for Python projects. However, it would be great if there were something available that would let me produce unit test and code coverage statistics, then have those presented through an attractive web

Re: Building from source -- zlib/binascii problems 2.5.2/2.6.1

2008-12-14 Thread peter s.
On Dec 14, 5:20 pm, "Martin v. Löwis" wrote: > > So.. it seems as though I need to get it to point to the 64 bit > > version (or compile the zlib that comes with Python source).  I'm not > > sure how to override that. > > The easiest solution would be to invoke the linker line manually, > and repl

Re: stable algorithm with complexity O(n)

2008-12-14 Thread Aaron Brady
On Dec 14, 8:18 pm, Roy Smith wrote: > Steven D'Aprano wrote: > > All the positive thinking in the world won't help you: > > > * make a four-sided triangle; > > > * split a magnet into two individual poles; > > These two are fundamentally different problems. > > The first is impossible by definit

Re: Looking for the best way to translate an idiom

2008-12-14 Thread James Stroud
Aahz wrote: In article , James Stroud wrote: In case its not obvious: Ah, so that's where Bruno's extra apostrophe came from! ;-) (Sorry about the spelling flame, but seeing three posts in quick succession with incorrect spelling of its/it's pushed me into making a public comment.) Yes.

Re: Python is slow

2008-12-14 Thread James Mills
On Mon, Dec 15, 2008 at 2:59 PM, James Mills wrote: > On Mon, Dec 15, 2008 at 2:44 PM, Benjamin Kaplan > wrote: >> On Sun, Dec 14, 2008 at 11:38 PM, cm_gui wrote: >>> >>> hahaha, do you know how much money they are spending on hardware to >>> make >>> youtube.com fast??? >> >> Obviously not enou

Re: Looking for the best way to translate an idiom

2008-12-14 Thread Aahz
In article , James Stroud wrote: > >In case its not obvious: Ah, so that's where Bruno's extra apostrophe came from! ;-) (Sorry about the spelling flame, but seeing three posts in quick succession with incorrect spelling of its/it's pushed me into making a public comment.) -- Aahz (a...@pyth

Re: Python is slow

2008-12-14 Thread James Mills
On Mon, Dec 15, 2008 at 2:44 PM, Benjamin Kaplan wrote: > On Sun, Dec 14, 2008 at 11:38 PM, cm_gui wrote: >> >> hahaha, do you know how much money they are spending on hardware to >> make >> youtube.com fast??? > > Obviously not enough to get to the point where it's cheaper to have the > programm

Re: Python is slow

2008-12-14 Thread Benjamin Kaplan
On Sun, Dec 14, 2008 at 11:38 PM, cm_gui wrote: > > hahaha, do you know how much money they are spending on hardware to > make > youtube.com fast??? Obviously not enough to get to the point where it's cheaper to have the programmers write C code. And the hardware is more for handling the intens

Re: Python is slow

2008-12-14 Thread cm_gui
hahaha, do you know how much money they are spending on hardware to make youtube.com fast??? > By the way... I know of a very slow Python site called YouTube.com. In > fact, it is so slow that nobody ever uses it. -- http://mail.python.org/mailman/listinfo/python-list

Re: How do I manually uninstall setuptools (installed by egg)?

2008-12-14 Thread excord80
On Dec 9, 10:48 pm, excor...@gmail.com wrote: > > Anyway, the direction I'm heading is to try and use setuptools *less*. > It seems like it might be too complicated for me. And, I notice that > the mailing list for it (distutils-sig, if that's the right one) is > loaded with questions on how to use

Re: Python music sequencer timing problems

2008-12-14 Thread John O'Hagan
On Sun, 14 Dec 2008, Bad Mutha Hubbard wrote: > John O'Hagan wrote: > > On Wed, 10 Dec 2008, badmuthahubbard wrote: [...] > > from time import time, sleep > > > > start = time() > > for event in music: > > duration=len(event) #Really, the length of the event > > play(event) > > while 1:

Re: Removing None objects from a sequence

2008-12-14 Thread Steven D'Aprano
On Mon, 15 Dec 2008 02:11:10 +, Lie Ryan wrote: >> So given the normal precedence rules of Python, there is no ambiguity. >> True, you have to learn the rules, but that's no hardship. > > *I* know about the precedence rule, but a newbie or a tired programmer > might not. He might want to reve

Python User Group - Calgary, Alberta, Canada

2008-12-14 Thread Greg
Hi all, this is just a brief announcement regarding the resurrection of the Python User Group in Calgary, Alberta, Canada. Our first meeting will be on Wednesday, January 14, 2009. Our official web site (albeit requiring a lot of work): http://www.pythoncalgary.com/ We have a mailing list set up

Re: [OT] stable algorithm with complexity O(n)

2008-12-14 Thread Roy Smith
Steven D'Aprano wrote: > All the positive thinking in the world won't help you: > > * make a four-sided triangle; > > * split a magnet into two individual poles; These two are fundamentally different problems. The first is impossible by definition. The definition of triangle is, "a three-si

Re: Removing None objects from a sequence

2008-12-14 Thread Lie Ryan
On Fri, 12 Dec 2008 22:55:20 +, Steven D'Aprano wrote: > On Fri, 12 Dec 2008 21:18:36 +, Lie Ryan wrote: >> Personally, I'd prefer VB's version: >> foo IsNot bar >> >> or in pseudo-python >> foo isnot bar >> >> since that would make it less ambiguous. > > "a is not b" is no more ambiguo

Re: execution time

2008-12-14 Thread Steven D'Aprano
On Sun, 14 Dec 2008 18:35:24 +0100, Andreas Kostyrka wrote: > On Sun, Dec 14, 2008 at 05:03:38PM +0100, David Hláčik wrote: >> Hi guys, >> >> #! /usr/bin/python >> >> import random >> import bucket2 >> >> data = [ random.randint(1,25) for i in range(5)] print "random data : >> %s" % data >> pri

Re: How do I manually uninstall setuptools (installed by egg)?

2008-12-14 Thread Stephen Thorne
On 2008-12-12, Nick Craig-Wood wrote: > Failing that I'll use bdist_rpm then alien to convert to a deb which > works well enough I find. Ages ago there was a bdist_deb that was in the python bug tracker, long since that bug tracker has been transitioned to another one, and that attachment was lost

Re: Removing None objects from a sequence

2008-12-14 Thread Stephen Thorne
On 2008-12-12, Filip Gruszczyński wrote: > Hi! > > I would like to iterate over a sequence nad ignore all None objects. > The most obvious way is explicitly checking if element is not None, > but it takes too much space. And I would like to get something faster. > I can use > [ sth for sth in self

Re: [OT] stable algorithm with complexity O(n)

2008-12-14 Thread Steven D'Aprano
On Sun, 14 Dec 2008 21:42:33 +, Lie Ryan wrote: > I'm sure someday, there will be a student who comes to class late and > sees this on the board: "Design a comparison sorting algorithm that has > better than O(n * log n) lower bound complexity." The unsuspecting > student copied it, thinking i

Re: Looking for the best way to translate an idiom

2008-12-14 Thread James Stroud
James Stroud wrote: inspect.stack()[1][0].f_locals[name] = val I just double checked this. Because of the way locals are implemented in cPython, this won't have the desired affect. James -- http://mail.python.org/mailman/listinfo/python-list

Re: Looking for the best way to translate an idiom

2008-12-14 Thread James Stroud
drobi...@gmail.com wrote: I'm baffled by this discussion. What's wrong with a, dontcare, dontcare2 = f() a = a + 1 Simple, clear, and correct. 1. This can't apply to a generalized f() that may return an arbitrary number of arguments >= len(num_assignments_you_care_about). 2. The examp

Re: Looking for the best way to translate an idiom

2008-12-14 Thread drobi...@gmail.com
On Dec 14, 11:19 am, Paul Moore wrote: > I'm translating some code from another language (Lua) which has > multiple function return values. So, In Lua, it's possible to define a > function > >     function f() >         return 1,2,3 >     end > > which returns 3 values. These can then be used/ass

Python shows up checking votes

2008-12-14 Thread Scott David Daniels
I just saw an interesting post -- The video linked to on http://www.blog.wired.com in Kim Zetter's "Threat Level" blog, there is a video describing the software used to provide open access to ballots after an election. The software used for this system is an open-source system written in Python.

Re: Looking for the best way to translate an idiom

2008-12-14 Thread James Stroud
James Stroud wrote: py> class mytuple(tuple): def magic(self, astr): names = astr.split() for name, val in zip(names, self): globals()[name] = val ... py> t = mytuple((1,2,3)) py> t.magic('a b') py> a 1 py> b 2 James In case its not obvious: def f(): return mytuple((1,2,3))

Re: stable algorithm with complexity O(n)

2008-12-14 Thread Aaron Brady
On Dec 14, 6:04 pm, greg wrote: > Lie Ryan wrote: > > "You know what you just did? You've > > just found a problem that was supposed to be an example of unsolvable > > problem." > > > It has happened before, why not again? > > There's a big difference between an unsolvable problem and an > unsolve

Re: Output to file gets lost - don't know where to look ...

2008-12-14 Thread Scott David Daniels
uair01 wrote: I will try the python program outside of IDLE. Yes, running the program from the Linux shell instead of from IDLE produces all output correctly. Now I'll have to look for a new simple development environment :-( I think I'll try SPE that has worked well for me ... Or you could t

Re: subprocess to C program

2008-12-14 Thread Aaron Brady
On Dec 13, 9:09 pm, MRAB wrote: > Aaron Brady wrote: > > On Dec 13, 7:51 pm, Grant Edwards wrote: > >> On 2008-12-14, MRAB wrote: > > I am writing a C process and I want to read data from a file that I > write to in Python.  I'm creating a pipe in Python, passing it to the > C pro

Re: [OT] stable algorithm with complexity O(n)

2008-12-14 Thread greg
Lie Ryan wrote: "You know what you just did? You've just found a problem that was supposed to be an example of unsolvable problem." It has happened before, why not again? There's a big difference between an unsolvable problem and an unsolved problem. In the cases you're talking about, nobody

Re: subprocess to C program

2008-12-14 Thread Aaron Brady
On Dec 14, 6:32 am, bobicanprogram wrote: > On Dec 13, 10:09 pm, MRAB wrote: > > > > > Aaron Brady wrote: > > > On Dec 13, 7:51 pm, Grant Edwards wrote: > > >> On 2008-12-14, MRAB wrote: > > > I am writing a C process and I want to read data from a file that I > > write to in Python.

Re: Python 3.0 crashes displaying Unicode at interactive prompt

2008-12-14 Thread Martin v. Löwis
> It's unfortunate that the default behaviour isn't > optimal at the interactive prompt for some configurations, though. As I said, it's a trade-off. The alternative, if it was the default, wouldn't be optimal at the interactive prompt for some other configurations. In particular, users of non-la

Re: Looking for the best way to translate an idiom

2008-12-14 Thread James Stroud
Paul Moore wrote: I'm translating some code from another language (Lua) which has multiple function return values. So, In Lua, it's possible to define a function function f() return 1,2,3 end which returns 3 values. These can then be used/assigned by the caller: a,b,c = f()

Re: Python 3.0 crashes displaying Unicode at interactive prompt

2008-12-14 Thread Paul Boddie
On 14 Des, 22:13, "Martin v. Löwis" wrote: > > But shouldn't the production of an object's representation via repr be > > a "safe" operation? > > It's a trade-off. It should also be legible. Right. I can understand that unlike Python 2.x, a representation of a string in Python 3.x (whose equivale

Game to test : MicroWar 2.0 alpha 6

2008-12-14 Thread Pierre-Alain Dorange
MicroWar 2.0 alpha 3 for test purpose Download : http://microwar.sourceforge.net/ Presentation - MicroWar is "Space Invaders" style arcade game, in the cruel world of micro-compter industry. You're a Macintosh faced to invading Wintel hordes year after year, kill more PC. Bonuses

Re: the official way of printing unicode strings

2008-12-14 Thread Martin v. Löwis
> My main problem is that when I use some language I want to use it the way it > is supposed to be used. Usually doing like that saves many problems. > Especially in Python, where there is one official way to do any elementary > task. And I just want to know what is the normal, official way of prin

Re: Need help improving number guessing game

2008-12-14 Thread James Stroud
It looks much better. But as Bruno suggests and as I alluded to earlier, you should get in the habit of forming verification loops on input channels that aren't already guaranteed to provide valid input messages. I'm not sure how to say that in English, but in python my example was: while True

Re: Python 3.0 crashes displaying Unicode at interactive prompt

2008-12-14 Thread James Mills
On Mon, Dec 15, 2008 at 9:03 AM, Fuzzyman wrote: > It seems to me to be a generally accepted term when an application > stops due to an unhandled error to say that it crashed. it == application Yes. #!/usr/bin/env python from traceback import format_exc def foo(): print

Re: Python 3.0 crashes displaying Unicode at interactive prompt

2008-12-14 Thread Fuzzyman
> That's an interesting definition of crash. You're just like saying: "C > has crashed because I made a bug in my program". In this context, it is > your program that crashes, not python nor C, it is misleading to say so. > > It will be python's crash if: > 1. Python 'segfault'ed > 2. Python inter

Re: Looking for the best way to translate an idiom

2008-12-14 Thread Fuzzyman
On Dec 14, 5:51 pm, Paul Moore wrote: > On 14 Dec, 16:22, Bruno Desthuilliers > > wrote: > > if you only want the first returned value, you can just apply a slice: > > > def f(): > >     return 1,2,3 > > > a = f()[0] + 1 > > Hmm, true. I'm not sure it's any less ugly, though :-) > > > FWIW, Pyth

Re: Looking for the best way to translate an idiom

2008-12-14 Thread Lie Ryan
On Sun, 14 Dec 2008 09:51:03 -0800, Paul Moore wrote: > On 14 Dec, 16:22, Bruno Desthuilliers > wrote: >> if you only want the first returned value, you can just apply a slice: >> >> def f(): >>     return 1,2,3 >> >> a = f()[0] + 1 > > Hmm, true. I'm not sure it's any less ugly, though :-) >

Re: Building from source -- zlib/binascii problems 2.5.2/2.6.1

2008-12-14 Thread Martin v. Löwis
> So.. it seems as though I need to get it to point to the 64 bit > version (or compile the zlib that comes with Python source). I'm not > sure how to override that. The easiest solution would be to invoke the linker line manually, and replace -lz with the absolute path to the right library. Reg

Re: Building from source -- zlib/binascii problems 2.5.2/2.6.1

2008-12-14 Thread peter s.
On Dec 14, 5:03 pm, "peter s." wrote: > On Dec 14, 4:54 pm, "Martin v. Löwis" wrote: > > > > > > Target: x86_64-redhat-linux > > > gcc -pthread -shared build/temp.linux-x86_64-2.5/location/of/ > > > Python-2.5.2/Modules/zlibmodule.o -L/usr/local/lib -lz -o build/ > > > lib.linux-x86_64-2.5/zlib.s

Re: Building from source -- zlib/binascii problems 2.5.2/2.6.1

2008-12-14 Thread peter s.
On Dec 14, 4:54 pm, "Martin v. Löwis" wrote: > > Target: x86_64-redhat-linux > > gcc -pthread -shared build/temp.linux-x86_64-2.5/location/of/ > > Python-2.5.2/Modules/zlibmodule.o -L/usr/local/lib -lz -o build/ > > lib.linux-x86_64-2.5/zlib.so > > /usr/bin/ld: skipping incompatible /usr/lib/libz.

Re: the official way of printing unicode strings

2008-12-14 Thread Ben Finney
Piotr Sobolewski writes: > in Python (contrary to Perl, for instance) there is one way to do > common tasks. More accurately: the ideal is that there should be only one *obvious* way to do things. Other ways may also exist. > Could somebody explain me what is the official python way of > printi

Re: the official way of printing unicode strings

2008-12-14 Thread J. Clifford Dyer
On Sun, 2008-12-14 at 11:16 +0100, Piotr Sobolewski wrote: > Marc 'BlackJack' Rintsch wrote: > > > I'd make that first line: > > sys.stdout = codecs.getwriter('utf-8')(sys.stdout) > > > > Why is it even more cumbersome to execute that line *once* instead > > encoding at every ``print`` statement?

Re: Building from source -- zlib/binascii problems 2.5.2/2.6.1

2008-12-14 Thread Martin v. Löwis
> Target: x86_64-redhat-linux > gcc -pthread -shared build/temp.linux-x86_64-2.5/location/of/ > Python-2.5.2/Modules/zlibmodule.o -L/usr/local/lib -lz -o build/ > lib.linux-x86_64-2.5/zlib.so > /usr/bin/ld: skipping incompatible /usr/lib/libz.so when searching for > -lz Do file /usr/lib/libz.so

Re: Output to file gets lost - don't know where to look ...

2008-12-14 Thread uair01
> I will try the python program outside of IDLE. Yes, running the program from the Linux shell instead of from IDLE produces all output correctly. Now I'll have to look for a new simple development environment :-( I think I'll try SPE that has worked well for me ... -- http://mail.python.org/mail

Re: Optimizing methods away or not?

2008-12-14 Thread Terry Reedy
Steven D'Aprano wrote: I have a class with a method meant to verify internal program logic (not data supplied by the caller). Because it is time-consuming but optional, I treat it as a complex assertion statement, and optimize it away if __debug__ is false: class Parrot: def __init__(self

Re: Bidrectional Subprocess Communication

2008-12-14 Thread Gabriel Genellina
En Sun, 14 Dec 2008 09:37:38 -0200, Emanuele D'Arrigo escribió: On Dec 14, 4:48 am, "Gabriel Genellina" wrote: - you have to close server.stdin when you don't have more data to send. The server will see an end-of-file and knows it has to exit the loop. Same thing on the client side. Hi Ga

Re: [OT] stable algorithm with complexity O(n)

2008-12-14 Thread Lie Ryan
On Sat, 13 Dec 2008 19:17:41 +, Duncan Booth wrote: > "Diez B. Roggisch" wrote: > >> David Hláčik schrieb: >>> Hi guys, >>> >>> i am really sorry for making offtopic, hope you will not kill me, but >>> this is for me life important problem which needs to be solved within >>> next 12 hours

Output to file gets lost - don't know where to look ...

2008-12-14 Thread uair01
I'm running python in IDLE on suse11. I have a python program and after writing 100kB to 200kB to a file, the write statements seem to stop working. Basically the print statements look like this: some loops: logFile.write(string1) logFile.write(string2) end of loops print(stringA) logFile.write(

Re: Bidirectional Networking

2008-12-14 Thread Gabriel Genellina
En Sun, 14 Dec 2008 11:00:18 -0200, Emanuele D'Arrigo escribió: On Dec 14, 4:10 am, "Gabriel Genellina" wrote: daemon became a property in Python 2.6; setDaemon was the only way to set it in previous versions. I thought that might be the case! The documentation is a bit vague: http://d

Re: Python 3.0 crashes displaying Unicode at interactive prompt

2008-12-14 Thread Martin v. Löwis
> But shouldn't the production of an object's representation via repr be > a "safe" operation? It's a trade-off. It should also be legible. Regards, Martin -- http://mail.python.org/mailman/listinfo/python-list

Re: [OT] stable algorithm with complexity O(n)

2008-12-14 Thread David Hláčik
Thank you guys for help and support! My homework is done and waiting for grading. Here it comes - bucket sort with time complexity O(n) == linear complexity #! /usr/bin/python def sort(numbers): "sort n positive integers in O(n) provided that they are all from interval [1, n^2]"

Re: package structure?

2008-12-14 Thread Torsten Mohr
>> I wonder how i can make AClass() known in that package. >> > > Why don't you put the contents of smod1.py in mod/smod1/__init__.py? > It'll work this way. Of course, thanks for that hint. Best regards, Torsten. -- http://mail.python.org/mailman/listinfo/python-list

Re: package structure?

2008-12-14 Thread Arnaud Delobelle
Torsten Mohr writes: > Hi, > > in a package i'd like to have a structure like this: > > Files end with ".py", others are directories: > > mod > __init__.py # sets __all__ = ['smod1'] > smod1.py # contains AClass() > smod1 > __init__.py # sets __all__ = ['abc', 'def']

Re: package structure?

2008-12-14 Thread Benjamin Kaplan
On Sun, Dec 14, 2008 at 3:16 PM, Torsten Mohr wrote: > Hi, > > in a package i'd like to have a structure like this: > > Files end with ".py", others are directories: > > mod > __init__.py # sets __all__ = ['smod1'] > smod1.py # contains AClass() > smod1 >__init__.py # se

Re: Looking for the best way to translate an idiom

2008-12-14 Thread Bruno Desthuilliers
Steve Holden a écrit : Bruno Desthuilliers wrote: [...] if you only want the first returned value, you can just apply a slice: def f(): return 1,2,3 a = f()[0] + 1 That isn't a slice, it's indexing Yeps, sorry - and thanks for the correction. -- http://mail.python.org/mailman/listinfo/p

package structure?

2008-12-14 Thread Torsten Mohr
Hi, in a package i'd like to have a structure like this: Files end with ".py", others are directories: mod __init__.py # sets __all__ = ['smod1'] smod1.py # contains AClass() smod1 __init__.py # sets __all__ = ['abc', 'def'] abc.py def.py So i can now do: i

Re: Why %e not in time.strftime directives?

2008-12-14 Thread Tim Chase
Any special reasons? Because it is there (at least on my Debian box)? But not on windows :( import time time.strftime("%e") '' Guess you'll have to take it up with the authors of strftime() at Microsoft :) The full set of format codes supported varies across platforms, because Python

Re: Shorter tracebacks

2008-12-14 Thread Peter Otten
Peter Otten wrote: > That's none of __future__'s business, I think. Python offers a hook which > you can modify: > import sys, traceback from functools import partial sys.excepthook = partial(traceback.print_exception, limit=5) I just stumbled upon >>> import sys >>> sys.tracebac

Building from source -- zlib/binascii problems 2.5.2/2.6.1

2008-12-14 Thread peter s.
I am trying to build Python from source on a RHEL system where I do not have root access. There are two modules that I am having trouble with: zlib & binascii. zlib -- This seems like a make configuration issue. I have noticed that 'gcc -v' returns '--with-system-zlib': $ gcc -v Using built-in s

Re: Python 3.0 crashes displaying Unicode at interactive prompt

2008-12-14 Thread Paul Boddie
On 14 Des, 05:46, "Martin v. Löwis" wrote: > > Yes. If you want a display that is guaranteed to work on your terminal, > use the ascii() builtin function. But shouldn't the production of an object's representation via repr be a "safe" operation? That is, the operation should always produce a resu

Re: curses and refreshing problem

2008-12-14 Thread Carl Banks
On Dec 14, 5:52 am, Karlo Lozovina <_kar...@_mosor.net_> wrote: > Carl Banks wrote > innews:69d2698a-6f44-4d85-adc3-1180ab158...@r15g2000prd.googlegroups.com: > > > Unless you are referring to some wget screen mode I don't know about, > > I suspect wget outputs its progress bar using carriage ret

Limit traceback from most recent call

2008-12-14 Thread Brian Allen Vanderburg II
I've looked at traceback module but I can't find how to limit traceback from the most recent call if it is possible. I see that extract_tb has a limit parameter, but it limits from the start and not the end. Currently I've made my own traceback code to do this but wonder if python already has

Re: Need help improving number guessing game

2008-12-14 Thread Bruno Desthuilliers
feba a écrit : #!/usr/bin/python #Py3k, UTF-8 import random def setup(): #global target, guess, a, b #a, b make minimum, maximum. Can be adjusted. a, b = 1, 99 target = random.randint(a, b) return a, b, target Seems ok. You may want to use arguments with default values for

Re: Looking for the best way to translate an idiom

2008-12-14 Thread Steve Holden
Bruno Desthuilliers wrote: [...] > if you only want the first returned value, you can just apply a slice: > > def f(): >return 1,2,3 > > a = f()[0] + 1 > That isn't a slice, it's indexing regards Steve -- Steve Holden+1 571 484 6266 +1 800 494 3119 Holden Web LLC ht

Re: Looking for the best way to translate an idiom

2008-12-14 Thread Paul Moore
On 14 Dec, 16:22, Bruno Desthuilliers wrote: > if you only want the first returned value, you can just apply a slice: > > def f(): >     return 1,2,3 > > a = f()[0] + 1 Hmm, true. I'm not sure it's any less ugly, though :-) > FWIW, Python 2.6 has NamedTuple objects... I know, but I want to targ

Re: execution time

2008-12-14 Thread Andreas Kostyrka
On Sun, Dec 14, 2008 at 05:03:38PM +0100, David Hláčik wrote: > Hi guys, > > #! /usr/bin/python > > import random > import bucket2 > > data = [ random.randint(1,25) for i in range(5)] > print "random data : %s" % data > print "result: %s" %bucket2.sort(data) > > How to write a test script which

Deepcopying slice objects

2008-12-14 Thread Max Argus
I stumbled across a thread about that suggests fixing deepcopy to let it copy slice objects. ( http://mail.python.org/pipermail/python-list/2006-August/398206.html). I expected this to work and don't see any reason why it shouldn't in case there is a good reason why it dosen't work can someone plea

Re: Need help improving number guessing game

2008-12-14 Thread Bruno Desthuilliers
feba a écrit : #!/usr/bin/python #Py3k, UTF-8 import random def startup(): print("WELCOME TO THE SUPER NUMBER GUESSING GAME!") global pnum, play, player, p1sc, p2sc You should now try to rewrite the whole thing to avoid using globals. pnum = int(input("1 OR 2 PLAYERS?\n> ")) W

Re: 1 or 1/0 doesn't raise an exception

2008-12-14 Thread Bruno Desthuilliers
Grant Edwards a écrit : On 2008-12-14, Daniel Fetchinson wrote: Let me just point out that unsuspecting people (like me) might rely on the whole expression to be evaluated and rely on exceptions being raised if needed. Short circuit evaluation of booleans is very common (and has been for dec

Re: execution time

2008-12-14 Thread Bruno Desthuilliers
David Hláčik a écrit : Hi guys, #! /usr/bin/python import random import bucket2 data = [ random.randint(1,25) for i in range(5)] print "random data : %s" % data print "result: %s" %bucket2.sort(data) How to write a test script which will outputs execution time for bucket2.sort(data) ? http:

Re: Looking for the best way to translate an idiom

2008-12-14 Thread Bruno Desthuilliers
Paul Moore a écrit : I'm translating some code from another language (Lua) which has multiple function return values. So, In Lua, it's possible to define a function function f() return 1,2,3 end which returns 3 values. These can then be used/assigned by the caller: a,b,c =

Re: 1 or 1/0 doesn't raise an exception

2008-12-14 Thread Benjamin Kaplan
On Sun, Dec 14, 2008 at 2:38 AM, Gabriel Genellina wrote: > En Sun, 14 Dec 2008 02:40:10 -0200, Benjamin Kaplan > escribió: > > On Sat, Dec 13, 2008 at 10:49 PM, Daniel Fetchinson < >> fetchin...@googlemail.com> wrote: >> >> >> Is it a feature that >>> >> >>> >> 1 or 1/0 >>> >> >>> >> returns 1

Re: 1 or 1/0 doesn't raise an exception

2008-12-14 Thread Peter Otten
Grant Edwards wrote: > Short circuit evaluation of booleans is very common (and has > been for decades), so I don't know why people would expect > something else. Visual Basic ;) -- http://mail.python.org/mailman/listinfo/python-list

Re: 1 or 1/0 doesn't raise an exception

2008-12-14 Thread Mel
Daniel Fetchinson wrote: [ ... ] > Let me just point out that unsuspecting people (like me) might rely on > the whole expression to be evaluated and rely on exceptions being > raised if needed. There are a lot of threads on comp.lang.python that mention beginners' possible reactions to language fe

Looking for the best way to translate an idiom

2008-12-14 Thread Paul Moore
I'm translating some code from another language (Lua) which has multiple function return values. So, In Lua, it's possible to define a function function f() return 1,2,3 end which returns 3 values. These can then be used/assigned by the caller: a,b,c = f() So far, much like

execution time

2008-12-14 Thread David Hláčik
Hi guys, #! /usr/bin/python import random import bucket2 data = [ random.randint(1,25) for i in range(5)] print "random data : %s" % data print "result: %s" %bucket2.sort(data) How to write a test script which will outputs execution time for bucket2.sort(data) ? Thanks in advance! -- http://ma

Re: 1 or 1/0 doesn't raise an exception

2008-12-14 Thread MRAB
Rohannes wrote: 'Dive into Python' has a very memorable and interesting section on the exact behaviour of 'and' and 'or' in Python: http://diveintopython.org/power_of_introspection/and_or.html No: &, | (and ^, too) perform bitwise operations in Python, C and Java: "In complete evaluation ...

Re: 1 or 1/0 doesn't raise an exception

2008-12-14 Thread Grant Edwards
On 2008-12-14, Daniel Fetchinson wrote: > Let me just point out that unsuspecting people (like me) might rely on > the whole expression to be evaluated and rely on exceptions being > raised if needed. Short circuit evaluation of booleans is very common (and has been for decades), so I don't know

Re: changing string encoding to different charset?

2008-12-14 Thread Philip Semanchuk
On Dec 14, 2008, at 9:21 AM, Daniel Woodhouse wrote: Is it possible to re-encode a string to a different character set in python? To be more specific, I want to change a text file encoded in windows-1251 to UTF-8. I've tried using string.encode, but get the error: UnicodeDecodeError: 'ascii' c

Re: Python music sequencer timing problems

2008-12-14 Thread Bad Mutha Hubbard
John O'Hagan wrote: > On Wed, 10 Dec 2008, badmuthahubbard wrote: >> I've been trying to get the timing right for a music sequencer using >> Tkinter. First I just loaded the Csound API module and ran a Csound >> engine in its own performance thread. The score timing was good, >> being controlled

changing string encoding to different charset?

2008-12-14 Thread Daniel Woodhouse
Is it possible to re-encode a string to a different character set in python? To be more specific, I want to change a text file encoded in windows-1251 to UTF-8. I've tried using string.encode, but get the error: UnicodeDecodeError: 'ascii' codec can't decode byte 0xce in position 0: ordinal not in

[OT] Alternative web server scripting language

2008-12-14 Thread Petite Abeille
Hello, Now that Lua [1] appears as a native scripting language in more [2] and more [3] mainstream web servers, here is an example of a web server written in Lua: http://svr225.stepx.com:3388/a The wiki demo sports content from the 2008/9 Wikipedia Selection, containing about 5500 articl

Re: Bidirectional Networking

2008-12-14 Thread Emanuele D'Arrigo
On Dec 14, 2:40 am, Brian Allen Vanderburg II wrote: > But what I think it means is that during the listen for an incoming > connection on the listening socket, if multiple connection attempts are > coming in at one time it can keep a backlog of up to 5 of these > connection attempts for that indi

  1   2   >