Re: Python 3 is killing Python

2014-07-18 Thread Ian Kelly
On Thu, Jul 17, 2014 at 9:37 PM, Rick Johnson wrote: > On Thursday, July 17, 2014 9:15:15 PM UTC-5, Chris Angelico wrote: >> For myself, though, I completely do not use the editor half of [IDLE]; but >> it's spectacularly useful (with limitations) as my primary interactive >> interpreter. > > Yes

Re: NaN comparisons - Call For Anecdotes

2014-07-17 Thread Ian Kelly
On Thu, Jul 17, 2014 at 5:00 PM, Ian Kelly wrote: > On Thu, Jul 17, 2014 at 3:08 PM, Marko Rauhamaa wrote: >> Ian Kelly : >> >>> Well, 0**0 is usually defined as 1, despite the limits being >>> ambiguous. >> >> https://www.math.hmc.edu/funfacts/ffil

Re: NaN comparisons - Call For Anecdotes

2014-07-17 Thread Ian Kelly
On Thu, Jul 17, 2014 at 3:08 PM, Marko Rauhamaa wrote: > Ian Kelly : > >> Well, 0**0 is usually defined as 1, despite the limits being >> ambiguous. > > https://www.math.hmc.edu/funfacts/ffiles/10005.3-5.shtml> > > But if it could be defined, what "shou

Re: NaN comparisons - Call For Anecdotes

2014-07-17 Thread Ian Kelly
On Thu, Jul 17, 2014 at 1:10 PM, Marko Rauhamaa wrote: > Mathematically, there are undefined operations, for a good reason. > That's because the limits are not unambiguous and that's why 0/0, 0**0, > 1/0 and inf-inf are undefined. Well, 0**0 is usually defined as 1, despite the limits being ambig

Re: This Python 3 is killing Python thread is killing me.

2014-07-16 Thread Ian Kelly
On Wed, Jul 16, 2014 at 11:32 AM, Deb Wyatt wrote: > Can you all stop already with the non python US bashing? Please? I read it more as counter-US-glorification-trolling than bashing, but in any case that subthread seems to have died down already, so you should be safe to start reading again if

Re: Python 3 is killing Python

2014-07-16 Thread Ian Kelly
On Wed, Jul 16, 2014 at 11:33 AM, Javier wrote: > I think there has been a severe miscalculation, and the change in the > name of the interpreter python3 to python > http://legacy.python.org/dev/peps/pep-0394/ is a good example of the > disconnection between GvR and the real world. Er, that PEP c

Re: Python 3 is killing Python

2014-07-15 Thread Ian Kelly
On Tue, Jul 15, 2014 at 2:20 PM, Rick Johnson wrote: > On Tuesday, July 15, 2014 1:53:27 PM UTC-5, Steven D'Aprano wrote: > >> No software developer is obliged to support their software >> forever, especially if they are giving it away for free >> [...] Nobody but nobody is supporting Python 1.1 a

Re: Python 3 is killing Python

2014-07-15 Thread Ian Kelly
On Tue, Jul 15, 2014 at 12:01 PM, Rick Johnson wrote: > On Tuesday, July 15, 2014 9:31:31 AM UTC-5, Chris Angelico wrote: >> [...] That said, though, I would advise you to give 2to3 a >> shot. You never know, it might do exactly what you need >> right out-of-the-box and give you a 3.x-compatible >

Re: python-aware wdiff?

2014-07-14 Thread Ian Kelly
On Mon, Jul 14, 2014 at 2:01 PM, Terry Reedy wrote: > The under-known difflib.differ shows within line differences. > Your example would look like: > > -if not metar.is_in_temp_range_f(...): > ? ^ > +if not info.is_in_temp_range_f > ? > > Deletions and insertio

Re: NaN comparisons - Call For Anecdotes

2014-07-14 Thread Ian Kelly
On Mon, Jul 14, 2014 at 10:44 AM, Anders J. Munch <2...@jmunch.dk> wrote: > alister wrote: >> >> I don't have time to start this discussion over again on another mailing >> list. >> Don't anyone on those lists read python-list also? >> >> they possibly do, but prefer to keep discussions to the prop

Re: codingbat question broken?

2014-07-12 Thread Ian Kelly
On Sat, Jul 12, 2014 at 8:05 PM, Rodrick Brown wrote: > if a == 13: > t = b + c This looks incorrect. So no, I don't think the problem is with codingbat. -- https://mail.python.org/mailman/listinfo/python-list

Re: What does (A ``quote'' is the character used to open the string, i.e. either ' or ".) mean?

2014-07-10 Thread Ian Kelly
On Thu, Jul 10, 2014 at 9:23 AM, fl wrote: > Is '\A' the same with '^'? > Is '\Z' the same with '$'? The meanings of these are explained at: https://docs.python.org/library/re.html#regular-expression-syntax Outside of multiline mode, they're equivalent. In multiline mode, ^ and $ will also match

Re: NaN comparisons - Call For Anecdotes

2014-07-09 Thread Ian Kelly
On Wed, Jul 9, 2014 at 5:03 PM, Anders J. Munch <2...@jmunch.dk> wrote: > Joel Goldstick wrote: >> >> I've been following along here, and it seems you haven't received the >> answer you want or need. > > > So far I received exactly the answer I was expecting. 0 examples of > NaN!=NaN being benefic

Re: Proposal: === and !=== operators

2014-07-09 Thread Ian Kelly
On Wed, Jul 9, 2014 at 12:05 PM, Tim Chase wrote: > def equalish(x, y): >return x == y or (math.isnan(x) and math.isnan(y)) With more generality: def nan_type(x): if isinstance(x, numbers.Complex): if cmath.isnan(x): return 'qnan' elif isinstance(x, decimal.Decimal):

Re: Help me write better Code

2014-07-09 Thread Ian Kelly
On Wed, Jul 9, 2014 at 8:27 AM, sssdevelop wrote: > prev = 0 > blocks = [] > tmp = [] > last = 0 > for element in a: >if prev == 0: Is 0 allowed to be in the input list? What would happen if it were? > next This line doesn't do anything. It looks up the builtin function named next an

Re: Proposal: === and !=== operators

2014-07-09 Thread Ian Kelly
On Wed, Jul 9, 2014 at 3:17 AM, Steven D'Aprano wrote: > People are already having problems, just listen to Anders. He's > (apparently) not doing NAN-aware computations on his data, he just wants > to be able to do something like > > this_list_of_floats == that_list_of_floats > > without NANs scre

Re: NaN comparisons - Call For Anecdotes

2014-07-09 Thread Ian Kelly
On Wed, Jul 9, 2014 at 10:53 AM, Steven D'Aprano > Cast your 64-bit float into a 64-bit int. Or, if it's a C single rather > than a double, cast the 32-bit float into a 32-bit int. Now you can > compare them for equality without carrying about NANs, and without losing > data. Later, when you're rea

Re: NaN comparisons - Call For Anecdotes

2014-07-08 Thread Ian Kelly
On Tue, Jul 8, 2014 at 4:03 PM, Ethan Furman wrote: > On 07/08/2014 11:54 AM, Anders J. Munch wrote: >> >> >> If a standard tells you to jump of a cliff... > > > because a bunch of tanks are chasing you down, there's water at the bottom, > and not a helicopter in sight... > > well, jumping off the

Re: [Python-Dev] == on object tests identity in 3.x

2014-07-08 Thread Ian Kelly
On Tue, Jul 8, 2014 at 3:53 PM, Ian Kelly wrote: > On Tue, Jul 8, 2014 at 2:10 PM, Anders J. Munch <2...@jmunch.dk> wrote: >> Steven D'Aprano wrote: >>> - Keeping reflexivity for NANs would have implied some pretty nasty >>>things, e.g. if log(-3) == log(

Re: [Python-Dev] == on object tests identity in 3.x

2014-07-08 Thread Ian Kelly
On Tue, Jul 8, 2014 at 2:10 PM, Anders J. Munch <2...@jmunch.dk> wrote: > Steven D'Aprano wrote: >> - Keeping reflexivity for NANs would have implied some pretty nasty >>things, e.g. if log(-3) == log(-5), then -3 == -5. > > log(-3) > Traceback (most recent call last): > File "", line 1, i

Re: NaN comparisons - Call For Anecdotes

2014-07-08 Thread Ian Kelly
On Tue, Jul 8, 2014 at 12:54 PM, Anders J. Munch <2...@jmunch.dk> wrote: > > Ian Kelly wrote: >> >> As far as I know nothing changed between 2.4 and 2.7 in this regard. >> Python has always had NaN compare unequal to everything, per the >> standard. > > I

Re: NaN comparisons - Call For Anecdotes

2014-07-08 Thread Ian Kelly
On Tue, Jul 8, 2014 at 1:16 PM, Ethan Furman wrote: > What you said is: "They just don't appear in normal computation, because the > > interpreter raises an exception instead." > > I just ran a calculation that created a NaN, the same as 4 - 3 creates a 1, > and no exception was raised. > > Do you

Re: NaN comparisons - Call For Anecdotes

2014-07-08 Thread Ian Kelly
On Tue, Jul 8, 2014 at 8:53 AM, Anders J. Munch <2...@jmunch.dk> wrote: > And that worked fine in my Python 2.4 apps. Then I upgraded to 2.7 > and it broke. Because 2.7 goes out of it's way to ensure that NaN's > don't compare equal to themselves. As far as I know nothing changed between 2.4 and

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: 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: How to write this repeat matching?

2014-07-06 Thread Ian Kelly
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 "matchObj.group() : ", matchObj.group() >print "matchObj.group(0) : ", matchObj.group() >print "matchObj.

Re: PEP8 and 4 spaces

2014-07-06 Thread Ian Kelly
On Sun, Jul 6, 2014 at 1:25 PM, Dan Stromberg wrote: > I like tabs. Tabs work better for me than spaces, because I know how > to use them. Also, some "make" tools insist on tabs. Those tools are just as broken as the ones that only work with spaces. Fortunately, I can't even remember the last t

Re: PEP8 and 4 spaces

2014-07-05 Thread Ian Kelly
On Fri, Jul 4, 2014 at 8:00 PM, Rick Johnson wrote: > Strangly, I rather fancy the idea of using tabs in code,,, > which allow each viewer to view the code in his or her level > of indention,,, however, i cannot justify using a tab as a > replacement for a space. Tabs should be used for "tabular"

Re: 1-0.95

2014-07-02 Thread Ian Kelly
On Wed, Jul 2, 2014 at 10:55 PM, Gregory Ewing wrote: > Although loss of precision might give you the > right answer anyway. :-) There aren't that many digits in the speed of light. Unless we're talking about a very, very slow-moving automobile. -- https://mail.python.org/mailman/listinfo/pytho

Re: What's the "right" way to abandon an open source package?

2014-07-01 Thread Ian Kelly
On Tue, Jul 1, 2014 at 1:05 PM, Paul Sokolovsky wrote: > On 01 Jul 2014 18:40:23 GMT > Steven D'Aprano wrote: >> http://nedbatchelder.com/blog/201405/github_monoculture.html > > Everyone who (re)posts stuff like that should have mandatory N.B. of "I > just bought a server farm to offer an alterna

Re: thread.interrupt_main() behaviour

2014-07-01 Thread Ian Kelly
On Tue, Jul 1, 2014 at 3:45 AM, Skip Montanaro wrote: > On Tue, Jul 1, 2014 at 3:58 AM, Piyush Verma <114piy...@gmail.com> wrote: >> >> Since two threads are running same method, I wanted to know which main >> thread will be interrupted in both case. > > I'm no threading expert, but a process can

Re: print statements and profiling a function slowed performance

2014-06-27 Thread Ian Kelly
On Fri, Jun 27, 2014 at 10:05 AM, Skip Montanaro wrote: > On Fri, Jun 27, 2014 at 10:55 AM, Mark Lawrence > wrote: >> Expectations don't count, measure it :) > > It's no contest. I have measured it (ages ago). The logging module > does so many things that it's impossible for it to ever be as fas

Re: python 3.44 float addition bug?

2014-06-27 Thread Ian Kelly
On Thu, Jun 26, 2014 at 9:24 PM, Chris Angelico wrote: > But you're right that this can be very surprising. And it's inherent > to the concept of digits having more range than just "high" or "low", > so there's no way you can get this with binary floats. For an average of two numbers, I think tha

Re: Execute a python script with CGI ?

2014-06-26 Thread Ian Kelly
On Thu, Jun 26, 2014 at 9:24 AM, dandrigo wrote: > Dear all, > > I coded a python script (web service with query postgresql/postgis). Up to > now, i did several test on my local laptop station (windows). > > Now i want to execute this python script on our remote server (Web server : > Apache;OS :

Re: how to check if a value is a floating point or not

2014-06-20 Thread Ian Kelly
On Fri, Jun 20, 2014 at 8:28 AM, Grant Edwards wrote: > On 2014-06-20, Mark Lawrence wrote: > >> For the OP a very important rule of thumb is never use a bare except, so >> this is right out. >> >> try: >> doSomething() >> except: >> WTF() > > IMO, that sort of depends on WTF() does. On

Re: how to check if a value is a floating point or not

2014-06-19 Thread Ian Kelly
On Fri, Jun 20, 2014 at 12:14 AM, Nicholas Cannon wrote: > Guys i am only a beginner at python most of the stuff you are saying i need > to do i dont understand. All we're saying is that the simplest and most accurate way to determine whether a string can be converted to an int or a float is to

Re: Understanding Python Code

2014-06-19 Thread Ian Kelly
On Thu, Jun 19, 2014 at 12:44 PM, wrote: > Dear Group, > Generally most of the issues are tackled here, but as I am trying to cross > check my understanding I found another question, > > f_curr[st] = e[st][x_i] * prev_f_sum > > Here, if I give one print command and see the results, > print "$$2"

Re: Understanding Python Code

2014-06-19 Thread Ian Kelly
On Thu, Jun 19, 2014 at 3:48 AM, wrote: > I am trying to see this line, > prev_f_sum = sum(f_prev[k]*a[k][st] for k in states) > > a[k][st], and f_prev[k] I could take out and understood. > Now as it is doing sum() so it must be over a list, > I am trying to understand the number of entities in t

Re: how to check if a value is a floating point or not

2014-06-19 Thread Ian Kelly
On Thu, Jun 19, 2014 at 1:23 AM, Ian Kelly wrote: > On Thu, Jun 19, 2014 at 12:48 AM, Nicholas Cannon > wrote: >> On Thursday, June 19, 2014 1:53:31 PM UTC+8, Nicholas Cannon wrote: >>> I am making a calculator and i need it to support floating point values but >&g

Re: how to check if a value is a floating point or not

2014-06-19 Thread Ian Kelly
On Thu, Jun 19, 2014 at 12:48 AM, Nicholas Cannon wrote: > On Thursday, June 19, 2014 1:53:31 PM UTC+8, Nicholas Cannon wrote: >> I am making a calculator and i need it to support floating point values but >> i am using the function isnumeric to check if the user has entered an int >> value. I n

Re: Understanding Python Code

2014-06-19 Thread Ian Kelly
On Wed, Jun 18, 2014 at 11:50 PM, wrote: > Thank you for the reply. But as I checked it again I found, > f_prev[k] is giving values of f_curr[st] = e[st][x_i] * prev_f_sum > which is calculated later and again uses prev_f_sum. f_prev is the f_curr that was calculated on the previous iteration of

Re: Not Responding When Dealing with Large Data

2014-06-18 Thread Ian Kelly
On Wed, Jun 18, 2014 at 4:32 PM, cutey Love wrote: > Hi, thanks for the replies, > > I mean windows displays "Not responding close the program now" > > How can I do it asynconistrically? > > It's simple code just open file, loop through line by line and do some > comparons with the string. If al

Re: Python Fails to Write to File

2014-06-18 Thread Ian Kelly
On Wed, Jun 18, 2014 at 5:03 PM, cutey Love wrote: > I'm trying to write data to a text file > > But I'm getting the error: > > TypeError: invalid file: <_io.TextIOWrapper Post the full traceback. By posting only the error message you're removing useful information. -- https://mail.python.org/m

Re: Understanding Python Code

2014-06-18 Thread Ian Kelly
On Wed, Jun 18, 2014 at 10:36 AM, wrote: > The questions are, > i) prev_f_sum = sum(f_prev[k]*a[k][st] for k in states) > here f_prev is called, > f_prev is assigned to f_curr ["f_prev = f_curr"] > f_curr[st] is again being calculated as, ["f_curr[st] = e[st][x_i] * > prev_f_sum"] which again

Re: Python's numeric tower

2014-06-15 Thread Ian Kelly
On Sun, Jun 15, 2014 at 11:28 AM, Roy Smith wrote: > In article <539dbcbe$0$29988$c3e8da3$54964...@news.astraweb.com>, > Steven D'Aprano wrote: > >> On Sun, 15 Jun 2014 01:22:50 -0600, Ian Kelly wrote: >> >> > On Sat, Jun 14, 2014 at 8:51 PM, Steven D&#

Re: Python's numeric tower

2014-06-15 Thread Ian Kelly
On Sat, Jun 14, 2014 at 8:51 PM, Steven D'Aprano wrote: > Does anyone know any examples of values or types from the standard > library or well-known third-party libraries which satisfies > isinstance(a, numbers.Number) but not isinstance(a, numbers.Complex)? >>> issubclass(decimal.Decimal, number

Re: Question about asyncio

2014-06-13 Thread Ian Kelly
On Fri, Jun 13, 2014 at 5:42 AM, Frank Millman wrote: > Now I want to use the functionality of asyncio by using a 'yield from' to > suspend the currently executing function at a particular point while it > waits for some information. I find that adding 'yield from' turns the > function into a gene

Re: Asymmetry in globals __getitem__/__setitem__

2014-06-12 Thread Ian Kelly
On Thu, Jun 12, 2014 at 12:18 PM, Robert Lehmann wrote: > Hi all, > > I have noticed there is a slight asymmetry in the way the interpreter > (v3.3.5, reproduced also in v3.5.x) loads and stores globals. While loading > globals from a custom mapping triggers __getitem__ just fine, writing seems >

Re: asyncio - how to stop loop?

2014-06-11 Thread Ian Kelly
On Wed, Jun 11, 2014 at 1:19 AM, Frank Millman wrote: > First attempt - same as before > > loop = asyncio.get_event_loop() > threading.Thread(target=loop.run_forever).start() > input('Press to stop') > loop.stop() > loop.close() Each event loop is hosted by a specific thread.

Re: Is MVC Design Pattern good enough?

2014-06-10 Thread Ian Kelly
On Mon, Jun 9, 2014 at 9:54 PM, Stefan Ram wrote: > Chris Angelico writes: >>On Tue, Jun 10, 2014 at 12:57 PM, Stefan Ram wrote: >>>AFAIK standard Python has no GUI library at all, so Java SE >>>and C# already are better than Python insofar as they >>>include a standard GUI toolkit at all! In Py

Re: None in string => TypeError?

2014-06-09 Thread Ian Kelly
On Mon, Jun 9, 2014 at 11:40 AM, Chris Angelico wrote: > Also, this is the first time I've seen None as a constant other than > the first. Usually co_consts[0] is None, but this time co_consts[4] is > None. Functions always seem to have None as the first constant, but modules and classes are othe

Re: None in string => TypeError?

2014-06-09 Thread Ian Kelly
On Mon, Jun 9, 2014 at 10:59 AM, Chris Angelico wrote: > On Tue, Jun 10, 2014 at 2:53 AM, Roy Smith wrote: >> In retrospect, I suspect: >> >> hourly_data = [(t if status in set('CSRP') else None) for (t, >> status) in hours] >> >> is a little cleaner. > > I'd go with this. It's clearer

Re: None in string => TypeError?

2014-06-09 Thread Ian Kelly
On Mon, Jun 9, 2014 at 9:34 AM, Roy Smith wrote: > We noticed recently that: > None in 'foo' > > raises (at least in Python 2.7) > > TypeError: 'in ' requires string as left operand, not NoneType > > This is surprising. The description of the 'in' operatator is, 'True if an > item of s is e

Re: Uniform Function Call Syntax (UFCS)

2014-06-09 Thread Ian Kelly
On Jun 8, 2014 9:56 PM, "Steven D'Aprano" > > which means that hasattr (which is defined by > > attempting to get the attribute and seeing if an exception is thrown) > > has to return True. > > Yes. And this is a problem why? Earlier in this thread I pointed out that returning True creates problem

Re: try/except/finally

2014-06-08 Thread Ian Kelly
On Sun, Jun 8, 2014 at 11:57 AM, Joshua Landau wrote: > On 8 June 2014 08:12, Marko Rauhamaa wrote: >> >> Does anyone have an example motivating a return from finally? It seems >> to me it would always be a bad idea as it silently clears all unexpected >> exceptions. > > In a general sense: > >

Re: try/except/finally

2014-06-08 Thread Ian Kelly
On Sun, Jun 8, 2014 at 12:02 PM, Ian Kelly wrote: > On Sun, Jun 8, 2014 at 11:57 AM, Joshua Landau wrote: >> On 8 June 2014 08:12, Marko Rauhamaa wrote: >>> >>> Does anyone have an example motivating a return from finally? It seems >>> to me it would always

Re: os.startfile hanging onto the launched app, or my IDE?

2014-06-08 Thread Ian Kelly
On Fri, Jun 6, 2014 at 2:34 PM, Josh English wrote: > I have been using os.startfile(filepath) to launch files I've created in > Python, mostly Excel spreadsheets, text files, or PDFs. > > When I run my script from my IDE, the file opens as I expect. But if I go > back to my script and re-run it

Re: Uniform Function Call Syntax (UFCS)

2014-06-08 Thread Ian Kelly
On Sun, Jun 8, 2014 at 11:13 AM, Chris Angelico wrote: > On Mon, Jun 9, 2014 at 3:08 AM, Ian Kelly wrote: >> On Sun, Jun 8, 2014 at 10:48 AM, Chris Angelico wrote: >>> Except that it's even more complicated than that, because hasattr >>> wasn't defined in y

Re: Uniform Function Call Syntax (UFCS)

2014-06-08 Thread Ian Kelly
On Sun, Jun 8, 2014 at 10:48 AM, Chris Angelico wrote: > Except that it's even more complicated than that, because hasattr > wasn't defined in your module, so it has a different set of globals. > In fact, this would mean that hasattr would become quite useless. hasattr is a builtin, so it has no

Re: Uniform Function Call Syntax (UFCS)

2014-06-08 Thread Ian Kelly
On Sun, Jun 8, 2014 at 2:15 AM, jongiddy wrote: > One problem with your untested code, the superclasses would need to be > checked before using UFCS, so the structure is: > > try: > return super().__getattr__(attr) > except AttributeError: > # resolve using UFCS And then if UFCS finds no

Re: Uniform Function Call Syntax (UFCS)

2014-06-08 Thread Ian Kelly
On Sun, Jun 8, 2014 at 10:24 AM, jongiddy wrote: > A contrived example - which of these is easier to understand? > > from base64 import b64encode > > # works now > print(b64encode(str(min(map(int, f.readlines()), key=lambda n: n % 10)), > b'?-')) > > # would work with UFCS > f.readlines().map(int

Re: Uniform Function Call Syntax (UFCS)

2014-06-08 Thread Ian Kelly
On Sun, Jun 8, 2014 at 9:56 AM, Marko Rauhamaa wrote: > Paul Sokolovsky : > >> Python already has that - like, len(x) calls x.__len__() if it's >> defined > > In fact, what's the point of having the duality? > >len(x) <==> x.__len__() > >x < y <==> x.__lt__(y) > >str(x) <==> x.__str__(

Re: Uniform Function Call Syntax (UFCS)

2014-06-07 Thread Ian Kelly
On Sat, Jun 7, 2014 at 12:45 AM, jongiddy wrote: > The language D has a feature called Uniform Function Call Syntax, which > allows instance methods to be resolved using function calls. > > In Python terms, the call: > > x.len() > > would first check if 'x' has a method 'len', and would then look

Re: How to use imported function to get current globals

2014-06-07 Thread Ian Kelly
On Sat, Jun 7, 2014 at 11:40 AM, 1989lzhh <1989l...@gmail.com> wrote: > Here is the code > m1.py > def f(): > print globals() > > m2.py > from m1 import f > f()# how to get current module's globals? Evaluate globals() in the current module and pass the resulting dict in as a parameter: # m1.p

Re: Unicode and Python - how often do you index strings?

2014-06-05 Thread Ian Kelly
On Thu, Jun 5, 2014 at 2:34 PM, Albert-Jan Roskam wrote: >> If you want to be really picky about removing exactly one line >> terminator, then this captures all the relatively modern variations: >> re.sub('\r?\n$|\n?\r$', line, '', count=1) > > or perhaps: re.sub("[^ \S]+$", "", line) That will r

Re: Unicode and Python - how often do you index strings?

2014-06-05 Thread Ian Kelly
On Thu, Jun 5, 2014 at 1:58 PM, Paul Rubin wrote: > Ryan Hiebert writes: >> How so? I was using line=line[:-1] for removing the trailing newline, and >> just replaced it with rstrip('\n'). What are you doing differently? > > rstrip removes all the newlines off the end, whether there are zero or >

Re: Python 3.2 has some deadly infection

2014-06-05 Thread Ian Kelly
On Thu, Jun 5, 2014 at 10:17 AM, Robin Becker wrote: > in python 2 str and unicode were much more comparable. On balance I think > just reversing them ie str --> bytes and unicode --> str was probably the > right thing to do if the default conversions had been turned off. However > making bytes a

Re: Having trouble in expressing constraints in Python

2014-06-04 Thread Ian Kelly
On Tue, Jun 3, 2014 at 7:44 AM, wrote: > I have a problem in writing a constraint in Python. Firstly, I wrote the code > in AMPL and it was working and I'm using Python for the reason that it is > more suitable to handle large data. I managed to write the code quite fine > except for one const

Re: Lock Windows Screen GUI using python

2014-06-03 Thread Ian Kelly
On Jun 3, 2014 11:46 PM, "Jaydeep Patil" wrote: > Below is the sample function which doing copy paste in my case. > I am copying data directly by column, not reading each & every value. > Data is too big in heavy. The approach I suggested also operates on ranges, not individual cells. -- https:/

Re: Micro Python -- a lean and efficient implementation of Python 3

2014-06-03 Thread Ian Kelly
On Jun 3, 2014 11:27 PM, "Steven D'Aprano" wrote: > For technical reasons which I don't fully understand, Unicode only > uses 21 of those 32 bits, giving a total of 1114112 available code > points. I think mainly it's to accommodate UTF-16. The surrogate pair scheme is sufficient to encode up to

Re: Micro Python -- a lean and efficient implementation of Python 3

2014-06-03 Thread Ian Kelly
On Tue, Jun 3, 2014 at 10:40 PM, Rustom Mody wrote: >> 1) Most or all Chinese and Japanese characters > > Dont know how you count 'most' > > | One possible rationale is the desire to limit the size of the full > | Unicode character set, where CJK characters as represented by discrete > | ideograms

Re: Lock Windows Screen GUI using python

2014-06-03 Thread Ian Kelly
On Tue, Jun 3, 2014 at 9:55 PM, Jaydeep Patil wrote: > Hi lan, > > For plotting one graph, I need to use four to five excel files. Currently I > am reading excel files one by one and copy data of excel files to another > single master excel file. This master excel file consists of all data from

Re: Lock Windows Screen GUI using python

2014-06-03 Thread Ian Kelly
On Jun 3, 2014 1:56 AM, "Jaydeep Patil" wrote: > I have another query. > > We can now block user inputs. But in my automation three is copy & paste work going on continuously in Excel before plotting the graphs. > > During copy paste of excel data, if user by mistake doing some copy & paste opera

Re: Lock Windows Screen GUI using python

2014-06-03 Thread Ian Kelly
On Tue, Jun 3, 2014 at 12:40 AM, Jaydeep Patil wrote: > Hi Lan, > > Currently I am doing some automation in python excel. It read the data & > plots number of graphs. It took more than 20 minutes. So while running my > python program if user clicks on excel, error came. > > So just i want to loc

Re: Lock Windows Screen GUI using python

2014-06-02 Thread Ian Kelly
On Mon, Jun 2, 2014 at 10:28 PM, Jaydeep Patil wrote: > Dear all, > Can we Lock Windows Screen GUI till program runs & unlock screen GUI when > program finishes? If you mean can you programmatically bring up the Windows lock screen, then you can do this: import ctypes ctypes.windll.user32.LockW

Re: can someone explain the concept of "strings (or whatever) being immutable"

2014-06-02 Thread Ian Kelly
On Jun 2, 2014 10:41 PM, "Deb Wyatt" wrote: > > a_string = "This is a string" > a_string is pointing to the above string > > now I change the value of a_string > a_string = "This string is different" > I understand that now a_string is pointing to a different string than it was before, in a differ

Re: Benefits of asyncio

2014-06-02 Thread Ian Kelly
On Mon, Jun 2, 2014 at 11:40 AM, Aseem Bansal wrote: > I read in these groups that asyncio is a great addition to Python 3. I have > looked around and saw the related PEP which is quite big BTW but couldn't > find a simple explanation for why this is such a great addition. Any simple > example

Re: Python 3 is killing Python

2014-06-02 Thread Ian Kelly
On Mon, Jun 2, 2014 at 10:15 AM, Steven D'Aprano wrote: > On Mon, 02 Jun 2014 09:01:01 -0600, Ian Kelly wrote: > >> On Jun 1, 2014 12:11 PM, wrote: >> >>> At least Py2 does not crash when using non ascii (eg sticking with >>> cp1252). >>>

Re: Obfuscated Python hack

2014-06-02 Thread Ian Kelly
On Mon, Jun 2, 2014 at 9:38 AM, Steven D'Aprano wrote: > On Mon, 02 Jun 2014 23:23:53 +1000, Chris Angelico wrote: > >> On Mon, Jun 2, 2014 at 10:27 PM, Tim Chase >> wrote: >>> Stripping off the exec() call makes it pretty transparent that you're >>> attempting (successfully on some platforms) to

Re: Python 3 is killing Python

2014-06-02 Thread Ian Kelly
On Jun 1, 2014 12:11 PM, wrote: > At least Py2 does not crash when using non ascii > (eg sticking with cp1252). > > I just noticed this last week, Thursday, when presenting > the absurdity of the Flexible String Representation. So have you reported this alleged crash bug to the bug tracker? If n

Re: Optparse to parsing Suggestions !!

2014-05-31 Thread Ian Kelly
On May 30, 2014 8:26 AM, "Ganesh Pal" wrote: > > > Hello Python world , > > > I wanted suggestion on how to modify the below code to help me accomodate the below two cases Your question was answered already, but I'd like to point out that optparse is deprecated. If possible, you should use argpar

Re: Yet another "simple" headscratcher

2014-05-30 Thread Ian Kelly
On Fri, May 30, 2014 at 9:38 PM, Josh English wrote: > I am trying to whip up a quick matrix class that can handle multiplication. > > Should be no problem, except when it fails. > > [SNIP] > > def zero_matrix(rows, cols): > row = [0] * cols > data = [] > for r in range(rows): >

Re: Binary data exchange

2014-05-29 Thread Ian Kelly
On Thu, May 29, 2014 at 5:09 PM, MRAB wrote: > On 2014-05-29 23:08, rasikasriniva...@gmail.com wrote: >> the received data for the messages 9 thru 13 are not as expected. >> >> I wonder if anyone can see what I am doing wrong? >> >> Appreciate any hints. thanks, srini >> > I don't understand why y

Re: Forking PyPI package

2014-05-29 Thread Ian Kelly
On Thu, May 29, 2014 at 1:40 AM, Chris Angelico wrote: > If you absolutely can't get in touch with him, the only option is to > go back to the original protocol and manually reimplement it, > completely ignoring this code. It's sad but true; some code dies > because of a trivial thing like "Oops,

Re: need help with this code please fix it or at least tell me what im doing wrong

2014-05-28 Thread Ian Kelly
On Wed, May 28, 2014 at 11:32 AM, funky wrote: > while done == False: > for event in pygame.event.get(): > if event.type == pygame.QUIT: > done == True Here is one fairly obvious bug; you used "==" where you presumably intended to do an assignment. As it stands it will ju

Re: Advice for choosing correct architecture/tech for a hobby project

2014-05-23 Thread Ian Kelly
On Thu, May 22, 2014 at 1:49 PM, Mark H Harris wrote: > On 5/22/14 1:54 PM, Aseem Bansal wrote: >> >> I am working on a hobby project - a Bookmarker{snip} > > > hi, no django is not really the correct tool-set. Django is for server-side > content management That's a common misconception. Django

Re: Advice for choosing correct architecture/tech for a hobby project

2014-05-22 Thread Ian Kelly
On Thu, May 22, 2014 at 1:28 PM, John Gordon wrote: > In <6a3c5b20-bce5-4c95-b27f-3840e9cc7...@googlegroups.com> Aseem Bansal > writes: > >> But I hit a snag today that webbrowser's won't allow client to open >> hyperlinks with file protocol. I have both offline and online bookmarks >> so that w

Re: Putting Py 3.4.1 to work.

2014-05-20 Thread Ian Kelly
On Tue, May 20, 2014 at 11:14 AM, John Gordon wrote: > In > wxjmfa...@gmail.com writes: > >> sys.path >> ['D:\\jm\\jmpy\\smid\\smid50beta1', 'C:\\Windows\\system32\\python34.zip', >> 'C:\\Python34\\DLLs\\DLLs', 'C:\\Python34\\DLLs\\lib', 'C:\\Python34\\DLLs', >> 'C:\\Python34\\DLLs\\lib\\site-pa

Re: 'Swampy' installation through 'pip'

2014-05-20 Thread Ian Kelly
On May 20, 2014 7:22 AM, "Mark Lawrence" wrote: > > On 20/05/2014 08:11, Ronak Dhakan wrote: >> >> I have just started learning python from How to Think Like a Computer Scientist. It requires me to install 'swampy' ( http://www.greenteapress.com/thinkpython/swampy/install.html) which requires

Re: bz2.decompress as file handle

2014-05-18 Thread Ian Kelly
On Sun, May 18, 2014 at 8:38 PM, Vincent Davis wrote: > Well after posting, I think I figured it out. > The key is to use StringIO to get a file handle on the string. The fact that > it is binary just complicates it a little. > > with open('Tests/Affy/affy_v3_ex.CEL.bz2', 'rb') as handle: > ce

Re: How do I access 'Beautiful Soup' on python 2.7 or 3.4 , console or idle versions.

2014-05-14 Thread Ian Kelly
On Wed, May 14, 2014 at 1:28 PM, Simon Evans > Again it does not recognise 'bs4'. I think having used 'Just unzip it' instead of 'WinZip' may have caused this problem, in the first place ,as when I looked at the WinZip version at a local net café, it did have a folder hierarchy, however I wanted, a

Re: How do I access 'Beautiful Soup' on python 2.7 or 3.4 , console or idle versions.

2014-05-14 Thread Ian Kelly
On Wed, May 14, 2014 at 12:58 PM, Simon Evans wrote: > c:\Beautiful Soup>pip install beautifulsoup4 > 'pip' is not recognized as an internal or external command, > operable program or batch file. > > c:\Beautiful Soup> > -

Re: Everything you did not want to know about Unicode in Python 3

2014-05-14 Thread Ian Kelly
On Wed, May 14, 2014 at 9:30 AM, Robin Becker wrote: > Doesn't this issue also come up wherever bytes are being read ie in sockets, > pipe file handles etc? Some sources may have well defined encodings and so > allow use of unicode strings but surely not all. I imagine all of the > problems associ

Re: Everything you did not want to know about Unicode in Python 3

2014-05-14 Thread Ian Kelly
On May 13, 2014 6:10 PM, "Chris Angelico" wrote: > > On Wed, May 14, 2014 at 9:53 AM, Steven D'Aprano > wrote: > > With the current system, all of us here are technically violating > > copyright every time we reply to an email and quote more than a small > > percentage of it. > > Oh wow... so whe

Re: Fortran

2014-05-13 Thread Ian Kelly
On Tue, May 13, 2014 at 6:10 PM, Steven D'Aprano wrote: > On Tue, 13 May 2014 22:57:16 +0300, Marko Rauhamaa wrote: > >> Producing an effective JIT for Python seems like a formidable challenge >> but not impossible in principle. > > Or in practice. > > http://pypy.org/ > > And it's predecessor: ht

Re: New to Python. For in loops curiosity

2014-05-13 Thread Ian Kelly
On Tue, May 13, 2014 at 9:38 PM, Leonardo Petry wrote: > The loop below (at the bottom) runs each line of the file > > fin = open('wordplay.txt'); > user_input = raw_input('Enter some characters: ') > count = 0 > for line in fin: > word = line.strip() > if(avoids(word, user_input)): >

Re: Everything you did not want to know about Unicode in Python 3

2014-05-13 Thread Ian Kelly
On Tue, May 13, 2014 at 5:19 AM, alister wrote: > I am only an amateur python coder which is why I asked if I am missing > something > > I could not see any reason to be using the shutil module if all that the > programm is doing is opening a file, reading it & then printing it. > > is it python t

Re: How do I access 'Beautiful Soup' on python 2.7 or 3.4 , console or idle versions.

2014-05-13 Thread Ian Kelly
On Tue, May 13, 2014 at 5:59 AM, Simon Evans wrote: > I can see no bs4 folder within the contents. > I can not see any setup.py file either, but this is how I downloaded it. You do have a setup.py in there, but your Windows explorer is showing it to you without the .py extension. Something unusu

<    12   13   14   15   16   17   18   19   20   21   >