Re: Replace in large text file ?

2010-06-06 Thread Nobody
On Sat, 05 Jun 2010 16:35:42 +0100, MRAB wrote: >>> In plain language what I wish to do is: >>> >>> Remove all comma's >>> Replace all @ with comma's >> input_file = open("some_huge_file.txt", "r") >> output_file = open("newfilename.txt", "w") >> for line in input_file: > I'd probably process it

Re: GUIs - A Modest Proposal

2010-06-07 Thread Nobody
On Sun, 06 Jun 2010 15:55:41 -0700, ant wrote: > If we are to make progress, I can see two obvious approaches: > 1) Improve Tkinter to the point where it is supportable and supported > by a good fraction of Python programmers > or > 2) Drop Tkinter as the default and use something else. You forgo

Re: Reading file bit by bit

2010-06-07 Thread Nobody
On Mon, 07 Jun 2010 02:31:08 -0700, Richard Thomas wrote: > You're reading those bits backwards. You want to read the most > significant bit of each byte first... Says who? There is no universal standard for bit-order. Among bitmap image formats, XBM is LSB-first while BMP and PBM are MSB-first

Re: How do subprocess.Popen("ls | grep foo", shell=True) with shell=False?

2010-06-10 Thread Nobody
On Wed, 09 Jun 2010 21:15:48 -0700, Chris Seberino wrote: > How do subprocess.Popen("ls | grep foo", shell=True) with shell=False? The same way that the shell does it, e.g.: from subprocess import Popen, PIPE p1 = Popen("ls", stdout=PIPE) p2 = Popen(["grep", "foo"], stdin=p1.stdout, stdout

Re: How do subprocess.Popen("ls | grep foo", shell=True) with shell=False?

2010-06-12 Thread Nobody
On Thu, 10 Jun 2010 08:40:03 -0700, Chris Seberino wrote: > On Jun 10, 6:52 am, Nobody wrote: >> Without the p1.stdout.close(), if the reader (grep) terminates before >> consuming all of its input, the writer (ls) won't terminate so long as >> Python retains the desc

Re: Python OpenSSL library

2010-06-14 Thread Nobody
On Mon, 14 Jun 2010 10:43:02 -0700, John Nagle wrote: > The new SSL module in Python 2.6 There isn't an SSL module in Python 2.6. There is a module named "ssl" which pretends to implement SSL, but in fact doesn't. > is convenient, but insecure. In which case, it isn't actually convenient, i

Re: Python OpenSSL library

2010-06-15 Thread Nobody
On Tue, 15 Jun 2010 22:57:24 +0200, Antoine Pitrou wrote: > Also, following issue1589 (certificate hostname checking), I think it > would be useful at least to provide the necessary helper functions in > order to check certificate conformity, even if they aren't called > implicitly. I would encour

Re: How do I fix this test so it runs on Windows? (it uses tzset)

2010-06-16 Thread Nobody
On Wed, 16 Jun 2010 16:30:02 +0100, Chris Withers wrote: > I'd like to make test_non_gmt_timezone at the bottom of > https://... > run on Windows, any suggestions? MSVCRT has _tzset(), which understands the TZ environment variable. http://msdn.microsoft.com/en-us/library/90s5c885%28VS.80%29.asp

Re: Writing to open subprocess pipes.

2010-06-16 Thread Nobody
On Wed, 16 Jun 2010 16:29:42 -0400, Brandon McGinty wrote: > Both subprocess and os.popen* only allow inputput and output one time, > and the output to be read only when the process terminates. This is incorrect; you can read from and write to the pipe as you wish. However: you may have problems

Re: How do I fix this test so it runs on Windows? (it uses tzset)

2010-06-18 Thread Nobody
On Thu, 17 Jun 2010 11:45:03 +0100, Chris Withers wrote: >> For whatever reason, tython's "time" module doesn't provide the tzset() >> function on Windows. However, you should be able to use it via ctypes. > > This sounds pretty heavyweight for a unit test. > I'm not even sure how I would do this

Re: Communicating with a program using subprocess

2010-06-18 Thread Nobody
On Thu, 17 Jun 2010 11:22:37 +0200, Laurent Verweijen wrote: > This is easy to understand, but I want to pipe it's input/output > by another python program. (I will show what I am doing on the > console to test it) > > >>> from subprocess import * > >>> p =

Re: daemonizing after binding to port

2010-06-20 Thread Nobody
On Sun, 20 Jun 2010 20:00:14 +1000, Ben Finney wrote: >> I'm starting a SocketServer.TCPServer in my program, but since I want >> to report problems to script starting the program, I want to go daemon >> *after* TCPServer has done binding to port. >> >> Is this likely to cause problems? I mean, my

Re: Pick items from list with probability based upon property of list member ?

2010-06-20 Thread Nobody
On Sun, 20 Jun 2010 03:19:55 -0700, southof40 wrote: > I want to select an object from the list with a probability of : cars > 0.7, bikes 0.3, trucks 0.1. > > I've currently implemented this by creating another list in which each > car object from the original list appears 7 times, each bike 3 ti

Re: Pythonic Idiom For Searching An Include Path

2010-06-24 Thread Nobody
On Wed, 23 Jun 2010 17:27:16 -0500, Tim Daneliuk wrote: > Given a program 'foo' that takes a command line argument '-I > includefile', I want to be able to look for 'includefile' in a path > specified in an environment variable, 'FOOPATH'. > > I'd like a semantic that says: > > "If 'includefil

Re: Why Is Escaping Data Considered So Magical?

2010-06-24 Thread Nobody
On Fri, 25 Jun 2010 12:25:56 +1200, Lawrence D'Oliveiro wrote: > Just been reading this article > ... > which says that a lot of security holes are arising these days because > everybody is concentrating on unit testing of their own particular > components, with less attention being devoted to ove

Re: Why Is Escaping Data Considered So Magical?

2010-06-25 Thread Nobody
On Fri, 25 Jun 2010 12:15:08 +, Jorgen Grahn wrote: > I don't do SQL and I don't even understand the terminology properly > ... but the discussion around it bothers me. > > Do those people really do this? Yes. And then some. Among web developers, the median level of programming knowledge am

Re: Why Is Escaping Data Considered So Magical?

2010-06-26 Thread Nobody
On Sat, 26 Jun 2010 12:40:41 +1200, Lawrence D'Oliveiro wrote: >>> I construct ad-hoc queries all the time. It really isn’t that hard to >>> do safely. >> >> Wrong. >> >> Even if you get the quoting absolutely correct (which is a very big "if"), >> you have to remember to perform it every time,

Re: Why Is Escaping Data Considered So Magical?

2010-06-26 Thread Nobody
On Fri, 25 Jun 2010 20:43:51 -0400, Roy Smith wrote: > To bring this back to something remotely Python related, the point of > all this is that security is hard. Oh, this isn't solely a security issue. Ask anyone with a surname like O'Neil, O'Connor, O'Leary, etc; they've probably broken a lot

Re: improving python performance by extension module (64bit)

2010-06-26 Thread Nobody
On Fri, 25 Jun 2010 20:08:27 -0400, geremy condra wrote: > I have written Haskell that runs faster than C, and Forth that runs > faster than C, Faster than *what* C, though? With Haskell, there's seldom a significant performance hit for using -fvia-C, so you would probably have been able to get

Re: I strongly dislike Python 3

2010-06-26 Thread Nobody
On Sat, 26 Jun 2010 18:33:02 +0200, Thomas Jollans wrote: > * str is now unicode => unicode is no longer a pain in the a True. Now byte strings are a pain in the arse. -- http://mail.python.org/mailman/listinfo/python-list

Re: I strongly dislike Python 3

2010-06-26 Thread Nobody
On Sat, 26 Jun 2010 21:08:48 +0200, Martin v. Loewis wrote: >> I think that's not true. If enough people want to support Python 2 it >> might be possible to advance Python 2. > > That won't be sufficient: enough people wanting support won't have any > effect. People also need to want it enough to

Re: Why Is Escaping Data Considered So Magical?

2010-06-27 Thread Nobody
On Sun, 27 Jun 2010 14:36:10 +1200, Lawrence D'Oliveiro wrote: >> In any case, you're still trying to make arguments about whether it's easy >> or hard to get it right, which completely misses the point. Eliminating >> the escaping entirely makes it impossible to

Re: Why are String Formatted Queries Considered So Magical?

2010-06-29 Thread Nobody
On Tue, 29 Jun 2010 12:30:36 +1200, Lawrence D'Oliveiro wrote: >> Seriously, almost every other kind of library uses a binary API. What >> makes databases so special that they need a string-command based API? > > HTML is also effectively a string-based API. HTML is a data format. The sane way to

Re: Why are String Formatted Queries Considered So Magical?

2010-06-30 Thread Nobody
On Tue, 29 Jun 2010 08:41:03 -0400, Roy Smith wrote: >> > And what about regular expressions? >> >> What about them? As the saying goes: >> >> Some people, when confronted with a problem, think >> "I know, I'll use regular expressions." >> Now they have two problems. > > That's s

Re: [farther OT] Re: Why Is Escaping Data Considered So Magical?

2010-07-01 Thread Nobody
On Wed, 30 Jun 2010 23:40:06 -0600, Michael Torrie wrote: > Given "char buf[512]", buf's type is char * according to the compiler > and every C textbook I know of. No, the type of "buf" is "char [512]", i.e. "array of 512 chars". If you use "buf" as an rvalue (rather than an lvalue), it will be i

Re: Very odd output from subprocess

2010-07-01 Thread Nobody
On Wed, 30 Jun 2010 21:12:12 -0700, m wrote: > If I add the line: > for l in line: print ord(l),'\t',l > after the first readline, I get the following: > > > 27 > 91[ > 480 > 480 > 109 m > 27 > 91[ > 513 > 557 > 109 m > > before the codes begin for the

Re: The real problem with Python 3 - no business case for conversion (was "I strongly dislike Python 3")

2010-07-03 Thread Nobody
On Fri, 02 Jul 2010 12:07:33 -0700, John Nagle wrote: >> I think one point which needs to be emphasized more is what does >> python 3 bring to people. The" what's new in python 3 page" gives >> the impression that python 3 is about removing cruft. That's a very >> poor argument to push people to s

Re: subprocess query

2010-07-03 Thread Nobody
On Sat, 03 Jul 2010 10:33:49 -0400, Sudheer wrote: > What's wrong with the following code. The program waits indefenitely > at 'output = p2.stdout.read()' > > > from subprocess import * > > p1=Popen(['tr', 'a-z', 'A-Z'],stdin=PIPE,stdout=PIPE) > p2=Popen(['tr','A-Z', 'a-z'],stdin=p1.stdout,st

Re: Python -- floating point arithmetic

2010-07-07 Thread Nobody
On Wed, 07 Jul 2010 15:08:07 +0200, Thomas Jollans wrote: > you should never rely on a floating-point number to have exactly a > certain value. "Never" is an overstatement. There are situations where you can rely upon a floating-point number having exactly a certain value. First, floating-point

Re: why is this group being spammed?

2010-07-19 Thread Nobody
On Sun, 18 Jul 2010 15:18:59 -0700, sturlamolden wrote: >> why is this group being spammed? > > There used to be bots that issued cancel messages against spam, but I > don't think they are actively maintained anymore. Mostly because cancel messages are invariably ignored nowadays. -- http://ma

Re: how to copy and move file with its attribute?

2010-07-19 Thread Nobody
On Mon, 19 Jul 2010 17:57:31 +0100, MRAB wrote: >> About this one. I tried the os.system copy. But it seems I cant find the >> right syntax. >> >> *os.system ("xcopy /s %s %s" % (dirname1, dirname2))* >> >> This one seems to not working. >> > In what way doesn't it work? > > If the names cont

Re: CPython Signal Handler Check for SIGKILL

2010-07-19 Thread Nobody
On Mon, 19 Jul 2010 20:06:16 +0200, Antoine Pitrou wrote: > So, in short, Python doesn't check SIGKILL by itself. It's just > forbidden by the underlying C standard library, Actually, it's forbidden by the kernel. The C library just passes along the error to Python, which just passes it to the ap

Re: Kick off a delete command from python and not wait

2010-07-20 Thread Nobody
On Tue, 20 Jul 2010 10:32:12 -0700, Chris Rebert wrote: > I believe you need to /eventually/ call .wait() as shown to avoid the > child becoming a zombie process. Alternatively, you can call .poll() periodically. This is similar to .wait() insofar as it will "reap" the process if it has terminate

Re: non-blocking IO EAGAIN on write

2010-07-23 Thread Nobody
On Fri, 23 Jul 2010 10:45:32 +0200, Thomas Guettler wrote: > I use non-blocking io to check for timeouts. Sometimes I get EAGAIN > (Resource temporarily unavailable) on write(). My working code looks > like this. But I am unsure how many bytes have been written to the pipe > if I get an EAGAIN IOE

Re: Unicode error

2010-07-23 Thread Nobody
On Fri, 23 Jul 2010 10:42:26 +, Steven D'Aprano wrote: > Don't write bare excepts, always catch the error you want and nothing > else. That advice would make more sense if it was possible to know which exceptions could be raised. In practice, that isn't possible, as the documentation seldom

Re: Unicode error

2010-07-25 Thread Nobody
On Fri, 23 Jul 2010 18:27:50 -0400, Terry Reedy wrote: > But in the > meanwhile, once you get an error, you know what it is. You can > intentionally feed code bad data and see what you get. And then maybe > add a test to make sure your code traps such errors. That doesn't really help with exce

Re: Unicode error

2010-07-25 Thread Nobody
On Sun, 25 Jul 2010 14:47:11 +, Steven D'Aprano wrote: >>> But in the >>> meanwhile, once you get an error, you know what it is. You can >>> intentionally feed code bad data and see what you get. And then maybe >>> add a test to make sure your code traps such errors. >> >> That doesn't really

Re: How to capture all the environment variables from shell?

2010-07-27 Thread Nobody
On Mon, 26 Jul 2010 21:42:24 -0500, Tim Chase wrote: >> Please! Never export anything from your .bashrc unless you >> really know what you're doing. Almost all exports should be >> done in your .bash_profile > > Could you elaborate on your reasoning why (or why-not)? I've > found that my .bash_

Re: Ascii to Unicode.

2010-07-29 Thread Nobody
On Thu, 29 Jul 2010 23:49:40 +, Steven D'Aprano wrote: > It looks to me like Python uses a 16-bit implementation internally, It typically uses the platform's wchar_t, which is 16-bit on Windows and (typically) 32-bit on Unix. IIRC, it's possible to build Python with 32-bit Unicode on Windows

Re: run subprocesses in parallel

2010-08-02 Thread Nobody
On Mon, 02 Aug 2010 14:21:38 +0200, Christian Heimes wrote: > You might want to drop shell=True and use > a list as arguments instead. The two issues (whether "shell" is True/False and whether the command is a list or string) are orthogonal. You should always use a list for the command, unless y

Re: Why is python not written in C++ ?

2010-08-03 Thread Nobody
On Mon, 02 Aug 2010 17:17:35 -0700, Peter wrote: > But I always used to tell > people - by the time I got a program to compile then I figured 99% of > the bugs were already discovered! Try that with C/C++ or almost any > other language you care to name :-) ML and Haskell are also quite good for t

Re: Why is python not written in C++ ?

2010-08-03 Thread Nobody
On Mon, 02 Aug 2010 15:18:30 -0700, sturlamolden wrote: >> Has it ever been planned to rewrite in C++ the historical implementation >> (of course in an object oriented design) ? > > OO programming is possible in C. Just take a look at GNOME and GTK. One feature which can't readily be implemente

Re: checking that process binds a port, fuser functionality

2010-08-03 Thread Nobody
On Mon, 02 Aug 2010 23:27:37 +0200, Zdenek Maxa wrote: > I need to start a process (using subprocess.Popen()) and wait until the > new process either fails or successfully binds a specified port. The > fuser command seems to be indented exactly for this purpose. Could > anyone please provided a hi

Re: Why is python not written in C++ ?

2010-08-03 Thread Nobody
On Tue, 03 Aug 2010 18:48:24 +1000, James Mills wrote: >> One feature which can't readily be implemented in C is the automatic >> clean-up side of the RAII idiom. > > C is a Turing-Complete Language is it not ? > > If so, therefore is it not true "anything" can be implemented ? > Even the "autom

Re: subprocess escaping POpen?!

2010-08-05 Thread Nobody
On Thu, 05 Aug 2010 12:23:35 +0100, Chris Withers wrote: >>> ...then the output is indeed captured. So, what is svn doing >>> differently? How is it escaping its jail? >> >> maybe it does not read from stdin but directly from /dev/tty > > But why only the request for auth credentials? So that

Re: ctypes: pointer to method

2010-08-05 Thread Nobody
On Thu, 05 Aug 2010 10:50:21 -0700, Martin Landa wrote: > is it possible to pass pointer to a method using ctypes. I don't know about methods, but it works for functions. > Sample code: > > ... > G_set_error_routine(byref(self._print_error)) This won't work; you have to be more explici

Re: How to read large amounts of output via popen

2010-08-06 Thread Nobody
On Fri, 06 Aug 2010 02:06:29 -0700, loial wrote: > I need to read a large amount of data that is being returned in > standard output by a shell script I am calling. > > (I think the script should really be writing to a file but I have no > control over that) If the script is writing to stdout, y

Re: Is there any way to minimize str()/unicode() objects memory usage [Python 2.6.4] ?

2010-08-07 Thread Nobody
On Fri, 06 Aug 2010 18:39:27 -0700, dmtr wrote: > Steven, thank you for answering. See my comments inline. Perhaps I > should have formulated my question a bit differently: Are there any > *compact* high performance containers for unicode()/str() objects in > Python? By *compact* I don't mean comp

Re: Python "why" questions

2010-08-07 Thread Nobody
On Sat, 07 Aug 2010 09:53:48 -0400, D'Arcy J.M. Cain wrote: >> A new born baby is in his/her first year. It's year 1 of his/her life. >> For this reason, also "the year 0" doesn't exist. From the fact that a >> baby can be half a year old, you derive that arrays should have floats >> as indi

Re: Python "why" questions

2010-08-07 Thread Nobody
On Sat, 07 Aug 2010 13:48:32 +0200, News123 wrote: >> "Common sense" is wrong. There are many compelling advantages to >> numbering from zero instead of one: >> >> http://lambda-the-ultimate.org/node/1950 > > It makes sense in assembly language and even in many byte code languages. > It makes

Re: easy question on parsing python: "is not None"

2010-08-09 Thread Nobody
On Mon, 09 Aug 2010 04:41:23 -0700, saeed.gnu wrote: > "x is not None" is a really silly statement!! because id(None) and id > of any constant object is not predictable! I don't know whay people > use "is" instead of "==". you should write "if x!=None" instead of "x > is not None" No, you should

Re: How to capture all the environment variables from shell?

2010-08-11 Thread Nobody
On Wed, 11 Aug 2010 13:08:59 +1000, Cameron Simpson wrote: > The reason .bashrc gets overused for envars, aside from ignorance and > propagated bad habits, is that in a GUI desktop the setup sequence is > often a bit backwards. A conventional terminal/console login means you > get a login shell th

Re: Line-by-line processing when stdin is not a tty

2010-08-11 Thread Nobody
On Wed, 11 Aug 2010 10:32:41 +, Tim Harig wrote: >>> Usually you either >>> need an option on the upstream program to tell it to line >>> buffer explicitly >> >> once cat had an option -u doing exactly that but nowadays >> -u seems to be ignored >> >> http://www.opengroup.org/onlinepubs/009695

Re: Line-by-line processing when stdin is not a tty

2010-08-12 Thread Nobody
On Wed, 11 Aug 2010 18:49:26 -0700, RG wrote: > This doesn't explain why "cat | cat" when run interactively outputs > line-by-line (which it does). STDIN to the first cat is a TTY, but the > second one isn't. GNU cat doesn't use stdio, it uses read() and write(), so there isn't any buffering.

Re: Floating numbers

2010-08-12 Thread Nobody
On Thu, 12 Aug 2010 18:19:40 -0700, Benjamin Kaplan wrote: > But that's not keeping the number the way it was typed. It's just not > showing you the exact approximation. Nor is 34.523 showing you the "exact approximation". The closest "double" to 34.52 is 4858258098025923 / 2**47, wh

Re: Importing libs on Windows?

2010-08-12 Thread Nobody
On Thu, 12 Aug 2010 16:09:10 -0700, Brian Salter wrote: > I've seen a number of tutorials that describe how to bring in a dll in > python, but does anybody know of a tutorial for how to bring in a lib? Is > it even possible? No. ctypes relies upon the OS to actually load the library, and the O

Re: writing \feff at the begining of a file

2010-08-13 Thread Nobody
On Fri, 13 Aug 2010 11:45:28 +0200, Jean-Michel Pichavant wrote: > I'm trying to update the content of a $Microsoft$ VC2005 project files > using a python application. > Since those files are XML data, I assumed I could easily do that. > > My problem is that VC somehow thinks that the file is co

Re: 79 chars or more?

2010-08-17 Thread Nobody
On Mon, 16 Aug 2010 22:35:49 -0400, AK wrote: > As monitors are getting bigger, is there a general change in opinion on > the 79 chars limit in source files? I've experimented with 98 characters > per line and I find it quite a bit more comfortable to work with that > length, even though sometimes

Re: when 'myArray * 'myObject' is not equal to 'myObject' * 'myArray'

2010-08-18 Thread Nobody
On Wed, 18 Aug 2010 05:56:27 -0700, Duim wrote: > Although I'm sure somewhere this issue is discussed in this (great) > group, I didn't know the proper search words for it (although I > tried). > > I'm using python (2.6) scientifically mostly, and created a simple > class to store time series (my

Re: path to data files

2010-08-19 Thread Nobody
On Thu, 19 Aug 2010 14:30:34 +0200, Alain Ketterlin wrote: >> If a python module requires a data file to run how would I reference >> this data file in the source in a way that does not depend on whether >> the module is installed system-wide, installed in $HOME/.local or is >> just placed in a di

Re: Reading the access attributes of directories in Windows

2010-08-19 Thread Nobody
On Fri, 20 Aug 2010 00:04:29 +0200, Thomas Jollans wrote: > This brings up an interesting, but probably quite complicated question: is it > reasonable to try to express Windows permissions using full POSIX ACLs > Do Windows NT permissions do anything more? Or, apart from the > "executable" bit,

Re: Reading the access attributes of directories in Windows

2010-08-21 Thread Nobody
On Fri, 20 Aug 2010 19:41:44 +0200, Thomas Jollans wrote: >> "Create Folders" and "Delete Subfolders and Files" correspond to having >> write permission on a directory. > > How does append differ from write? If you have appending permissions, but not > writing ones, is it impossible to seek? Or

Re: Discarding STDERR generated during subprocess.popen

2010-08-23 Thread Nobody
On Mon, 23 Aug 2010 10:38:02 -0700, Leon Derczynski wrote: > I would like to run an external program, and discard anything written > to stderr during its execution, capturing only stdout. My code > currently looks like: > > def blaheta_tag(filename): > blaheta_dir = '/home/leon/signal_ann

Re: ElementTree.XML(string XML) and ElementTree.fromstring(string XML) not working

2009-06-25 Thread Nobody
On Thu, 25 Jun 2009 18:02:25 -0700, Kee Nethery wrote: > Summary: I have XML as string and I want to pull it into ElementTree > so that I can play with it but it is not working for me. XML and > fromstring when used with a string do not do the same thing as parse > does with a file. How do I

Re: validating HTTPS certificates?

2009-06-26 Thread Nobody
On Fri, 26 Jun 2009 10:04:21 +0200, Andras.Horvath wrote: > (disclaimer: this might be a FAQ entry somewhere but I honestly did use > Google) > > I'm in the process of picking a language for a client application that > accesses a HTTPS (actually SOAP) server. This would be easy enough in > Pytho

Re: What does Guido want in a GUI toolkit for Python?

2009-06-28 Thread Nobody
On Sat, 27 Jun 2009 17:17:22 -0700, Dennis Lee Bieber wrote: >> His concern really isn't what is in the toolkit, but what isn't. >> It must not require lots of lines of code to produce a simple >> GUI, it must not require specification of absolute coordinates, >> ... - you should be able to contin

Re: [RELEASED] Python 3.1 final

2009-06-28 Thread Nobody
On Sat, 27 Jun 2009 16:12:10 -0500, Benjamin Peterson wrote: > Python 3.1 focuses on the stabilization and optimization of the features and > changes that Python 3.0 introduced. For example, the new I/O system has been > rewritten in C for speed. File system APIs that use unicode strings now > h

Re: [RELEASED] Python 3.1 final

2009-06-28 Thread Nobody
On Sun, 28 Jun 2009 15:22:15 +, Benjamin Peterson wrote: > Nobody nowhere.com> writes: >> All in all, Python 3.x still has a long way to go before it will be >> suitable for real-world use. > > Such as? Such as not trying to shoe-horn every byte string it encounte

Re: [RELEASED] Python 3.1 final

2009-06-28 Thread Nobody
On Sun, 28 Jun 2009 19:21:49 +, Benjamin Peterson wrote: >> Yes, but do you get back the original byte strings? Maybe I'm missing >> something, but my impression is that this is still an issue for the email >> module as well as command-line arguments and environment variables. > > The email

Re: [RELEASED] Python 3.1 final

2009-06-28 Thread Nobody
On Sun, 28 Jun 2009 13:31:50 -0400, Terry Reedy wrote: >>> Nobody nowhere.com> writes: >>>> All in all, Python 3.x still has a long way to go before it will be >>>> suitable for real-world use. >>> Such as? >> >> Such as not trying to

Re: No trees in the stdlib?

2009-06-29 Thread Nobody
On Sun, 28 Jun 2009 20:54:11 -0700, Paul Rubin wrote: > João Valverde writes: >> Could you clarify what you mean by immutable? As in... not mutable? As >> in without supporting insertions and deletions? > > Correct. > >> That's has the same performance as using binary search on a sorted >>

Re: validating HTTPS certificates?

2009-06-29 Thread Nobody
On Mon, 29 Jun 2009 09:18:20 +0200, Andras.Horvath wrote: >> For a urllib-style interface, there's not much point in performing >> verification after the fact. Either the library performs verification or >> it doesn't. If it doesn't, you've just sent the (potentially confidential) >> request to an

Re: [RELEASED] Python 3.1 final

2009-06-29 Thread Nobody
On Sun, 28 Jun 2009 21:25:13 +, Benjamin Peterson wrote: >> > The email module is, yes, broken. You can recover the bytestrings of >> > command-line arguments and environment variables. >> >> 1. Does Python offer any assistance in doing so, or do you have to >> manually convert the surrogates

Re: [RELEASED] Python 3.1 final

2009-06-29 Thread Nobody
On Sun, 28 Jun 2009 14:36:37 +0200, Martin v. Löwis wrote: >> That's a significant improvement. It still decodes os.environ and sys.argv >> before you have a chance to call sys.setfilesystemencoding(), but it >> appears to be recoverable (with some effort; I can't find any way to re-do >> the enco

Re: [RELEASED] Python 3.1 final

2009-06-29 Thread Nobody
On Mon, 29 Jun 2009 13:57:49 +0200, Hallvard B Furuseth wrote: >> Okay, that's useful, except that it may have some bugs: >> (...) >> Assuming that this gets fixed, it should make most of the problems with >> 3.0 solvable. OTOH, it wouldn't have killed them to have added e.g. >> sys.argv_bytes and

Re: [RELEASED] Python 3.1 final

2009-06-29 Thread Nobody
On Mon, 29 Jun 2009 11:41:11 +, Antoine Pitrou wrote: > Nobody nowhere.com> writes: >> >> This results in an internal error: >> >> > "\udce4\udceb\udcef\udcf6\udcfc".encode("iso-8859-1", "surrogateescape") >> Traceb

Re: [RELEASED] Python 3.1 final

2009-06-29 Thread Nobody
On Mon, 29 Jun 2009 13:05:51 +0100, Paul Moore wrote: >> As for a bytes version of sys.argv and os.environ, you're welcome to >> propose a patch (this would be a separate issue on the aforementioned >> issue tracker). > > But please be aware that such a proposal would have to consider: > > 1. Th

Re: python library call equivalent to `which' command

2009-06-29 Thread Nobody
On Mon, 29 Jun 2009 13:53:30 -0500, Tim Pinkawa wrote: >> I'm looking for a Python library function that provides the same >> functionality as the `which' command--namely, search the $PATH >> variable for a given string and see if it exists anywhere within. I >> currently examine the output from

Re: Q: finding distance between 2 time's

2009-06-29 Thread Nobody
On Mon, 29 Jun 2009 19:15:08 +, John Gordon wrote: >> > if time_difference < 3601: > >> That's a potential off-by-one error. [...] The right test is: > >> if time_difference <= 3600: > > Aren't those two comparisons the same? Not if time_difference is a float. -- http://mail.pyth

Re: python library call equivalent to `which' command

2009-06-29 Thread Nobody
On Mon, 29 Jun 2009 14:31:25 -0500, Tim Pinkawa wrote: >> "if file in os.list()" is slow and not correct. You have to check if the >> file is either a real file or a symlink to a file and not a directory or >> special. Then you have to verify that the file has the executable bit, too. > > I reali

Re: python library call equivalent to `which' command

2009-06-29 Thread Nobody
On Mon, 29 Jun 2009 21:53:42 +0200, Christian Heimes wrote: >> I am curious about it being slow, though. Is there a faster way to get >> the contents of a directory than os.listdir() or is there a faster way >> to see if an element is in a list other than "x in y"? I believe >> 'which' will termin

Re: Direct interaction with subprocess - the curse of blocking I/O

2009-06-29 Thread Nobody
On Mon, 29 Jun 2009 21:15:52 +0200, Pascal Chambon wrote: > I've had real issues with subprocesses recently : from a python script, > on windows, I wanted to "give control" to a command line utility, i.e > forward user in put to it and display its output on console. Are you talking about a pope

Re: Using Python for file packing

2009-06-30 Thread Nobody
On Mon, 29 Jun 2009 14:16:34 -0700, Scott David Daniels wrote: >>> Do you mean like a zip or tar file? >>> >>> http://docs.python.org/library/zipfile.htmlhttp://docs.python.org/library/tarfile.html >>> >> >> I had no idea you could access a single file from a ZIP or TAR without >> explicitly extr

Re: PEP368 and pixeliterators

2009-07-02 Thread Nobody
On Thu, 02 Jul 2009 10:32:04 +0200, Joachim Strömbergson wrote: > I just read the PEP368 and really liked the proposed idea, sound like a > great battery addition to include in the std lib: > > http://www.python.org/dev/peps/pep-0368/ Unfortunately, it's too simplistic, meaning that most of the

Re: regex question on .findall and \b

2009-07-02 Thread Nobody
On Thu, 02 Jul 2009 09:38:56 -0700, Ethan Furman wrote: > Greetings! > > My closest to successfull attempt: > > Python 2.5.4 (r254:67916, Dec 23 2008, 15:10:54) [MSC v.1310 32 bit (Intel)] > Type "copyright", "credits" or "license" for more information. > > IPython 0.9.1 -- An enhanced Interact

Re: Code that ought to run fast, but can't due to Python limitations.

2009-07-04 Thread Nobody
On Sat, 04 Jul 2009 16:35:08 -0700, John Nagle wrote: > The temptation is to write tokenizers in C, but that's an admission > of language design failure. The only part that really needs to be written in C is the DFA loop. The code to construct the state table from regexps could be written ent

Re: Python and webcam capture delay?

2009-07-06 Thread Nobody
On Mon, 06 Jul 2009 20:41:03 +0300, jack catcher (nick) wrote: >> Does the webcam just deliver frames, or are you getting frames out of >> a decoder layer? If it's the latter, you want to distribute the encoded >> video, which should be much lower bandwidth. Exactly how you do that >> depends a

Re: Python and webcam capture delay?

2009-07-07 Thread Nobody
On Tue, 07 Jul 2009 09:01:39 +0300, jack catcher (nick) wrote: > Thanks for the comments. Unfortunately, such specifications aren't easy > to find, even in reviews. Fortunately several newer webcams seem at > least to use usb2. Supporting USB-2 doesn't mean that the camera necessarily uses high

Re: Python and webcam capture delay?

2009-07-08 Thread Nobody
On Tue, 07 Jul 2009 22:49:22 -0700, Dennis Lee Bieber wrote: > On Tue, 07 Jul 2009 23:37:43 +0100, Nobody > declaimed the following in gmane.comp.python.general: > >> AFAIK, the only real difference between "USB-1 conformant" and "USB-2 >> conformant"

Re: Python and webcam capture delay?

2009-07-08 Thread Nobody
On Tue, 07 Jul 2009 22:11:12 -0700, Tim Roberts wrote: >>The webcam is bound to do some encoding; most of them use USB "full speed" >>(12Mbit/sec), which isn't enough for raw 640x480x24...@30fps data. > > That's not true. Most of the web cams made in the last 5 years or so run > at high speed, 4

Re: Check file is locked?

2009-07-08 Thread Nobody
On Tue, 07 Jul 2009 21:31:12 -0700, Rajat wrote: >> > By the way most operating systems don't lock a file when it's opened for >> > reading or writing or even executed. >> >> The general conclusion seems to be that mandatory locking is more trouble >> than it's worth. > > My OS is a windows XP sp

Re: IP Address Function

2009-07-08 Thread Nobody
On Wed, 08 Jul 2009 20:53:12 -0700, Fred Atkinson wrote: >>ipaddr = (getenv("HTTP_CLIENT_IP") or >> getenv("HTTP_X_FORWARDED_FOR") or >> getenv("HTTP_X_FORWARDED_FOR") or >> getenv("REMOTE_ADDR") or >> "UNKNOWN") >> >>print ipaddr > > That did it. > > I wonder why they don'

Re: Clarity vs. code reuse/generality

2009-07-09 Thread Nobody
On Thu, 09 Jul 2009 04:57:15 -0300, Gabriel Genellina wrote: > Nobody says you shouldn't check your data. Only that "assert" is not the > right way to do that. "assert" is not the right way to check your *inputs*. It's a perfectly reasonable way to check d

Re: How to check if any item from a list of strings is in a big string?

2009-07-09 Thread Nobody
On Thu, 09 Jul 2009 18:36:05 -0700, inkhorn wrote: > For one of my projects, I came across the need to check if one of many > items from a list of strings could be found in a long string. If you need to match many strings or very long strings against the same list of items, the following should (

Re: Colour of output text

2009-07-10 Thread Nobody
On Fri, 10 Jul 2009 09:23:54 +, garabik-news-2005-05 wrote: >>> I would like to learn a way of changing the colour of a particular >>> part of the output text. I've tried the following > >> On Unix operating systems this would be done through the curses interface: >> >> http://docs.python.or

Re: How to check if any item from a list of strings is in a big string?

2009-07-14 Thread Nobody
On Tue, 14 Jul 2009 02:06:04 -0300, Gabriel Genellina wrote: >> Matt, how many words are you looking for, in how long a string ? >> Were you able to time any( substr in long_string ) against re.compile >> ( "|".join( list_items )) ? > > There is a known algorithm to solve specifically this proble

Re: why did you choose the programming language(s)you currently use?

2009-07-14 Thread Nobody
On Tue, 14 Jul 2009 11:47:08 -0700, Paul Rubin wrote: >> - unlimited precision integers >> - easy to program >> - IDE not required >> - reasonable speed >> - math library needs to include number theoretic functions >> like GCD, LCM, Modular Inverse, etc. >> - not fucking retarded like F# > > Ha

Re: Colour of output text

2009-07-15 Thread Nobody
On Wed, 15 Jul 2009 17:03:30 +0200, Jean-Michel Pichavant wrote: >> Hard-coding control/escape sequences is just lame. Use the curses modules >> to obtain the correct sequences for the terminal. >> >> > As the OP I'm really interested in doing so. I currently have all my > colors hard-coded. >

Re: missing 'xor' Boolean operator

2009-07-15 Thread Nobody
On Wed, 15 Jul 2009 21:05:16 +0200, Jean-Michel Pichavant wrote: > So if I resume: > - not 'foo' => False > - 'foo' or 'foo' => 'foo' > > I may be missing something, but honestly, Guido must have smoked some > heavy stuff to write such logic, has he ? Several languages (e.g. Lisp, Bourne shell)

Re: missing 'xor' Boolean operator

2009-07-16 Thread Nobody
On Thu, 16 Jul 2009 11:06:54 +0200, Jean-Michel Pichavant wrote: >>> So if I resume: >>> - not 'foo' => False >>> - 'foo' or 'foo' => 'foo' >>> >>> I may be missing something, but honestly, Guido must have smoked some >>> heavy stuff to write such logic, has he ? >> >> Several languages (e.g. Lis

<    1   2   3   4   5   6   7   8   >