Re: error handling when opening files

2014-07-07 Thread Chris Angelico
On Tue, Jul 8, 2014 at 9:49 AM, Alex Burke wrote: > The reason I preferred the second was in addition to catching the > IOError when attempting the open() if the file does not exist I > thought I was accounting for the possibility en error occurs while > reading data out of the file. If that's wh

error handling when opening files

2014-07-07 Thread Alex Burke
Hi there, While reading up on a previous thread 'open() and EOFError' I saw the following (with minor changes to help make my question clearer) block suggested as a canonical way to open files and do something: try: f = open(path) except IOError: handle_error() else: with f: d

Re: finditer

2014-07-07 Thread Jason Friedman
On Mon, Jul 7, 2014 at 1:19 AM, gintare wrote: > If smbd has time, maybe you could advice how to accomplish this task in > faster way. > > I have a text = """ word{vb} > wordtransl {vb} > > sent1. > > sent1trans. > > sent2 > > sent2trans... """ > > I need to match once wordtransl, and than many t

Re: PEP8 and 4 spaces

2014-07-07 Thread Ben Finney
Dan Sommers writes: > On Mon, 07 Jul 2014 11:00:59 +1000, Ben Finney wrote: > > > […] a poor design decision (a line beginning with U+0020 SPACE is > > semantically different from a line beginning with U+0009 CHARACTER > > TABULATION) can be irrevocable – the syntax can't be changed now, > > with

Re: open() and EOFError

2014-07-07 Thread Chris Angelico
On Tue, Jul 8, 2014 at 3:40 AM, Marko Rauhamaa wrote: > Chris Angelico : > >> if you always break everything out to keep exception-catching scope as >> narrow as possible, you begin to lose readability in other ways. > > I've begun to wonder if there might exist a new, easier-to-read > try-except

Re: open() and EOFError

2014-07-07 Thread Roy Smith
In article , Chris Angelico wrote: > On Mon, Jul 7, 2014 at 10:39 PM, Roy Smith wrote: > > $ stty -e [...] > Not sure what you're running, but 'stty -e' throws an error for me > (Debian Wheezy). That was on OSX. -- https://mail.python.org/mailman/listinfo/python-list

Re: open() and EOFError

2014-07-07 Thread Roy Smith
In article , Chris Angelico wrote: > I love how Unix will happily let you unlink a file and keep using it. > Sure, it's a pitfall for people who are trying to figure out where on > earth their disk space has gone ("I deleted that huge file, but my > disk's still full!!"), but it's soo much e

Re: open() and EOFError

2014-07-07 Thread Roy Smith
In article <53bae1db$0$29995$c3e8da3$54964...@news.astraweb.com>, Steven D'Aprano wrote: > While I agree with the general idea that try blocks should be as narrow > *as reasonable*, they shouldn't be as narrow *as possible* since one can > start guarding against unreasonable things. I'm more

Re: open() and EOFError

2014-07-07 Thread Mark Lawrence
On 07/07/2014 23:09, Gregory Ewing wrote: Marko Rauhamaa wrote: with open(path) as f: ... If the open() call is guarded against exceptions (as it usually should), one must revert to the classic syntax: Hmmm, maybe we could do with a with-except statement: with open(path) as f

Re: open() and EOFError

2014-07-07 Thread Gregory Ewing
Marko Rauhamaa wrote: with open(path) as f: ... If the open() call is guarded against exceptions (as it usually should), one must revert to the classic syntax: Hmmm, maybe we could do with a with-except statement: with open(path) as f: ... except IOError: # Catch

Re: open() and EOFError

2014-07-07 Thread Gregory Ewing
Terry Reedy wrote: Avoid EOFError. Much better, I think, is the somewhat customary s = input("Enter something, or hit to exit") if not s: sys.exit() else: I beg to differ -- on Unix, Ctrl-D *is* the customary way to exit from something that's reading from stdin. In any case, you need to be

Re: open() and EOFError

2014-07-07 Thread Gregory Ewing
Roy Smith wrote: We've since modified our cleanup script to run lsof and skip purging any releases which are still in use :-) Or, if you're on Unix, make sure you open all the files you're likely to need at the beginning and hold onto them. :-) -- Greg -- https://mail.python.org/mailman/listin

Re: Question about metacharacter '*'

2014-07-07 Thread Mark Lawrence
On 07/07/2014 19:51, rxjw...@gmail.com wrote: Will you please do something about the double spaced google crap that you keep sending, I've already asked you twice. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence --- Th

Re: Question about metacharacter '*'

2014-07-07 Thread Devin Jeanpierre
On Mon, Jul 7, 2014 at 11:51 AM, wrote: > Would you give me an example using your pattern: `.*` -- `.`? > I try it, but it cannot pass. (of course, I use it incorrectly) Those are two patterns. Python 3.4.1 (default, Jul 7 2014, 13:22:02) [GCC 4.6.3] on linux Type "help", "copyright", "credits

Re: Question about metacharacter '*'

2014-07-07 Thread rxjwg98
On Sunday, July 6, 2014 8:09:57 AM UTC-4, Devin Jeanpierre wrote: > On Sun, Jul 6, 2014 at 4:51 AM, wrote: > > > Hi, > > > > > > I just begin to learn Python. I do not see the usefulness of '*' in its > > > description below: > > > > > > > > > > > > > > > The first metacharacter for repe

Re: open() and EOFError

2014-07-07 Thread Terry Reedy
On 7/7/2014 8:39 AM, Roy Smith wrote: On a different topic, I've always disliked embedding instructions to "type Ctrl-D". The problem is, how to generate an EOF (or interrupt, or whatever) is configurable in the tty driver (see below). In theory, the user could have remapped EOF to be somethin

Re: open() and EOFError

2014-07-07 Thread Marko Rauhamaa
Steven D'Aprano : > try: > f = open(path) > except Whatever: > handle_error() > else: > with f: > do_stuff() That's cool. Never really used try-else. > That gets old really quickly! But then, handling errors is always the > ugliest part of coding. Hiding the messy details ins

Re: open() and EOFError

2014-07-07 Thread Steven D'Aprano
On Mon, 07 Jul 2014 20:31:53 +0300, Marko Rauhamaa wrote: > If the open() call is guarded against exceptions (as it usually should), > one must revert to the classic syntax: > > try: > f = open(path) > except IOError: > ... > try: > ... > finally: >

Re: open() and EOFError

2014-07-07 Thread Marko Rauhamaa
Chris Angelico : > if you always break everything out to keep exception-catching scope as > narrow as possible, you begin to lose readability in other ways. I've begun to wonder if there might exist a new, easier-to-read try-except syntax. Marko -- https://mail.python.org/mailman/listinfo/pyth

Re: open() and EOFError

2014-07-07 Thread Marko Rauhamaa
Ian Kelly : > It's good practice to keep your try blocks as narrow as possible in > any case. True. Unfortunately, that leads to trouble with the handy "with" construct: with open(path) as f: ... If the open() call is guarded against exceptions (as it usually should), one must rever

Re: open() and EOFError

2014-07-07 Thread Chris Angelico
On Tue, Jul 8, 2014 at 3:25 AM, Ian Kelly wrote: > On Mon, Jul 7, 2014 at 2:09 AM, Chris Angelico wrote: >> But if the code's more complicated and it's not so easy to split, then >> sure, doesn't seem a problem. It's like spam[foo//bar] and then >> catching either IndexError or ZeroDivisionError

Re: open() and EOFError

2014-07-07 Thread Ian Kelly
On Mon, Jul 7, 2014 at 2:09 AM, Chris Angelico wrote: > But if the code's more complicated and it's not so easy to split, then > sure, doesn't seem a problem. It's like spam[foo//bar] and then > catching either IndexError or ZeroDivisionError - there's no big > confusion from having two distinct s

Re: Question about metacharacter '*'

2014-07-07 Thread Ian Kelly
On Sun, Jul 6, 2014 at 4:49 PM, MRAB wrote: > \d also matches more than just [0-9] in Unicode. I think that anything matched by \d will also be accepted by int(). >>> decimals = [c for c in (chr(i) for i in range(17 * 2**16)) if >>> unicodedata.category(c) == 'Nd'] >>> len(decimals) 460 >>> re.

Re: What is 're.M'?

2014-07-07 Thread Mark Lawrence
On 07/07/2014 16:20, rxjw...@gmail.com wrote: For the second time, would you please use the mailing list https://mail.python.org/mailman/listinfo/python-list or read and action this https://wiki.python.org/moin/GoogleGroupsPython to prevent us seeing double line spacing and single line paragra

Re: thread.interrupt_main() behaviour

2014-07-07 Thread Ian Kelly
On Mon, Jul 7, 2014 at 8:41 AM, Piyush Verma <114piy...@gmail.com> wrote: > Thanks Ian for information. There is slightly more I want to do. Consider if > I want to kill some threads not all, is there a way to do that? You can't safely interrupt threads. What you can do is *request* the thread to

Re: How to write this repeat matching?

2014-07-07 Thread Ian Kelly
On Mon, Jul 7, 2014 at 7:30 AM, wrote: > Because I am new to Python, I may not describe the question clearly. Could you > read the original problem on web: > > https://docs.python.org/2/howto/regex.html > > It says that it gets 'abcb'. Could you explain it to me? Thanks again The string being ma

Re: open() and EOFError

2014-07-07 Thread Marko Rauhamaa
Marko Rauhamaa : > input() quite naturally can raise an IOError. For example: > > import os, socket > s = socket.socket(socket.AF_UNIX) > s.bind("xyz") > os.dup2(s.fileno(), 0); print(input()) > > results in an IOError (EINVAL, to be exact). Even simpler: >>> import os >>>

Re: open() and EOFError

2014-07-07 Thread Marko Rauhamaa
Steven D'Aprano : > On Mon, 07 Jul 2014 22:19:20 +1000, Chris Angelico wrote: > >> It's possible for input() to raise IOError, if I'm not mistaken; >> consider redirection, for instance. > > What indirection? Do you mean, if built-in input() has been monkey- > patched? Well, sure, but in that case

Re: open() and EOFError

2014-07-07 Thread Dan Stromberg
On 7/7/14, Mark Lawrence wrote: > On 07/07/2014 09:09, Chris Angelico wrote: >> On Mon, Jul 7, 2014 at 6:00 PM, Steven D'Aprano >> wrote: >>> How do people feel about code like this? >>> >>> try: >>> name = input("Enter file name, or Ctrl-D to exit") >>> # On Windows, use Ctrl-Z [enter]

Re: open() and EOFError

2014-07-07 Thread Chris Angelico
On Tue, Jul 8, 2014 at 1:45 AM, Steven D'Aprano wrote: > On Mon, 07 Jul 2014 22:19:20 +1000, Chris Angelico wrote: > >> It's possible for input() to raise IOError, if I'm not mistaken; >> consider redirection, for instance. > > What indirection? Do you mean, if built-in input() has been monkey- >

Re: How to write this repeat matching?

2014-07-07 Thread Anssi Saari
rxjw...@gmail.com writes: > Because I am new to Python, I may not describe the question clearly. Could you > read the original problem on web: > > https://docs.python.org/2/howto/regex.html > > It says that it gets 'abcb'. Could you explain it to me? Thanks again Actually, it tries to explain how

Re: open() and EOFError

2014-07-07 Thread Steven D'Aprano
On Mon, 07 Jul 2014 22:19:20 +1000, Chris Angelico wrote: > It's possible for input() to raise IOError, if I'm not mistaken; > consider redirection, for instance. What indirection? Do you mean, if built-in input() has been monkey- patched? Well, sure, but in that case it could do anything. I'm on

[Python Brasil 10] Registrations are now open!

2014-07-07 Thread Renato Oliveira
Hey everyone! Registrations for Python Brasil are now open! http://2014.pythonbrasil.org.br/register Sadly the payment form is in portuguese, so if you have any trouble please let me know (in private message). The call for papers will open on Jul 10th as you can see here http://2014.pythonbrasil

Re: What is 're.M'?

2014-07-07 Thread rxjwg98
On Monday, July 7, 2014 10:46:19 AM UTC-4, Steven D'Aprano wrote: > On Mon, 07 Jul 2014 07:08:53 -0700, rxjwg98 wrote: > > > > > More specific, what does 're.M' means? > > > > > > Feel free to look at it interactively. re.M is a flag to control the > > meaning of the regular expression. I

Re: What is 're.M'?

2014-07-07 Thread rxjwg98
On Monday, July 7, 2014 10:46:19 AM UTC-4, Steven D'Aprano wrote: > On Mon, 07 Jul 2014 07:08:53 -0700, rxjwg98 wrote: > > > > > More specific, what does 're.M' means? > > > > > > Feel free to look at it interactively. re.M is a flag to control the > > meaning of the regular expression. I

Re: What is 're.M'?

2014-07-07 Thread rxjwg98
On Monday, July 7, 2014 10:46:19 AM UTC-4, Steven D'Aprano wrote: > On Mon, 07 Jul 2014 07:08:53 -0700, rxjwg98 wrote: > > > > > More specific, what does 're.M' means? > > > > > > Feel free to look at it interactively. re.M is a flag to control the > > meaning of the regular expression. I

Re: What is 're.M'?

2014-07-07 Thread Steven D'Aprano
On Mon, 07 Jul 2014 07:08:53 -0700, rxjwg98 wrote: > More specific, what does 're.M' means? Feel free to look at it interactively. re.M is a flag to control the meaning of the regular expression. It is short for re.MULTILINE, just as re.I is short for re.IGNORECASE: py> import re py> re.M ==

Re: Module name does not match file name

2014-07-07 Thread Robert Kern
On 2014-07-07 12:56, Steven D'Aprano wrote: On Mon, 07 Jul 2014 12:15:51 +0100, Robert Kern wrote: On 2014-07-07 09:57, Steven D'Aprano wrote: What I don't understand is how "import pg" gets turned into "run pgmodule.so"? This has been standard Python behavior for extension modules since for

Re: What is 're.M'?

2014-07-07 Thread Mark Lawrence
On 07/07/2014 15:08, rxjw...@gmail.com wrote: Hi, I learn this short Python code from: http://www.tutorialspoint.com/python/python_reg_expressions.htm but I still do not decipher the meaning in its line, even after read its command explanation. It says that: re.M: Makes $ match the end of

Re: What is 're.M'?

2014-07-07 Thread Skip Montanaro
Scroll down to the "Module Contents" section of this page: https://docs.python.org/2/library/re.html It explains re.M and other "constants". Skip -- https://mail.python.org/mailman/listinfo/python-list

What is 're.M'?

2014-07-07 Thread rxjwg98
Hi, I learn this short Python code from: http://www.tutorialspoint.com/python/python_reg_expressions.htm but I still do not decipher the meaning in its line, even after read its command explanation. It says that: re.M: Makes $ match the end of a line (not just the end of the string) and makes

Re: How to write this repeat matching?

2014-07-07 Thread rxjwg98
On Sunday, July 6, 2014 3:26:44 PM UTC-4, Ian wrote: > On Sun, Jul 6, 2014 at 12:57 PM, wrote: > > > I write the following code: > > > > > > ... > > > import re > > > > > > line = "abcdb" > > > > > > matchObj = re.match( 'a[bcd]*b', line) > > > > > > if matchObj: > > >print "ma

Re: open() and EOFError

2014-07-07 Thread Chris Angelico
On Mon, Jul 7, 2014 at 11:06 PM, Mark Lawrence wrote: >> try: >> name = input("Enter file name, or Ctrl-D to exit") >> # On Windows, use Ctrl-Z [enter] instead. >> except EOFError: >> sys.exit() >> try: >> fp = open(name) >> except IOError: >> handle_bad_file(name) >> else

Re: open() and EOFError

2014-07-07 Thread Chris Angelico
On Mon, Jul 7, 2014 at 11:06 PM, Mark Lawrence wrote: > On 07/07/2014 09:09, Chris Angelico wrote: >> >> It seems trivial in this example to break it into two try blocks: >> >> try: >> name = input("Enter file name, or Ctrl-D to exit") >> # On Windows, use Ctrl-Z [enter] instead. >> exce

Re: open() and EOFError

2014-07-07 Thread Mark Lawrence
On 07/07/2014 09:09, Chris Angelico wrote: On Mon, Jul 7, 2014 at 6:00 PM, Steven D'Aprano wrote: How do people feel about code like this? try: name = input("Enter file name, or Ctrl-D to exit") # On Windows, use Ctrl-Z [enter] instead. fp = open(name) except EOFError: sys.

Re: open() and EOFError

2014-07-07 Thread Chris Angelico
On Mon, Jul 7, 2014 at 10:46 PM, Roy Smith wrote: > We've since modified our cleanup script to run lsof and skip purging any > releases which are still in use :-) LOL! I have a computer on which I periodically build and install new versions of a few pieces of software. Most of them don't keep ru

Re: open() and EOFError

2014-07-07 Thread Chris Angelico
On Mon, Jul 7, 2014 at 10:39 PM, Roy Smith wrote: > $ stty -e > speed 9600 baud; 24 rows; 80 columns; > lflags: icanon isig iexten echo echoe -echok echoke -echonl echoctl >-echoprt -altwerase -noflsh -tostop -flusho pendin -nokerninfo >-extproc > iflags: -istrip icrnl -inlcr -igncr ixon -

Re: open() and EOFError

2014-07-07 Thread Roy Smith
In article , Chris Angelico wrote: > On Mon, Jul 7, 2014 at 6:00 PM, Steven D'Aprano wrote: > > How do people feel about code like this? > > > > try: > > name = input("Enter file name, or Ctrl-D to exit") > > # On Windows, use Ctrl-Z [enter] instead. > > fp = open(name) > > except E

Re: open() and EOFError

2014-07-07 Thread Roy Smith
In article <53ba538d$0$2926$c3e8da3$76491...@news.astraweb.com>, Steven D'Aprano wrote: > On Mon, 07 Jul 2014 17:04:12 +1200, Gregory Ewing wrote: > > > Steven D'Aprano wrote: > >> Are there any circumstances where merely *opening* a file (before > >> reading it) can raise EOFError? > > > > I

Re: open() and EOFError

2014-07-07 Thread Chris Angelico
On Mon, Jul 7, 2014 at 6:00 PM, Steven D'Aprano wrote: > How do people feel about code like this? > > try: > name = input("Enter file name, or Ctrl-D to exit") > # On Windows, use Ctrl-Z [enter] instead. > fp = open(name) > except EOFError: > sys.exit() > except IOError: > hand

Re: open() and EOFError

2014-07-07 Thread Dave Angel
Steven D'Aprano Wrote in message: > On Mon, 07 Jul 2014 17:04:12 +1200, Gregory Ewing wrote: > >> Steven D'Aprano wrote: >>> Are there any circumstances where merely *opening* a file (before >>> reading it) can raise EOFError? >> >> I don't think so. As far as I know, the only built-in thing tha

Re: Module name does not match file name

2014-07-07 Thread Chris Angelico
On Mon, Jul 7, 2014 at 9:56 PM, Steven D'Aprano wrote: > Hmmm. Well, that is very special. Is this documented anywhere? "Special", in the sense of Shepherd Book addressing Mal. "Isn't that... special." ChrisA -- https://mail.python.org/mailman/listinfo/python-list

Re: Module name does not match file name

2014-07-07 Thread Steven D'Aprano
On Mon, 07 Jul 2014 12:15:51 +0100, Robert Kern wrote: > On 2014-07-07 09:57, Steven D'Aprano wrote: >> What I don't understand is how "import pg" gets turned into "run >> pgmodule.so"? > > This has been standard Python behavior for extension modules since > forever. It's a very old practice and

Re: How do you use `help` when write your code

2014-07-07 Thread Chris Angelico
On Mon, Jul 7, 2014 at 9:22 PM, Roy Smith wrote: > In article , > Chris Angelico wrote: > >> That's about it, yeah. I tend to find both strace and tcpdump rather >> too spammy for most usage, so any time I reach for those tools, it's >> usually with some tight filtering - and even that's not alw

Re: How do you use `help` when write your code

2014-07-07 Thread Roy Smith
In article , Chris Angelico wrote: > That's about it, yeah. I tend to find both strace and tcpdump rather > too spammy for most usage, so any time I reach for those tools, it's > usually with some tight filtering - and even that's not always > helpful. Usually, when I fire up strace, it's beca

Re: Module name does not match file name

2014-07-07 Thread Robert Kern
On 2014-07-07 09:57, Steven D'Aprano wrote: Ah, I think I have a partial answer... but not a complete answer. On Mon, 07 Jul 2014 07:57:21 +, Steven D'Aprano wrote: Can anyone explain how "import pg" can end up coming from pgmodule.so? Sure enough: import pg pg.__file__ '/usr/local/l

Re: Module name does not match file name

2014-07-07 Thread Peter Otten
Steven D'Aprano wrote: > Ah, I think I have a partial answer... but not a complete answer. > > > On Mon, 07 Jul 2014 07:57:21 +, Steven D'Aprano wrote: > >> Can anyone explain how "import pg" can end up coming from pgmodule.so? >> >> >> Sure enough: >> > import pg > pg.__file__ >

Emperor's New Coroutines?

2014-07-07 Thread Marko Rauhamaa
The asyncio module comes with coroutine support. Investigating the topic on the net reveals that FSM's are for old people and the brave new world uses coroutines. Unfortunately, all examples I could find seem to be overly simplistic, and I'm left thinking coroutines have few practical uses in netw

Re: Saving

2014-07-07 Thread Denis McMahon
On Sun, 06 Jul 2014 23:03:07 +, mrwhackadoo1 wrote: > Hi, I’ve been looking forever for this and I cant get it. > > I need to know how to save my code and save as programs because I write > code and I run it but then I cant save it for later. > > Please help and thank you for your time. Wri

Re: Module name does not match file name

2014-07-07 Thread Steven D'Aprano
On Mon, 07 Jul 2014 19:03:33 +1000, Chris Angelico wrote: > On Mon, Jul 7, 2014 at 6:57 PM, Steven D'Aprano > wrote: >> which suggests that the pgmodule.so file creates a module called "pg". >> What I don't understand is how "import pg" gets turned into "run >> pgmodule.so"? > > What happens if

Re: Module name does not match file name

2014-07-07 Thread Chris Angelico
On Mon, Jul 7, 2014 at 7:03 PM, Steven D'Aprano wrote: > On Mon, 07 Jul 2014 18:04:36 +1000, Chris Angelico wrote: > >> On Mon, Jul 7, 2014 at 5:57 PM, Steven D'Aprano >> wrote: >>> Can anyone explain how "import pg" can end up coming from pgmodule.so? >> >> First guess: There's a "pg.py" somewhe

Re: Module name does not match file name

2014-07-07 Thread Steven D'Aprano
On Mon, 07 Jul 2014 18:04:36 +1000, Chris Angelico wrote: > On Mon, Jul 7, 2014 at 5:57 PM, Steven D'Aprano > wrote: >> Can anyone explain how "import pg" can end up coming from pgmodule.so? > > First guess: There's a "pg.py" somewhere that imports the so, then > replaces itself in sys.modules.

Re: Module name does not match file name

2014-07-07 Thread Chris Angelico
On Mon, Jul 7, 2014 at 6:57 PM, Steven D'Aprano wrote: > which suggests that the pgmodule.so file creates a module called "pg". > What I don't understand is how "import pg" gets turned into "run > pgmodule.so"? What happens if you *don't* import pg? Is there a sys.modules["pg"] already? If so, I'

Re: Module name does not match file name

2014-07-07 Thread Steven D'Aprano
Ah, I think I have a partial answer... but not a complete answer. On Mon, 07 Jul 2014 07:57:21 +, Steven D'Aprano wrote: > Can anyone explain how "import pg" can end up coming from pgmodule.so? > > > Sure enough: > import pg pg.__file__ > '/usr/local/lib/python2.6/dist-packages/

Re: open() and EOFError

2014-07-07 Thread Chris Angelico
On Mon, Jul 7, 2014 at 6:00 PM, Steven D'Aprano wrote: > How do people feel about code like this? > > try: > name = input("Enter file name, or Ctrl-D to exit") > # On Windows, use Ctrl-Z [enter] instead. > fp = open(name) > except EOFError: > sys.exit() > except IOError: > hand

Re: open() and EOFError

2014-07-07 Thread Steven D'Aprano
On Mon, 07 Jul 2014 17:04:12 +1200, Gregory Ewing wrote: > Steven D'Aprano wrote: >> Are there any circumstances where merely *opening* a file (before >> reading it) can raise EOFError? > > I don't think so. As far as I know, the only built-in thing that raises > EOFError is input() (and raw_inpu

Re: Module name does not match file name

2014-07-07 Thread Chris Angelico
On Mon, Jul 7, 2014 at 5:57 PM, Steven D'Aprano wrote: > Can anyone explain how "import pg" can end up coming from pgmodule.so? First guess: There's a "pg.py" somewhere that imports the so, then replaces itself in sys.modules. # importme.py import sys sys.modules["importme"]=sys >>> import imp

Module name does not match file name

2014-07-07 Thread Steven D'Aprano
Cut a long story short... I'm trying to debug a Tkinter app written in Python. The author of this app designed it as a maze of twisty dependencies, all alike, and his idea of source control was to make multiple copies of every file and drop them in random places on the hard drive. He also has

finditer

2014-07-07 Thread gintare
If smbd has time, maybe you could advice how to accomplish this task in faster way. I have a text = """ word{vb} wordtransl {vb} sent1. sent1trans. sent2 sent2trans... """ I need to match once wordtransl, and than many times repeating patterns consisting of sent and senttrans. The way i