Function/method returning list of chars in string?

2009-06-09 Thread Hendrik van Rooyen
One can go from lb = ['b','a','n','a','n','a'] to s = "banana" by using s = "".join(lb) Is there a way to go the reverse route? I have not been able to find one. It is obviously easy to write a for char in s loop or list comprehension, but there seems to be no function or string method to return

Re: Function/method returning list of chars in string?

2009-06-09 Thread Chris Rebert
On Tue, Jun 9, 2009 at 12:25 AM, Hendrik van Rooyen wrote: > One can go from lb = ['b','a','n','a','n','a'] > to s = "banana" by using s = "".join(lb) > > Is there a way to go the reverse route? lb = list("banana") Cheers, Chris -- http://blog.rebertia.com -- http://mail.python.org/mailman/list

Re: Function/method returning list of chars in string?

2009-06-09 Thread Diez B. Roggisch
Hendrik van Rooyen schrieb: One can go from lb = ['b','a','n','a','n','a'] to s = "banana" by using s = "".join(lb) Is there a way to go the reverse route? I have not been able to find one. It is obviously easy to write a for char in s loop or list comprehension, but there seems to be no funct

Re: Function/method returning list of chars in string?

2009-06-09 Thread jon vs. python
Sorry, I didn't realize that you already proposed list comprehension. There is some kind of asymmetry in several areas.I guess that's somehow related to this post: http://www.zedshaw.com/blog/2009-05-29.html -- http://mail.python.org/mailman/listinfo/

Re: python version in snow leopard?

2009-06-09 Thread Mark Dickinson
On Jun 9, 7:30 am, Alia Khouri wrote: > Does anyone know what version of python will appear in snow leopard > which is apparently being released in September? The python-dev thread starting at http://mail.python.org/pipermail/python-3000/2008-September/014816.html suggests that back in Septembe

Re: Extract value and average

2009-06-09 Thread Glauco
Francesco Pietra ha scritto: I come 'naked', which is unusual and unfair. However, I find it difficult to give a correct start. The files consist, among other things, of a huge number of blocks of the type NSTEP = 1000 TIME(PS) = 152.000 TEMP(K) = 298.54 PRESS =89.4 Etot =

Re: Function/method returning list of chars in string?

2009-06-09 Thread John Machin
Hendrik van Rooyen microcorp.co.za> writes: > > One can go from lb = ['b','a','n','a','n','a'] > to s = "banana" by using s = "".join(lb) > > Is there a way to go the reverse route? | >>> list('Hendrik') ['H', 'e', 'n', 'd', 'r', 'i', 'k'] Bonus extras: try tuple() and set() > I have not bee

Re: preferring [] or () in list of error codes?

2009-06-09 Thread Steven D'Aprano
On Tue, 09 Jun 2009 09:43:45 +1000, Ben Finney wrote: > Use a list when the semantic meaning of an item doesn't depend on all > the other items: it's “only” a collection of values. > > Your list of message codes is a good example: if a value appears at > index 3, that doesn't make it mean somethi

Re: Unbound Method Error

2009-06-09 Thread Piet van Oostrum
> "Enrico" <4...@755189.45> (E) wrote: >E> "lczancanella" ha scritto nel messaggio >E> news:32bf5ccb-5bfd-49a5-b423-9d41180a0...@l28g2000vba.googlegroups.com... >>> Hi, i am brand new in Python, so sorry if this question is too basic, >>> but i have tried a lot and dont have success... I have

Start the interactive shell within an application

2009-06-09 Thread Jean-Michel Pichavant
I was wondering if there is a way to start an interactive shell within a script/application. I'm sometimes tired of adding prints to scan the current namespace so I'd like to pause the execution and give the user the shell prompt. This is obviously for debugging purpose. I know that I may use t

Re: python version in snow leopard?

2009-06-09 Thread Alia K
Mark Dickinson wrote: > The python-dev thread starting at > > http://mail.python.org/pipermail/python-3000/2008-September/014816.html > > suggests that back in September 2008, there was a 'MajorOS Vendor > (tm)' > who was interested in getting Python 2.6 into their next OS release, > provided that

Re: Start the interactive shell within an application

2009-06-09 Thread eGlyph
On Jun 9, 11:49 am, Jean-Michel Pichavant wrote: > I'm sometimes tired of adding prints to scan the current namespace so > I'd like to pause the execution and give the user the shell prompt. > This is obviously for debugging purpose. This is definitely doable, have look at rhythmbox or gedit - th

Re: Start the interactive shell within an application

2009-06-09 Thread Javier Collado
Take a look either at code.interact or at IPython.ipapi.launch_new_instance. Basically, the only thing that you have to provide is a dictionary object that contains the namespace that you would like to have in your shell once it's launched. Best regards, Javier 2009/6/9 eGlyph : > On Jun 9, 1

Re: Function/method returning list of chars in string?

2009-06-09 Thread Hendrik van Rooyen
jon vs. python wrote: >Sorry, I didn't realize that you already proposed list comprehension. > > >There is some kind of asymmetry in several areas.I guess that's somehow related to this post: >http://www.zedshaw.com/blog/2009-05-29.html Thanks for the link - I am not quite as rabid, but it wou

Re: SPAM-LOW: Re: Function/method returning list of chars in string?

2009-06-09 Thread Hendrik van Rooyen
"Chris Rebert" wrote: > lb = list("banana") Aaargh! I should have known - you use a string method to get a list of words, but you have to go to the list to get a list of characters from a string. There is no string method to do it, which is what I am complaining about. Is there a reason for th

Re: Function/method returning list of chars in string?

2009-06-09 Thread Hendrik van Rooyen
"Diez B. Roggisch" wrote: > > I think > > lb = list(s) > > is good enough. It does the job, of course, but it is not a string method. - Hendrik -- http://mail.python.org/mailman/listinfo/python-list

Re: SPAM-LOW: Re: Function/method returning list of chars in string?

2009-06-09 Thread Chris Rebert
On Tue, Jun 9, 2009 at 2:42 AM, Hendrik van Rooyen wrote: > "Chris Rebert" wrote: > >> lb = list("banana") > > Aaargh! > > I should have known - you use a string method to get a list of words, > but you have to go to the list to get a list of characters from a string. > There is no string method t

Re: Function/method returning list of chars in string?

2009-06-09 Thread Diez B. Roggisch
Hendrik van Rooyen wrote: > "Diez B. Roggisch" wrote: > >> >> I think >> >> lb = list(s) >> >> is good enough. > > It does the job, of course, but it is not a string method. And that is a bad thing because of what? Also as list-comps are going away and are replaced by list() I'd say it'

Re: SPAM-LOW: Re: Function/method returning list of chars in string?

2009-06-09 Thread Marco Mariani
Hendrik van Rooyen wrote: lb = list("banana") Aaargh! I should have known - you use a string method to get a list of words, but you have to go to the list to get a list of characters from a string. As they say, "Python is not Java". Strings support the sequence protocol (aka interface), he

using libraries not installed on campus computers (numpy)

2009-06-09 Thread Chandramouli
I built and installed Numpy on my campus account, the install couldn't be done on the python install location. So I did it on my local storage location but I am clueless about how to use it I was expecting to see a numpy.py in the install dir so I could I suppose just give import numpy and expect

Re: using libraries not installed on campus computers (numpy)

2009-06-09 Thread David Cournapeau
On Tue, Jun 9, 2009 at 7:40 PM, Chandramouli wrote: > I built and installed Numpy on my campus account, the install couldn't > be done on the python install location. So I did it on my local > storage location but I am clueless about how to use it I was expecting > to see a numpy.py in the install

Re: preferring [] or () in list of error codes?

2009-06-09 Thread samwyse
On Jun 8, 10:06 pm, Chris Rebert wrote: > On Mon, Jun 8, 2009 at 6:57 PM, samwyse wrote: > > On Jun 8, 7:37 pm, Carl Banks wrote: > >> On Jun 8, 4:43 pm, Ben Finney wrote: > >> > m...@pixar.com writes: > >> > > Is there any reason to prefer one or the other of these statements? > > >> > >      

Re: preferring [] or () in list of error codes?

2009-06-09 Thread samwyse
On Jun 8, 8:57 pm, samwyse wrote: > I conclude that using constructors is generally a bad idea, since the > compiler doesn't know if you're calling the builtin or something with > an overloaded name.  I presume that the compiler will eventually > optimize the second example to match the last, but

pywin32 - word object reference module - automating form filling

2009-06-09 Thread Brendan
I was hoping to use pywin32 to automate some rather tedious filling in of Word forms. I thought -- http://mail.python.org/mailman/listinfo/python-list

pywin32 - word object reference module - automating form filling

2009-06-09 Thread Brendan
I was hoping to use pywin32 to automate some rather tedious filling in of Word forms. I thought -- http://mail.python.org/mailman/listinfo/python-list

pywin32 - word object reference module - automating form filling

2009-06-09 Thread Brendan
I was hoping to use pywin32 to automate some rather tedious filling in of Word forms. I thought the process would be analogous to dealing with xml documents or DOM but find myself somewhat lost in the word object reference manual (http://msdn.microsoft.com/en-us/library/ bb244515.aspx) . I was hop

Re: preferring [] or () in list of error codes?

2009-06-09 Thread Ben Finney
Steven D'Aprano writes: > On Tue, 09 Jun 2009 09:43:45 +1000, Ben Finney wrote: > > > Use a list when the semantic meaning of an item doesn't depend on > > all the other items: it's “only” a collection of values. > > > > Your list of message codes is a good example: if a value appears at > > in

Re: Making the case for repeat

2009-06-09 Thread alex23
Steven D'Aprano wrote: > e.g. the Wright Brothers weren't lone inventors working at a time when > everyone knew powered flight was impossible, they were experienced > engineers and glider-pilots who paid a lot of attention to research done > by their many competitors. Be careful, the idea that hum

Re: Unbound Method Error

2009-06-09 Thread Enrico
"lczancanella" ha scritto nel messaggio news:32bf5ccb-5bfd-49a5-b423-9d41180a0...@l28g2000vba.googlegroups.com... > Hi, i am brand new in Python, so sorry if this question is too basic, > but i have tried a lot and dont have success... I have the following > code... > > class Funcoes: > def Ci

Re: Unbound Method Error

2009-06-09 Thread Enrico
"Piet van Oostrum" ha scritto nel messaggio news:m2ljo1ajnx@cs.uu.nl... > The method doesn't need the class at all, so a staticmethod would be > preferable: > class Funcoes: > @staticmethod > def CifradorDeCesar(self, mensagem, chave, funcao): Yes, in this case self is not needed. >

Re: Unbound Method Error

2009-06-09 Thread Scott David Daniels
lczancanella wrote: Hi, i am brand new in Python, so sorry if this question is too basic, but i have tried a lot and dont have success... I have the following code... class Funcoes: def CifradorDeCesar(mensagem, chave, funcao): ... You've gotten some "interesting" advice. You wan

Re: pywin32 - word object reference module - automating form filling

2009-06-09 Thread Brendan
On Jun 9, 9:54 am, Brendan wrote: > I was hoping to use pywin32 to automate some rather tedious filling in > of Word forms. I thought the process would be analogous to dealing > with xml documents or DOM but find myself somewhat lost in the word > object reference manual (http://msdn.microsoft.com

Re: pywin32 - word object reference module - automating form filling

2009-06-09 Thread Tim Golden
Brendan wrote: Hmmm. The VB examples in the Word Object Reference give the best idea of how to play with Word documents. No further help required on this although I am still curious about why the python does not return the "real" objects and methods for the COM object. Try doing it this way:

Re: preferring [] or () in list of error codes?

2009-06-09 Thread samwyse
On Jun 9, 12:30 am, Emile van Sebille wrote: > On 6/8/2009 8:43 PM Ben Finney said... > > The fact that literal set syntax is a relative newcomer is the primary > > reason for that, I'd wager. > > Well, no.  It really is more, "that's odd... why use set?" Until I ran some timing tests this morni

Re: Function/method returning list of chars in string?

2009-06-09 Thread Carl Banks
On Jun 9, 2:47 am, "Hendrik van Rooyen" wrote: > "Diez B. Roggisch" wrote: > > > I think > > > lb = list(s) > > > is good enough. > > It does the job, of course, but it is not a string method. A. Your post's subject included the words "function/method" B. Who cares Carl Banks -- http://mail.

List comprehension and string conversion with formatting

2009-06-09 Thread stephen_b
I'd like to convert a list of floats to a list of strings constrained to one .1f format. These don't work. Is there a better way? [".1f" % i for i in l] or [(".1f" % i) for i in l] StephenB -- http://mail.python.org/mailman/listinfo/python-list

Re: List comprehension and string conversion with formatting

2009-06-09 Thread Carl Banks
On Jun 9, 8:38 am, stephen_b wrote: > I'd like to convert a list of floats to a list of strings constrained > to one .1f format. These don't work. Is there a better way? > > [".1f" % i for i in l] > or > [(".1f" % i) for i in l] You need a % in there, chief. [ "%.1f" % x for x in lst ] BTW, I t

Re: List comprehension and string conversion with formatting

2009-06-09 Thread Jaime Fernandez del Rio
On Tue, Jun 9, 2009 at 5:38 PM, stephen_b wrote: > I'd like to convert a list of floats to a list of strings constrained > to one .1f format. These don't work. Is there a better way? > > [".1f" % i for i in l] > or > [(".1f" % i) for i in l] There's a missing %, this does work... ["%.1f" % i for

Re: List comprehension and string conversion with formatting

2009-06-09 Thread stephen_b
On Jun 9, 10:43 am, Carl Banks wrote: > You need a % in there, chief. > > Carl Banks You are so right. Thanks. -- http://mail.python.org/mailman/listinfo/python-list

Using logging module to log into flash drive

2009-06-09 Thread kretel
Hi All, I am trying to implement the following functionality: 1. log messages to the flash drive 2. if the flash drive is not available, switch handler to the BufferringHandler and log into buffer, 3. once the flash drive is plugged in and available store the logs from BufferHandler into that flas

Re: Start the interactive shell within an application

2009-06-09 Thread Ben Charrow
If you're looking to debug your program, try "import pdb" and then wherever you want to debug put: pdb.set_trace() Your program will then enter the debugger when it executes that line. It's quite nice really. If you get confused on what to do, just type "help" http://docs.python.org/library/pd

Re: preferring [] or () in list of error codes?

2009-06-09 Thread Carl Banks
On Jun 9, 4:57 am, samwyse wrote: > On Jun 8, 8:57 pm, samwyse wrote: > > > I conclude that using constructors is generally a bad idea, since the > > compiler doesn't know if you're calling the builtin or something with > > an overloaded name.  I presume that the compiler will eventually > > opti

Re: preferring [] or () in list of error codes?

2009-06-09 Thread Carl Banks
On Jun 9, 8:20 am, samwyse wrote: > On Jun 9, 12:30 am, Emile van Sebille wrote: > > > On 6/8/2009 8:43 PM Ben Finney said... > > > The fact that literal set syntax is a relative newcomer is the primary > > > reason for that, I'd wager. > > > Well, no.  It really is more, "that's odd... why use s

Re: preferring [] or () in list of error codes?

2009-06-09 Thread mh
John Machin wrote: > T=lambda x:x in(25401,25402,25408);import dis;dis.dis(L);dis.dis(T) I've learned a lot from this thread, but this is the niftiest bit I've picked up... thanks! -- Mark Harrison Pixar Animation Studios -- http://mail.python.org/mailman/listinfo/python-list

Re: multi-thread python interpreaters and c++ program

2009-06-09 Thread Lie Ryan
myopc wrote: > hi, all > I am ruuning a c++ program (boost python) , which create many python > interpreaters and each run a python script with use multi-thread > (threading). > when the c++ main program exit, I want to shut down python > interpreaters, but it crashed. I have googled a lot but can

python and getopt and spaces in option

2009-06-09 Thread David Shapiro
Hello, I have been trying to find an example of how to deal with options that have spaces in them. I am using jython, which is the same I think as python 2.2.3. I feebly tried to use optparse and argparse with no success (got gettext, locale, and optparse). The code is as follows: try

Re: Using logging module to log into flash drive

2009-06-09 Thread A. Cavallo
Hi, the problem screams for a separate thread. Anyway there's a TimedRotatingFileHandler handler in the logging package: you can derive from it and change the emit/doRollover pair to hold the records until a device is not ready. Regards, Antonio On Tuesday 09 June 2009 16:57:00 kretel wrote:

Re: Unbound Method Error

2009-06-09 Thread Chris Rebert
On Tue, Jun 9, 2009 at 8:19 AM, Scott David Daniels wrote: > lczancanella wrote: >> >> Hi, i am brand new in Python, so sorry if this question is too basic, >> but i have tried a lot and dont have success... I have the following >> code... >> >> class Funcoes: >>    def CifradorDeCesar(mensagem, ch

Re: Using logging module to log into flash drive

2009-06-09 Thread Krzysztof Retel
On Jun 9, 6:10 pm, "A. Cavallo" wrote: > Hi, > the problem screams for a separate thread. I was thinking about that, as mentioned in the first post. Although, I was wonder if there is another way to tackle the problem. > Anyway there's a TimedRotatingFileHandler handler in the logging package:

Re: multi-core software

2009-06-09 Thread toby
On Jun 7, 2:41 pm, Jon Harrop wrote: > Arved Sandstrom wrote: > > Jon Harrop wrote: > >> I see no problem with mutable shared state. > > > In which case, Jon, you're in a small minority. > > No. Most programmers still care about performance Frequently when they shouldn't. > and performance means

Re: pylint naming conventions?

2009-06-09 Thread Esmail
R. David Murray wrote: Well, I for one looked at that long pylint output when I first tried it, and switched to another tool :) (pyflakes...but I don't think it does PEP 8) :-) Ok, so I'm not the only one who thinks the output is rather lengthy. I've since dug into the docs and searched on

Unbuffered keyboard input?

2009-06-09 Thread Ken D'Ambrosio
I need to have some non-buffered keyboard interaction with a Python script (on Linux). Back in the day, I fired up Curses to do this in Perl. Any idea if that's still how I have to fly? Or is there a different mechanism? Thanks! -Ken -- This message has been scanned for viruses and dangero

Re: Unbound Method Error

2009-06-09 Thread Piet van Oostrum
> "Enrico" <4...@755189.45> (E) wrote: >E> "Piet van Oostrum" ha scritto nel messaggio >E> news:m2ljo1ajnx@cs.uu.nl... >>> The method doesn't need the class at all, so a staticmethod would be >>> preferable: >>> class Funcoes: >>> @staticmethod >>> def CifradorDeCesar(self, mensagem, chav

Re: Using logging module to log into flash drive

2009-06-09 Thread Krzysztof Retel
> > Anyway there's a TimedRotatingFileHandler handler in the logging package: > > you can derive from it and change the emit/doRollover pair to hold the > > records > > until a device is not ready. > > Hm, that might be the way to go. Will have a try. I had another look at the logging package. Th

What is the actual type of "interrupted system call"?

2009-06-09 Thread mrstevegross
I'm trying to write a try/catch block to handle an "interrupted system call". However, I can't seem to locate information on the actual typename of the exception. Does anyone know what it would be? I want my code to look like this: try: ... except InterruptedSystemCall # what's the right name?

Re: preferring [] or () in list of error codes?

2009-06-09 Thread Terry Reedy
Steven D'Aprano wrote: James Tauber explains this at http://jtauber.com/blog/2006/04/15/ python_tuples_are_not_just_constant_lists/>. He doesn't really explain anything though, he merely states it as revealed wisdom. The closest he comes to an explanation is to declare that in tuples "the i

Re: Function/method returning list of chars in string?

2009-06-09 Thread Miles Kaufmann
On Jun 9, 2009, at 6:05 AM, Diez B. Roggisch wrote: Also as list-comps are going away and are replaced by list() Where did you hear that? -Miles -- http://mail.python.org/mailman/listinfo/python-list

Re: preferring [] or () in list of error codes?

2009-06-09 Thread Terry Reedy
m...@pixar.com wrote: John Machin wrote: T=lambda x:x in(25401,25402,25408);import dis;dis.dis(L);dis.dis(T) I've learned a lot from this thread, but this is the niftiest bit I've picked up... thanks! If you are doing a lot of dissing, starting with from dis import dis saves subsequent typi

spawning a process using os.spawn

2009-06-09 Thread rkmr...@gmail.com
hi im spawning a script that runs for a long from a web app like this: os.spawnle(os.P_NOWAIT, "../bin/producenotify.py", "producenotify.py", "xx",os.environ) the script is spawned and it runs, but till it gets over i am not able to free the port that is used by the web app, or in other words i

Re: Unbuffered keyboard input?

2009-06-09 Thread Grant Edwards
On 2009-06-09, Ken D'Ambrosio wrote: > I need to have some non-buffered keyboard interaction with a Python script > (on Linux). Back in the day, I fired up Curses to do this in Perl. Any > idea if that's still how I have to fly? Or is there a different > mechanism? Same as it ever was (in the

Re: Unbuffered keyboard input?

2009-06-09 Thread Jerry Hill
On Tue, Jun 9, 2009 at 1:52 PM, Ken D'Ambrosio wrote: > I need to have some non-buffered keyboard interaction with a Python script > (on Linux). Assuming you're running your code from a command prompt, something like this recipe might do the trick: http://code.activestate.com/recipes/134892/ --

Re: multi-core software

2009-06-09 Thread Jon Harrop
toby wrote: > On Jun 7, 2:41 pm, Jon Harrop wrote: >> Arved Sandstrom wrote: >> > Jon Harrop wrote: >> >> I see no problem with mutable shared state. >> >> > In which case, Jon, you're in a small minority. >> >> No. Most programmers still care about performance > > Frequently when they shouldn't.

Re: Using logging module to log into flash drive

2009-06-09 Thread Carl Banks
On Jun 9, 8:57 am, kretel wrote: > Hi All, > > I am trying to implement the following functionality: > 1. log messages to the flash drive > 2. if the flash drive is not available, switch handler to the > BufferringHandler and log into buffer, > 3. once the flash drive is plugged in and available s

Re: What is the actual type of "interrupted system call"?

2009-06-09 Thread mrstevegross
> exceptions.EOFError exceptions.ReferenceError exceptions.ZeroDivisionError >... > exceptions.NotImplementedError exceptions.UnicodeError exceptions.__str__ Is there a single parent exception to all those? Or should I just write it as: try: ... catch Exception: ... Thanks, --Steve -- http://

Re: What is the actual type of "interrupted system call"?

2009-06-09 Thread Jean-Michel Pichavant
mrstevegross wrote: I'm trying to write a try/catch block to handle an "interrupted system call". However, I can't seem to locate information on the actual typename of the exception. Does anyone know what it would be? I want my code to look like this: try: ... except InterruptedSystemCall # wh

Re: What is the actual type of "interrupted system call"?

2009-06-09 Thread Jeff McNeil
On Jun 9, 2:22 pm, mrstevegross wrote: > I'm trying to write a try/catch block to handle an "interrupted system > call". However, I can't seem to locate information on the actual > typename of the exception. Does anyone know what it would be? I want > my code to look like this: > > try: >   ... >

csv.reader has trouble with comma inside quotes inside brackets

2009-06-09 Thread Bret
i have a csv file like so: row1,field1,[field2][text in field2 "quote, quote"],field3,field row2,field1,[field2]text in field2 "quote, quote",field3,field using csv.reader to read the file, the first row is broken into two fields: [field2][text in field2 "quote and quote" while the second row is

Re: Start the interactive shell within an application

2009-06-09 Thread Robert Kern
On 2009-06-09 03:49, Jean-Michel Pichavant wrote: I was wondering if there is a way to start an interactive shell within a script/application. I'm sometimes tired of adding prints to scan the current namespace so I'd like to pause the execution and give the user the shell prompt. This is obviousl

Re: What is the actual type of "interrupted system call"?

2009-06-09 Thread mrstevegross
> That works for me.  There isn't an "InterruptedSystemCall" error or > equivalent in the standard exception hierarchy.  EnvironmentError is > the parent of OSError & IOError, which is where you'll most likely be > encountering that state. Thanks! --Steve -- http://mail.python.org/mailman/listinf

Re: SPAM-LOW: Re: Function/method returning list of chars in string?

2009-06-09 Thread Terry Reedy
Hendrik van Rooyen wrote: I should have known - you use a string method to get a list of words, but you have to go to the list to get a list of characters from a string. That is symmetry. There is no string method to do it, which is what I am complaining about. That would be asymmetry.

Re: Function/method returning list of chars in string?

2009-06-09 Thread Terry Reedy
jon vs. python wrote: Sorry, I didn't realize that you already proposed list comprehension. There is some kind of asymmetry in several areas.I guess that's somehow related to this post: http://www.zedshaw.com/blog/2009-05-29.html The premise of this post by Zed the Insightful is that Python

setting program name, like $0= in perl?

2009-06-09 Thread mh
I'm sure this is a FAQ, but I certainly haven't been able to find an answer. Is it possible to set the program name as seen by the operating system or lower-level libraries? I'm connecting to a database, and the runtime helpfully sends some information to the server, such as username, pid, and pr

Re: multi-core software

2009-06-09 Thread George Neuner
On Tue, 9 Jun 2009 10:47:11 -0700 (PDT), toby wrote: >On Jun 7, 2:41 pm, Jon Harrop wrote: >> Arved Sandstrom wrote: >> > Jon Harrop wrote: >> >> performance means mutable state. > >Hm, not sure Erlangers would wholly agree. Erlang uses quite a bit of mutable state behind the scenes ... the pro

Re: Function/method returning list of chars in string?

2009-06-09 Thread Robert Kern
On 2009-06-09 14:43, Terry Reedy wrote: jon vs. python wrote: Sorry, I didn't realize that you already proposed list comprehension. There is some kind of asymmetry in several areas.I guess that's somehow related to this post: http://www.zedshaw.com/blog/2009-05-29.html The premise of this po

Re: Function/method returning list of chars in string?

2009-06-09 Thread Terry Reedy
Miles Kaufmann wrote: On Jun 9, 2009, at 6:05 AM, Diez B. Roggisch wrote: Also as list-comps are going away and are replaced by list() Where did you hear that? Perhaps in the discussion of possible changes for 3.0 about 18 months ago. The idea was rejected because set/list/dict(genexp) i

Re: csv.reader has trouble with comma inside quotes inside brackets

2009-06-09 Thread John Machin
Bret gmail.com> writes: > > i have a csv file like so: > row1,field1,[field2][text in field2 "quote, quote"],field3,field > row2,field1,[field2]text in field2 "quote, quote",field3,field > > using csv.reader to read the file, the first row is broken into two > fields: > [field2][text in field2

Re: setting program name, like $0= in perl?

2009-06-09 Thread Emile van Sebille
On 6/9/2009 1:06 PM m...@pixar.com said... I'm sure this is a FAQ, but I certainly haven't been able to find an answer. Is it possible to set the program name as seen by the operating system or lower-level libraries? I'm connecting to a database, and the runtime helpfully sends some information

Re: setting program name, like $0= in perl?

2009-06-09 Thread Daniel Fetchinson
> I'm sure this is a FAQ, but I certainly haven't been able > to find an answer. > > Is it possible to set the program name as seen by the > operating system or lower-level libraries? > > I'm connecting to a database, and the runtime helpfully > sends some information to the server, such as usernam

Re: csv.reader has trouble with comma inside quotes inside brackets

2009-06-09 Thread Terry Reedy
Bret wrote: i have a csv file like so: row1,field1,[field2][text in field2 "quote, quote"],field3,field row2,field1,[field2]text in field2 "quote, quote",field3,field using csv.reader to read the file, the first row is broken into two fields: [field2][text in field2 "quote and quote" while the

Re: csv.reader has trouble with comma inside quotes inside brackets

2009-06-09 Thread Bret
Thanks John, I didn't realize that the quotes were supposed to surround the entire field. I ended up making a quick script to replace comma's outside quotes with tabs. I was just trying to clean this crazy "csv" file to import into msyql. thanks again, bret -- http://mail.python.org/mailman/l

Re: multi-core software

2009-06-09 Thread Dimiter "malkia" Stanev
Erlang uses quite a bit of mutable state behind the scenes ... the programmers just don't see it. George Heh... "The CPUs use quite a bit of mutable state behind the scenes ... the programmers just don't see it." Actually with CPU they see it more, than... say Erlang (that's why you need to

random number including 1 - i.e. [0,1]

2009-06-09 Thread Esmail
Hi, random.random() will generate a random value in the range [0, 1). Is there an easy way to generate random values in the range [0, 1]? I.e., including 1? I am implementing an algorithm and want to stay as true to the original design specifications as possible though I suppose the difference

Re: Function/method returning list of chars in string?

2009-06-09 Thread Terry Reedy
Robert Kern wrote: On 2009-06-09 14:43, Terry Reedy wrote: jon vs. python wrote: Python and the stdlib is all open source. If he were to submit a patch, and it were ignored or rejected for whatever reason, he could still release it and register it on PyPI. I just checked and NONE of the 6710

Re: multi-core software

2009-06-09 Thread Emile van Sebille
On 6/9/2009 11:59 AM Jon Harrop said... toby wrote: On Jun 7, 2:41 pm, Jon Harrop wrote: No. Most programmers still care about performance Frequently when they shouldn't. I disagree. A lot of software is still far too slow because the programmers failed to pay attention to performance.

.pth files and figuring out valid paths..

2009-06-09 Thread rh0dium
I have a .pth file which has some logic in it - but it isn't quite enough... It started with this.. import os, site; site.addsitedir(os.path.join(os.environ["TECHROOT"], "tools/python/modules")) But that eventually evolved into.. import os, site; site.addsitedir(os.path.join(os.environ.get ("TECH

Re: SPAM-LOW: Re: Function/method returning list of chars in string?

2009-06-09 Thread Carl Banks
On Jun 9, 12:42 pm, Terry Reedy wrote: > Hendrik van Rooyen wrote: > > I should have known - you use a string method to get a list of words, > > but you have to go to the list to get a list of characters from a string. > > That is symmetry. > > > There is no string method to do it, which is what I

Re: Function/method returning list of chars in string?

2009-06-09 Thread Robert Kern
On 2009-06-09 16:34, Terry Reedy wrote: Robert Kern wrote: On 2009-06-09 14:43, Terry Reedy wrote: jon vs. python wrote: Python and the stdlib is all open source. If he were to submit a patch, and it were ignored or rejected for whatever reason, he could still release it and register it on P

Re: SPAM-LOW: Re: Function/method returning list of chars in string?

2009-06-09 Thread Robert Kern
On 2009-06-09 17:06, Carl Banks wrote: On Jun 9, 12:42 pm, Terry Reedy wrote: Hendrik van Rooyen wrote: I should have known - you use a string method to get a list of words, but you have to go to the list to get a list of characters from a string. That is symmetry. There is no string method

Re: .pth files and figuring out valid paths..

2009-06-09 Thread Emile van Sebille
On 6/9/2009 3:00 PM rh0dium said... I have a .pth file which has some logic in it - but it isn't quite enough... It started with this.. import os, site; site.addsitedir(os.path.join(os.environ["TECHROOT"], "tools/python/modules")) But that eventually evolved into.. import os, site; site.addsite

Re: random number including 1 - i.e. [0,1]

2009-06-09 Thread Gabriel Genellina
En Tue, 09 Jun 2009 18:33:39 -0300, Esmail escribió: random.random() will generate a random value in the range [0, 1). Is there an easy way to generate random values in the range [0, 1]? I.e., including 1? I think you shouldn't worry about that - the difference may be as small as 2**-53, o

Re: random number including 1 - i.e. [0,1]

2009-06-09 Thread Mensanator
On Jun 9, 4:33 pm, Esmail wrote: > Hi, > > random.random() will generate a random value in the range [0, 1). > > Is there an easy way to generate random values in the range [0, 1]? > I.e., including 1? > > I am implementing an algorithm and want to stay as true to the > original design specificati

Re: random number including 1 - i.e. [0,1]

2009-06-09 Thread Robert Kern
On 2009-06-09 18:05, Mensanator wrote: On Jun 9, 4:33 pm, Esmail wrote: Hi, random.random() will generate a random value in the range [0, 1). Is there an easy way to generate random values in the range [0, 1]? I.e., including 1? I am implementing an algorithm and want to stay as true to the

Re: random number including 1 - i.e. [0,1]

2009-06-09 Thread Miles Kaufmann
On Jun 9, 2009, at 7:05 PM, Mensanator wrote: On Jun 9, 4:33 pm, Esmail wrote: Hi, random.random() will generate a random value in the range [0, 1). Is there an easy way to generate random values in the range [0, 1]? I.e., including 1? I am implementing an algorithm and want to stay as true

Re: .pth files and figuring out valid paths..

2009-06-09 Thread rh0dium
On Jun 9, 3:28 pm, Emile van Sebille wrote: > On 6/9/2009 3:00 PM rh0dium said... > > > > > > > I have a .pth file which has some logic in it - but it isn't quite > > enough... > > > It started with this.. > > import os, site; site.addsitedir(os.path.join(os.environ["TECHROOT"], > > "tools/python/

Re: Any idea of stopping the execution of PyRun_File()

2009-06-09 Thread Gabriel Genellina
En Mon, 08 Jun 2009 22:15:22 -0300, BigHand escribió: I have an embedded python application. which is a MFC app with Python interpreter embedded. In the App, I have a separate thread to execute a Python script (using the PyRun_File), but if the user want to stop the executing script, ho

Re: preferring [] or () in list of error codes?

2009-06-09 Thread Steven D'Aprano
On Tue, 09 Jun 2009 04:57:48 -0700, samwyse wrote: > Time to test things! I'm going to compare three things using Python > 3.0: > X={...}\nS=lambda x: x in X > S=lambda x: x in {...} > S=lambda x: x in (...) > where the ... is replaced by lists of integers of various lengths. > Here's the

Re: random number including 1 - i.e. [0,1]

2009-06-09 Thread Esmail
Gabriel Genellina wrote: En Tue, 09 Jun 2009 18:33:39 -0300, Esmail escribió: random.random() will generate a random value in the range [0, 1). Is there an easy way to generate random values in the range [0, 1]? I.e., including 1? I think you shouldn't worry about that - the difference may

Re: random number including 1 - i.e. [0,1]

2009-06-09 Thread Esmail
Robert Kern wrote: On 2009-06-09 18:05, Mensanator wrote: On Jun 9, 4:33 pm, Esmail wrote: That's wrong. Where did you get it? http://docs.python.org/library/random What he said :-) (thanks Robert) -- http://mail.python.org/mailman/listinfo/python-list

Re: random number including 1 - i.e. [0,1]

2009-06-09 Thread Esmail
Miles Kaufmann wrote: I'm curious what algorithm calls for random numbers on a closed interval. I'm implementing a Particle Swarm Optimizer. Depending on what paper you read you'll see mention of required random values "between 0 and 1" which is somewhat ambiguous. I came across one paper that

Re: .pth files and figuring out valid paths..

2009-06-09 Thread David Lyon
On Tue, 9 Jun 2009 16:30:06 -0700 (PDT), rh0dium wrote: >> > Apparently there is a problem with the if statement??? >> >> > Thanks > > No for .pth files this needs to be on a single line.. I can't really see why you need conditional code... If you want to add more locations... Simply create a

  1   2   >