Re: missing 'xor' Boolean operator

2009-07-16 Thread Nobody
On Wed, 15 Jul 2009 18:14:10 +0200, Hrvoje Niksic wrote: >> If the question was "Why is there no 'or' operator ?", would "because >> A or B <=> not(not A and not B)" be a proper answer ? > > Note that in Python A or B is in fact not equivalent to not(not A and > not B). Ah, but it *is* "equivale

Re: Why aren't OrderedDicts comparable with < etc?

2009-07-16 Thread Nobody
On Thu, 16 Jul 2009 03:59:47 -0700, Mark wrote: >> > Or maybe not. If OrderedDicts are sequences as well as mappings, then we >> > should be able to sort them. And that seems a bit much even for me. >> One thing that I've just noticed is that you can use <, <=, >=, and > >> with sets: >> It seem

Re: missing 'xor' Boolean operator

2009-07-16 Thread Nobody
On Thu, 16 Jul 2009 14:59:22 -0700, Emile van Sebille wrote: If the question was "Why is there no 'or' operator ?", would "because A or B <=> not(not A and not B)" be a proper answer ? >>> Note that in Python A or B is in fact not equivalent to not(not A and >>> not B). >> >> Ah, but it

Re: UnicodeEncodeError: 'ascii' codec can't encode character u'\xb7' in position 13: ordinal not in range(128)

2009-07-16 Thread Nobody
On Thu, 16 Jul 2009 15:43:37 -0700, akhil1988 wrote: >> In Python 3 you can't decode strings because they are Unicode strings >> and it doesn't make sense to decode a Unicode string. You can only >> decode encoded things which are byte strings. So you are mixing up byte >> strings and Unicode stri

Re: UnicodeEncodeError: 'ascii' codec can't encode character u'\xb7' in position 13: ordinal not in range(128)

2009-07-17 Thread Nobody
On Thu, 16 Jul 2009 20:26:39 -0700, akhil1988 wrote: > Well, you were write: unintentionally I removed strip(). But the problem does > not ends here: > > I get this error now: > > File "./temp.py", line 488, in > main() > File "./temp.py", line 475, in main > for line in sys.stdin: >

Re: Why not enforce four space indentations in version 3.x?

2009-07-17 Thread Nobody
On Thu, 16 Jul 2009 09:18:47 -0500, Tim Chase wrote: > Yes, the dictatorial "a tab always equals 8 spaces" Saying "always" is incorrect; it is more accurate to say that tab stops are every 8 columns unless proven otherwise, with the burden of proof falling on whoever wants to use something differ

Re: How to receive a data file of unknown length using a python socket?

2009-07-18 Thread Nobody
On Sat, 18 Jul 2009 14:33:48 -0700, twgray wrote: > It appears to be locking up in 'data=self.s.recv(MAXPACKETLEN)' on > the final packet, which will always be less than MAXPACKETLEN. > > I guess my question is, how do I detect end of data on the client side? recv() should return zero when the

Re: If Scheme is so good why MIT drops it?

2009-07-23 Thread Nobody
On Wed, 22 Jul 2009 15:17:52 -0700, Carl Banks wrote: > So do all these OSes have some kind of __mega_unifying_poll system > call that works for anything that might possibly block, that you can > exploit from a user process? Threads ;) They also have the advantage that one thread can run while a

Re: Multiple versions of python

2009-07-23 Thread Nobody
On Tue, 21 Jul 2009 10:19:42 -0400, Dave Angel wrote: > The other thing you may want to do in a batch file is to change the file > associations so that you can run the .py file directly, without typing > "python" or "pythonw" in front of it. > > The relevant Windows commands are: assoc and

Re: Failed Regression Test: What socket.gethostname() is supposed to return?

2009-07-26 Thread Nobody
On Sun, 26 Jul 2009 08:30:30 +1000, Lie Ryan wrote: > since on my system socket.gethostname() returns 'lieryan', and since > socket.gethostbyname('lieryan') does not resolve to anything; the test > becomes an error. > > My system is Gentoo, but I think this also happened on Ubuntu (still on > thi

Re: Gracefully exiting CLI application

2009-07-28 Thread Nobody
On Mon, 27 Jul 2009 22:35:01 +0200, David wrote: > I am writing a command line application, and I need to perform some > cleaning on exit even if the process is killed. How can I do that with > python? Killed by what means? Ctrl-C sends SIGINT which is converted to a KeyboardInterrupt exception.

Re: bad certificate error

2009-07-28 Thread Nobody
On Tue, 28 Jul 2009 21:44:05 +0200, Piet van Oostrum wrote: >>j># cert_file is a PEM formatted certificate chain file. >>j>connection = httplib.HTTPSConnection(host, int(port), key_file, >>j> cert_file) > > What happens if you set cert_file to None? This would indicate tha

Re: Regular expression solution

2009-07-28 Thread Nobody
On Tue, 28 Jul 2009 16:12:19 -0700, nickname wrote: > I'm a newbie with python. I am looking to write a regex > program which can take in a piece of text and remove some parts of it > and supply the remaining parts back. > > The input can be something like: > document.write("h" +"e"+

Re: escaping characters in filenames

2009-07-29 Thread Nobody
On Wed, 29 Jul 2009 09:29:55 -0400, J Kenneth King wrote: > I wrote a script to process some files using another program. One thing > I noticed was that both os.listdir() and os.path.walk() will return > unescaped file names (ie: "My File With Spaces & Stuff" instead of "My\ > File\ With\ Spaces\

Re: Differences Between Arrays and Matrices in Numpy

2009-07-29 Thread Nobody
On Wed, 29 Jul 2009 16:23:33 -0400, Nanime Puloski wrote: > What are some differences between arrays and matrices using the Numpy > library? Matrices are always two-dimensional, as are slices of them. Matrices override mulitplication and exponentiation to use matrix multiplication rather than ele

Re: gamma approximation : what is module cmath and where is it located ?

2009-07-30 Thread Nobody
On Wed, 29 Jul 2009 23:24:11 -0500, pdlemper wrote: > The following numerical approximation for Euler's Gamma function > is found in http://en.wikipedia.org/wiki/Lanczos_approximation > > from cmath import * > This works in Python 3.0 > > But I can't figure out where it gets "cmath".S

Re: Help with Regex for domain names

2009-07-30 Thread Nobody
On Thu, 30 Jul 2009 10:29:09 -0700, rurpy wrote: >> regex = re.compile(r'[\w\-\.]+\.(?:us|au|de)') > > You might also want to consider that some country > codes such as "co" for Columbia might match more than > you want, for example: > > re.match(r'[\w\-\.]+\.(?:us|au|de|co)', 'foo.boo.com') >

Re: Printing with colors in a portable way

2009-07-31 Thread Nobody
On Thu, 30 Jul 2009 15:40:37 -0700, Robert Dailey wrote: > Anyone know of a way to print text in Python 3.1 with colors in a > portable way? In other words, I should be able to do something like > this: > > print_color( "This is my text", COLOR_BLUE ) > > And this should be portable (i.e. it sho

Re: Python docs disappointing

2009-08-01 Thread Nobody
On Fri, 31 Jul 2009 20:10:45 +, kj wrote: > I'm pretty new to Python, and I like a lot overall, but I find the > documentation for Python rather poor, overall. FWIW, I find the module documentation to be mostly adequate. What's missing is a human-readable language *manual*. The tutorial omit

Re: Help understanding the decisions *behind* python?

2009-08-01 Thread Nobody
On Sat, 01 Aug 2009 19:19:43 -0700, sturlamolden wrote: >> More than one person here has >> observed that the time to learn to program Pythonically is inversely >> proportional to their experience in Java. > > I believe it is opposite. The longer the Java experience, the longer > it takes to prog

Re: Queryable Daemon

2009-08-03 Thread Nobody
On Sun, 02 Aug 2009 19:36:08 -0600, Michael Torrie wrote: > Another possibility is shared memory segments. I'm not sure how > security is done in this case. Shared memory segments have an owner, group, and the standard ugo=rwx permissions (execute permission is present but ignored); see the shmg

Re: Help with regex

2009-08-06 Thread Nobody
On Thu, 06 Aug 2009 08:35:57 -0700, Robert Dailey wrote: > I'm creating a python script that is going to try to search a text > file for any text that matches my regular expression. The thing it is > looking for is: > > FILEVERSION #,#,#,# > > The # symbol represents any number that can be any l

Re: Character encoding & the copyright symbol

2009-08-06 Thread Nobody
On Thu, 06 Aug 2009 09:14:08 -0700, Robert Dailey wrote: > I'm loading a file via open() in Python 3.1 and I'm getting the > following error when I try to print the contents of the file that I > obtained through a call to read(): > > UnicodeEncodeError: 'charmap' codec can't encode character '\xa

Re: Help with regex

2009-08-06 Thread Nobody
On Thu, 06 Aug 2009 14:23:47 -0700, Ethan Furman wrote: >> [0-9]+ allows any number of leading zeros, which is sometimes undesirable. >> Using: >> >> (0|[1-9][0-9]*) >> >> is more robust. > > You make a good point about possibly being undesirable, but I question > the assertion that your

Re: Executing untrusted code

2009-08-07 Thread Nobody
On Fri, 07 Aug 2009 08:15:08 -0700, Emanuele D'Arrigo wrote: > Are > there best practices to at least minimize some of the risks associated > with untrusted code execution? Yes: don't execute it. Failing that, run the Python interpreter within a sandbox. If you want to support restricted executi

Re: Help with regex

2009-08-08 Thread Nobody
On Thu, 06 Aug 2009 17:02:44 +0100, MRAB wrote: > The character class \d is equivalent to [0-9] Not for Unicode, which is the default in 3.x. -- http://mail.python.org/mailman/listinfo/python-list

Re: How to page output in >>> ?

2009-08-12 Thread Nobody
On Wed, 12 Aug 2009 21:41:38 +, kj wrote: > How does one tell the python interactive interpreter to run the > next output to stdout through the default pager? Basically, I'm > looking for Python's equivalent of Perl's debugger's "|" prefix, > as in > > DB<1> |print $long_output Something

Re: PIL and Python

2009-08-13 Thread Nobody
On Thu, 13 Aug 2009 16:38:07 -0700, Martin wrote: >> I want use python to change the "note" from .jpeg files . >> What is the functions on PIL how make this ? > > What do u mean by the note? I think he means the EXIF data. -- http://mail.python.org/mailman/listinfo/python-list

Re: OT Signature quote [was Re: Unrecognized escape sequences in string literals]

2009-08-16 Thread Nobody
On Sun, 16 Aug 2009 05:05:01 +, Steven D'Aprano wrote: > Now that I understand what the semantics of cout << "Hello world" are, I > don't have any problem with it either. It is a bit weird, "Hello world" > >> cout would probably be better, Placing the stream on the LHS allows the main forms

Re: Python 'for' loop is memory inefficient

2009-08-16 Thread Nobody
On Sun, 16 Aug 2009 11:41:21 -0400, Benjamin Kaplan wrote: > It's not that the code is bad, but too many people coming from Java > and C keep thinking of for loops like they're using Java or C and > therefore that "for i in range(a,b)" is identical to "for(int i = a; i > < b; i++)". It's not and,

Re: wxFormBuilder finally supports wxPython

2009-08-16 Thread Nobody
On Sun, 16 Aug 2009 03:19:51 -0700, sturlamolden wrote: > Version 3.1 of wxFormBuilder can generate wxPython code. I have > previously used wxFormBuilder to generate XRC files for my wxPython > projects. Though still in beta, this might be even better. :-) Is there a reason to prefer code over XR

Re: web frameworks that support Python 3

2009-08-25 Thread Nobody
On Sun, 23 Aug 2009 16:32:09 -0400, Albert Hopkins wrote: > What's different about Python 3 is that there is only unicode strings, > whereas Python 2 has a string type and a unicode type. Python 2 has "str" (char) and "unicode" (wchar) types. Python 3 has "bytes" (char) and "str" (wchar) types.

Re: sgmllib.py

2009-08-25 Thread Nobody
On Mon, 24 Aug 2009 09:08:07 +0200, Stefan Behnel wrote: > But note that sgmllib is a particularly cumbersome way to deal with HTML. Mostly because it only provides a tokeniser, not a parser. Whoever wrote it doesn't appear to understand the difference. -- http://mail.python.org/mailman/listinf

Re: print() and unicode strings (python 3.1)

2009-08-25 Thread Nobody
On Tue, 25 Aug 2009 03:41:54 -0700, 7stud wrote: > Why does echoing $LC_ALL or $LC_CTYPE just give me a blank string? Because the variables aren't set. The default locale for a particular category (e.g. LC_CTYPE) is taken from $LC_ALL if that is set, otherwise $LC_CTYPE, otherwise $LANG, otherwi

Re: os.popen output different from native shell output

2009-08-25 Thread Nobody
On Tue, 25 Aug 2009 01:36:08 -0700, nickname wrote: >I am a relative newbie to python, I am using os.popen to run an > ls command. The output that I get using the read() function is > different in look and feel from when I run the ls command natively > from the shell (not via python). As

Re: os.popen output different from native shell output

2009-08-26 Thread Nobody
On Tue, 25 Aug 2009 11:42:31 -0700, nickname wrote: > The reason why I want to do this is because I am going to do a little > project. I will write a python script called ls which will log the > time and username and then will show the actual ls output. I want this > to be transparent and so want

Re: [OT] How do I reply to a thread by sending a message to [email protected]

2009-08-28 Thread Nobody
On Thu, 27 Aug 2009 05:47:50 -0400, Terry Reedy wrote: >> I use Thunderbird, and treat the list as ordinary mail. I use >> reply-all, and it seems to do the right thing. Or at least if I'm >> breaking threads, nobody has pointed it out to me yet. > > reply-all m

Re: Query screen resolution?

2009-08-28 Thread Nobody
On Fri, 28 Aug 2009 11:13:06 -0700, AK Eric wrote: > Thought this would be easy, maybe I'm missing something :) Trying to > query the x,y resolution of my screen. I've seen this available > through http://python.net/crew/mhammond/win32/ : > > from win32api import GetSystemMetrics > print "width

Re: What python can NOT do?

2009-08-28 Thread Nobody
On Fri, 28 Aug 2009 17:31:22 -0700, r wrote: >> Since Python is Turing-complete, there's no reason a whole OS >> couldn't be authored in Python. > > Yes, and one could go from NY to LA on a unicycle but would one really > want to? Talk about some redass and blueballs! *yikes* > > Yes, if i have

Re: What python can NOT do?

2009-08-28 Thread Nobody
On Fri, 28 Aug 2009 17:26:06 -0700, qwe rty wrote: > if you don't know the answer please don't reply If you don't understand the question, don't post it in the first place. -- http://mail.python.org/mailman/listinfo/python-list

Re: (Simple?) Unicode Question

2009-08-29 Thread Nobody
On Sat, 29 Aug 2009 08:26:54 +, Steven D'Aprano wrote: > Python only needs to know when you convert the text to or from bytes. I > can do this: > s = "hello" t = "world" print(' '.join([s, t])) > hello world > > and not need to care anything about encodings. > > So long as y

Re: Query screen resolution?

2009-08-29 Thread Nobody
On Fri, 28 Aug 2009 20:15:57 -0700, Warpcat wrote: >> Your question is based upon the notion that "the screen" is a meaningful >> concept. Once you move away from Windows (and systems which intentionally >> try to be like Windows), that's no longer true. > > Good points. Always something I haven

Re: break unichr instead of fix ord?

2009-08-30 Thread Nobody
On Sun, 30 Aug 2009 06:54:21 +0200, Dieter Maurer wrote: >> What you propose would break the property "unichr(i) always returns >> a string of length one, if it returns anything at all". > > But getting a "ValueError" in some builds (and not in others) > is rather worse than getting unicode strin

Re: (Simple?) Unicode Question

2009-08-30 Thread Nobody
On Sun, 30 Aug 2009 02:36:49 +, Steven D'Aprano wrote: >>> So long as your terminal has a sensible encoding, and you have a good >>> quality font, you should be able to print any string you can create. >> >> UTF-8 isn't a particularly sensible encoding for terminals. > > Did I mention UTF-8?

Re: What python can NOT do?

2009-08-30 Thread Nobody
On Sat, 29 Aug 2009 23:07:17 +, exarkun wrote: >>>Personally, I consider Python to be a good language held back by >>>too-close ties to a naive interpreter implementation and the lack >>>of a formal standard for the language. >> >>Name one language under active development that has not bee

Re: An assessment of the Unicode standard

2009-08-30 Thread Nobody
On Sat, 29 Aug 2009 22:14:55 -0700, John Nagle wrote: > (I wish the HTML standards people would do the same. HTML 5 > should have been ASCII only (with the "&" escapes if desired) > or Unicode. No "Latin-1", no upper code pages, no JIS, etc.) IOW, you want the HTML standards to continue to

Re: Why does this group have so much spam?

2009-08-30 Thread Nobody
On Sun, 30 Aug 2009 11:18:35 +0200, David wrote: >> So much of it could be removed even by simple keyword filtering. > > I think there is only one final solution to the spam pestilence: a tiny tax > on email and posts. > Spammers send hundreds of thousands of emails/posts a day and a tax of > 0.0

Re: IDE for python similar to visual basic

2009-08-30 Thread Nobody
On Sun, 30 Aug 2009 10:48:24 -0700, r wrote: > I think a point and click GUI builder (although some may disagree) is > actually detrimental to your programming skills. The ability to > visualize the GUI only from the source code as you read it, is as > important to a programmer as site reading she

Re: map

2009-08-31 Thread Nobody
On Sun, 30 Aug 2009 21:55:52 -0700, elsa wrote: > say I have a list, myList. Now say I have a function with more than > one argument: > > myFunc(a, b='None') > > now, say I want to map myFunc onto myList, with always the same > argument for b, but iterating over a: > > map(myFunc(b='booHoo'), m

Re: obscure problem using elementtree to make xhtml website

2009-09-04 Thread Nobody
On Fri, 04 Sep 2009 13:21:54 +0200, Stefan Behnel wrote: Not a bug in IE (this time), which is correctly parsing the file as html. >>> ... which is obviously not the correct thing to do when it's XHTML. >> >> It isn't though; it's HTML with a XHTML DOCTYPE > > Not the page I look at (i.e. t

Re: Subclassing list and splicing

2009-09-04 Thread Nobody
On Thu, 03 Sep 2009 17:10:12 +, Kreso wrote: > I would prefer that resulting object m belonged to myclist class. > How to obtain such behaviour? Must I somehow implement __getslice__ > method myself? Yes; you should also implement __getitem__(), as this is used for extended slices. -- http:

Re: IDE for python similar to visual basic

2009-09-11 Thread Nobody
On Mon, 07 Sep 2009 23:56:17 +, Albert van der Horst wrote: >>The main advantage of a GUI builder is that it helps prevent you from >>hard-coding the GUI into the program. You could get the same effect by >>coding a UIL/XRC/etc file manually, but a GUI builder tends to force it. > > A GUI bui

Re: IDE for python similar to visual basic

2009-09-11 Thread Nobody
On Mon, 07 Sep 2009 18:04:40 -0700, r wrote: >> >It also allows the GUI to be edited by without requiring any programming >> >knowledge. This eliminates the need for the GUI designer to be familiar >> >with the programming language used (or any programming language), and >> >allows customisation b

Re: IDE for python similar to visual basic

2009-09-13 Thread Nobody
On Fri, 11 Sep 2009 05:27:59 -0700, r wrote: >> I'm saying that the user understands their workflow and environment better >> than the application's programmers. The user should be able to decide >> which menu items are shown and where, which buttons are shown and where, >> etc. The code doesn't n

Re: VT100 in Python

2009-09-17 Thread Nobody
On Mon, 14 Sep 2009 04:29:57 -0500, Nick Craig-Wood wrote: > At a basic level parsing VT100 is quite easy, so you can get rid of > the VT100 control. They start with ESC, have other characters in the > middle then end with a letter (upper or lowercase), so a regexp will > make short work of them.

Re: os.execv Overhead

2009-09-17 Thread Nobody
On Wed, 16 Sep 2009 08:12:50 -0700, [email protected] wrote: > I have a script that automates running a program X times by preparing > the required files and passing the external program right variables. > > What I am unsure about though is the overhead of: > > program = "externalSc

Re: Comparison of parsers in python?

2009-09-21 Thread Nobody
On Sat, 19 Sep 2009 13:21:58 -0700, Peng Yu wrote: > I did a google search and found various parser in python that can be > used to parse different files in various situation. I don't see a page > that summarizes and compares all the available parsers in python, from > simple and easy-to-use ones

Re: OK to memoize re objects?

2009-09-21 Thread Nobody
On Mon, 21 Sep 2009 07:11:36 -0700, Ethan Furman wrote: > Looking in the code for re in 2.5: > _MAXCACHE = 100 > On the other hand, I (a > re novice, to be sure) have only used between two to five in any one > program... it'll be a while before I hit _MAXCACHE! Do you know how many REs import-e

Re: socket send O(N**2) complexity

2009-09-22 Thread Nobody
On Mon, 21 Sep 2009 16:33:08 -0400, Jack Diederich wrote: >> AIUI, as a python string is imutable, a slice of a string is a >> new string which points (C char *) to the start of the slice data >> and with a length that is the length of the slice, about 8 bytes >> on 32 bit machine. > > Not in CPy

Re: Reading the access attributes of directories in Windows

2010-08-27 Thread Nobody
On Fri, 27 Aug 2010 13:28:46 +0600, Rami Chowdhury wrote: >>> Having this as a separate permission allows normal users to add entries >>> to log files but not to erase existing entries. >> >> Unix/Linux systems can do this already. > > Ooh, I didn't know that -- what combination of permissions wo

Re: Writing byte stream as jpeg format to disk

2010-08-27 Thread Nobody
On Thu, 26 Aug 2010 23:56:26 -0700, Bryan wrote: >> follow our advice. Split using b'\r\n\r\n' and use the maxsplit=1 >> argument to make sure that you do not split on spurious b'\r\n\r\n' >> sequences inside the JPEG body. Do not decode the bytes. > > Correct, and I'll add that this is a case wh

Re: How to convert (unicode) text to image?

2010-08-30 Thread Nobody
On Mon, 30 Aug 2010 12:50:32 +0200, Thomas Jollans wrote: >> Face the facts dude. The Python docs have some major problems. >> They were pretty good when Python was a new, cool, project used >> by a handful of geeks. They are good relative to the "average" >> (whatever that is) open source proje

Re: shlex, unicode, and subprocess.Popen on Windows

2010-08-30 Thread Nobody
On Mon, 30 Aug 2010 10:24:26 -0400, python wrote: >> Kudos for avoiding shell=True > > My understanding is that the only time one needs to use shell=True is > when they are 'executing' a non-executable file whose executable must be > discovered via file association rules? Does that sound accurate

Re: Saving (unusual) linux filenames

2010-08-31 Thread Nobody
On Tue, 31 Aug 2010 18:13:44 +0100, MRAB wrote: this works for "normal" paths but as soon as i have a path that does include a "," it breaks. The problem now is that (afaik) linux allows every char (aside from "/" and null) to be used in filenames. The only solution i can think

Re: Saving (unusual) linux filenames

2010-08-31 Thread Nobody
On Tue, 31 Aug 2010 18:49:33 +, Grant Edwards wrote: >> How many filenames contain control characters? > > How many filenames contain ","? Not many, Unless you only ever deal with "Unix folk", it's not /that/ uncommon to encounter filenames which are essentially complete sentences, punctuat

Re: killing all subprocess childrens

2010-09-02 Thread Nobody
On Thu, 02 Sep 2010 13:12:07 +1000, Astan Chee wrote: > I have a piece of code that looks like this: > > import subprocess > retcode = subprocess.call(["java","test","string"]) > print "Exited with retcode " + str(retcode) > > What I'm trying to do (and wondering if its possible) is to make sure

Re: python path separator

2010-09-02 Thread Nobody
On Wed, 01 Sep 2010 23:57:21 -0700, swapnil wrote: > I could not find any documentation for variables os.path.sep and > os.path.altsep. Although the first is pretty straightforward can > anyone explain the purpose of the second variable? Is it even useful? The purpose is so that you can do e.g.:

Re: Speed-up for loops

2010-09-02 Thread Nobody
On Thu, 02 Sep 2010 12:02:40 +0200, Michael Kreim wrote: > I was comparing the speed of a simple loop program between Matlab and > Python. > imax = 10 > a = 0 > for i in xrange(imax): > a = a + 10 > print a > Are there any ways to speed up the for/xrange loop? Sure; the above can

Re: Speed-up for loops

2010-09-03 Thread Nobody
On Fri, 03 Sep 2010 11:21:36 +0200, Michael Kreim wrote: > An anonymous Nobody suggested to use Numpy. I did not do this, because I > am very very new to Numpy and I did not figure out a Numpy specific way > to do this. Maybe a Numpy expert has something for me? The problem wi

Re: Difference between queues and pipes in multiprocessing

2010-09-09 Thread Nobody
On Thu, 09 Sep 2010 12:23:17 -0700, Ethan Furman wrote: >> basically a Queue is a syncronization primitive used to >> share and pass data to and from parent/child processes. >> >> A pipe is as the name suggests, a socket pair connected >> end-to-end allowing for full-duplex communications. >> >

Re: accessing a text file

2010-09-09 Thread Nobody
On Wed, 08 Sep 2010 03:30:00 -0700, Baba wrote: > Who is licensed to judge what can and cannot be posted as a question? Exactly the same set of people who are licensed to judge what can and cannot be posted as an answer. If you don't like the responses you get here, you could try posting your qu

Re: Catching a SIGSEGV signal on an import

2010-09-09 Thread Nobody
On Thu, 09 Sep 2010 05:23:14 -0700, Ryan wrote: > But, since SIGSEGV is asynchronous SIGSEGV is almost always synchronous. > In general, is there anyway to catch a SIGSEGV on import? No. If SIGSEGV is raised, it often indicates that memory has been corrupted. At that point, you can't assume th

Re: Expected bahaviour of os.chroot and os.getcwd

2010-09-14 Thread Nobody
On Mon, 13 Sep 2010 19:04:53 +0100, r0g wrote: > i.e. So do I always have to change directory after changing into a chroot? You don't *have* to change the directory, but not doing so probably defeats the point of performing a chroot(). > The reason I ask is because an app I was running inside th

Re: Converting an ugly path to a shell path

2010-09-14 Thread Nobody
On Tue, 14 Sep 2010 01:07:48 +0200, AmFreak wrote: > im using a QFileDialog to let the user select a path that is used later in > a command send to the shell like this: > > retcode = Popen(command + " " + path, shell=True, stdout = PIPE, stderr = > PIPE) > > The problem that occurs now is wh

Re: os.path.normcase rationale?

2010-09-16 Thread Nobody
On Wed, 15 Sep 2010 14:49:09 +0100, Chris Withers wrote: > I'm curious as to why, with a file called "Foo.txt" > os.path.normcase('FoO.txt') will return "foo.txt" rather than "Foo.txt"? normcase() doesn't look at the filesystem; it's just string manipulation. -- http://mail.python.org/mailman

Re: os.path.normcase rationale?

2010-09-16 Thread Nobody
On Thu, 16 Sep 2010 07:12:16 +1000, Ben Finney wrote: >> Yes, I know the behaviour is documented > > The docstring is fairly poor, IMO. You might want to submit a bug report > to improve it. The description in the library documentation is misleading: os.path.normcase(path) Normalize the cas

Re: socket.error: [Errno 98] Address already in use

2010-09-18 Thread Nobody
On Sun, 19 Sep 2010 12:27:08 +1200, Lawrence D'Oliveiro wrote: >> That's why Stevens recommends that all TCP servers use the >> SO_REUSEADDR socket option. > > I don’t think I’ve ever used that. It seems to defeat a safety mechanism > which was put in for a reason. It was put in for the benefit

Re: socket.error: [Errno 98] Address already in use

2010-09-19 Thread Nobody
On Sun, 19 Sep 2010 18:42:51 +1200, Lawrence D'Oliveiro wrote: That's why Stevens recommends that all TCP servers use the SO_REUSEADDR socket option. >>> >>> I don’t think I’ve ever used that. It seems to defeat a safety mechanism >>> which was put in for a reason. >> >> It was put in

Re: socket.error: [Errno 98] Address already in use

2010-09-21 Thread Nobody
On Mon, 20 Sep 2010 12:00:41 +1200, Lawrence D'Oliveiro wrote: >> However, some clients choose their own source ports. E.g. rlogin/rsh use >> privileged (low-numbered) ports, and you can't get the kernel to choose a >> random privileged port for you. > > B

Re: os.path.normcase rationale?

2010-09-21 Thread Nobody
On Tue, 21 Sep 2010 10:12:27 +1000, Ben Finney wrote: > Another is that filesystems don't have a standard way of determining > whether they are case-sensitive. The operating system's driver for that > particular filesystem knows, I'm not even sure that's true; with a networked filesytem, some par

Re: Arrays and CTYPE

2010-09-21 Thread Nobody
On Mon, 20 Sep 2010 15:47:32 -0700, Glenn Pringle wrote: > Ok. I ran into a problem here. I have been dabbling with Python and I > thought that this would be a good exercise but I got stuck. > > I have a DLL and one of the functions(getState) in that DLL returns an > array. If the DLL was writte

Re: Subprocess does not return for longer-running process

2010-09-22 Thread Nobody
On Tue, 21 Sep 2010 23:54:04 -0700, Dennis Lee Bieber wrote: >> As your Traceback clearly indicates, the Popen() call has already >> completed; it's *the os.waitpid() call* that's blocking, but that's >> entirely to be expected given its defined behavior. If you don't want >> to wait around for th

Re: how to get partition information of a hard disk with python

2010-09-22 Thread Nobody
On Wed, 22 Sep 2010 00:31:04 +0200, Hellmut Weber wrote: > I'm looking for a possibility to access the partiton inforamtion of a > hard disk of my computer from within a python program. Have you considered parsing /proc/partitions? -- http://mail.python.org/mailman/listinfo/python-list

Re: Best way for rotating a matrix of data?

2010-09-22 Thread Nobody
On Tue, 21 Sep 2010 19:38:06 -0700, Raphaël Plasson wrote: > Actually, I more precisely extract my 2D array from much higher > dimensions data (i.e. 10-20 fields of different data in 3 dimensions > of space+1 dimension of time), contained in a hdf5 file. I typically > would like to extract arbitra

Re: Subprocess does not return for longer-running process

2010-09-23 Thread Nobody
On Thu, 23 Sep 2010 12:25:53 +1200, Lawrence D'Oliveiro wrote: >> And I can't think of any reason why you should use os.waitpid() or >> similar; use the .wait() method. > > I have used WNOHANG to poll for completion of a subprocess while providing > progress updates to the user. This can be don

Re: Check whether file is being written to

2010-09-23 Thread Nobody
On Thu, 23 Sep 2010 17:55:52 +0200, Diez B. Roggisch wrote: > Last time I checked, file-locking in unix was co-operative. Linux supports mandatory locking, but it's seldom enabled. -- http://mail.python.org/mailman/listinfo/python-list

Re: Subprocess does not return for longer-running process

2010-09-24 Thread Nobody
On Fri, 24 Sep 2010 15:18:47 +1200, Lawrence D'Oliveiro wrote: And I can't think of any reason why you should use os.waitpid() or similar; use the .wait() method. >>> >>> I have used WNOHANG to poll for completion of a subprocess while >>> providing progress updates to the user. >> >>

Re: Raw Sockets - IP-Encapsulation

2010-09-24 Thread Nobody
On Thu, 23 Sep 2010 21:41:19 +0200, Matthias Guentert wrote: > I would like to create an IP tunnel using the IP protocol type 4 > (socket.IPPROTO_IPIP) on a Linux host. (I also would be happy if I > could create a GRE tunnel) > > The thing is, I just don't understand how I such a socket could be

Re: SocketServer: replace network by hard drive

2010-09-25 Thread Nobody
On Fri, 24 Sep 2010 19:28:45 +0200, Thomas Jollans wrote: > If you're using UNIX, and you don't actually need the stream to be > passed via the hard drive (why would you?), but for some reason want to > use the file system, look info UNIX/local sockets. But, really, I'm > guessing that local TCP s

Re: SocketServer: replace network by hard drive

2010-09-25 Thread Nobody
On Sat, 25 Sep 2010 14:45:29 +0200, Thomas Jollans wrote: >> The problem with using the loopback interface is that it's still >> "network access", which can run into all kinds of issues with security >> policies, firewalls, etc. > > What kind of crappy firewall blocks loopback traffic? Really? T

Re: how to get partition information of a hard disk with python

2010-09-30 Thread Nobody
On Thu, 30 Sep 2010 11:41:48 +0300, Anssi Saari wrote: >>> I'm looking for a possibility to access the partiton inforamtion of a >>> hard disk of my computer from within a python program. >> >> Have you considered parsing /proc/partitions? > > One could also just read the partition table directly

Re: Crummy BS Script

2010-10-03 Thread Nobody
On Sat, 02 Oct 2010 22:15:31 -0700, flebber wrote: > Cargo Cult Coding? > > Not sure what it is but it sounds good. Imitation without understanding, aka monkey-see-monkey-do. http://en.wikipedia.org/wiki/Cargo_cult -- http://mail.python.org/mailman/listinfo/python-list

Re: SQLite is quite SQL compliant

2010-10-03 Thread Nobody
On Sat, 02 Oct 2010 13:06:12 -0700, Ravi wrote: > The documentation of the sqlite module at > http://docs.python.org/library/sqlite3.html says: > > "...allows accessing the database using a nonstandard variant of the > SQL..." > > But if you see SQLite website they clearly say at > http://sqlite

Re: I don't get why sys.exit(1) doesn't exit the while loop in the follow case

2010-10-05 Thread Nobody
On Tue, 05 Oct 2010 13:57:11 +1100, Ben Finney wrote: > Here's your problem. Don't ever use a bare ‘except’ unless you know > exactly why you're doing so. Rather, figure out what exception types you > want to catch, and catch *only* those types. If I use a bare except, I usually have a good reaso

Re: Unicode Support in Ruby, Perl, Python, Emacs Lisp

2010-10-10 Thread Nobody
On Sat, 09 Oct 2010 15:45:42 -0700, Sean McAfee wrote: >> I'll have to say, as far as text processing goes, the most beautiful >> lang with respect to unicode is emacs lisp. In elisp code (e.g. >> Generate a Web Links Report with Emacs Lisp ), i don't have to declare >> none of the unicode or enco

Re: Help with pointers when calling from python to C

2010-10-10 Thread Nobody
On Fri, 08 Oct 2010 18:02:15 +0200, Jonas H. wrote: > On 10/08/2010 05:23 PM, Carolyn MacLeod wrote: >> "How do I pass an integer by reference to a C function?" > > That's impossible in pure Python. The only thing I can think of is a > wrapper in C. I didn't see the original message, but if you

Re: I don't get why sys.exit(1) doesn't exit the while loop in the follow case

2010-10-11 Thread Nobody
On Mon, 11 Oct 2010 05:42:39 -0700, Ethan Furman wrote: >>>If I'm catching exceptions in order to perform clean-up, I'll use a bare >>>except and re-raise the exception afterwards. In that situation, a bare >>>except is usually the right thing to do. >> >> Wrong way to do it. > > What, then, is

Re: How is correct use of eval()

2010-10-11 Thread Nobody
On Mon, 11 Oct 2010 11:18:37 -0700, Chris Rebert wrote: >> What is correct way to use this function? > > To not use it in the first place if at all possible (use int(), > float(), getattr(), etc. instead, Use read(). Oh wait, Python doesn't have that. Because parsing literals and executing code

Re: How is correct use of eval()

2010-10-11 Thread Nobody
On Tue, 12 Oct 2010 01:26:25 +0100, Nobody wrote: >>> What is correct way to use this function? >> >> To not use it in the first place if at all possible (use int(), >> float(), getattr(), etc. instead, > > Use read(). Oh wait, Python doesn't have that. Be

Re: send command to parent shell

2010-10-13 Thread Nobody
On Wed, 13 Oct 2010 06:30:15 -0700, Martin Landa wrote: > is there a way how to send command from python script to the shell > (known id) from which the python script has been called? For Unix, this should work, but in general it's the wrong thing to do: import os import signal

<    2   3   4   5   6   7   8   >