Re: [Twisted-Python] Announcing pyOpenSSL 0.12

2011-04-11 Thread anatoly techtonik
Good news. It may worth to update http://wiki.python.org/moin/SSL with details. Right now it says that pyOpenSSL can not validate server identity. -- anatoly t. On Tue, Apr 12, 2011 at 3:19 AM, wrote: > Exciting news everyone, > > I have just released pyOpenSSL 0.12.  pyOpenSSL provides Python

Re: Feature suggestion -- return if true

2011-04-11 Thread James Mills
On Tue, Apr 12, 2011 at 4:08 PM, Nobody wrote: > It should be abundantly clear that this only returns if the expression is > considered true, otherwise it continues on to the following statements. Uggh come on guys. We've been over this. You cannot make that assumption. cheers James -- -- Jam

Re: Feature suggestion -- return if true

2011-04-11 Thread Nobody
On Tue, 12 Apr 2011 13:01:43 +1000, James Mills wrote: >> That's still not equivalent. "return expr or None" will always >> terminate the function. The OP's request was for something which would >> terminate the function if and only if expr is non-false. > > The OP did not state this at all. > Th

Re: Help with regex needed

2011-04-11 Thread Chris Rebert
On Mon, Apr 11, 2011 at 10:20 PM, Yuri Slobodyanyuk wrote: > Good day everyone, > I am trying to make this pretty simple regex to work but got stuck, > I'd appreciate your help . "Some people, when confronted with a problem, think 'I know, I'll use regular expressions.' Now they have two problems

Re: Help with regex needed

2011-04-11 Thread Chris Rebert
On Mon, Apr 11, 2011 at 10:20 PM, Yuri Slobodyanyuk wrote: > Good day everyone, > I am trying to make this pretty simple regex to work but got stuck, > I'd appreciate your help . > Task: Get current date , then read file of format below, find the line that > matches > the current date of month,mon

Re: Help with regex needed

2011-04-11 Thread Kushal Kumaran
On Tue, Apr 12, 2011 at 10:50 AM, Yuri Slobodyanyuk wrote: > Good day everyone, > I am trying to make this pretty simple regex to work but got stuck, > I'd appreciate your help . > Task: Get current date , then read file of format below, find the line that > matches > the current date of month,mon

Help with regex needed

2011-04-11 Thread Yuri Slobodyanyuk
Good day everyone, I am trying to make this pretty simple regex to work but got stuck, I'd appreciate your help . Task: Get current date , then read file of format below, find the line that matches the current date of month,month and year and extract the number from such line. Here is what I did ,

Re: Literate Programming

2011-04-11 Thread Tim Arnold
"Hans Georg Schaathun" wrote in message news:aca678-b87@svn.schaathun.net... > On Fri, 8 Apr 2011 12:58:34 -0400, Tim Arnold > wrote: > : If you already know LaTeX, you might experiment with the *.dtx docstrip > : capability. > > Hi. Hmmm. That's a new thought. I never thought of using

Re: Feature suggestion -- return if true

2011-04-11 Thread James Mills
On Tue, Apr 12, 2011 at 12:44 PM, Chris Angelico wrote: > That's still not equivalent. "return expr or None" will always > terminate the function. The OP's request was for something which would > terminate the function if and only if expr is non-false. The OP did not state this at all. There was

Re: dict.setdefault()

2011-04-11 Thread rantingrick
On Apr 11, 5:41 pm, MRAB wrote: > A new method like "updatedefault" may be better, IMHO. It would act > like "update" except that it wouldn't overwrite existing values. That's sounds good MRAB! After you mentioned this i had an epiphany... why not just add an extra argument to dict.update? >>>

Re: Feature suggestion -- return if true

2011-04-11 Thread James Mills
On Tue, Apr 12, 2011 at 12:43 PM, Zero Piraeus wrote: > I think the point is that OP doesn't want to return *at all* if expr > is False - presumably because there are further statements after the > proposed 'conditional' return. If that's the case then we're all making assumptions about what the

Re: Feature suggestion -- return if true

2011-04-11 Thread Chris Angelico
On Tue, Apr 12, 2011 at 12:43 PM, Zero Piraeus wrote: >  return? expr > > isn't very pythonic - so how about one of these? > >  return expr if True >  return expr else continue > > I kid, I kid ... Or: if expr: return it Actually, I'm not sure how stupid an idea that is. Inside an if, 'it' is

Re: Feature suggestion -- return if true

2011-04-11 Thread James Mills
On Tue, Apr 12, 2011 at 12:18 PM, Grant Edwards wrote: > You stated that > >  return? > > was equivalent to > >  return or None This is _not_ what I said. Quoting from my earlier post: """ >return? expr This syntax does not fit well within python ideology. > be expanded to > >_temp

Re: Feature suggestion -- return if true

2011-04-11 Thread Chris Angelico
On Tue, Apr 12, 2011 at 12:20 PM, James Mills wrote: > On Tue, Apr 12, 2011 at 12:18 PM, Jason Swails wrote: >> This is only true if n < 5.  Otherwise, the first returns None and the >> second returns False. > > Which is why I said: > > return expr or None > > But hey let's argue the point to dea

Re: Feature suggestion -- return if true

2011-04-11 Thread Zero Piraeus
: >> This is only true if n < 5.  Otherwise, the first returns None and the >> second returns False. > > Which is why I said: > > return expr or None > > But hey let's argue the point to death! Ok ;-) I think the point is that OP doesn't want to return *at all* if expr is False - presumably beca

Re: Feature suggestion -- return if true

2011-04-11 Thread James Mills
On Tue, Apr 12, 2011 at 12:18 PM, Jason Swails wrote: > This is only true if n < 5.  Otherwise, the first returns None and the > second returns False. Which is why I said: return expr or None But hey let's argue the point to death! cheers James -- -- James Mills -- -- "Problems are solved by

Re: Feature suggestion -- return if true

2011-04-11 Thread Grant Edwards
On 2011-04-12, James Mills wrote: > On Tue, Apr 12, 2011 at 11:44 AM, Grant Edwards > wrote: >> How is that the same? >> >> ??return? something() ?? ?? ?? ?? ?? ?? ?? ?? ??return something() or None >> ??return? somethingelse() ?? ?? ?? ?? ?? ?? ??return somethingelse() or None >> ??log("didn't

Re: Feature suggestion -- return if true

2011-04-11 Thread Jason Swails
On Mon, Apr 11, 2011 at 7:12 PM, James Mills wrote: > > > Are you saying the two snippets above are equivalent? > > def foo(n): >x = n < 5 >if x: >return x > > is functionally equivalent to: > > def foo(n): >return n < 5 > > This is only true if n < 5. Otherwise, the first ret

Re: Feature suggestion -- return if true

2011-04-11 Thread James Mills
On Tue, Apr 12, 2011 at 11:44 AM, Grant Edwards wrote: > How is that the same? > >  return? something()                  return something() or None >  return? somethingelse()              return somethingelse() or None >  log("didn't find an answer")         log("didn't find an answer") >  raise V

Re: Feature suggestion -- return if true

2011-04-11 Thread Grant Edwards
On 2011-04-12, James Mills wrote: > On Tue, Apr 12, 2011 at 9:17 AM, zildjohn01 wrote: >> This is an idea I've had bouncing around in my head for a long time >> now. I propose the following syntax: > > Maybe this is more appropriare for the python-ideas list ? > >> ?? ??return? expr > > This synt

Re: Feature suggestion -- return if true

2011-04-11 Thread Chris Angelico
On Tue, Apr 12, 2011 at 10:46 AM, Chris Angelico wrote: > def fac(n): >    return cache[n] or (cache[n]=1 if n<=1 else fac(n-1)*n) Hmm. The function-call version of dictionary assignment IS legal in an expression, but it's getting stupid... def fac(n): return cache.get(n) or (cache.__setitem

Re: Feature suggestion -- return if true

2011-04-11 Thread Chris Angelico
On Tue, Apr 12, 2011 at 10:27 AM, James Mills wrote: > This could be simplified to just: > > return expr or None > > And more to the point... If your calee is relying > on the result of this function, just returning the > evaluation of "expr" is enough. I'm thinking here that that's not a solutio

Re: Feature suggestion -- return if true

2011-04-11 Thread James Mills
On Tue, Apr 12, 2011 at 9:17 AM, zildjohn01 wrote: > This is an idea I've had bouncing around in my head for a long time > now. I propose the following syntax: Maybe this is more appropriare for the python-ideas list ? >    return? expr This syntax does not fit well within python ideology. > b

Re: dict.setdefault()

2011-04-11 Thread Raymond Hettinger
On Apr 11, 4:25 pm, Tim Chase wrote: > Finally, if it were added, I'd call it something like merge() Guido rejected merge() a long time ago. Anyway, there is a new ChainMap() tool in the collections module for Py3.3 that should address a number of use cases for handling default values. Raymond

Announcing pyOpenSSL 0.12

2011-04-11 Thread exarkun
Exciting news everyone, I have just released pyOpenSSL 0.12. pyOpenSSL provides Python bindings to a number of OpenSSL APIs, including certificates, public and private keys, and of course running TLS (SSL) over sockets or arbitrary in- memory buffiers. This release fixes an incompatibility

Re: [Feature Request] dict.setdefault()

2011-04-11 Thread Tim Chase
On 04/11/2011 05:44 PM, Chris Angelico wrote: On Tue, Apr 12, 2011 at 8:41 AM, MRAB wrote: I'm not sure that "setdefault" should take **kw args for this because of its existing argument structure (key + optional value). A new method like "updatedefault" may be better, IMHO. It would act like "

Re: [OT] Free software versus software idea patents

2011-04-11 Thread Ben Finney
geremy condra writes: > […] I think it's quite reasonable to contend that the existence of > lambda calculus no more rules out the applicability of patents to > software (which I detest) than it rules out the applicability of > patents to hardware (which I find only slightly less ridiculous) or >

Feature suggestion -- return if true

2011-04-11 Thread zildjohn01
This is an idea I've had bouncing around in my head for a long time now. I propose the following syntax: return? expr be expanded to _temp = expr if _temp: return _temp It's a pattern I use all the time in my code, and although it's a bit unorthodox, IMO it's concise, readable, and

Re: [Feature Request] dict.setdefault()

2011-04-11 Thread MRAB
On 11/04/2011 23:44, Chris Angelico wrote: On Tue, Apr 12, 2011 at 8:41 AM, MRAB wrote: I'm not sure that "setdefault" should take **kw args for this because of its existing argument structure (key + optional value). A new method like "updatedefault" may be better, IMHO. It would act like "upd

Re: [OT] Free software versus software idea patents

2011-04-11 Thread geremy condra
On Mon, Apr 11, 2011 at 3:28 PM, Steven D'Aprano wrote: > On Mon, 11 Apr 2011 11:17:09 -0700, geremy condra wrote: > >> On Mon, Apr 11, 2011 at 2:10 AM, Steven D'Aprano >> wrote: > [...] >>> Of course, some mathematics is obvious, or at least intuitive (although >>> proving it rigorously can be r

Re: [Feature Request] dict.setdefault()

2011-04-11 Thread Chris Rebert
On Mon, Apr 11, 2011 at 2:35 PM, rantingrick wrote: > > setdefault should take **kw args in the case of needing to set > multiple defaults at one time. I would even settle for an *arg list if > i had to. What would the return value be? dict.setdefault() doesn't currently just return None you know

Re: dict.setdefault()

2011-04-11 Thread Raymond Hettinger
On Apr 11, 2:35 pm, rantingrick wrote: > setdefault should take **kw args in the case of needing to set > multiple defaults at one time. I would even settle for an *arg list if > i had to. Anything is better than... > > d.setdefault(blah, blah) > d.setdefault(blah, blah) > d.setdefault(blah, blah)

Re: Argument of the bool function

2011-04-11 Thread Ethan Furman
Mel wrote: Python is a pragmatic language, so all the rules come pre-broken. +1 QOTW -- http://mail.python.org/mailman/listinfo/python-list

Re: [Feature Request] dict.setdefault()

2011-04-11 Thread Chris Angelico
On Tue, Apr 12, 2011 at 8:41 AM, MRAB wrote: > I'm not sure that "setdefault" should take **kw args for this because > of its existing argument structure (key + optional value). > > A new method like "updatedefault" may be better, IMHO. It would act > like "update" except that it wouldn't overwrit

Re: [Feature Request] dict.setdefault()

2011-04-11 Thread MRAB
On 11/04/2011 23:16, Westley Martínez wrote: On Mon, 2011-04-11 at 14:35 -0700, rantingrick wrote: setdefault should take **kw args in the case of needing to set multiple defaults at one time. I would even settle for an *arg list if i had to. Anything is better than... d.setdefault(blah, blah)

Re: [OT] Free software versus software idea patents

2011-04-11 Thread Steven D'Aprano
On Mon, 11 Apr 2011 11:17:09 -0700, geremy condra wrote: > On Mon, Apr 11, 2011 at 2:10 AM, Steven D'Aprano > wrote: [...] >> Of course, some mathematics is obvious, or at least intuitive (although >> proving it rigorously can be remarkably difficult -- after 4000 years >> of maths, we still don'

Re: Dump interpreter history?

2011-04-11 Thread John Gordon
In Tim Chase writes: > > import readline > > readline.write_history_file([filename]) > Just to clarify (I thought Daniel's answer was so easy it must > have misinterpreted the OP's request), that's a single string as > a filename, not a list containing a filename. I tried In most documenta

Re: [Feature Request] dict.setdefault()

2011-04-11 Thread Westley Martínez
On Mon, 2011-04-11 at 14:35 -0700, rantingrick wrote: > setdefault should take **kw args in the case of needing to set > multiple defaults at one time. I would even settle for an *arg list if > i had to. Anything is better than... > > d.setdefault(blah, blah) > d.setdefault(blah, blah) > d.setdefa

[Feature Request] dict.setdefault()

2011-04-11 Thread rantingrick
setdefault should take **kw args in the case of needing to set multiple defaults at one time. I would even settle for an *arg list if i had to. Anything is better than... d.setdefault(blah, blah) d.setdefault(blah, blah) d.setdefault(blah, blah) d.setdefault(blah, blah) if blah is not blah: d

Re: Multiprocessing, shared memory vs. pickled copies

2011-04-11 Thread sturlamolden
On 11 apr, 21:11, sturlamolden wrote: > import numpy as np > import sharedmem as sm > private_array = np.zeros((10,10)) > shared_array  = sm.zeros((10,10)) I am also using this to implement synchronization primitives (barrier, lock, semaphore, event) that can be sent over an instance of multipro

Re: Multiprocessing, shared memory vs. pickled copies

2011-04-11 Thread sturlamolden
On 11 apr, 09:21, John Nagle wrote: >      Because nobody can fix the Global Interpreter Lock problem in CPython. > >      The multiprocessing module is a hack to get around the fact > that Python threads don't run concurrently, and thus, threaded > programs don't effectively use multi-core CPUs.

Re: [OT] Free software versus software idea patents

2011-04-11 Thread geremy condra
On Mon, Apr 11, 2011 at 2:10 AM, Steven D'Aprano wrote: > On Mon, 11 Apr 2011 00:53:57 -0700, geremy condra wrote: >> I am extremely skeptical of this argument. Leaving aside the fact that >> you've randomly decided to drop the "decidable" qualifier here- a big >> problem in its own right- it i

Re: Do UART require data structure/format for serial communication?

2011-04-11 Thread John Nagle
On 4/11/2011 4:57 AM, Jean-Michel Pichavant wrote: VGNU Linux wrote: Hi All, I have two chips one understands Python and the other embedded C.I have connected both chips using UART serial communication channel, however I have no idea how data communication must be achieved between this 2 chips.

Re: Dump interpreter history?

2011-04-11 Thread Terry Reedy
On 4/11/2011 11:54 AM, Aahz wrote: In article, Ken D'Ambrosio wrote: Hey, all. A co-worker asked me a question, and I've got no idea how (or if) it can be done. Bottom line: he'd like to save off the text from an interpreter session, his thinking being that you've already tried to get what y

Re: [OT] Free software versus software idea patents

2011-04-11 Thread Chris Angelico
On Tue, Apr 12, 2011 at 3:26 AM, Ian Kelly wrote: > So what is that number?  Anecdotes are unreliable; I would like to see > the actual data.  The only non-techie I personally know who uses Linux > is my wife, and she only uses it because it's what's installed at > home.  My brother-in-law was a L

Re: Feature suggestion: math.zod for painlessly avoiding ZeroDivisionError

2011-04-11 Thread Terry Reedy
On 4/11/2011 10:10 AM, Natan Yellin wrote: Hey everyone, This is my first posting to python-list, so be gentle. I propose the following function for the math module (which can, of course, be rewritten in C): zod = lambda a, b: b and a / b This is way too trivial to add. zod, the zero

Re: [OT] Free software versus software idea patents

2011-04-11 Thread Ian Kelly
On Sun, Apr 10, 2011 at 6:04 PM, harrismh777 wrote: > The deal with motive number (2) is that there are fewer and fewer teams who > are concerned with interoperability. For instance (my team), we moved our > stuff to gnulinux based systems and dumped Microsoft completely... we have > no need for t

Re: Dump interpreter history?

2011-04-11 Thread rusi
script readline ipython all nice solutions... There's one more (old) one: emacs ie you can run python inside (under) emacs That way you can pun thus: your interactions with python are a session when you choose and a file when you choose (buffer in emacs-speak). [Frank admission: The emacs python

Re: Dump interpreter history?

2011-04-11 Thread Aahz
In article , Ken D'Ambrosio wrote: > >Hey, all. A co-worker asked me a question, and I've got no idea how (or >if) it can be done. Bottom line: he'd like to save off the text from an >interpreter session, his thinking being that you've already tried to get >what you want, and now you just need t

Re: Feature suggestion: math.zod for painlessly avoiding ZeroDivisionError

2011-04-11 Thread Natan Yellin
On Mon, Apr 11, 2011 at 5:20 PM, Chris Angelico wrote: > On Tue, Apr 12, 2011 at 12:10 AM, Natan Yellin wrote: > > Hey everyone, > > This is my first posting to python-list, so be gentle. > > I propose the following function for the math module (which can, of > course, > > be rewritten in C): >

Feature suggestion: math.zod for painlessly avoiding ZeroDivisionError

2011-04-11 Thread Natan Yellin
Hey everyone, This is my first posting to python-list, so be gentle. I propose the following function for the math module (which can, of course, be rewritten in C): > zod = lambda a, b: b and a / b zod, the zero or divide function, is useful for division where the denominator can be 0. For exa

Re: Help Amigos

2011-04-11 Thread Jean-Michel Pichavant
Gabriel Novaes wrote: Hello community My name is Gabriel. I'am from Brazil. 27. I finished last year Degree in Computer Engineering and I would go to the U.S.A to learn the local language. I wonder how is the market for developers, which city ​​is best for this? I program for 5 years PHP (MVC) a

Re: Retrieving Python Keywords

2011-04-11 Thread Glazner
On Apr 10, 4:28 am, candide wrote: > Python is very good at introspection, so I was wondering if Python (2.7) > provides any feature to retrieve the list of its keywords (and, as, > assert, break, ...). >>> import keyword >>> keyword.kwlist ['and', 'as', 'assert', 'break', 'class', 'continue', 'd

Re: Help Amigos

2011-04-11 Thread Gabriel Novaes
On 11 abr, 09:01, Gabriel Novaes wrote: > Hello community > > My name is Gabriel. I'am from Brazil. 27. I finished last year > Degree in Computer Engineering and I would go to the U.S.A > to learn the local language. > I wonder how is the market for developers, which > city ​​is best for this? > I

Help Amigos

2011-04-11 Thread Gabriel Novaes
Hello community My name is Gabriel. I'am from Brazil. 27. I finished last year Degree in Computer Engineering and I would go to the U.S.A to learn the local language. I wonder how is the market for developers, which city ​​is best for this? I program for 5 years PHP (MVC) and for the past four mon

Re: Do UART require data structure/format for serial communication?

2011-04-11 Thread Jean-Michel Pichavant
VGNU Linux wrote: Hi All, I have two chips one understands Python and the other embedded C.I have connected both chips using UART serial communication channel, however I have no idea how data communication must be achieved between this 2 chips. As for example send using C chip string "Hello Py

Send Sms with Nokia Phone

2011-04-11 Thread Santhosh Kumar
Hi all, I try to implement a sms forwarding system. My aim is to when some hits happen in database It should send a sms so I did some research with gammu and gammu-smsd I did all the configuration and also test sms is working fine when I give echo "hello world" /etc/gammu text +91xx th

Do UART require data structure/format for serial communication?

2011-04-11 Thread VGNU Linux
Hi All, I have two chips one understands Python and the other embedded C.I have connected both chips using UART serial communication channel, however I have no idea how data communication must be achieved between this 2 chips. As for example send using C chip string "Hello Python" which python chip

Re: [OT] Free software versus software idea patents

2011-04-11 Thread Steven D'Aprano
On Mon, 11 Apr 2011 00:53:57 -0700, geremy condra wrote: > On Sun, Apr 10, 2011 at 7:49 PM, harrismh777 > wrote: >> Chris Angelico wrote: >      All software can be expressed as lambda calculus. The point >      being, > all >  software is mathematics... >> >>> With enoug

Re: Encoding problem when launching Python27 via DOS

2011-04-11 Thread Jean-Pierre M
Thanks a lot for this quick answer! It is very clear! Ti better understand what the difference between encoding and decoding is I found the following website: http://www.evanjones.ca/python-utf8.html I change the program to (changes are in bold): *# -*- c

Re: Free software versus software idea patents

2011-04-11 Thread rusi
On Apr 11, 12:53 pm, geremy condra wrote: > On Sun, Apr 10, 2011 at 7:49 PM, harrismh777 wrote: > > Chris Angelico wrote: > > >>> >      All software can be expressed as lambda calculus. The point being, > >>> > all > >>> >  software is mathematics... > > >> With enough software, you can simulate

Re: [OT] Free software versus software idea patents

2011-04-11 Thread geremy condra
On Sun, Apr 10, 2011 at 7:49 PM, harrismh777 wrote: > Chris Angelico wrote: >>> >>> >      All software can be expressed as lambda calculus. The point being, >>> > all >>> >  software is mathematics... > >> With enough software, you can simulate anything. That means that the >> entire universe can

Re: Multiprocessing, shared memory vs. pickled copies

2011-04-11 Thread John Nagle
On 4/10/2011 3:29 PM, sturlamolden wrote: On 10 apr, 18:27, John Nagle wrote: Unless you have a performance problem, don't bother with shared memory. If you have a performance problem, Python is probably the wrong tool for the job anyway. Then why does Python have a multiprocessin

Re: Free software versus software idea patents

2011-04-11 Thread wisecracker
Hi harrismh777... >> With enough software, you can simulate anything. That means that the >> entire universe can be expressed as lambda calculus. Does that mean >> that nothing can ever be patented, because it's all just mathematics? > Great question... the simple answer is, no. But the exten