Re: python module

2012-04-16 Thread Chris Angelico
On Tue, Apr 17, 2012 at 9:43 AM, Mark Lawrence wrote: > I'd like to point out that it's frustrating when you find a piece of code > that you'd like to use but neither easy_install nor pip work cos it can't be > found.  Worse still when you want to try a really popular product like > taskcoach, but

Re: PrintPreviewDialog problem

2012-04-17 Thread Chris Angelico
On Tue, Apr 17, 2012 at 4:09 PM, alhad wrote: > but, i am getting AttributeError for "paintRequested" Before executing that line, find out what 'preview' contains. My guess is that you have an error return such as None, which will of course not have a paintRequested attribute. If it's not obvious

Re: How to determine if IO redirection is occurring with the output from a Python program?

2012-04-17 Thread Chris Angelico
On Wed, Apr 18, 2012 at 12:21 AM, Edward d'Auvergne wrote: > I was wondering if anyone knows of how to detect when IO redirection > of any form is happening within a Python program?  I would like to > emulate the behaviour of the GNU tools (for example the Unix commands > 'ls' or 'grep') whereby a

Re: File traversing

2012-04-17 Thread Chris Angelico
On Wed, Apr 18, 2012 at 12:31 AM, Nibin V M wrote: > # python test.py >   File "test.py", line 1 >     with open('/etc/trueuserowners') as res_own_file: >     ^ > IndentationError: unexpected indent Make sure your first code line is flush left. Since indentation indicates block structure (and not

Re: How to determine if IO redirection is occurring with the output from a Python program?

2012-04-17 Thread Chris Angelico
On Wed, Apr 18, 2012 at 12:59 AM, Edward d'Auvergne wrote: > Hi, > > Thanks for the incredibly quick responses!  The os.isatty() call (and > sys.std*.isatty() calls as suggested by Chris Angelico at > http://mail.python.org/pipermail/python-list/2012-April/1291048.html) >

Re: Suggest design to accomodate non-unix platforms ?

2012-04-18 Thread Chris Rebert
(cmd) It's slightly less reasonable considering that the `subprocess` module is preferred over os.system(). Cheers, Chris -- http://mail.python.org/mailman/listinfo/python-list

Re: A case for "real" multiline comments

2012-04-18 Thread Chris Angelico
On Thu, Apr 19, 2012 at 2:29 PM, Cameron Simpson wrote: > On 18Apr2012 22:07, Jordan Perr wrote: > | I came across this case while debugging some Python code that contained an > | error stemming from the use of multiline strings as comments. The code > | contained a very long list of objects, and

Re: A case for "real" multiline comments

2012-04-18 Thread Chris Angelico
t if a triple-quoted string contains Python code, but that would always be an issue. Option 1: New keyword. comment def ... parser completely ignores these lines ... comment break Option 2: Reuse keywords. from None import ... ignore these lines ... from True import The exact choice of key

Re: md5 check

2012-04-19 Thread Chris Angelico
On Thu, Apr 19, 2012 at 5:46 PM, contro opinion wrote: import hashlib > f=open('c:\gpg4win-2.1.0.exe','rb') print  hashlib.md5(f.read()).hexdigest() > ad6245f3238922bb7afdc4a6d3402a65 print  hashlib.sha1(f.read()).hexdigest() > da39a3ee5e6b4b0d3255bfef95601890afd80709 > > i get

Re: A case for "real" multiline comments

2012-04-19 Thread Chris Angelico
On Thu, Apr 19, 2012 at 8:17 PM, Alek Storm wrote: >> comment def >> ... parser completely ignores these lines ... >> comment break > > > I believe the more Pythonic syntax would be: > > comment: >     ...some >     ...indented >     ...lines > > God help us if that ever happens. Certainly not. T

Re: Framework for a beginner

2012-04-19 Thread Chris Angelico
On Thu, Apr 19, 2012 at 9:14 PM, Kiuhnm wrote: > There are many things I don't like about Python. The first flaw is the > absence of anonymous code blocks, but I've already solved this problem. You mean lambdas? Yeah, they're a lot more limited in Python than in some other languages. However, you

Re: A case for "real" multiline comments

2012-04-19 Thread Chris Angelico
On Thu, Apr 19, 2012 at 10:15 PM, Devin Jeanpierre wrote: > Why don't you allow nested multiline comments? Many languages (e.g. > ML, Scheme, Haskell, etc.) allow you to nest multi-line comments. It's > mostly the C family of languages that refuse to do this, AFAIK. Allowing nesting or not allowi

Re: Bug in Python

2012-04-19 Thread Chris Angelico
On Thu, Apr 19, 2012 at 10:01 PM, Kiuhnm wrote: > I read that bug fix releases have a 6-month cycle :( > It seems that I'll have to work around the problem... If a fix has been committed, the easiest thing to do is clone the Mercurial repository and build Python from source. Takes a little bit of

Re: Regular expressions, help?

2012-04-19 Thread Chris Angelico
On Thu, Apr 19, 2012 at 10:02 PM, Sania wrote: > So now my regex is > >    dead=re.match(r".*death toll.{0,20}(\d[,\d\.]*)", text) > > But I only find 7 not 657. How is it that the group is only matching > the last digit? The whole thing is parenthesis not just the last > part. ? Your problem is

Re: How do you refer to an iterator in docs?

2012-04-19 Thread Chris Angelico
On Thu, Apr 19, 2012 at 10:21 PM, Roy Smith wrote: > def foo(words): >   "Foo-ify words (which must be a list)" > > What if I want words to be the more general case of something you can > iterate over?  How do people talk about that in docstrings?  Do you say > "something which can be iterated ove

Re: Python Gotcha's?

2012-04-19 Thread Chris Angelico
On Thu, Apr 19, 2012 at 11:11 PM, Albert van der Horst wrote: > I still think the doubling convention of Algol68 is superior: > """Help me Obiwan,"" she said, ""You're my only hope!""" > > No special treatment of any other symbol than the quote itself. > A quoting symbol is such a devious syntacti

Re: Framework for a beginner

2012-04-19 Thread Chris Angelico
On Thu, Apr 19, 2012 at 10:12 PM, lkcl luke wrote: >  that's what i meant about beauty and elegance.  the "bang per buck" > ratio in python, results obtained for the number of characters used, > is higher, and that's something that i personally find to be a > priority over speed. Number of charac

Re: Framework for a beginner

2012-04-19 Thread Chris Angelico
On Thu, Apr 19, 2012 at 10:56 PM, lkcl luke wrote: > i'm belabouring the point (not entirely intentionally) but you see how > clumsy that is?  it's probably just as complex in the actual > lexer/grammar file in the http://python.org source code itself, as it > is to think about in real life and to

Re: Regular expressions, help?

2012-04-19 Thread Chris Angelico
On Fri, Apr 20, 2012 at 1:07 AM, Sania wrote: > Azrazer what you suggested works but I need to make sure that it > catches numbers like 6,370 as well as 637. And I tried tweaking the > regex around from the one you said in your reply but It didn't work > (probably would have if I was more adept).

Re: Request META Help

2012-04-19 Thread Chris Angelico
On Thu, Apr 19, 2012 at 11:32 PM, Gabriel Novaes wrote: > The domains testes1.xyz.com.br, tes.xyzk.com.br, xx.xyzk.com.br through a DNS > redirect TYPE A link to the server IP. > > In most cases I get the request.META ['HTTP_HOST'] with the URL in the > request header, but today I had a problem

Re: Suggest design to accomodate non-unix platforms ?

2012-04-19 Thread Chris Angelico
On Fri, Apr 20, 2012 at 8:35 AM, Dan Stromberg wrote: > It's not nearly as adaptive as scaning $PATH for ssh, falling back on putty > if necessary - this is analogous to GNU autoconf.  You'd probably have a > small class you genericize this with - with one instance for each such > executable that

Re: can I overload operators like "=>", "->" or something like that?

2012-04-19 Thread Chris Angelico
On Fri, Apr 20, 2012 at 2:38 PM, alex23 wrote: > On Apr 20, 5:54 am, Jacob MacDonald wrote: > >> On Thursday, April 19, 2012 12:28:50 PM UTC-7, dmitrey wrote: >> > can I somehow overload operators like "=>", "->" or something like >> > that? > >> I don't believe that you could overload those part

Re: os.system()

2012-04-20 Thread Chris Angelico
On Fri, Apr 20, 2012 at 8:51 PM, Yigit Turgut wrote: > On Apr 19, 11:02 pm, "Steve" wrote: >> > "Yigit Turgut"  wrote in message >> >news:[email protected]... >> > When I use os.system() function, script waits for termination of the >> >> windows tha

Re: Suggest design to accomodate non-unix platforms ?

2012-04-20 Thread Chris Angelico
On Sat, Apr 21, 2012 at 3:44 AM, Dan Stromberg wrote: > > On Thu, Apr 19, 2012 at 5:14 PM, Chris Angelico wrote: >> >> The question then is whether to choose or auto-detect. Attempting to >> auto-detect could be quite inefficient; imagine if you have to call on >&g

Re: can I overload operators like "=>", "->" or something like that?

2012-04-20 Thread Chris Angelico
On Sat, Apr 21, 2012 at 4:21 AM, Kiuhnm wrote: > Another option is to rely on ugly pseudo-operators: >  a .imp. b >  a .imp (b .imp. c) Or functions: implies(a,b) implies(a,implies(b,c)) That's the simplest option :) No hacks required, syntax is clear even if the reader doesn't know what you're

Re: why () is () and [] is [] work in other way?

2012-04-20 Thread Chris Angelico
On Sat, Apr 21, 2012 at 5:10 AM, dmitrey wrote: > I have spent some time searching for a bug in my code, it was due to > different work of "is" with () and []: () is () > True [] is [] > False Okay, let's take a step back. What do you expect "is" to be doing? It doesn't check for equali

Re: Appending to []

2012-04-20 Thread Chris Angelico
t [].append(1) > None This looks at the return value of the append() method. Since it doesn't return self, the return value isn't much use. Incidentally, your function call in the first block would have displayed the return value had it not been None - that's how the interactive

Re: Appending to []

2012-04-20 Thread Chris Angelico
On Sat, Apr 21, 2012 at 6:17 AM, Rotwang wrote: > In general there's no reason why > a.method(arguments) print a > > will print the same thing as > print a.method(arguments) > > since a method doesn't assign the value it returns to the instance on which > it is called; what it does

Re: can I overload operators like "=>", "->" or something like that?

2012-04-20 Thread Chris Angelico
On Sat, Apr 21, 2012 at 7:34 AM, Steven W. Orr wrote: > Then define a class called Bool that redefines things like __rlshift__ and > __rrshift__. That would get >>= and <<= for Implications and nodus tolens. > It's not a total solution. I can't see how you're going to get IFF, NAND and > NOR. IFF

Re: Unable to Concatenate a file - destination kept getting overwritten

2012-04-20 Thread Chris Angelico
On Sat, Apr 21, 2012 at 11:03 AM, Foster Rilindo wrote: > Is this right way to concatenate a file or is there a better way? I'd be inclined to ignore shutil and simply open one file for reading, the other for appending, and manually transfer data from one to the other. open(disk1,"ab").write(ope

Re: How do you refer to an iterator in docs?

2012-04-20 Thread Chris Angelico
On Sat, Apr 21, 2012 at 9:40 AM, Terry Reedy wrote: > On 4/20/2012 9:41 AM, Roy Smith wrote: > >> Except that "list of foos" and "sequence of foos" make sense from a >> grammar standpoint, but "iterator of foos" does not.  Or maybe it does? > > I consider it grammatical, but idiomatically, it *is*

Re: How do you refer to an iterator in docs?

2012-04-20 Thread Chris Angelico
On Sat, Apr 21, 2012 at 1:01 PM, Roy Smith wrote: > Because an iterator isn't a container.  I don't know, maybe it does make > sense, but my first impression is that it sounds wrong. > > A basket of apples is a basket which contains apples, in the same way a > list contains foos.  But an iterator

Re: why () is () and [] is [] work in other way?

2012-04-21 Thread Chris Angelico
On Sat, Apr 21, 2012 at 10:51 PM, gst wrote: > case 2) also ok to me: > x = id([]) ; y = id([]) x == y > True > > > case 3) NOT ok to me : > x = id([]) y = id([]) x == y > False The fact that ids get reused at all is an implementation detail ONLY. In CPython, id

Re: why () is () and [] is [] work in other way?

2012-04-21 Thread Chris Angelico
On Sun, Apr 22, 2012 at 1:14 PM, Steven D'Aprano wrote: > The CPython interpreter is especially aggressive in optimizing multiple > literals in the same line. Compare this: > x = 3.1; y = 3.1; x is y > True > > with this: > x = 3.1 y = 3.1 x is y > False > > > Again, this is an

Re: why () is () and [] is [] work in other way?

2012-04-22 Thread Chris Angelico
On Mon, Apr 23, 2012 at 5:43 AM, John Nagle wrote: > Operator "is" should be be an error between immutables > unless one is a built-in constant.  ("True" and "False" > should be made hard constants, like "None". You can't assign > to None, but you can assign to True, usually with > unwanted result

Re: global vars across modules

2012-04-22 Thread Chris Angelico
On Mon, Apr 23, 2012 at 6:08 AM, wrote: > Thanks! Here is what I need to do, perhaps you can give me some hints. > > A generic module, used across different independent programs, puts its > computing results in a var fairly big, ~50KB. > > I need the functions in these programs to access that va

Re: global vars across modules

2012-04-22 Thread Chris Angelico
On Mon, Apr 23, 2012 at 8:13 AM, Kiuhnm wrote: > It makes sense though. > "Import" imports values, not variables. Python doesn't _have_ variables. Python has names and objects. http://python.net/~mwh/hacks/objectthink.html ChrisA -- http://mail.python.org/mailman/listinfo/python-list

Re: This code not working, need suggetions

2012-04-23 Thread Chris Rebert
ement (http://www.python.org/dev/peps/pep-0343/ ). > get_file = raw_input("Which file would you like to browse ?") Presumably this line should be under your `if __name__ == "__main__":`? And you're not actually doing anything with `get_file` after you obtain it from the user... Regards, Chris -- http://mail.python.org/mailman/listinfo/python-list

Re: I couldn't use the sign funcion inside of another function

2012-04-23 Thread Chris Rebert
9, in tst >      s = sign(x) >  NameError: global name 'sign' is not defined > > > Do you have any idea why is this happening? There is no built-in sign() function in Python. It must be coming from some library that you imported. You need to add that import to pp.py s

Re: why () is () and [] is [] work in other way?

2012-04-25 Thread Chris Angelico
On Thu, Apr 26, 2012 at 3:27 AM, Steven D'Aprano wrote: > By the way, in mathematics, ≡ normally means "is equivalent to", which is > not quite the same as "identical to". That's perhaps because, in mathematics, nobody would even think of asking if this 4 is the same as that 4. What sort of quest

Re: Strange __import__() behavior

2012-04-25 Thread Chris Kaynor
On Wed, Apr 25, 2012 at 1:05 PM, Frank Miles wrote: > I have an exceedingly simple function that does a "named import". > It works perfectly for one file "r"- and fails for the second "x". > > If I reverse the order of being called, it is still "x" that fails, > and "r" still succeeds. > > os.acc

Re: why () is () and [] is [] work in other way?

2012-04-25 Thread Chris Angelico
On Thu, Apr 26, 2012 at 1:50 PM, Adam Skutt wrote: > On Apr 25, 8:01 pm, Steven D'Aprano [email protected]> wrote: >> 2) The "is" operator always has the exact same semantics and cannot be >> overridden. The id() function can be monkey-patched. > > I can't see how that's useful at a

Re: why () is () and [] is [] work in other way?

2012-04-25 Thread Chris Angelico
On Thu, Apr 26, 2012 at 3:48 PM, John Nagle wrote: >   This assumes that everything is, internally, an object.  In CPython, > that's the case, because Python is a naive interpreter and everything, > including numbers, is "boxed".  That's not true of PyPy or Shed Skin. > So does "is" have to force

Re: why () is () and [] is [] work in other way?

2012-04-26 Thread Chris Angelico
On Thu, Apr 26, 2012 at 9:42 PM, Adam Skutt wrote: > Would you call the result of casting a C pointer to an int an > address?  If so, you must call the result of id() an address as well-- > you can't dereference either of them.  If not, then you need to > provide an alternate name for the result o

Re: why () is () and [] is [] work in other way?

2012-04-26 Thread Chris Angelico
On Thu, Apr 26, 2012 at 10:12 PM, Robert Kern wrote: > Yes. Win64 has 64-bit pointers and 32-bit C longs (and thus 32-bit Python > ints). > > It returns a Python long. Ah, that solves that one. Definite improvement in Python 3 with the merging of the two types, though. Machine integers are simply

Re: why () is () and [] is [] work in other way?

2012-04-26 Thread Chris Angelico
On Fri, Apr 27, 2012 at 12:00 AM, Adam Skutt wrote: > C# and Python do have a misfeature: '==' is identity comparison only > if operator== / __eq__ is not overloaded.  Identity comparison and > value comparison are disjoint operations, so it's entirely > inappropriate to combine them. So what sho

Re: Half-baked idea: list comprehensions with "while"

2012-04-26 Thread Chris Rebert
> for a in iterable: >    if not a: >        break >    x.append(a) Someone borrowed Guido's time machine: http://docs.python.org/library/itertools.html#itertools.takewhile Cheers, Chris -- http://rebertia.com -- http://mail.python.org/mailman/listinfo/python-list

Re: Half-baked idea: list comprehensions with "while"

2012-04-26 Thread Chris Kaynor
On Thu, Apr 26, 2012 at 10:02 AM, Roy Smith wrote: > > I'm not seriously suggesting this as a language addition, just an interesting > idea to simplify some code I'm writing now: > > x = [a for a in iterable while a] > > which equates to: > > x = [] > for a in iterable: >    if not a: >        br

Re: (3.2) Overload print() using the C API?

2012-04-26 Thread Chris Angelico
On Fri, Apr 27, 2012 at 3:57 AM, Peter Faulks wrote: > I want to extend an embedded interpreter so that calls to print() are > automagically sent to a C++ gui (windows exe) via a callback function in the > DLL. > > Then I'll be able to do this: > > test.py > import printoverload > > printo

Re: (3.2) Overload print() using the C API?

2012-04-26 Thread Chris Angelico
On Fri, Apr 27, 2012 at 5:28 AM, Peter Faulks wrote: > Cheers, > > Yes was aware this would (might) be possible in 3.x only. > > "All you have to do is assign to print". Sounds great! Can some kind soul > hit me with a clue stick? Were do I look in the API? (We prefer to avoid top-posting on this

Re: why () is () and [] is [] work in other way?

2012-04-26 Thread Chris Angelico
On Fri, Apr 27, 2012 at 7:39 AM, Ian Kelly wrote: > I'm not sure precisely what you mean by "temporary object", so I am > taking it to mean an object that is referenced only by the VM stack > (or something equivalent for other implementations). > > In that case: no, you can't.  Take "f() is g()",

Re: why () is () and [] is [] work in other way?

2012-04-26 Thread Chris Angelico
On Fri, Apr 27, 2012 at 8:04 AM, Ian Kelly wrote: > You can't check ref counts at parse time. I know, and it'd be impossible to recognize at parse time for any but the most trivial cases (since names can always be rebound). The detection of temporaries can only be done at run time. ChrisA -- ht

Re: why () is () and [] is [] work in other way?

2012-04-26 Thread Chris Angelico
On Fri, Apr 27, 2012 at 12:47 PM, Steven D'Aprano wrote: > On Thu, 26 Apr 2012 17:16:10 -0700, Adam Skutt wrote: > >> On Apr 26, 7:33 pm, Steven D'Aprano > [email protected]> wrote: >>> On Thu, 26 Apr 2012 12:22:55 -0700, Adam Skutt wrote: >>> > I often wonder what the world would be

Re: Half-baked idea: list comprehensions with "while"

2012-04-27 Thread Chris Angelico
On Fri, Apr 27, 2012 at 7:49 PM, Miles Rout wrote: > We have if inside list comprehensions? I didn't know that, could you provide > an example? You mean like: [x*2+1 for x in range(10) if x%3] ? ChrisA -- http://mail.python.org/mailman/listinfo/python-list

Re: Half-baked idea: list comprehensions with "while"

2012-04-27 Thread Chris Angelico
On Fri, Apr 27, 2012 at 8:37 PM, Tim Wintle wrote: > Or like: > print [ 0 if b%2==1 else 1 for b in range(10)] > [1, 0, 1, 0, 1, 0, 1, 0, 1, 0] That's nothing to do with the list comp, that's just the expression-if syntax that you can use anywhere. ChrisA -- http://mail.python.org/mailman/

Re: why () is () and [] is [] work in other way?

2012-04-27 Thread Chris Angelico
On Fri, Apr 27, 2012 at 10:07 PM, Kiuhnm wrote: > Conceptually, NaN is the class of all elements which are not numbers, > therefore NaN = NaN. The conceptually correct way would be to check for > 'NaN' explicitly. Conceptually, "single-digit-numbers" is the class of all elements which are integer

Re: Half-baked idea: list comprehensions with "while"

2012-04-27 Thread Chris Angelico
On Fri, Apr 27, 2012 at 10:17 PM, John O'Hagan wrote: > results = [x = expensive_call(i) for i in iterable if condition(x)] Nest it: results = [x for x in (expensive_call(i) for i in iterable) if condition(x)] ChrisA -- http://mail.python.org/mailman/listinfo/python-list

Re: Borg identity [was Re: why () is () and [] is [] work in other way?]

2012-04-27 Thread Chris Angelico
On Sat, Apr 28, 2012 at 3:33 AM, Adam Skutt wrote: > I think you misunderstood me.  Define a Borg class where somehow > identity is the same for all instances.  Inherit from that class and > add per-instance members.  Now, identity can't be the same for all > instances.  As a result, you've just v

Re: Python id() does not return an address [was Re: why () is () and [] is [] work in other way?]

2012-04-27 Thread Chris Angelico
On Sat, Apr 28, 2012 at 3:51 AM, Adam Skutt wrote: > Yes, there is a way.  You add a function deref() to the language.  In > CPython, that simply treats the passed value as a memory address and > treats it as an object, perhaps with an optional check.  In Jython, > it'd access a global table of nu

Re: CPython thread starvation

2012-04-27 Thread Chris Angelico
On Sat, Apr 28, 2012 at 1:35 PM, John Nagle wrote: > On CentOS, "getaddrinfo()" at the > glibc level doesn't always cache locally (ref > https://bugzilla.redhat.com/show_bug.cgi?id=576801).  Python > doesn't cache either. How do you manage your local cache? The Python getaddrinfo function doesn't

Re: why () is () and [] is [] work in other way?

2012-04-28 Thread Chris Angelico
On Sat, Apr 28, 2012 at 9:26 PM, Kiuhnm wrote: > Your problem is that you think that copy semantics requires real copying. I > really don't see any technical difficulty in virtualizing the all thing. "Copy semantics" without "real copying" is an optimization that a program should never need to be

Re: CPython thread starvation

2012-04-28 Thread Chris Angelico
On Sat, Apr 28, 2012 at 11:46 PM, Danyel Lawson wrote: > The DNS lookup is one of those things that may make sense to run as a > separate daemon process that listens on a socket. Yeah, it does. One that listens on port 53, TCP and UDP, perhaps. :) You've just recommended installing a separate ca

Re: CPython thread starvation

2012-04-28 Thread Chris Angelico
On Sun, Apr 29, 2012 at 12:27 AM, Danyel Lawson wrote: > I'm glad I thought of it. ;) But the trick is to use port 5353 and set > a really short timeout on responses in the config for the DNS cache. I don't think false timeouts are any better than true ones, if you actually know the true ones. Bu

Re: confusing doc: mutable and hashable

2012-04-28 Thread Chris Rebert
#set-types-set-frozenset: >  Since it is mutable, it has no hash value and cannot be used as either a > dictionary key or as an element of another set. > Cheers, Chris -- http://mail.python.org/mailman/listinfo/python-list

Re: Learn Technical Writing from Unix Man in 10 Days

2012-04-28 Thread Chris Angelico
On Sun, Apr 29, 2012 at 8:36 AM, Temia Eszteri wrote: > And what does this have to do with a multiplatform language like > Python? :P Nothing. Xah Lee is a professional troll. You can save yourself some trouble by ignoring his posts altogether. ChrisA -- http://mail.python.org/mailman/listinfo/

Re: Communication between C++ server and Python app

2012-04-28 Thread Chris Angelico
On Sun, Apr 29, 2012 at 10:45 AM, kenk wrote: > Hi, > > I've got a server process written in C++ running on Unix machine. > On the same box I'd like to run multiple Python scripts that will > communicate with this server. > > Can you please suggest what would be best was to achieve this ? Persona

Re: Communication between C++ server and Python app

2012-04-29 Thread Chris Angelico
On Sun, Apr 29, 2012 at 4:24 PM, Cameron Simpson wrote: > On 29Apr2012 11:42, Chris Angelico wrote: > | Personally, I would recommend a TCP socket, because that allows the > | flexibility of splitting across multiple computers. > > And the pain of ensuring security, if you'r

Re: Help with how to combine two csv files

2012-04-29 Thread Chris Angelico
On Mon, Apr 30, 2012 at 1:49 AM, Dennis Lee Bieber wrote: >        What do you want done if one file has fewer records than the other? The OP did state that the files had the same number of rows. I'd say this issue is outside the scope of the question. ChrisA -- http://mail.python.org/mailman/l

Re: convert integer to string

2012-04-29 Thread Chris Rebert
gt; TypeError: 'module' object is not callable >>>> > What is it wrong? Presumably, at some point you did: import string str = string Or similar, thus shadowing the built-in type. As I said, there's no need to `import string`, and the `str` type is built-in, s

Re: Learn Technical Writing from Unix Man in 10 Days

2012-04-29 Thread Chris Angelico
On Mon, Apr 30, 2012 at 12:43 PM, Jason Earl wrote: > It is considerably worse than that.  If you look at what the > documentation for apt-get actually says, instead of just the badly > mangled version that Xah shares you would realize that the post was > basically a bald-face troll. Not only tha

Re: Learn Technical Writing from Unix Man in 10 Days

2012-04-29 Thread Chris Angelico
On Mon, Apr 30, 2012 at 2:50 PM, Xah Lee wrote: > jason, are you trolling me, or me you? Am I Turing dreaming I am a machine, or a machine dreaming I am Turing? Personally, I've never Turred. ChrisA -- http://mail.python.org/mailman/listinfo/python-list

Re: For loop

2012-04-30 Thread Chris Angelico
t finishes with a newline or '\n'. You'll find information on how to suppress that here: http://docs.python.org/reference/simple_stmts.html#the-print-statement Hope that helps! Chris Angelico -- http://mail.python.org/mailman/listinfo/python-list

Re: Creating a directory structure and modifying files automatically in Python

2012-04-30 Thread Chris Rebert
script would use the following modules: http://docs.python.org/library/shutil.html http://docs.python.org/library/os.path.html Cheers, Chris -- http://mail.python.org/mailman/listinfo/python-list

Re: Create directories and modify files with Python

2012-05-01 Thread Chris Angelico
On Tue, May 1, 2012 at 9:45 PM, Peter Otten <[email protected]> wrote: > In that spirit I'd like to make an alternative offer: put some effort into > the job yourself, write a solution in bash and post it here. I (or someone > else) will then help you translate it into basic Python. That will typica

Re: syntax for code blocks

2012-05-01 Thread Chris Angelico
On Wed, May 2, 2012 at 12:18 AM, Kiuhnm wrote: > "Most Pythonic" doesn't mean better, unfortunately. > > For instance, assume that you want to write a function that accepts a > dictionary of callbacks: >  func(some_args, callbacks) > > Pythonic way > > > def when_odd(n): >    pass > >

Re: syntax for code blocks

2012-05-01 Thread Chris Angelico
On Wed, May 2, 2012 at 1:11 AM, Steven D'Aprano wrote: > So in this case, even though Python is slightly more verbose, and forces > you to have the discipline of writing named functions ahead of time, this > is actually a *good* thing because it encourages you to test them. > > If the callbacks ar

Re: linux

2012-05-02 Thread Chris Angelico
On Wed, May 2, 2012 at 4:25 PM, Debashish Saha wrote: > can anyone say me how to subscribe linux mailing list like 'python > mailing list'. Actually i want to post question there. Search the web, you'll find something. ChrisA -- http://mail.python.org/mailman/listinfo/python-list

Re: DateTime objectFormatting

2012-05-02 Thread Chris Rebert
docs.python.org/library/datetime.html#strftime-and-strptime-behavior : "%p -- Locale’s equivalent of either AM or PM." So, strftime("%A %p, %B %d"). Regards, Chris -- http://mail.python.org/mailman/listinfo/python-list

Re: John Carmack glorifying functional programing in 3k words

2012-05-02 Thread Chris Angelico
On Thu, May 3, 2012 at 1:31 AM, Tomasz Rola wrote: > He may be smart but obviously hasn't figured out this yet: positive aura > drives more people and more permamently towards you. You catch more flies with honey than with vinegar, but who wants to catch flies? I don't see much value in Xah Lee'

Re: [GENERAL] Uppercase to lowercase trigger?

2012-05-02 Thread Chris Angelico
On Wed, May 2, 2012 at 10:33 PM, Chrishelring wrote: > Hi, > > I´ve got some tables with column names in lowercase. Before updatering these > tables I want to add a trigger that can convert these lowercase to > uppercase, and when the tables are updates convert them back to lowercase.. Not entire

Re: [GENERAL] Uppercase to lowercase trigger?

2012-05-02 Thread Chris Angelico
On Thu, May 3, 2012 at 2:29 AM, Chris Angelico wrote: > On Wed, May 2, 2012 at 10:33 PM, Chrishelring > wrote: >> Hi, >> >> I´ve got some tables with column names in lowercase. Before updatering these >> tables I want to add a trigger that can convert these lower

Re: try/except in a loop

2012-05-02 Thread Chris Kaynor
On Wed, May 2, 2012 at 12:51 PM, J. Mwebaze wrote: > I have multiple objects, where any of them can serve my purpose.. However > some objects might not have some dependencies. I can not tell before hand if > the all the dependencies exsit. What i want to is begin processing from the > 1st object,

Re: try/except in a loop

2012-05-02 Thread Chris Kaynor
On Wed, May 2, 2012 at 1:12 PM, Prasad, Ramit wrote: >> > I have multiple objects, where any of them can serve my purpose.. >> However >> > some objects might not have some dependencies. I can not tell before >> hand if >> > the all the dependencies exsit. What i want to is begin processing from >

Re: John Carmack glorifying functional programing in 3k words

2012-05-02 Thread Chris Angelico
On Thu, May 3, 2012 at 3:22 AM, Tomasz Rola wrote: > I think you can catch more girls with honey and I'm not sure if I'd like > to catch those who prefer vinegar. I think we can make it into some kind > of law, say Angelico-Rola Law (of girlscatching), ok? > > "One cannot catch a girl on honey wit

Re: John Carmack glorifying functional programing in 3k words

2012-05-02 Thread Chris Angelico
On Thu, May 3, 2012 at 8:04 AM, Michael Torrie wrote: > Others who have crossed this list appear to have aspergers or autism > too, such as Ranting Rick.  He pops up occasionally, posts quite > normally and even helpfully, and then lapses back into periods of > ranting about how he can fix python

Re: Converting a string to list for submission to easygui multenterb​ox

2012-05-02 Thread Chris Angelico
On Thu, May 3, 2012 at 3:57 AM, Laurent Pointal wrote: > If you have it as a string, you can use eval() (not safe!) on the string to > retrieve the tuple, then list() on the tuple to get a list. Are you saying that eval is not safe (which it isn't), or that it has to be eval() and not safe_eval()

c-based version of pyPdf?

2012-05-03 Thread Chris Curvey
I'm a long-time user of the pyPdf library, but now I'm having to work with bigger volumes -- larger PDFs and thousands of them at a shot. So performance is starting to become a problem. Does anyone know of an analogue to pyPdf that is faster? (Maybe something based on C with Python bindings?

Re: syntax for code blocks

2012-05-03 Thread Chris Angelico
On Fri, May 4, 2012 at 12:44 PM, alex23 wrote: > On May 4, 2:17 am, Kiuhnm wrote: >> I would've come up with something even better if only Python wasn't so rigid. > > The inability for people to add 6 billion mini-DSLs to solve any > stupid problem _is a good thing_. It makes Python consistent an

Re: When convert two sets with the same elements to lists, are the lists always going to be the same?

2012-05-04 Thread Chris Angelico
On Fri, May 4, 2012 at 8:14 PM, Peng Yu wrote: > Thanks. This is what I'm looking for. I think that this should be > added to the python document as a manifestation (but nonnormalized) of > what "A set object is an unordered collection of distinct hashable > objects" means. There are other things

Re: syntax for code blocks

2012-05-04 Thread Chris Angelico
On Fri, May 4, 2012 at 9:12 PM, Kiuhnm wrote: > If I and my group of programmers devised a good and concise syntax and > semantics to describe some applicative domain, then we would want to > translate that into the language we use. > Unfortunately, Python doesn't let you do that. No, this is not

Re: recruiter spam

2012-05-04 Thread Chris Withers
Please don't spam the list with job adverts, post to the job board instead: http://www.python.org/community/jobs/howto/ cheers, Chris On 03/05/2012 22:13, Preeti Bhattad wrote: Hi there, If you have USA work visa and if you reside in USA; -- Simplistix - Content Management,

Re: When convert two sets with the same elements to lists, are the lists always going to be the same?

2012-05-05 Thread Chris Angelico
On Sat, May 5, 2012 at 9:04 PM, Peng Yu wrote: > I agree that people have different opinions on issues like this. But I > think that "The Customer Is God". Readers of the doc is the customers, > the writers of the doc is the producers. The opinion of customers > should carry more weight than produ

Re: How to compute a delta: the difference between lists of strings

2012-05-05 Thread Chris Angelico
On Sat, May 5, 2012 at 10:12 PM, J. Mwebaze wrote: > This is out of curiosity, i know this can be done with python diffllib > module, but been figuring out how to compute the delta, Consider two lists > below. > > s1 = ['e', 'f', 'g', 'A', 'B', 'C', 'D', 'C'] > s2 =['e', 'A', 'B', 'f', 'g', 'C', '

Re: Problem with time.time() standing still

2012-05-05 Thread Chris Angelico
On Sun, May 6, 2012 at 6:51 AM, Bob Cowdery wrote: > The time.clock() function does increment correctly. CPU is around 30% 30% of how many cores? If that's a quad-core processor, that could indicate one core completely pegged plus a little usage elsewhere. ChrisA -- http://mail.python.org/mailm

Re: Problem with time.time() standing still

2012-05-06 Thread Chris Angelico
On Sun, May 6, 2012 at 6:18 PM, Bob Cowdery wrote: > On 05/05/2012 23:05, Cameron Simpson wrote: >> Thought #1: you are calling time.time() and haven't unfortunately >> renamed it? (I doubt this scenario, though the lack of fractional part >> is interesting.) > Not sure what you mean by renamed it

Re: sorting 1172026 entries

2012-05-06 Thread Chris Rebert
pen(filename.strip('.txt')+ '.sorted', 'wb') as p: strip() doesn't do quite what you think it does: $ python Python 2.7.1 (r271:86832, Jul 31 2011, 19:30:53) >>> '.xtx.foo'.strip('.txt') 'foo' >>> Consult the docs. Also, please avoid top-posting in the future. Cheers, Chris -- http://mail.python.org/mailman/listinfo/python-list

Re: sorting 1172026 entries

2012-05-06 Thread Chris Rebert
t by append(), one > item at a time. That should have runtime cost of the square of the list > length, 1172026 * 1172026. Though I've just done this: Er, what? list.append() is O(1) amortized. Perhaps you're confusing list.append() with list.insert(), which is indeed O(n)? Cheers, Chris -- http://mail.python.org/mailman/listinfo/python-list

Re: sorting 1172026 entries

2012-05-06 Thread Chris Angelico
On Mon, May 7, 2012 at 10:31 AM, Cameron Simpson wrote: > I didn't mean per .append() call (which I'd expect to be O(n) for large > n), I meant overall for the completed list. > > Don't the realloc()s make it O(n^2) overall for large n? The list > must get copied when the underlying space fills. I

Re: return respective values when mutiple keys are passed in dictionary

2012-05-07 Thread Chris Angelico
On Mon, May 7, 2012 at 9:31 PM, Nikhil Verma wrote: > mydict = {'a':'apple' , 'b':'boy' ,'c' : 'cat', 'd':'duck','e':'egg'} > > Now if i do :- > > mydict.get('a') > 'apple' > > What i want is some i pass keys in get and in return i should have all the > values of those keys which i pass. > > #

Re: How do I run a python program from an internet address?

2012-05-07 Thread Chris Angelico
On Tue, May 8, 2012 at 9:20 AM, Albert wrote: > I have a small text based python program that I want to make available > to people who might be behind a firewall or can't install python on > their office computers, but can access the internet.  It is just an > algorithm that makes a handful of str

<    21   22   23   24   25   26   27   28   29   30   >