Re: Optimizing methods away or not?

2008-12-14 Thread James Stroud
Steven D'Aprano wrote: class Parrot: def __init__(self, *args): print "Initialising instance..." if __debug__: self.verify() # check internal program state, not args if __debug__: def verify(self): print "Verifying..." +1 It looks good to

Re: Bidrectional Subprocess Communication

2008-12-14 Thread greg
Gabriel Genellina wrote: (Pipes don't work the same as sockets, although unix-like systems try hard to hide the differences...) BSD-based unixes implement pipes using socketpair(), so pipes actually *are* sockets (or at least they used to be, not sure whether it's still true). -- Greg -- htt

Re: __future__ and compile: unrecognised flags

2008-12-14 Thread Rhamphoryncus
On Dec 13, 6:03 am, Steve Holden wrote: > Poor Yorick wrote: > > I have a future statement in a script which is intended to work in 2.6 and > > 3. > > Shouldn't compile flags in __future__ objects essentially be noops for > > versions > > that already support the feature? doctest is complaining

Re: Optimizing methods away or not?

2008-12-14 Thread Marc 'BlackJack' Rintsch
On Sun, 14 Dec 2008 07:41:55 +, 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 fal

Re: XMPP xmpppy - User Authorization

2008-12-14 Thread James Mills
On Sun, Dec 14, 2008 at 3:47 PM, Henson wrote: > In my own bot, using the latest xmpppy, I've been printing everything > going to the message handler to the screen. I've yet to see a > 'subscribe' string. Has this changed? No this hasn't changed. This is the string you need to check for. It doe

Re: Optimizing methods away or not?

2008-12-14 Thread Marc 'BlackJack' Rintsch
On Sun, 14 Dec 2008 09:19:45 +, Marc 'BlackJack' Rintsch wrote: > class Parrot: > def __init__(self, *args): > print "Initialising instance..." > assert self.verify() Here I meant ``assert self._verify()`` of course. > def _verify(self): > print "Verifying..."

Re: the official way of printing unicode strings

2008-12-14 Thread Marc 'BlackJack' Rintsch
On Sun, 14 Dec 2008 06:48:19 +0100, Piotr Sobolewski wrote: > Then I tried to do this that way: > sys.stdout = codecs.getwriter("utf-8")(sys.__stdout__) > s = u"Stanisław Lem" > print u > This works but is even more combersome. > > So, my question is: what is the official, recommended Python way?

Re: the official way of printing unicode strings

2008-12-14 Thread Piotr Sobolewski
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? Oh, maybe it's not cumbersome, but a little bit strange - but sure, I c

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

2008-12-14 Thread Rohannes
'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 ... both expressions

Re: subprocess to pipe through several processes?

2008-12-14 Thread rdmurray
On Sat, 13 Dec 2008 at 23:05, Neal Becker wrote: How would I use suprocess to do the equivalent of: cat - | program_a | program_b Have you tried extending the pipe example from the manual? http://docs.python.org/library/subprocess.html#replacing-shell-pipeline --David -- http://mail.python.o

Re: Optimizing methods away or not?

2008-12-14 Thread Steven D'Aprano
On Sun, 14 Dec 2008 09:19:45 +, Marc 'BlackJack' Rintsch wrote: > On Sun, 14 Dec 2008 07:41:55 +, 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

Re: problem adding custom module in cgi script

2008-12-14 Thread bobicanprogram
On Dec 11, 8:03 pm, bobicanprogram wrote: > Problem: > > Apache server serving an HTML file to a Firefox Browser containing a > form and > a CGI python CGI script. HTML works fine, meat of the CGI script works > fine > except that when a home grown and ordinarily functional module that is > to be

Re: Optimizing methods away or not?

2008-12-14 Thread Arnaud Delobelle
Steven D'Aprano writes: > On Sun, 14 Dec 2008 10:52:25 +, Arnaud Delobelle wrote: > >> You could also not use the metaclass and use post_verify as a decorator > > Except that self.verify doesn't exist if __debug__ is false. OK I wrote this as an afterthought. I'm, sure it's not beyond your

Re: subprocess to C program

2008-12-14 Thread bobicanprogram
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. I'm creating a pipe in Python, passing it to the > C pr

Re: Bidirectional Networking

2008-12-14 Thread Emanuele D'Arrigo
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://docs.python.org/library/threading.html?highlight=threading#threading.Th

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

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

2008-12-14 Thread Arnaud Delobelle
Steven D'Aprano writes: > On Sat, 13 Dec 2008 19:17:41 +, Duncan Booth wrote: > >> I think you must have fallen asleep during CS101. The lower bound for >> sorting where you make a two way branch at each step is O(n * log_2 n), >> but if you can choose between k possible orderings in a single

Swig for Python 2.6

2008-12-14 Thread Doron Tal
Hi I'm trying to wrap a c library for use with Python 2.6. I'm using swig 1.3.36, and I get the following error: linux-python/log_wrap.c: In function '_PySwigObject_type': linux-python/log_wrap.c:1680: warning: missing initializer linux-python/log_wrap.c:1680: warning: (near initialization for '

Re: Bidrectional Subprocess Communication

2008-12-14 Thread Emanuele D'Arrigo
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 Gabriel, thanks for modifying the code to make it work. I've just tr

Re: Optimizing methods away or not?

2008-12-14 Thread Steven D'Aprano
On Sun, 14 Dec 2008 10:52:25 +, Arnaud Delobelle wrote: > You could also not use the metaclass and use post_verify as a decorator Except that self.verify doesn't exist if __debug__ is false. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

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

2008-12-14 Thread News123
Hi. r wrote: > These are just the kind of things that make Python so beautiful ;) > Thanks Guido! You shouldn't forget to thank K&R ;-) Shortcutting logical operation shortcuts existed already in C and has been adopted by quite a lot of programming languages. bye N -- http://mail.python.org/

Re: Optimizing methods away or not?

2008-12-14 Thread Arnaud Delobelle
Steven D'Aprano writes: > 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

Re: curses and refreshing problem

2008-12-14 Thread Karlo Lozovina
Carl Banks wrote in news: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 returns > without newlines. If that's all you want, there is no need to us

[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: Need help improving number guessing game

2008-12-14 Thread feba
#!/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 def playerswitch(player): #Player Switch #if player's a witch, burn her!

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

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

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: 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: 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 ...

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

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

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

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 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: 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: 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: 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: 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

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: 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

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: 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: 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

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: 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

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

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: 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

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

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: 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

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: 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 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: [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: 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: 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

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: [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

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: 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: 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: 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: 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: 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: 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: 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 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: 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: 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: 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: 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: 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: 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

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: 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

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 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: 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: [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 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: 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: 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: 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))

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 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

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 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: [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: 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: 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: 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: 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: [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

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: 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

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: 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 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

  1   2   >