Re: Biased random?

2007-08-27 Thread J. Cliff Dyer
I don't know if this is pythonic or not, but try something like this: from math import log from random import randint def: skewedrandom(n): int(log(randrange(1,n), 2)) Play with your log to get the range you want Cheers, Cliff Grant Edwards wrote: On 2007-08-27, Jun-geun Park [EMAIL

Re: Socket - gaierror

2007-08-27 Thread Lawrence D'Oliveiro
In message [EMAIL PROTECTED], [EMAIL PROTECTED] wrote: What could cause the shell to be able to resolve the addresses properly, but not python? nnsswitch.conf ? How did you test the name resolution in the shell--was it with host or ping? I would recommend ping, because that would use the

Re: Try: which only encompasses head of compound statement

2007-08-27 Thread Lawrence D'Oliveiro
In message [EMAIL PROTECTED], [EMAIL PROTECTED] wrote: try: for line in open(myFileName): count += 1 except IOError: print Can't open myfile (I know, this is bad, I never close the file, but its just for illustration). No, that's fine. The file object returned by open

Re: Biased random?

2007-08-27 Thread Sebastian Bassi
On 8/27/07, J. Cliff Dyer [EMAIL PROTECTED] wrote: Play with your log to get the range you want Here you can get true random numbers (not pseudorandom, they claim to use a quatum generaton (?)) by fetching them from: http://random.irb.hr/ They give you a python class t insert into your code,

Re: an eval()-like exec()

2007-08-27 Thread Matt McCredie
A python interactive interpreter works by having the user type in some code, compiling and running that code, then printing the results. For printing, the results are turned into strings. I would like make an interpreter which does this, without the last part: i.e. where the results are

Re: Biased random?

2007-08-27 Thread Robert Kern
Jun-geun Park wrote: Ivan Voras wrote: Hi, I have a list of items, and need to choose several elements from it, almost random. The catch is that the elements from the beginning should have more chance of being selected than those at the end (how much more? I don't care how the envelope of

Re: Try: which only encompasses head of compound statement

2007-08-27 Thread Carl Banks
On Aug 27, 5:35 pm, [EMAIL PROTECTED] wrote: I have: try: for line in open(myFileName): count += 1 except IOError: print Can't open myfile (I know, this is bad, I never close the file, but its just for illustration). But then I change it to: try: for line in

Re: Socket - gaierror

2007-08-27 Thread Douglas Wells
In article [EMAIL PROTECTED], [EMAIL PROTECTED] writes: On Aug 27, 12:32 pm, Larry Bates [EMAIL PROTECTED] wrote: Changing it to IP gives me the same exact error... File bin/prgram.py, line 123, in notify smtp = smtplib.SMTP(XXX.XXX.XXX.XXX) File /usr/lib/python2.4/smtplib.py,

Re: Try: which only encompasses head of compound statement

2007-08-27 Thread Ben Finney
[EMAIL PROTECTED] writes: try: for line in open(myFileName): count += openAndProcessSubfile(line) except IOError: print Can't open myfile ... now the 'except' incorrectly catches errors from openAndProcessSubfile. So don't include it. You've discovered a good principle

Re: convert non-delimited to delimited

2007-08-27 Thread Paul McGuire
On Aug 27, 12:59 pm, RyanL [EMAIL PROTECTED] wrote: I'm a newbie! I have a non-delimited data file that I'd like to convert to delimited. Example... Line in non-delimited file: 01397256359210100534+42050-102800FM-15+1198KAIA Should be:

Re: Socket - gaierror

2007-08-27 Thread half . italian
On Aug 27, 4:22 pm, [EMAIL PROTECTED] (Douglas Wells) wrote: In article [EMAIL PROTECTED], [EMAIL PROTECTED] writes: On Aug 27, 12:32 pm, Larry Bates [EMAIL PROTECTED] wrote: Changing it to IP gives me the same exact error... File bin/prgram.py, line 123, in notify smtp =

Re: Error with Simplemapi.py

2007-08-27 Thread Mick Duprez
On Aug 27, 4:46 pm, Gabriel Genellina [EMAIL PROTECTED] wrote: En Mon, 27 Aug 2007 03:05:30 -0300, Mick Duprez [EMAIL PROTECTED] escribi?: Thank you very much Gabriel, changing the NULL to None did the trick (it also helps if I reload the changed module after editing!:( ). Glad to see it

Re: some problems with mod_python

2007-08-27 Thread Bruno Desthuilliers
Johan a écrit : Hi I have installed and tested this on centos, fedora and freebsd all give the same problem so I guess I missed some steps. I have compiled bot apache (2.2.4) and mod_python (3.3.1) according to the docs and no problem with this. But when I have made everything about

XML File -- dictionary edit/search

2007-08-27 Thread -b
I am trying to put together a python program that will be able to ask for a word and its definition, then save that information into an xml file for reference. I am not down right set on the file being in xml format, but xml is the first thing that comes to mind, since I do not want to use a MySQL

Re: some problems with mod_python

2007-08-27 Thread Bruno Desthuilliers
Bruno Desthuilliers a écrit : Johan a écrit : Hi I have installed and tested this on centos, fedora and freebsd all give the same problem so I guess I missed some steps. I have compiled bot apache (2.2.4) and mod_python (3.3.1) according to the docs and no problem with this. But when I

Re: Socket - gaierror

2007-08-27 Thread Steve Holden
[EMAIL PROTECTED] wrote: On Aug 27, 12:47 pm, [EMAIL PROTECTED] wrote: On Aug 27, 12:32 pm, Larry Bates [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] wrote: Hi all, I'm having trouble with the socket module resolving a hostname. It seems like this is a system level problem, but I'm not even

Re: SCF released to GPL

2007-08-27 Thread hg
Méta-MCI (MVP) wrote: Salut ! Le deuxième envoi aurait pu être en français. Cela aurait évité le doublon, tout en maintenant le message. @+ Michel Claveau ;-) No: 1) The redundancy is due to the fact that I just moved to another state/ISP and that ... for some reason, the initial

Re: SCF released to GPL

2007-08-27 Thread hg
hg wrote: Méta-MCI (MVP) wrote: Salut ! Le deuxième envoi aurait pu être en français. Cela aurait évité le doublon, tout en maintenant le message. @+ Michel Claveau ;-) No: 1) The redundancy is due to the fact that I just moved to another state/ISP and that ... for some reason,

Re: How to parse this line of code manually

2007-08-27 Thread Davy
On Aug 28, 11:00 am, Davy [EMAIL PROTECTED] wrote: Hi all, It is well known that Python is appreciated for its merit of concise. However, I found the over concise code is too hard to understand for me. Consider, for instance, def known_edits2(word): return set(e2 for e1 in

How to parse this line of code manually

2007-08-27 Thread Davy
Hi all, It is well known that Python is appreciated for its merit of concise. However, I found the over concise code is too hard to understand for me. Consider, for instance, def known_edits2(word): return set(e2 for e1 in edits1(word) for e2 in edits1(e1) if e2 in NWORDS) Shall I

Asking all python programmers.

2007-08-27 Thread Lamonte Harris
Okay, I know you've guys told me millions of times to read the manual I've read a lot of it. What do you recommend studying the most? Python is my goal for the next year in the half. :) -- http://mail.python.org/mailman/listinfo/python-list

Re: some problems with mod_python

2007-08-27 Thread Johan
On Aug 24, 3:39 pm, Bruno Desthuilliers [EMAIL PROTECTED] wrote: Your problem is with Apache configuration, not with mod_python. The AddHandler directive maps dirpath/*.py to your handler. So you have to call anythinghere.py to trigger the desired behaviour. If you want *any* url under

Re: Biased random?

2007-08-27 Thread Scott David Daniels
Ivan Voras wrote: I have a list of items, and need to choose several elements from it, almost random. The catch is that the elements from the beginning should have more chance of being selected than those at the end (how much more? I don't care how the envelope of probability looks like at

Re: Chaining programs with pipe

2007-08-27 Thread Gabriel Genellina
En Mon, 27 Aug 2007 05:35:51 -0300, Lawrence D'Oliveiro [EMAIL PROTECTED] escribi�: In message [EMAIL PROTECTED], Gabriel Genellina wrote: On 22 ago, 11:08, Grant Edwards [EMAIL PROTECTED] wrote: but I'm a Unix guy who occasionally tries to ship a Windows version of a Python app: the

Re: Try: which only encompasses head of compound statement

2007-08-27 Thread Scott David Daniels
Ben Finney wrote: [EMAIL PROTECTED] writes: ... try to only catch exceptions from the minimum amount of code that does one discrete action. try: input_file = open(my_filename) except IOError, exc: print Can't open myfile: %(exc) % locals() for line in

Re: Image.open( C:\test.jpg) is this wrong ?

2007-08-27 Thread Gabriel Genellina
En Mon, 27 Aug 2007 11:48:46 -0300, Carnell, James E [EMAIL PROTECTED] escribi�: Image.open(C:\test.jpg) # this is what I have right now. And it can't find the file or directory. The file is there (it is everywhere on my computer now!!!) Use C:\\test.jpg or rC:\test.jpg or C:/test.jpg

Re: include folder

2007-08-27 Thread Zentrader
My Linux version is: Debian GNU-Linux My Python version is: 2.3 Reinstalling Python would be my first option. Any of the versions can be downloaded from python.org but on debian you should be able to just use apt-get or one of the GUIs for apt-get. --

Re: Socket - gaierror

2007-08-27 Thread Douglas Wells
In article [EMAIL PROTECTED], [EMAIL PROTECTED] writes: On Aug 27, 4:22 pm, [EMAIL PROTECTED] (Douglas Wells) wrote: In article [EMAIL PROTECTED], [EMAIL PROTECTED] writes: On Aug 27, 12:32 pm, Larry Bates [EMAIL PROTECTED] wrote: Changing it to IP gives me the same exact error...

Re: sorting a list of lists

2007-08-27 Thread Gabriel Genellina
En Mon, 27 Aug 2007 15:41:15 -0300, iapain [EMAIL PROTECTED] escribi�: Taking advantage of stable sorting is totally not a hack. The OP just tried the two sorting steps in the wrong order. I didnt say not to use stable sorting, but write a generic function and hacky code. It is always

Re: Biased random?

2007-08-27 Thread Jun-geun Park
Jun-geun Park wrote: Ivan Voras wrote: Hi, I have a list of items, and need to choose several elements from it, almost random. The catch is that the elements from the beginning should have more chance of being selected than those at the end (how much more? I don't care how the envelope of

Re: XML File -- dictionary edit/search

2007-08-27 Thread Nagarajan
On Aug 28, 6:15 am, -b [EMAIL PROTECTED] wrote: I am trying to put together a python program that will be able to ask for a word and its definition, then save that information into an xml file for reference. I am not down right set on the file being in xml format, but xml is the first thing

Re: an eval()-like exec()

2007-08-27 Thread Gabriel Genellina
En Mon, 27 Aug 2007 15:59:25 -0300, Abel Daniel [EMAIL PROTECTED] escribi�: Hi! A python interactive interpreter works by having the user type in some code, compiling and running that code, then printing the results. For printing, the results are turned into strings. This last stage is

Re: Try: which only encompasses head of compound statement

2007-08-27 Thread Lawrence D'Oliveiro
In message [EMAIL PROTECTED], Carl Banks wrote: Consider this: is there any other code in your program that has to do something different based on whether you successfully opened this file or not? If so, how will you notify it whether the call has succeeded or not? Very often, the caller

Re: Chaining programs with pipe

2007-08-27 Thread Lawrence D'Oliveiro
In message [EMAIL PROTECTED], Gabriel Genellina wrote: En Mon, 27 Aug 2007 05:35:51 -0300, Lawrence D'Oliveiro [EMAIL PROTECTED] escribi�: In message [EMAIL PROTECTED], Gabriel Genellina wrote: On 22 ago, 11:08, Grant Edwards [EMAIL PROTECTED] wrote: but I'm a Unix guy who occasionally

Re: Try: which only encompasses head of compound statement

2007-08-27 Thread Ben Finney
Scott David Daniels [EMAIL PROTECTED] writes: Actually, this will be followed by some foolishness because (1) [the print format argument was wrong] and (2) [the code attempts to loop over the failed input file anyway] You're right. Shame on me for posting untested code snippets, Thanks for

Re: XML File -- dictionary edit/search

2007-08-27 Thread Marc 'BlackJack' Rintsch
On Mon, 27 Aug 2007 18:15:24 -0700, -b wrote: I am trying to put together a python program that will be able to ask for a word and its definition, then save that information into an xml file for reference. I am not down right set on the file being in xml format, but xml is the first thing

Python Classes

2007-08-27 Thread Lamonte Harris
How come you have to set the initialized created variables to equal the parameters, shouldn't that be default? class testing: def __init__(self,testing): self.testing = testing x = testing(testing) print x.testing How come self.testing = testing Can someone explain

Re: include folder

2007-08-27 Thread Lawrence D'Oliveiro
In message [EMAIL PROTECTED], Raul Araya wrote: Today while trying to install a python based program I got an error regarding the Python.h file that should be in the /include/Phyton2.3 folder. So I went looking for the file but it wasn't there, I mean the whole folder /Phyton2.3 inside the

[issue1035] bytes buffer API needs to support PyBUF_LOCKDATA

2007-08-27 Thread Gregory P. Smith
New submission from Gregory P. Smith: I've converted _bsddb.c to use the py3k buffer API for all data and keys it takes as input. All tests now fail with this error: BufferError: Cannot make this object read-only. This presumably results from this call: PyObject_GetBuffer(obj, view,

[issue1036] py3k _bsddb.c patch to use the new buffer API

2007-08-27 Thread Gregory P. Smith
New submission from Gregory P. Smith: This is my svn diff of a py3k Modules/_bsddb.c converted to use the buffer API. I'm submitting it here as so it doesn't get misplaced as it currently won't work until bytes objects support PyBUF_LOCKDATA (a separate bug) -- assignee:

[issue1035] bytes buffer API needs to support PyBUF_LOCKDATA

2007-08-27 Thread Gregory P. Smith
Changes by Gregory P. Smith: -- priority: normal - __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1035 __ ___ Python-bugs-list mailing list Unsubscribe:

[issue1037] Ill-coded identifier crashes python when coding spec is utf-8

2007-08-27 Thread Hye-Shik Chang
New submission from Hye-Shik Chang: Illegal identifier makes python crash on UTF-8 source codes/interpreters. Python 3.0x (py3k:57555M, Aug 27 2007, 21:23:47) [GCC 3.4.6 [FreeBSD] 20060305] on freebsd6 compile(b'#coding:utf-8\n\xfc', '', 'exec') zsh: segmentation fault (core dumped) ./python

[issue1202533] a bunch of infinite C recursions

2007-08-27 Thread Armin Rigo
Armin Rigo added the comment: Assigning to Brett instead of me (according to the tracker history). -- assignee: arigo - brett.cannon _ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1202533 _

[issue1771364] Misc improvements for the io module

2007-08-27 Thread Guido van Rossum
Guido van Rossum added the comment: Thanks!! Committed revision 57564. SocketIO was recently moved to socket.py because that's the only place that uses it. So I've removed it from io.__all__. The only other change I applied was related to the isatty check -- you accidentally changed things

[issue1739468] Add a -z interpreter flag to execute a zip file

2007-08-27 Thread Phillip J. Eby
Phillip J. Eby added the comment: Patch implementing an alternate approach: support automatically importing __main__ when sys.argv[0] is an importable path. This allows zip files, directories, and any future importable locations (e.g. URLs) to be used on the command line. Note that this also

[issue1739468] Add a -z interpreter flag to execute a zip file

2007-08-27 Thread Phillip J. Eby
Changes by Phillip J. Eby: _ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1739468 _ ___ Python-bugs-list mailing list Unsubscribe:

[issue1024] documentation for new SSL module

2007-08-27 Thread Guido van Rossum
Guido van Rossum added the comment: Committed revision 57570. I didn't review it though. -- nosy: +gvanrossum resolution: - accepted status: open - closed __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1024 __

[issue1739906] Add reduce to functools in 2.6

2007-08-27 Thread Guido van Rossum
Guido van Rossum added the comment: Committed revision 57574. -- nosy: +gvanrossum resolution: - accepted status: open - closed _ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1739906 _

[issue1029] py3k: io.StringIO.getvalue() returns \r\n

2007-08-27 Thread Alexandre Vassalotti
Alexandre Vassalotti added the comment: That's why the current behaviour is not correct: When I write('\n'), getvalue() currently returns '\r\n'. Oh, I missed your example in your initial message. So yes, I agree that StringIO shouldn't translate newlines like that. I attached a patch that

[issue1038] [py3k] pdb does not work in python 3000

2007-08-27 Thread Gregory P. Smith
New submission from Gregory P. Smith: The Lib/pdb.py debugger fails in the py3k branch. Traceback (most recent call last): File /usr/local/gps/python/py3k/Lib/pdb.py, line 1247, in main pdb._runscript(mainpyfile) File /usr/local/gps/python/py3k/Lib/pdb.py, line 1173, in _runscript

[issue1670765] email.Generator: no header wrapping for multipart/signed

2007-08-27 Thread Collin Winter
Collin Winter added the comment: I'd like some tests demonstrating where the current implementation fails and your patch helps, yes. _ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1670765 _

[issue1670765] email.Generator: no header wrapping for multipart/signed

2007-08-27 Thread Martin von Gagern
Martin von Gagern added the comment: Looks like I missed your comments on this patch. What kind of tests do you have in mind? Tests demonstrating where current implementation fails and my patch will help? Or rather tests checking that this patch won't break anything else? The former would be

[issue1032] Improve the hackish runtime_library_dirs support for gcc

2007-08-27 Thread Seo Sanghyeon
Seo Sanghyeon added the comment: The patch is incorrect since find returns -1 on failure. This is also a duplicate of #1254718. -- nosy: +sanxiyn __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1032 __

[issue1670765] email.Generator: no header wrapping for multipart/signed

2007-08-27 Thread Martin von Gagern
Martin von Gagern added the comment: Take the attached test5.eml. Run it through the following python script: import email print (email.message_from_file(open(test5.eml)).as_string(False)) The result will have both instances of the X-Long-Line header rewrapped. As the second instance is

[issue1528802] Turkish Character

2007-08-27 Thread Ismail Donmez
Ismail Donmez added the comment: This works fine with python 2.4 : import locale locale.setlocale(locale.LC_ALL,tr_TR.UTF-8) 'tr_TR.UTF-8' print uMayıs.upper() MAYIS -- nosy: +cartman _ Tracker [EMAIL PROTECTED]

[issue1033] Support for newline and encoding in tempfile module

2007-08-27 Thread Guido van Rossum
Guido van Rossum added the comment: Thanks! Committed revision 57594. General note: please run Tools/scripts/reindent.py over your files after editing so I won't have to. -- nosy: +gvanrossum resolution: - accepted status: open - closed __ Tracker

[issue1774736] Binding Control-space fails

2007-08-27 Thread Ali Gholami Rudi
Changes by Ali Gholami Rudi: -- versions: +Python 3.0 _ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1774736 _ ___ Python-bugs-list mailing list Unsubscribe:

<    1   2