Re: Python re.search simple question

2014-12-07 Thread Ganesh Pal
Thanks guys , I escaped the '[' character and my issue is sloved .. Thank you guys u all rock :) Regards, Ganesh On Mon, Dec 8, 2014 at 12:41 PM, Zachary Ware wrote: > On Mon, Dec 8, 2014 at 12:52 AM, Ganesh Pal wrote: > > Hi Folks , > > > > This might seem to be very trivial question but ia

Re: Python re.search simple question

2014-12-07 Thread Jussi Piitulainen
Jussi Piitulainen writes: > Ganesh Pal writes: > > > why is re.search failing in the below case ?? > > Your pattern, '... level-based: [prev 0 , now 1]', matches a literal > string '--- level-based: ' followed by 'p', 'r', 'e', 'v', ' ', '0', > ..., or '1', none of which is the '[' found in you

Re: Python re.search simple question

2014-12-07 Thread Zachary Ware
On Mon, Dec 8, 2014 at 12:52 AM, Ganesh Pal wrote: > Hi Folks , > > This might seem to be very trivial question but iam breaking my head over > it for a while . > > My understanding is that re.search should search for the match anywhere in > the string . > > > why is re.search failing in the bel

Re: Python re.search simple question

2014-12-07 Thread Shiyao Ma
On Dec 08 at 12:22 +0530, Ganesh Pal wrote: > Hi Folks , > > This might seem to be very trivial question but iam breaking my head over > it for a while . > > My understanding is that re.search should search for the match anywhere in > the string . > > > why is re.search failing in the below case

Re: Python re.search simple question

2014-12-07 Thread Jussi Piitulainen
Ganesh Pal writes: > why is re.search failing in the below case ?? Your pattern, '... level-based: [prev 0 , now 1]', matches a literal string '--- level-based: ' followed by 'p', 'r', 'e', 'v', ' ', '0', ..., or '1', none of which is the '[' found in your text at that position. Are you sure yo

Python re.search simple question

2014-12-07 Thread Ganesh Pal
Hi Folks , This might seem to be very trivial question but iam breaking my head over it for a while . My understanding is that re.search should search for the match anywhere in the string . why is re.search failing in the below case ?? >>> pattern 'Token-based migrations cannot be mixed wit

Re: Reasons for source code line length limits

2014-12-07 Thread Terry Reedy
On 12/7/2014 11:44 PM, Ben Finney wrote: Much more relevant is the ability to have two or even three code windows side-by-side, for comparison during a merge operation. For this purpose, a 75–80 column limit is a great help. Or Idle Shell | Idle editor1 | Idle editor2 Editor 1 has file being b

Re: Python, C++ interaction

2014-12-07 Thread Gayathri J
Cython and number it is... they definitely rule! But of course I am also interfacing my python code (with all the structuring and UI and object orientation) with some sse and fortran. if u can get a grip of programming fortran/sse, they work too On 12/7/14, Mark Lawrence wrote: > On 07/12/2014

Re: Python Iterables struggling using map() built-in

2014-12-07 Thread Gregory Ewing
Terry Reedy wrote: However, this 'beautiful' code has a trap. If one gets rid of the seemingly unneeded temporary list res by telescoping the last two lines into a bit too much into yield tuple(next(i) for i in iters) we now have an infinite generator, because tuple() swallows th

Re: Python Iterables struggling using map() built-in

2014-12-07 Thread Gregory Ewing
Steven D'Aprano wrote: I do not believe that good code must be obviously right. It's okay for code to be subtly right. If you write code as subtly as you can, you're not subtle enough to debug it... -- Greg -- https://mail.python.org/mailman/listinfo/python-list

Re: Reasons for source code line length limits

2014-12-07 Thread Ben Finney
Chris Angelico writes: > Sure, a 500-character line is less readable than a 75-character line. So we agree that merely being able to *display* more text on a line is not a reason to have arbitrarily-long lines of code. Good! > But how much difference is there between 79 and, say, 90? I'd say >

Re: Maintaining Maximum Line Length When Using Tabs Instead of Spaces?

2014-12-07 Thread Ben Finney
Aahan Krish writes: > It's just that I don't like arbitrary rules. IMHO, spaces aren't > "better than" tabs, and people should refrain from saying that. Simplicity has value. The rule “use four spaces for indentation” is simple to stick to, and simple to obtain sane display results by default.

Re: Maintaining Maximum Line Length When Using Tabs Instead of Spaces?

2014-12-07 Thread Ben Finney
Chris Angelico writes: > On Mon, Dec 8, 2014 at 1:15 PM, Aahan Krish wrote: > > My question is to them (because I want to use tabs too) is: how do you > > maintain a line-length of 79 characters? > > > > E.g. scenario: The tab setting in your editor could be 2 or 4, and in > > other developer's

Re: Reasons for source code line length limits (was: Maintaining Maximum Line Length When Using Tabs Instead of Spaces?)

2014-12-07 Thread Chris Angelico
On Mon, Dec 8, 2014 at 3:44 PM, Ben Finney wrote: > But regardless of display technology, the biggest reason to stick to a > limit like 80 or less is: reader technology. The ability for humans to > comprehend long lines of text is poor, and there *is* a cognitive point > beyond which it's not help

Re: Maintaining Maximum Line Length When Using Tabs Instead of Spaces?

2014-12-07 Thread Chris Angelico
On Mon, Dec 8, 2014 at 3:39 PM, Aahan Krish wrote: > As for why I care the "79 chars" part of PEP 8: > > - Coding in terminals and VIM with multiple windows open. Then measure your width with tabs set to 8 spaces, and nothing else matters. Otherwise, go back to your previous statement about avoid

Reasons for source code line length limits (was: Maintaining Maximum Line Length When Using Tabs Instead of Spaces?)

2014-12-07 Thread Ben Finney
jtan writes: > One reason why you would want max length 79 is because of working with > terminals. That reason is decreasingly relevant as terminals become virtual, in a display window that can be much larger if we choose. Much more relevant is the ability to have two or even three code windows

Re: Maintaining Maximum Line Length When Using Tabs Instead of Spaces?

2014-12-07 Thread Aahan Krish
Hi Ned, > I'm curious why you care about the "79 characters" part of PEP8 if you don't > care about the "use spaces" part of PEP8. It's just that I don't like arbitrary rules. IMHO, spaces aren't "better than" tabs, and people should refrain from saying that. Both have their fair bit of disadvan

Re: Maintaining Maximum Line Length When Using Tabs Instead of Spaces?

2014-12-07 Thread Ned Batchelder
On 12/7/14 9:15 PM, Aahan Krish wrote: My understanding from talking to different people is that many do use tabs (instead of spaces) for indentation in their code. My question is to them (because I want to use tabs too) is: how do you maintain a line-length of 79 characters? E.g. scenario: The

Re: Python Iterables struggling using map() built-in

2014-12-07 Thread MRAB
On 2014-12-08 01:00, Chris Angelico wrote: On Mon, Dec 8, 2014 at 11:45 AM, Roy Smith wrote: I take it as "result", which makes plenty of sense to me. OK, so spell it out. Three more keystrokes (well, plus another three when you use it on the next line). And one of them is a vowel; they don

Re: Maintaining Maximum Line Length When Using Tabs Instead of Spaces?

2014-12-07 Thread jtan
On Mon, Dec 8, 2014 at 10:23 AM, Chris Angelico wrote: > On Mon, Dec 8, 2014 at 1:15 PM, Aahan Krish wrote: > > My question is to them (because I want to use tabs too) is: how do you > > maintain a line-length of 79 characters? > > > > E.g. scenario: The tab setting in your editor could be 2 or

Re: Maintaining Maximum Line Length When Using Tabs Instead of Spaces?

2014-12-07 Thread jtan
One reason why you would want max length 79 is because of working with terminals. Maybe ssh to you server and check how many spaces are consumed by a tab? In my boxes, it is usually 1 tab = 8 spaces. So perhaps just use that setting in your editor? On Mon, Dec 8, 2014 at 10:15 AM, Aahan Krish

Re: Maintaining Maximum Line Length When Using Tabs Instead of Spaces?

2014-12-07 Thread Chris Angelico
On Mon, Dec 8, 2014 at 1:15 PM, Aahan Krish wrote: > My question is to them (because I want to use tabs too) is: how do you > maintain a line-length of 79 characters? > > E.g. scenario: The tab setting in your editor could be 2 or 4, and in > other developer's browser it could be 8. The code will

Maintaining Maximum Line Length When Using Tabs Instead of Spaces?

2014-12-07 Thread Aahan Krish
My understanding from talking to different people is that many do use tabs (instead of spaces) for indentation in their code. My question is to them (because I want to use tabs too) is: how do you maintain a line-length of 79 characters? E.g. scenario: The tab setting in your editor could be 2 or

Re: Python Iterables struggling using map() built-in

2014-12-07 Thread Ned Batchelder
On 12/7/14 7:12 PM, Roy Smith wrote: Chris Angelico wrote: I'm actually glad PEP 479 will break this kind of code. Gives a good excuse for rewriting it to be more readable. Steven D'Aprano wrote: What kind of code is that? Short, simple, Pythonic and elegant? :-) Here's the code again, with

Re: Python Iterables struggling using map() built-in

2014-12-07 Thread Chris Angelico
On Mon, Dec 8, 2014 at 11:45 AM, Roy Smith wrote: >> I take it as "result", which makes plenty of sense to me. > > OK, so spell it out. Three more keystrokes (well, plus another three > when you use it on the next line). And one of them is a vowel; they > don't even cost much. The next guy who

Re: Python Iterables struggling using map() built-in

2014-12-07 Thread Roy Smith
In article , Chris Angelico wrote: > > Next problem, what the heck is "res"? We're not back in the punch-card > > days. We don't have to abbreviate variable names to save columns. > > Variable names are supposed to describe what they hold, and thus help > > you understand the code. I have no

Re: Python Iterables struggling using map() built-in

2014-12-07 Thread Terry Reedy
On 12/7/2014 7:12 PM, Roy Smith wrote: Chris Angelico wrote: I'm actually glad PEP 479 will break this kind of code. Gives a good excuse for rewriting it to be more readable. Steven D'Aprano wrote: What kind of code is that? Short, simple, Pythonic and elegant? :-) Here's the code again, wi

Re: Python Iterables struggling using map() built-in

2014-12-07 Thread Chris Angelico
On Mon, Dec 8, 2014 at 11:27 AM, Roy Smith wrote: > Although, to be honest, I'm wondering if this is more straight-forward > (also not tested): > > def myzip37(*args): > if not args: > return > iters = list(map(iter, args)) Yes, I prefer this too. It's explicit and clear that pass

Re: Python Iterables struggling using map() built-in

2014-12-07 Thread Chris Angelico
On Mon, Dec 8, 2014 at 11:12 AM, Roy Smith wrote: > Ugh. When I see "while foo", my brain says, "OK, you're about to see a > loop which is controlled by the value of foo being changed inside the > loop". That's not at all what's happening here, so my brain runs into a > wall. I agree, with the

Re: Python Iterables struggling using map() built-in

2014-12-07 Thread Roy Smith
In article , Chris Angelico wrote: > On Mon, Dec 8, 2014 at 10:33 AM, Steven D'Aprano > wrote: > > How would we re-write this to work in the future Python 3.7? Unless I have > > missed something, I think we could write it like this: > > > > def myzip37(*args): > > iters = list(map(iter, arg

Re: Python Iterables struggling using map() built-in

2014-12-07 Thread Roy Smith
Chris Angelico wrote: > > I'm actually glad PEP 479 will break this kind of code. Gives a good > > excuse for rewriting it to be more readable. Steven D'Aprano wrote: > What kind of code is that? Short, simple, Pythonic and elegant? :-) > > Here's the code again, with indentation fixed: > > >

Re: Nested dictionaries from a list ?

2014-12-07 Thread Denis McMahon
On Sun, 07 Dec 2014 12:01:26 -0500, Dave Angel wrote: > On 12/07/2014 11:18 AM, Wacky wrote: >> I've a list of users > I haven't run this through the Python, so please forgive any typos. > users = [ > mess = { users is redundant, as it's mess.keys() maintaining a separate list

Re: Python Iterables struggling using map() built-in

2014-12-07 Thread Chris Angelico
On Mon, Dec 8, 2014 at 10:33 AM, Steven D'Aprano wrote: > How would we re-write this to work in the future Python 3.7? Unless I have > missed something, I think we could write it like this: > > def myzip37(*args): > iters = list(map(iter, args)) > while iters: > try: >

Re: Nested dictionaries from a list ?

2014-12-07 Thread Denis McMahon
On Sun, 07 Dec 2014 08:18:03 -0800, Wacky wrote: > New to Python, so please go easy. > I've a list of users, who have different profiles . How are you getting on with this assignment / homework? I have a solution I could post, but I thought I'd wait to see what your solution was first. Her

Re: Python Iterables struggling using map() built-in

2014-12-07 Thread Steven D'Aprano
Chris Angelico wrote: > On Mon, Dec 8, 2014 at 5:27 AM, Ian Kelly wrote: >> On Dec 7, 2014 8:31 AM, "Ned Batchelder" wrote: >>> NOTE: THIS EXAMPLE IS HORRIBLE. This code is crazy-confusing, and >>> should never have been used as an example of iteration. It layers at >>> least three iterations o

ANN: A new version (0.3.7) of python-gnupg has been released.

2014-12-07 Thread Vinay Sajip
A new version of the Python module which wraps GnuPG has been released. What Changed? = This is an enhancement and bug-fix release, but the bug-fixes include some security improvements, so all users are encouraged to upgrade. See the project website [1] for more information. Brief sum

Re: Tuple of lists concatenation - function vs comprehension

2014-12-07 Thread Terry Reedy
On 12/7/2014 10:28 AM, Ivan Evstegneev wrote: Hi Shiyao, Now I see, that it was kind of dumb question... x = ([1, 2], [3, 4], [5, 6]) L = [] [L.extend(i) for i in x] [None, None, None] Using a list comprehension for the expression side-effect, when you do not actually want the list produc

Re: Setting default_factory of defaultdict to key

2014-12-07 Thread Terry Reedy
On 12/5/2014 3:51 PM, John J Posner wrote: The defaultdict documentation is confusing on this point. A *long* time ago, I filed Bug 9536 to improve the doc, but the fix hasn't bubbled to the surface yet. Untrue. Your patch 'bubbled to the surface' and got provisionally rejected in 5 hours an

Re: Python Iterables struggling using map() built-in

2014-12-07 Thread Chris Angelico
On Mon, Dec 8, 2014 at 5:27 AM, Ian Kelly wrote: > On Dec 7, 2014 8:31 AM, "Ned Batchelder" wrote: >> NOTE: THIS EXAMPLE IS HORRIBLE. This code is crazy-confusing, and should >> never have been used as an example of iteration. It layers at least three >> iterations on top of each other, making i

Re: Python Iterables struggling using map() built-in

2014-12-07 Thread Ian Kelly
On Dec 7, 2014 8:31 AM, "Ned Batchelder" wrote: > NOTE: THIS EXAMPLE IS HORRIBLE. This code is crazy-confusing, and should never have been used as an example of iteration. It layers at least three iterations on top of each other, making it very difficult to see what is going on. It uses "while i

Re: Python Iterables struggling using map() built-in

2014-12-07 Thread Chris Angelico
On Mon, Dec 8, 2014 at 2:29 AM, Ned Batchelder wrote: > 3. The only operation supported on iterators is next(). You cannot start > them over, you cannot ask if there will be more values, you cannot find out > how many values there will be, you can't ask what the last value was, etc. > By supporti

Re: Setting default_factory of defaultdict to key

2014-12-07 Thread Ian Kelly
On Dec 7, 2014 9:33 AM, "Dave Angel" wrote: > > On 12/05/2014 03:51 PM, John J Posner wrote: >> >> At the beginning of this thread, Ian Kelly said: > > > Since this clearly is intended to be part of the earlier thread, please make it so by using reply-list or whatever equivalent your email program

Re: Python, C++ interaction

2014-12-07 Thread Mark Lawrence
On 07/12/2014 15:05, Sturla Molden wrote: On 05/12/14 23:17, wesleiram...@gmail.com wrote: m'giu vous êtès nom souris, pseudo nom cha'rs out oiu êtès, i'ret egop c'hâse I have not idea what that means, but I am sure it would be interesting if I knew French (or whatever it is). Please be ca

Re: Setting default_factory of defaultdict to key

2014-12-07 Thread Dave Angel
On 12/07/2014 11:43 AM, Shiyao Ma wrote: On Dec 07 at 11:31 -0500, Dave Angel wrote: Since this clearly is intended to be part of the earlier thread, please make it so by using reply-list or whatever equivalent your email program has. Kinda OT. But interested what's the difference between repl

Different “reply” functions: reply-to-sender, reply-to-list, reply-to-all (was: Setting default_factory of defaultdict to key)

2014-12-07 Thread Ben Finney
Shiyao Ma writes: > On Dec 07 at 11:31 -0500, Dave Angel wrote: > > Since this clearly is intended to be part of the earlier thread, > > please make it so by using reply-list or whatever equivalent your > > email program has. > > Kinda OT. But interested what's the difference between reply-list a

Re: Nested dictionaries from a list ?

2014-12-07 Thread Dave Angel
On 12/07/2014 11:18 AM, Wacky wrote: New to Python, so please go easy. I've a list of users, who have different profiles on different computers. How to tackle this through lists and dictionaries? Here is the data example. More interested in learning how to declare this structure and add/delete/

Re: Setting default_factory of defaultdict to key

2014-12-07 Thread Shiyao Ma
On Dec 07 at 11:31 -0500, Dave Angel wrote: > Since this clearly is intended to be part of the earlier thread, please make > it so by using reply-list or whatever equivalent your email program has. Kinda OT. But interested what's the difference between reply-list and to. In addition, based on what

Re: Setting default_factory of defaultdict to key

2014-12-07 Thread Dave Angel
On 12/05/2014 03:51 PM, John J Posner wrote: At the beginning of this thread, Ian Kelly said: Since this clearly is intended to be part of the earlier thread, please make it so by using reply-list or whatever equivalent your email program has. Not with defaultdict, but you can subcla

Re: module import questions and question about pytest and module imports

2014-12-07 Thread Dave Angel
On 12/05/2014 11:50 PM, sam pendleton wrote: garage/ |- __init__.py |- cars/ |- __init__.py |- hummer.py tests/ |- test_cars.py at the top of test_cars.py, there is this: from garage.cars import hummer pytest is on this import statement, so i guess it's inc

Nested dictionaries from a list ?

2014-12-07 Thread Wacky
New to Python, so please go easy. I've a list of users, who have different profiles on different computers. How to tackle this through lists and dictionaries? Here is the data example. More interested in learning how to declare this structure and add/delete/extract values from whatever data stru

RE: Python Iterables struggling using map() built-in

2014-12-07 Thread Ivan Evstegneev
Awesome Ned, Believe it or not, but I was browsing web for the answer about a half an hour ago. Guess what? I found your web page with the explanations you provided there. ))) Finally, I was ready to send this question to you directly, cause I didn't know that you subscribed to this mailing lis

RE: Tuple of lists concatenation - function vs comprehension

2014-12-07 Thread Ivan Evstegneev
Hi Shiyao, Now I see, that it was kind of dumb question... x = ([1, 2], [3, 4], [5, 6]) L = [] >>>[L.extend(i) for i in x] [None, None, None] BUT when I check L itself I'll see this one >>>L [1,2,3,5,6] Ok. Thanks. -Original Message- From: Shiyao Ma [mailto:i...@introo.me] S

Re: Tuple of lists concatenation - function vs comprehension

2014-12-07 Thread Shiyao Ma
On 12/07, Ivan Evstegneev wrote: > Hello, > > When I have worked in Python shell (IDLE) I found this issue: > > >>>x = ([1, 2], [3, 4], [5, 6]) > >>>L = [] > >>>for I in x: > L.extend(i) > > >>>L > [1,2,3,4,5,6] > > But when I try to make comprehension using above expression, I get this: > >

Tuple of lists concatenation - function vs comprehension

2014-12-07 Thread Ivan Evstegneev
Hello, When I have worked in Python shell (IDLE) I found this issue: >>>x = ([1, 2], [3, 4], [5, 6]) >>>L = [] >>>for I in x: L.extend(i) >>>L [1,2,3,4,5,6] But when I try to make comprehension using above expression, I get this: >>>x = ([1, 2], [3, 4], [5, 6]) >>>L = [] >>> [L.extend

Re: Python, C++ interaction

2014-12-07 Thread Sturla Molden
On 05/12/14 23:17, wesleiram...@gmail.com wrote: m'giu vous êtès nom souris, pseudo nom cha'rs out oiu êtès, i'ret egop c'hâse I have not idea what that means, but I am sure it would be interesting if I knew French (or whatever it is). Sturla -- https://mail.python.org/mailman/listinfo/py

how to install paramiko correctly?

2014-12-07 Thread sir
My system:win7+python3.4 . I have installed Crypto and Paramiko . C:\Windows\system32>pip3.4 install Crypto Requirement already satisfied (use --upgrade to upgrade): Crypto in d:\python34\ lib\site-packages Cleaning up... C:\Windows\system32>pip3.4 install Paramiko Requ

Re: jitpy - Library to embed PyPy into CPython

2014-12-07 Thread Albert-Jan Roskam
On Sun, Dec 7, 2014 11:06 AM CET Stefan Behnel wrote: >Albert-Jan Roskam schrieb am 06.12.2014 um 21:28: >> On Fri, Dec 5, 2014 8:54 PM CET Mark Lawrence wrote: >> For those who haven't heard thought this might be of interest >> https://github.com/fijal/jitpy >> >> I

The preferred way to implement a new transport in asyncio

2014-12-07 Thread Jonas Wielicki
Hello fellow pythoneers, First some background: I am implementing an XMPP client library in asyncio. XMPP uses (START-)TLS. However, the native SSL support of Python is rather restricted: We cannot hook into the certificate validation process (it is PKI-all-or-nothing) at all, in addition many of

Re: Python Iterables struggling using map() built-in

2014-12-07 Thread Chris Angelico
On Sun, Dec 7, 2014 at 3:44 AM, Ivan Evstegneev wrote: > (quoting from the book) > Because this code uses iter and next, it works on any type of iterable. Note > that there > is no reason to catch the StopIteration raised by the next(it) inside the > comprehension > here when any one of the argume

Python Iterables struggling using map() built-in

2014-12-07 Thread Ivan Evstegneev
Hello everyone, I'm currently in the process of self-study journey, so I have some questions arisen from time to time. Today I would like to talk about iterables and iterators,(ask for your help actually ^_^). Before I'll continue, just wanted to draw your attention to the fact that I di

Re: Setting default_factory of defaultdict to key

2014-12-07 Thread John J Posner
At the beginning of this thread, Ian Kelly said: Not with defaultdict, but you can subclass dict and provide a __missing__ method directly To emphasize, you don't need to subclass "defaultdict" -- you need only subclass "dict" itself: class MyDict(dict): def __missing__(self, key):

module import questions and question about pytest and module imports

2014-12-07 Thread sam pendleton
garage/ |- __init__.py |- cars/ |- __init__.py |- hummer.py tests/ |- test_cars.py at the top of test_cars.py, there is this: from garage.cars import hummer pytest is on this import statement, so i guess it's incorrect. what should it be? if i open a python repl

Help with exscript with Cisco asa

2014-12-07 Thread Edward Manning
I am trying to login to enable mode on a Cisco ASA with this script. I can’t seem to get the enable mode to work. Can anyone help. Does anyone know of a good doc for exscript lib. Thank you Ed from Exscript.util.start import quickstart from Exscript.util.file import get_hosts_from_fil

Re: jitpy - Library to embed PyPy into CPython

2014-12-07 Thread Stefan Behnel
Albert-Jan Roskam schrieb am 06.12.2014 um 21:28: > On Fri, Dec 5, 2014 8:54 PM CET Mark Lawrence wrote: >> For those who haven't heard thought this might be of interest >> https://github.com/fijal/jitpy > > Interesting, but it is not clear to me when you would use jitpy instead > of pypy. I thin