Re: unicode as valid naming symbols

2014-03-31 Thread Ian Kelly
On Mon, Mar 31, 2014 at 1:31 PM, Antoon Pardon wrote: > Op 31-03-14 19:40, Ian Kelly schreef: >> That was an exaggeration on my part. It wouldn't affect my job, as I >> wouldn't expect to ever actually have to maintain anything like the >> above. My greater

Re: Code style query: multiple assignments in if/elif tree

2014-03-31 Thread Ian Kelly
On Mon, Mar 31, 2014 at 11:01 PM, Chris Angelico wrote: > On Tue, Apr 1, 2014 at 3:26 PM, Steven D'Aprano wrote: >> The scenario you describe has (effectively) infinite rate-of-change-of- >> acceleration, often called "jerk". (A jerk is a rapid change in >> acceleration.) Human comfort is (within

Re: Code style query: multiple assignments in if/elif tree

2014-03-31 Thread Ian Kelly
On Mon, Mar 31, 2014 at 11:45 PM, Rustom Mody wrote: > On Tue, Apr 1, 2014 at 3:26 PM, Steven D'Aprano wrote: > >> Haskell has nifty pattern-matching syntax for this that looks quite close >> to the mathematical hybrid function syntax, but in Python, we're limited >> to explicitly using an if. If

Re: Code style query: multiple assignments in if/elif tree

2014-03-31 Thread Ian Kelly
On Tue, Apr 1, 2014 at 12:24 AM, David Hutto wrote: >> >> >> (1) v = u + at >> >> (2) s = 1/2(u + v)t >> >> (3) s = ut + 1/2(at^2) >> >> (4) v^2 = u^2 + 2as >> >> >> >> Only (1) and (3) are needed. >> > >> > Okay, what's u here? Heh. >> >> u is the initial velocity; v is the velocity after acceler

Re: Code style query: multiple assignments in if/elif tree

2014-04-01 Thread Ian Kelly
On Tue, Apr 1, 2014 at 1:35 AM, Chris Angelico wrote: > On Tue, Apr 1, 2014 at 6:20 PM, Steven D'Aprano wrote: >> 177.2133 >> >> compared to 177.2652780002 calculated the rough way. That's not bad, >> only about 5cm off! Effectively, your rough calculation was accurate to >> one decim

Re: Code style query: multiple assignments in if/elif tree

2014-04-01 Thread Ian Kelly
On Tue, Apr 1, 2014 at 2:18 AM, Ian Kelly wrote: > The reason the velocity is different after 2 seconds is because the > linear deceleration does not match the constraints of the problem. The > average deceleration for the first second is not 0.2 m/s, and the > average deceleration fo

Re: Code style query: multiple assignments in if/elif tree

2014-04-01 Thread Ian Kelly
On Tue, Apr 1, 2014 at 1:59 AM, Ian Kelly wrote: > Given that, I have to question your figures: > >> 177.2133 > >> compared to 177.2652780002 calculated the rough way. That's not bad, >> only about 5cm off! Effectively, your rough calculation was

Re: Code style query: multiple assignments in if/elif tree

2014-04-01 Thread Ian Kelly
On Tue, Apr 1, 2014 at 12:55 AM, Chris Angelico wrote: > On Tue, Apr 1, 2014 at 5:13 PM, Ian Kelly wrote: >> Then your computation is incorrect and will systematically >> underestimate the stopping distance. Assuming for simplicity that the >> acceleration actually increa

Re: unicode as valid naming symbols

2014-04-01 Thread Ian Kelly
On Tue, Apr 1, 2014 at 2:19 AM, Antoon Pardon wrote: > On 01-04-14 02:47, Ian Kelly wrote: >> On Mon, Mar 31, 2014 at 1:31 PM, Antoon Pardon >> wrote: >>> Second of all I >>> think a good chosen symbolic name can be more readable than a >>> name in a

Re: unicode as valid naming symbols

2014-04-01 Thread Ian Kelly
On Tue, Apr 1, 2014 at 3:32 AM, Marko Rauhamaa wrote: > Ian Kelly : > >> On Tue, Apr 1, 2014 at 2:19 AM, Antoon Pardon >>> Which will give me the normal result. Maybe I missed it but I haven't >>> heard scheme being called an unreadable language. >> >

Re: unicode as valid naming symbols

2014-04-01 Thread Ian Kelly
On Tue, Apr 1, 2014 at 7:44 AM, Chris Angelico wrote: > On Wed, Apr 2, 2014 at 12:33 AM, Ned Batchelder > wrote: >> Maybe I'm misunderstanding the discussion... It seems like we're talking >> about a hypothetical definition of identifiers based on Unicode character >> categories, but there's no

Re: Yet Another Switch-Case Syntax Proposal

2014-04-02 Thread Ian Kelly
On Wed, Apr 2, 2014 at 8:53 AM, Lucas Malor <3kywjyd...@snkmail.com> wrote: > Hi all. I would proposeto you all a switch-case syntax for Python. I already > read PEP 3103 and I'm not completely satisfied by any of the proposed > solutions. This is my proposal: A more suitable place to propose th

Re: Yet Another Switch-Case Syntax Proposal

2014-04-02 Thread Ian Kelly
On Wed, Apr 2, 2014 at 7:06 PM, Steven D'Aprano wrote: > If we're going to add "switch" and "case" keywords, how about we also add > "of"? Then we can write: > > switch x case of a, b, c: > # x equals one of a, b or c > case of d, e, f: > # x equals one of d, e or f > case in g, h, i: >

Re: Retrieve item deep in dict tree?

2014-04-03 Thread Ian Kelly
On Wed, Apr 2, 2014 at 10:15 PM, Rustom Mody wrote: > On Thursday, April 3, 2014 8:11:33 AM UTC+5:30, Rustom Mody wrote: >> On Wednesday, April 2, 2014 11:28:16 PM UTC+5:30, Roy Smith wrote: >> > I have a big hairy data structure which is a tree of nested dicts. I have >> > a sequence of strings

Re: Two Questions about Python on Windows

2014-04-03 Thread Ian Kelly
On Apr 3, 2014 11:12 AM, "Walter Hurry" wrote: > > Normally my Python development is done on FreeBSD and Linux. I know that on *ix I simply have to make foo.py executable (the shebang line is present, of course) to make it runnable. > > For my son's school assignment, I have to help him with Pytho

Re: Yet Another Switch-Case Syntax Proposal

2014-04-03 Thread Ian Kelly
On Thu, Apr 3, 2014 at 10:02 AM, Lucas Malor <3kywjyd...@snkmail.com> wrote: >> __contains__ is not part of the interface for iterables > > For what I know there's not an Iterable interface. For example List simply > extends Object. I hope that an ABC Iterable class will be introduced in a > futu

Re: Default mutable parameters in functions

2014-04-03 Thread Ian Kelly
On Thu, Apr 3, 2014 at 12:49 PM, wrote: > Now call it with a value: > foo([ 3 ]) > > as you might expect: > It's a parrot, not a cheese: [3] > > But now go back to no parameter in the call: > foo() > foo() > foo() > > It's a parrot, not a cheese: [46] > It's a parrot, not a cheese: [47] > It's a

Re: Two Questions about Python on Windows

2014-04-03 Thread Ian Kelly
On Thu, Apr 3, 2014 at 2:15 PM, Mark Lawrence wrote: > On 03/04/2014 18:54, Ian Kelly wrote: >> >> >> On Apr 3, 2014 11:12 AM, "Walter Hurry" > <mailto:walterhu...@gmail.com>> wrote: >> > >> > Normally my Python development is done

Re: Explanation of this Python language feature? [x for x in x for x in x] (to flatten a nested list)

2014-04-04 Thread Ian Kelly
On Fri, Apr 4, 2014 at 1:52 AM, Steven D'Aprano wrote: > py> from decimal import * > py> getcontext().prec = 16 > py> x = Decimal("0.77787516") > py> y = Decimal("0.77787518") > py> (x + y) / 2 > Decimal('0.77787515') > > "Guido, why can't Python do maths???" Well, you nee

Re: Yet Another Switch-Case Syntax Proposal

2014-04-04 Thread Ian Kelly
On Apr 4, 2014 3:51 AM, "Marko Rauhamaa" wrote: > > >>> switch day casein ("Monday", "Thursday", "Wednesday", "Tuesday", > >>> "Friday"): > >>> gotowork = True > >>> continue > >>> casein ("Monday", "Thursday", "Wednesday", "Tuesday", "Friday"): > >>> daytype = "ferial" > >>> casein

Re: Explanation of this Python language feature? [x for x in x for x in x] (to flatten a nested list)

2014-04-04 Thread Ian Kelly
On Fri, Apr 4, 2014 at 4:08 AM, Steven D'Aprano wrote: > On Fri, 04 Apr 2014 02:13:13 -0600, Ian Kelly wrote: > >> On Fri, Apr 4, 2014 at 1:52 AM, Steven D'Aprano >> wrote: >>> py> from decimal import * >>> py> getcontext().prec = 16 >>&

Re: Yet Another Switch-Case Syntax Proposal

2014-04-04 Thread Ian Kelly
On Fri, Apr 4, 2014 at 10:44 AM, Marko Rauhamaa wrote: > Consider: > > switch local_sabbath():# bad > case (1, 2, 3) as sabbath: > ... I'm not overly fond of that either. That's why I liked the OP's choice to put the first case in the switch statement. > Now Python "fram

Re: Scoping rules for class definitions

2014-04-04 Thread Ian Kelly
On Fri, Apr 4, 2014 at 12:37 PM, Rotwang wrote: > Hi all. I thought I had a pretty good grasp of Python's scoping rules, but > today I noticed something that I don't understand. Can anyone explain to me > why this happens? > x = 'global' def f1(): > x = 'local' > class C: >

Re: Explanation of this Python language feature? [x for x in x for x in x] (to flatten a nested list)

2014-04-04 Thread Ian Kelly
On Fri, Apr 4, 2014 at 2:58 PM, Mark H Harris wrote: > On 4/4/14 3:20 AM, Mark Lawrence wrote: >> >> On 04/04/2014 03:29, Mark H Harris wrote: >>> >>> >>> Now, about Python2. It has not died. It appears to be 'useful'. >>> {snip} >>> >> >> For a lot of people, if it ain't broke, don't fix it

Re: Explanation of this Python language feature? [x for x in x for x in x] (to flatten a nested list)

2014-04-04 Thread Ian Kelly
On Fri, Apr 4, 2014 at 10:10 PM, Mark H Harris wrote: > On 4/4/14 6:16 PM, Mark Lawrence wrote: >> >> Fear/panic of a fork, where did that come from? It's certainly the >> first I've ever heard of it. >> > > hi Mark, it came from Ian; or, my interpretation of Ian. It comes out on the > net too (f

Re: Explanation of this Python language feature? [x for x in x for x in x] (to flatten a nested list)

2014-04-04 Thread Ian Kelly
On Fri, Apr 4, 2014 at 10:40 PM, Chris Angelico wrote: > On Sat, Apr 5, 2014 at 3:10 PM, Mark H Harris wrote: >> we don't want folks to be driven away from Cpython as a language, and we >> don't want them to fork the Cpython interpreter, so we'll take a very casual >> and methodically conservativ

Re: Yet Another Switch-Case Syntax Proposal

2014-04-06 Thread Ian Kelly
On Sun, Apr 6, 2014 at 11:49 AM, Lucas Malor <3kywjyd...@snkmail.com> wrote: > On 3 April 2014 20:12, Ian Kelly ian.g.kelly-at-gmail.com > |python-list@python.org| wrote: >> Use this instead [of continue]: > >> >> switch day case in ("Mon", "Tue&

Re: Keeping track of things with dictionaries

2014-04-08 Thread Ian Kelly
On Tue, Apr 8, 2014 at 1:14 AM, Frank Millman wrote: > > "Chris Angelico" wrote in message > news:captjjmqfbt2xx+bdfnhz0gagordkhtpbzrr29duwn36girz...@mail.gmail.com... >> On Tue, Apr 8, 2014 at 2:02 PM, Josh English >> wrote: >>> >>> Would dict.setdefault() solve this problem? Is there any advan

Re: Keeping track of things with dictionaries

2014-04-08 Thread Ian Kelly
On Tue, Apr 8, 2014 at 8:45 PM, alex23 wrote: > On 9/04/2014 12:33 PM, Chris Angelico wrote: >>> >>> Unfortunately I seem to be missing antidisestablishmentarianism, >>> because the longest words in my dict are only 24 characters, >>> excluding the '\n'. Should I ask for my money back? >> >> >> I

Re: Keeping track of things with dictionaries

2014-04-08 Thread Ian Kelly
On Tue, Apr 8, 2014 at 9:31 PM, Gene Heskett wrote: >> 'Pneumonoultramicroscopicsilicovolcanoconiosis' has them all beat. > > Source citation please? http://en.wikipedia.org/wiki/Pneumonoultramicroscopicsilicovolcanoconiosis http://www.oxforddictionaries.com/definition/english/pneumonoultramicros

Re: python obfuscate

2014-04-10 Thread Ian Kelly
On Thu, Apr 10, 2014 at 7:48 PM, Tobiah wrote: > On 4/10/2014 6:29 PM, Wesley wrote: >> Hi all, Does python has any good obfuscate? >> >> Currently our company wanna release one product developed by python >> to our customer. But dont's wanna others see the py code. >> >> I googled for a while but

Re: python obfuscate

2014-04-10 Thread Ian Kelly
On Thu, Apr 10, 2014 at 8:17 PM, Wesley wrote: > Umm, just wanna make all .py files not human readable. > > Or, maybe need a tool like zend in php. The only reliable way to prevent a customer from reverse-engineering your software is to not give them the software. For example, instead of giving

Re: Teaching python to non-programmers

2014-04-10 Thread Ian Kelly
On Thu, Apr 10, 2014 at 11:11 PM, Chris Angelico wrote: > On Fri, Apr 11, 2014 at 2:37 PM, Rustom Mody wrote: >> Right. Its true that when I was at a fairly large corporate, I was not told: >> "Please always top post!" >> >> What I was very gently and super politely told was: >> "Please dont dele

Re: python obfuscate

2014-04-11 Thread Ian Kelly
On Fri, Apr 11, 2014 at 3:17 AM, Sturla Molden wrote: > Ian Kelly wrote: > >> The only reliable way to prevent a customer from reverse-engineering >> your software is to not give them the software. > > Not really... On Fri, Apr 11, 2014 at 3:17 AM, Sturla Molden wr

Re: Teaching python to non-programmers

2014-04-14 Thread Ian Kelly
On Mon, Apr 14, 2014 at 12:13 AM, alex23 wrote: > http://www.ietf.org/rfc/rfc1855.txt > > If you are sending a reply to a message or a posting be sure you > summarize the original at the top of the message, or include just > enough text of the original to give a context. This will mak

Re: Martijn Faassen: The Call of Python 2.8

2014-04-14 Thread Ian Kelly
On Apr 14, 2014 11:46 AM, wrote: > > I will most probably backport two quite large applications > to Py27 ("scientific data processing apps"). These applications are already on Python 3? Why do you want them on Python 2? Even the people talking about a 2.8 are only seeing it as an upgrade path to

Re: Why Python 3?

2014-04-19 Thread Ian Kelly
On Sat, Apr 19, 2014 at 1:34 AM, Chris Angelico wrote: > That'll make Python 2.6/2.7 behave like Python 3.x in three ways: > firstly, "print" will be a function instead of a statement (and it's > more powerful than the statement form, as well as being more > flexible); secondly, quoted strings wil

Re: Why Python 3?

2014-04-19 Thread Ian Kelly
On Sat, Apr 19, 2014 at 3:37 AM, Chris Angelico wrote: > On Sat, Apr 19, 2014 at 7:25 PM, Ian Kelly wrote: >> The change from / denoting "classic >> division" to "true division" really only affects the case where both >> operands are integers, so far

Re: Why Python 3?

2014-04-19 Thread Ian Kelly
On Sat, Apr 19, 2014 at 2:31 PM, Chris Angelico wrote: > On Sun, Apr 20, 2014 at 5:58 AM, Ian Kelly wrote: >> Considering that Fraction and Decimal did not exist yet, what type do >> you think the PEP 238 implementers should have chosen for the result >> of dividing two i

Re: Why Python 3?

2014-04-20 Thread Ian Kelly
On Apr 19, 2014 2:54 PM, "Chris Angelico" wrote: > > On Sun, Apr 20, 2014 at 6:38 AM, Ian Kelly wrote: > >> Or you just cast one of them to float. That way you're sure you're > >> working with floats. > > > > Which is inappropriate if th

Re: Why Python 3?

2014-04-20 Thread Ian Kelly
On Apr 20, 2014 8:01 PM, "Gregory Ewing" wrote: > > Ian Kelly wrote: > >> def average(values): >> return sum(values) / len(values) >> >> This works for decimals, it works for fractions, it works for complex numbers, it works for numpy types, an

Re: Unicode in Python

2014-04-21 Thread Ian Kelly
On Apr 22, 2014 12:01 AM, "Rustom Mody" wrote: > As a unicode user (ok wannabe unicode user :D ) Ive > written up some unicode ideas that have been discussed here in the > last couple of weeks: > > http://blog.languager.org/2014/04/unicoded-python.html I'm reminded of this satire: http://www.ojoh

Re: Moving to an OOP model from an classically imperitive one

2014-04-23 Thread Ian Kelly
On Apr 23, 2014 5:01 PM, wrote: > I asked on IRC and it was sugested that I use multiple classes, however I see no logical way to separate a SubuserProgram object into multiple classes. You say you already have the methods logically separated into files. How about adding one abstract class per fi

Re: Unicode in Python

2014-04-26 Thread Ian Kelly
On Apr 26, 2014 3:46 AM, "Frank Millman" wrote: > > > wrote in message > news:03bb12d8-93be-4ef6-94ae-4a02789ae...@googlegroups.com... > > == > > > > I wrote once 90 % of Python 2 apps (a generic term) supposed to > > process text, strings are not working. > > > > In Python 3, that's 100

Re: Help with changes in traceback stack from Python 2.7 to Python 3.x

2014-04-26 Thread Ian Kelly
On Apr 26, 2014 8:12 AM, "Ned Batchelder" wrote: > Looking at your code, I see: > > > tplArgs = map(None, lstVarNames, args) > > I didn't realize map accepted a callable of None (TIL!), but it no longer does in Python 3. You'll have to do this a different way. The Python 3 replacement for ma

Re: Off-topic circumnavigating the earth in a mile or less [was Re: Significant digits in a float?]

2014-04-30 Thread Ian Kelly
On Wed, Apr 30, 2014 at 7:14 AM, Ethan Furman wrote: > On 04/29/2014 03:51 PM, Chris Angelico wrote: >> >> On Wed, Apr 30, 2014 at 8:42 AM, emile wrote: >>> >>> On 04/29/2014 01:16 PM, Adam Funk wrote: >>> "A man pitches his tent, walks 1 km south, walks 1 km east, kills a bear, & walks

Re: Python Image Registration and Cropping?

2014-05-04 Thread Ian Kelly
On Sun, May 4, 2014 at 7:24 AM, Dave Angel wrote: > mikejohnrya...@gmail.com Wrote in message: >> Hello, >> >> Is there a Python tool or function that can register two images together >> (line them up visually), and then crop them to the common overlap area? I'm >> assuming this can probably be

Re: Why has __new__ been implemented as a static method?

2014-05-04 Thread Ian Kelly
On Sun, May 4, 2014 at 8:16 AM, Steven D'Aprano wrote: > On Sun, 04 May 2014 20:03:35 +1200, Gregory Ewing wrote: > >> Steven D'Aprano wrote: >>> If it were a class method, you would call it by MyBaseClass.__new__() >>> rather than explicitly providing the cls argument. >> >> But that wouldn't be

Re: Add "Received:" header to email msg in correct position?

2014-05-07 Thread Ian Kelly
On May 7, 2014 9:13 AM, "Chris Angelico" wrote: > > On Thu, May 8, 2014 at 1:06 AM, Burak Arslan wrote: > > Seeing how discussion is still going on about this, I'd like to state > > once more what I said above in other words: You just need to do this: > > > > "Received: blah\r\n" + message.to_str

Re: data: protocol

2014-05-07 Thread Ian Kelly
On Wed, May 7, 2014 at 4:42 AM, Robin Becker wrote: > I have an outstanding request for ReportLab to allow images to be opened > using the data: scheme. That used to be supported in python 2.7 using > urllib, but in python 3.3 urllib2 --> urllib and at least the default > urlopener doesn't support

Re: Python under the sea and in space

2014-05-07 Thread Ian Kelly
On Tue, May 6, 2014 at 8:31 PM, Jessica McKellar wrote: > Hi folks, > > I'm trying to determine the greatest depth (in the ocean or underground) and > highest altitude at which Python code has been executed. > > Please note that I'm interested in where the code was executed, and not, > say, where

Re: data: protocol

2014-05-08 Thread Ian Kelly
On Thu, May 8, 2014 at 4:34 AM, Robin Becker wrote: > Since urllib doesn't always work as expected in 3.3 I've had to write a > small stub for the special data: case. Doing all the splitting off of the > headers seems harder than just doing the special case. > > However, there are a lot of these '

Re: Real-world use of concurrent.futures

2014-05-08 Thread Ian Kelly
On May 8, 2014 12:57 PM, "Andrew McLean" wrote: > So far so good. However, I thought this would be an opportunity to > explore concurrent.futures and to see whether it offered any benefits > over the more explicit approach discussed above. The problem I am having > is that all the discussions I ca

Re: how to create an external string when binding C to Python?

2014-05-08 Thread Ian Kelly
On Thu, May 8, 2014 at 5:10 PM, Simon wrote: > I'd like to make a C memory buffer available inside Python via the Python > C/API without copying that memory into Python. How to do this? I've read [1] > but it's not clear that this functionality exists. In javascript it's > possible using String

Re: trailing underscores naming convention_

2014-05-08 Thread Ian Kelly
On Thu, May 8, 2014 at 9:28 PM, Metallicow wrote: > I seem to be comfortable with all the information out around the net dealing > with python naming conventions. Occasionally I have to remind myself on some > of this stuff. The PEP8 does a good job for most of it, but I am having a bit > of troub

Re: Python Internet Database

2014-05-09 Thread Ian Kelly
On Fri, May 9, 2014 at 2:45 PM, wrote: > I am writing a PhD thesis comparing computer languages, and Python and Ruby > is among the languages I am working with. I am using the Rasch Model to > measure latent traits and like productivity, expressivity, referential > transparency and efficiency

Re: Python Internet Database

2014-05-09 Thread Ian Kelly
On Fri, May 9, 2014 at 2:45 PM, wrote: > 1 - Internet servers. In Lisp, one has hunchentoot. In Racket, one has the > Racket Web Framework. Bigloo has hiphop. twisted, tornado, Django, pylons, turbogears, bottle, flask among many others. > 2 - Jit compiler for using from a web server. I mean,

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

2014-05-11 Thread Ian Kelly
On Sun, May 11, 2014 at 5:19 PM, Simon Evans wrote: > Yeah well at no point does the book say to start inputting the code mentioned > in Python command prompt rather than the Windows command prompt, but thank > you for your guidance anyway. > I have downloaded the latest version of Beautiful Sou

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

2014-05-11 Thread Ian Kelly
On Sun, May 11, 2014 at 5:47 PM, Ian Kelly wrote: > Also, use Python 3.4 as Terry Reedy suggested, unless the book is > using 2.7 in which case you should probably use the same version as > the book. Following up on that, if this is the book you are using: http://www.amazon.com/Gettin

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

2014-05-12 Thread Ian Kelly
On Mon, May 12, 2014 at 11:47 AM, alister wrote: > On Mon, 12 May 2014 16:19:17 +0100, Mark Lawrence wrote: > >> This was *NOT* written by our resident unicode expert >> http://lucumr.pocoo.org/2014/5/12/everything-about-unicode/ >> >> Posted as I thought it would make a rather pleasant change fro

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

2014-05-12 Thread Ian Kelly
On Mon, May 12, 2014 at 10:35 AM, Simon Evans wrote: > Dear Ian, > The book does recommend to use Python 2.7 (see bottom line of page 10). > The book also recommends to use Beautiful Soup 4. > You are right that in that I have placed the unzipped BS4 folder within a > folder, and I therefore remo

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

2014-05-12 Thread Ian Kelly
On Mon, May 12, 2014 at 1:42 PM, MRAB wrote: > How about checking sys.stdin.mode and sys.stdout.mode? Seems to work, but I notice that the docs only define the mode attribute for the FileIO class, which sys.stdin and sys.stdout are not instances of. -- https://mail.python.org/mailman/listinfo/py

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

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: 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: 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: 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: 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: 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: 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: 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: '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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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 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: 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: 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: 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: 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-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 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: 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: 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: 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: 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: Lambda function Turing completeness

2013-08-01 Thread Ian Kelly
On Wed, Jul 31, 2013 at 11:55 PM, Steven D'Aprano wrote: > On Wed, 31 Jul 2013 13:53:26 +0700, Musical Notation wrote: > >> Is it possible to write a Turing-complete lambda function (which does >> not depend on named functions) in Python? > > > lambda s: eval(s) eval is a named function. -- http

Re: Oddity with 'yield' as expression - parentheses demanded

2013-08-01 Thread Ian Kelly
On Thu, Aug 1, 2013 at 12:25 AM, Chris Angelico wrote: > Was playing around with yield inside a lambda and ran into a distinct oddity. > > Python 3.3.0 (v3.3.0:bd8afb90ebf2, Sep 29 2012, 10:55:48) [MSC v.1600 > 32 bit (Intel)] on win32 foo=lambda x: yield(x) > SyntaxError: invalid syntax

Re: Best practice for connections and cursors

2013-08-01 Thread Ian Kelly
On Thu, Aug 1, 2013 at 6:49 PM, Dennis Lee Bieber wrote: > On Thu, 1 Aug 2013 15:05:08 +, "Joseph L. Casale" > declaimed the following: > >> >>As the module opens a connection, wherever I import it I call a commit against >>the connection after invoking any methods that insert or change data.

Re: __iadd__ for a subclass of array - howto

2013-08-05 Thread Ian Kelly
On Mon, Aug 5, 2013 at 1:34 AM, Helmut Jarausch wrote: > Hi, > > I'd like to subclass array.array and implement operators like __iadd__ > How can this be accomplished. > > I'tried > > from array import array > > class Vec(array) : > def __new__(cls,Vinit) : > return array.__new__(cls,'d',Vin

Re: Bug? ( () == [] ) != ( ().__eq__([]) )

2013-08-05 Thread Ian Kelly
On Mon, Aug 5, 2013 at 8:58 AM, Markus Rother wrote: > Thanks for the good explanation. > > My intention was to pass a custom method/function as a comparator > to an object. My misconception was, that __eq__ is equivalent to > the '==' operator, and could be passed as a first class function. > Ap

Re: Newbie: static typing?

2013-08-05 Thread Ian Kelly
On Mon, Aug 5, 2013 at 2:46 PM, Rui Maciel wrote: > Is there any pythonic way to perform static typing? After searching the web > I've stumbled on a significant number of comments that appear to cover > static typing as a proof of concept , but in the process I've found no > tutorial on how to im

Enum vs OrderedEnum

2013-08-06 Thread Ian Kelly
Using the OrderedEnum recipe from the Python 3.4 docs, I have the following code: class Environment(OrderedEnum): gaia = 1 fertile = 2 terran, jungle, ocean, arid, steppe, desert, minimal = range(3, 10) barren, tundra, dead, inferno, toxic, radiated = range(10, 16) def is_st

<    17   18   19   20   21   22   23   24   25   26   >