Re: Trouble with Multi-threading

2013-12-11 Thread Roy Smith
In article <52a84061$0$29992$c3e8da3$54964...@news.astraweb.com>, Steven D'Aprano wrote: > When did this forum become so intolerant of even the tiniest, most minor > breaches of old-school tech etiquette? Have we really got nothing better > to do than to go on the war path over such trivial is

Re: Experiences/guidance on teaching Python as a first programming language

2013-12-11 Thread Roy Smith
In article , Larry Martell wrote: > On Wed, Dec 11, 2013 at 8:42 PM, Roy Smith wrote: > > In article , > > rusi wrote: > > > >> Kernighan and Ritchie set an important "first" in our field by making > >> "Hello World" their first p

Re: Strange crashes

2013-12-11 Thread Roy Smith
In article , Chris Angelico wrote: > On Thu, Dec 12, 2013 at 4:25 PM, Igor Korot wrote: > > ProgrammingError: SQLite objects created in a thread can only be used > > in that same thread.The object was created in thread id 14260 and this > > is thread id 9264 > > > > Where should I start looking

Re: min max from tuples in list

2013-12-12 Thread Roy Smith
In article <52a9a1a0$0$29992$c3e8da3$54964...@news.astraweb.com>, Steven D'Aprano wrote: > I'm afraid I don't know what you mean by "performant". I've heard the term used often. It means something like, "performs well" or "runs fast". It may or may not be an English word, but that doesn't s

Re: Is it possible to mix python with php?

2013-12-13 Thread Roy Smith
In article , JL wrote: > Python is my favorite language. Very often, I am forced to use other > languages like php because of better library support for web applications. Is > it possible to write functions in python and then get php to call these > functions? At one time, Songza was half PH

Re: collections Counter most_common method

2013-12-14 Thread Roy Smith
In article , Mark Lawrence wrote: > This method returns a list, the example from The Fine Docs being:- > > >>> Counter('abracadabra').most_common(3) > [('a', 5), ('r', 2), ('b', 2)] > > With the trend in Python being more and more towards methods returning > iterators, is there ever likely t

Re: [newbie] trying socket as a replacement for nc

2013-12-15 Thread Roy Smith
In article , Grant Edwards wrote: > UDP is a a _datagram_ service. Either all the bytes in a write() > should get sent or none of them. Sending a paritial datagram is _not_ > a valid option. I would agree with the above if you said send() instead of write(). Python socket objects don't have

Re: [newbie] trying socket as a replacement for nc

2013-12-15 Thread Roy Smith
In article , Chris Angelico wrote: > On Mon, Dec 16, 2013 at 2:51 AM, Roy Smith wrote: > > In article , > > Grant Edwards wrote: > > > >> UDP is a a _datagram_ service. Either all the bytes in a write() > >> should get sent or none of them. Sending a

Re: Comparing values of counter in python 3.3

2013-12-15 Thread Roy Smith
In article <905d6e7e-6748-42dd-8b63-d80a4d175...@googlegroups.com>, rusi wrote: > On Monday, December 16, 2013 7:29:31 AM UTC+5:30, alex23 wrote: > > > # Need to compare values of counter and reject in function/routine in > > > value in counter2 is higher then value in counter1 for a current ke

Re: [newbie] trying socket as a replacement for nc

2013-12-16 Thread Roy Smith
On Friday, December 13, 2013 5:58:49 AM UTC+8, Chris Angelico wrote: > > Now, if you want reliability AND datagrams, it's a lot easier to add > > boundaries to a TCP stream (sentinel or length prefixes) than to add > > reliability to UDP... In article <11cb8cd3-7a12-46b2-abc6-53fbc2a54...@googlegr

Re: Experiences/guidance on teaching Python as a first programming language

2013-12-16 Thread Roy Smith
In article , Rick Johnson wrote: > Dovetails are nothing more than sadistic nostalgia -- > they give old men a "chubby" and young men a nightmare. There is nothing more satisfying than cutting a set of dovetails by hand and having them glide together like silk, the first time you test-fit

Re: Experiences/guidance on teaching Python as a first programming language

2013-12-17 Thread Roy Smith
In article , Neil Cerutti wrote: > On 2013-12-17, Steven D'Aprano > wrote: > > I would really like to see good quality statistics about bugs > > per program written in different languages. I expect that, for > > all we like to make fun of COBOL, it probably has few bugs per > > unit-of-useful-w

Re: Experiences/guidance on teaching Python as a first programming language

2013-12-17 Thread Roy Smith
In article <20131217165144.39bf9ba1cd4e4f27a9689...@gmx.net>, Wolfgang Keller wrote: > C is just a kafkaesque mess invented by a sadistic pervert who must > have regularly consumed illegal substances for breakfast. Don't be absurd. C is a perfectly good language for the kinds of things it's

Re: Experiences/guidance on teaching Python as a first programming language

2013-12-17 Thread Roy Smith
In article , Grant Edwards wrote: > Ideally, you should also have written at least one functioning > compiler before learning C as well. Why? I've never written a compiler. I've written plenty of C. I don't see how my lack of compiler writing experience has hindered my ability to write C.

Re: Logger module in python

2013-12-17 Thread Roy Smith
In article , smilesonisa...@gmail.com wrote: > Hi, > I am a newbie in python. I am looking for a existing module which I can > import in my program to log the objects to a file? > > I know there is a module Data::Dumper in perl which dumps the objects to > file. But not sure about python.

Re: C langauge recvmmsg() function in Python

2013-12-18 Thread Roy Smith
In article <11b3f519-e0d6-40c3-a73d-aa673b225...@googlegroups.com>, justhots...@gmail.com wrote: > Hi All, > > Is there a C langauge recvmmsg() function (receive multiple messages on a > socket) equivalent in python? > recvmmsg details url: http://man7.org/linux/man-pages/man2/recvmmsg.2.html

Re: Experiences/guidance on teaching Python as a first programming language

2013-12-18 Thread Roy Smith
In article , Grant Edwards wrote: > On 2013-12-18, Roy Smith wrote: > > In article , > > Grant Edwards wrote: > > > >> Ideally, you should also have written at least one functioning > >> compiler before learning C as well. > > > > Why? I&#

Re: Experiences/guidance on teaching Python as a first programming language

2013-12-18 Thread Roy Smith
In article , Mark Lawrence wrote: > I've never contemplated writing a compiler, let alone actually written > one. It's like the comments along the lines of "you can't call yourself > a programmer until you've mastered regular expressions". Who makes comments like that? As far as I can tell,

Re: Experiences/guidance on teaching Python as a first programming language

2013-12-18 Thread Roy Smith
In article , Grant Edwards wrote: > On 2013-12-18, Chris Angelico wrote: > > > Well, okay. In C you can't have Foo.foo(). > > If "Foo" is a structure with a field named "foo" that is a pointer to > a function, then you can indeed "have" Foo.foo(). Sigh. This has gone off in a direction I ne

Re: Experiences/guidance on teaching Python as a first programming language

2013-12-18 Thread Roy Smith
In article <07c6e6a3-c5f4-4846-9551-434bdaba8...@googlegroups.com>, rusi wrote: > Soon the foo has to split into foo1.c and foo2.c. And suddenly you need to > understand: > > 1. Separate compilation > 2. Make (which is separate from 'separate compilation') > 3. Header files and libraries and t

Re: Experiences/guidance on teaching Python as a first programming language

2013-12-18 Thread Roy Smith
In article , Gregory Ewing wrote: > Roy Smith wrote: > > even > > if you've got all the signatures of foo() in front of you, it can > > sometimes be hard to figure out which one the compiler will pick. > > And conversely, sometimes the compiler will have a ha

Use of Python for teaching geometry.

2013-12-19 Thread Roy Smith
https://www.facebook.com/photo.php?fbid=688904791141196&set=a.46529938016 8406.10.465298390168505&type=1&theater Shortened version: http://tinyurl.com/kvtcye9 -- https://mail.python.org/mailman/listinfo/python-list

Re: Experiences/guidance on teaching Python as a first programming language

2013-12-19 Thread Roy Smith
In article <52b365b6$0$6512$c3e8da3$54964...@news.astraweb.com>, Steven D'Aprano wrote: [some stuff] > where Unix went, so did C; [some more stuff] What he said. -- https://mail.python.org/mailman/listinfo/python-list

Re: Experiences/guidance on teaching Python as a first programming language

2013-12-19 Thread Roy Smith
In article <52b328f7$0$6512$c3e8da3$54964...@news.astraweb.com>, Steven D'Aprano wrote: > Correct. The *great deal of trouble* part is important. Things which are > the responsibility of the language and compiler in (say) Java, D, Rust, > Go, etc. are the responsibility of the programmer with

Why Python is like C++

2013-12-20 Thread Roy Smith
http://xkcd.com/1306/ -- https://mail.python.org/mailman/listinfo/python-list

Re: Why Python is like C++

2013-12-21 Thread Roy Smith
In article , Dan Stromberg wrote: > On Fri, Dec 20, 2013 at 9:34 PM, Mark Lawrence > wrote: > > On 20/12/2013 14:19, Roy Smith wrote: > >> > >> http://xkcd.com/1306/ > >> > > > > I believe that to be a very superficial like. They're unl

Re: Why Python is like C++

2013-12-21 Thread Roy Smith
In article , Tim Chase wrote: > In know that my first BASIC, Applesoft BASIC had the 2-character > names, and you had to load Integer Basic (with Ints in addition to the > standard Floats used in the BASIC provided by the ROM, a strange > choice). Why is it a strange choice? If you're only goi

Re: Why Python is like C++

2013-12-21 Thread Roy Smith
In article , Terry Reedy wrote: > On 12/21/2013 10:10 AM, Roy Smith wrote: > > > On the last large C++ project I worked on, we decided (i.e. obeyed a > > corporate mandate) to start using Coverity's static analysis tool on our > > 15 year old codebase. I lear

Re: cascading python executions only if return code is 0

2013-12-22 Thread Roy Smith
In article , Frank Cui wrote: > hey guys, > I have a requirement where I need to sequentially execute a bunch of > executions, each execution has a return code. the followed executions should > only be executed if the return code is 0. is there a cleaner or more pythonic > way to do this othe

Re: cascading python executions only if return code is 0

2013-12-22 Thread Roy Smith
In article , Mark Lawrence wrote: > On 22/12/2013 19:17, Roy Smith wrote: > > In article , > > Frank Cui wrote: > > > >> hey guys, > >> I have a requirement where I need to sequentially execute a bunch of > >> executions, each execution has a r

Re: cascading python executions only if return code is 0

2013-12-22 Thread Roy Smith
In article , Cameron Simpson wrote: > Roy's code _depends_ upon the return value being equivalent to False. Yes. You view this as a flaw. I view it as a feature :-) > A better approach would be: > > a() == 0 and b() == 1 and c() == 0 > > i.e. to explicitly check each return code against

Re: cascading python executions only if return code is 0

2013-12-22 Thread Roy Smith
In article <52b782db$0$6599$c3e8da3$54964...@news.astraweb.com>, Steven D'Aprano wrote: > Code that relies on side-effects is usually a sign of poor > design. I don't understand what you're trying to say there. A bit later in your post, you wrote: try: a() b() c() except SomeErr

Re: testing

2013-12-22 Thread Roy Smith
In article <52b788bb$0$6599$c3e8da3$54964...@news.astraweb.com>, Steven D'Aprano wrote: > Is this thing still working? Yes. Do you want to know how many times your previous message was posted? :-) -- https://mail.python.org/mailman/listinfo/python-list

Re: cascading python executions only if return code is 0

2013-12-22 Thread Roy Smith
In article <52b7a0e4$0$29994$c3e8da3$54964...@news.astraweb.com>, Steven D'Aprano wrote: > Anyway, I may be completely misinterpreting what I'm reading. Perhaps the > assertion is checking a function invariant ("one of the strategies will > always succeed") in which case you're doing it exactly

Re: cascading python executions only if return code is 0

2013-12-23 Thread Roy Smith
In article , Ethan Furman wrote: > On 12/22/2013 08:57 PM, Roy Smith wrote: > > In article <52b7a0e4$0$29994$c3e8da3$54964...@news.astraweb.com>, > > Steven D'Aprano wrote: > > > >> Anyway, I may be completely misinterpreting what I'm rea

Re: cascading python executions only if return code is 0

2013-12-23 Thread Roy Smith
On Monday, December 23, 2013 12:05:22 PM UTC-5, Steven D'Aprano wrote: > Roy Smith wrote: > > And, yes, I know that assertions get turned off with -O (frankly, I > > think that's a design flaw).  We don't run with -O. > > > Until such time as somebody d

Re: cascading python executions only if return code is 0

2013-12-23 Thread Roy Smith
In article <52b90263$0$30003$c3e8da3$54964...@news.astraweb.com>, Steven D'Aprano wrote: > Roy Smith wrote: > > > So, here's the deeper question.  Is your issue strictly that -O elides > > assert statements? That's a purely mechanical issue that could

nosetests vs. relative imports?

2013-12-24 Thread Roy Smith
Environment: Ubuntu Linux 12.04 (precise) Python 2.7.3 I have a package (i.e. a directory with a __init__.py file). In that directory, I have files math.py and test_math.py; test_math.py contains the single line: from .math import EMA If I run on the command line, "nosetests test_math.py" eve

Re: [OT]Royal pardon for codebreaker Turing

2013-12-25 Thread Roy Smith
In article <52bb64d7$0$29973$c3e8da3$54964...@news.astraweb.com>, Steven D'Aprano wrote: > Tim Johnson wrote: > > > I'm not sure if you have a cause or if you want an argument. > > I thought we were having a conversation. > > Not every exchange of messages on the internet is best understood a

Re: need to print seconds from the epoch including the millisecond

2013-12-26 Thread Roy Smith
In article <59aa73ac-e06e-4c0e-83a4-147ac42ca...@googlegroups.com>, matt.doolittl...@gmail.com wrote: > > In [1]: import time > > In [2]: time.time() > > Out[2]: 1388085670.1567955 > > OK i did what you said but I am only getting 2 decimal places. > Why is this and what can I do to get the mil

Re: cascading python executions only if return code is 0

2013-12-26 Thread Roy Smith
In article , Ethan Furman wrote: > Mostly I don't want newbies thinking "Hey! I can use assertions for all my > confidence testing!" How about this one, that I wrote yesterday; assert second >= self.current_second, "time went backwards" I think that's pretty high up on the "can neve

Re: cascading python executions only if return code is 0

2013-12-26 Thread Roy Smith
In article , Chris Angelico wrote: > On Fri, Dec 27, 2013 at 1:20 PM, Dennis Lee Bieber > wrote: > > On Fri, 27 Dec 2013 12:44:35 +1100, Chris Angelico > > declaimed the following: > > > >>On Fri, Dec 27, 2013 at 12:37 PM, Roy Smith wrote: > >>&g

Re: So, what's the real story on Python 2 vs Python 3?

2013-12-26 Thread Roy Smith
In article , Travis McGee wrote: > The Python.org site says that the future is Python 3, yet whenever I try > something new in Python, such as Tkinter which I am learning now, > everything seems to default to Python 2. By this I mean that, whenever I > find that I need to install another pack

Re: cascading python executions only if return code is 0

2013-12-26 Thread Roy Smith
In article <52bd049d$0$29992$c3e8da3$54964...@news.astraweb.com>, Steven D'Aprano wrote: > Roy Smith wrote: > > > In article , > > Ethan Furman wrote: > > > >> Mostly I don't want newbies thinking "Hey! I can use assertions for all &g

Re: cascading python executions only if return code is 0

2013-12-26 Thread Roy Smith
In article , Chris Angelico wrote: > On Fri, Dec 27, 2013 at 4:05 PM, Roy Smith wrote: > > There's lists like that for names and genders too. As in, what do you > > mean there are people who don't have exactly two names and one gender? > > And addresses, too.

Re: Brython (Python in the browser)

2013-12-27 Thread Roy Smith
In article <234a1a8d-e491-4eec-8bd5-7931cf4f7...@googlegroups.com>, Pierre Quentel wrote: > Hi, > > Ever wanted to use Python instead of Javascript for web client programming ? > Take a look at Brython, an implementation of Python 3 in the browser, with an > interface with DOM elements and ev

Re: need to print seconds from the epoch including the millisecond

2013-12-27 Thread Roy Smith
In article <0c33b7e4-edc9-4e1e-b919-fec210c92...@googlegroups.com>, matt.doolittl...@gmail.com wrote: > I am on Ubuntu 12.10. I am still working with the 2 decimal places. > Sometime ago i had this issue and I forget how i solved it. maybe i used > datetime? thanks! That's strange. Linux

Re: cascading python executions only if return code is 0

2013-12-27 Thread Roy Smith
In article , Dennis Lee Bieber wrote: > On Thu, 26 Dec 2013 23:29:30 -0500, Roy Smith declaimed the > following: > > > > >NTP is never supposed to move the clock backwards. If your system clock > >is fast, it's supposed to reduce the rate your clock runs un

Re: need to print seconds from the epoch including the millisecond

2013-12-27 Thread Roy Smith
In article <1db0d993-9d2d-46af-9ee8-69d9250dc...@googlegroups.com>, matt.doolittl...@gmail.com wrote: > > Please post the *exact* code you're running. The code you posted > > earlier is obviously only a fragment of some larger program, so we can > > only guess what's happening. Assuming your

Re: need to print seconds from the epoch including the millisecond

2013-12-27 Thread Roy Smith
In article , Roy Smith wrote: > self.logfile.write("str=%s, repr=%s", (str(t), repr(t))) Ugh, make that: > self.logfile.write("str=%s, repr=%s" % ((str(t), repr(t))) -- https://mail.python.org/mailman/listinfo/python-list

Re: need to print seconds from the epoch including the millisecond

2013-12-27 Thread Roy Smith
matt.doolittl...@gmail.com wrote: > I need to print the time in seconds from the epoch with > millisecond precision. I wrote: > What happens if you do: > > t = time.time() > self.logfile.write("str=%s, repr=%s", (str(t), repr(t))) At the time I originally posted that, I was baffled as to wha

Re: Unit tests and coverage

2013-12-28 Thread Roy Smith
In article , "Joseph L. Casale" wrote: > I have a script that accepts cmdline arguments and receives input via stdin. > I have a unit test for it that uses Popen to setup an environment, pass the > args and provide the stdin. > > Problem is obviously this does nothing for providing coverage. G

Re: need to print seconds from the epoch including the millisecond

2013-12-30 Thread Roy Smith
In article , Ned Batchelder wrote: > A float's str() includes two decimal points of precision It's actually weirder than that. What str() appears to do is print some variable number of digits after the decimal place, depending on the magnitude of the number, and then flips over to exponentia

Re: PyDev 3.2.0 Released

2013-12-30 Thread Roy Smith
On Monday, December 30, 2013 8:16:03 AM UTC-5, Fabio Zadrozny wrote: > [lots of stuff] > What is PyDev? > --- > > PyDev is a plugin that enables users to use Eclipse for Python... A suggestion for announcements of this type. Put the "What is X" part up front, so people c

Re: Python 2.x and 3.x usage survey

2013-12-31 Thread Roy Smith
In article <52c29782$0$29979$c3e8da3$54964...@news.astraweb.com>, Steven D'Aprano wrote: > Mark Lawrence wrote: > > > On 30/12/2013 21:56, Dan Stromberg wrote: > >> I keep hearing naysayers, nay saying about Python 3.x. > >> > >> Here's a 9 question, multiple choice survey I put together about

Re: Blog "about python 3"

2013-12-31 Thread Roy Smith
In article , Antoine Pitrou wrote: > Steven D'Aprano pearwood.info> writes: > > > > I expect that as excuses for not migrating get fewer, and the deadline for > > Python 2.7 end-of-life starts to loom closer, more and more haters^W > > Concerned People will whine about the lack of version 2.8

What does --no-skip do in nose?

2013-12-31 Thread Roy Smith
Environment: Python 2.7.3 nose 1.3.0 Ubuntu 12.04 Linux I'm befuddled about how test skipping, and in particular, --no-skip, is supposed to work in nose. I've got a trivial test file: > from nose import SkipTest > def test_skip(): > raise SkipTest > assert 0 If I run this, it skip

Re: Suggest an open-source log analyser?

2014-01-01 Thread Roy Smith
In article , Alec Taylor wrote: > I use the Python logger class; with the example syntax of: > Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s') > > Can of course easily use e.g.: a JSON syntax here instead. > > Are there any open-source log viewers (e.g.: with a web-interf

Score one for unit testing.

2014-01-02 Thread Roy Smith
We've got a test that's been running fine ever since it was written a month or so ago. Now, it's failing intermittently on our CI (continuous integration) box, so I took a look. It turns out it's a stupid test because it depends on pre-existing data in the database. But, the win is that while

Re: Ifs and assignments

2014-01-02 Thread Roy Smith
In article , John Allsup wrote: > if testFunc() as x: > do something with x +1 The most common place I wish for an atomic "test and assign" is with regexes, as in your examples. This would be so much nicer than what we have to do now: if re.match(string) as m: print m.g

Re: Ifs and assignments

2014-01-02 Thread Roy Smith
In article , Chris Angelico wrote: > On Fri, Jan 3, 2014 at 2:33 PM, Steven D'Aprano > wrote: > > Personally, I find it hard to care about assignment as an expression. I find > > the obvious C-inspired syntax terrible, as it is too easy to mistakenly use > > == instead of = or visa versa: > >

Re: Ifs and assignments

2014-01-02 Thread Roy Smith
In article , Chris Angelico wrote: > while (var = func()) > { > > } > > In Python, that gets a lot clunkier. The most popular way is to turn > it into an infinite loop: > > while True: > var = func() > if not var: break > Or turn it into a generator: def funcinator(

Re: How to read and post tracebacks (was Registry Key Value Help)

2014-01-02 Thread Roy Smith
In article , Chris Angelico wrote: > On Fri, Jan 3, 2014 at 2:58 PM, Rustom Mody wrote: > > Why not write up a few lines on "How to read and post python tracebacks" > > and post it on the wiki? > > You mean "copy and paste the whole output"? I'm not sure what more > needs to be said about post

Re: Blog "about python 3"

2014-01-03 Thread Roy Smith
In article , Robin Becker wrote: > On 03/01/2014 09:01, Terry Reedy wrote: > > There was more speedup in 3.3.2 and possibly even more in 3.3.3, so OP > > should run the latter. > > python 3.3.3 is what I use on windows. As for astral / non-bmp etc etc that's > almost irrelevant for the sort of

Re: Creating a list with holes

2014-01-03 Thread Roy Smith
In article , Larry Martell wrote: > I think I know the answer is no, but is there any package that allows > creating a list with holes in it? E.g. I'd want to do something like: > > x[10] = 12 > x[20] = 30 Whenever you ask, "What data structure do I want", you need to be able to answer, "What

Re: Creating a list with holes

2014-01-03 Thread Roy Smith
In article , Chris Angelico wrote: > Alternatively, if you expect to fill in most of the elements, it's > possible you'd be happier working with a subclass of list that > auto-expands by filling in the spare space with a singleton meaning > "no element here". And, if you know ahead of time the

Re: Is Python really "Lisp without parentheses"? So would it be easy to *implement* a lot of Python in Scheme/Lisp?

2014-01-03 Thread Roy Smith
In article , Devin Jeanpierre wrote: > // C++ > Foo x = y; > x.bar = 3; > > // Java > Foo x = y; > x.bar = 3; > > // Scheme > (define x y) > (foo-bar x 3) > > The syntax of the first two is identical, so the uneducated would > assume they do the same thing. This is one of the things that tr

Re: Creating a list with holes

2014-01-03 Thread Roy Smith
In article , Larry Martell wrote: > > Thanks, but I know all that about dicts. I need to use a list for > compatibility with existing code. Generalizing what I think the situation is, "A dict is the best data structure for the parsing phase, but I need a list later to hand off to legacy inte

Re: Blog "about python 3"

2014-01-04 Thread Roy Smith
In article , Mark Lawrence wrote: > Surely everybody prefers fast but incorrect code in > preference to something that is correct but slow? I realize I'm taking this statement out of context, but yes, sometimes fast is more important than correct. Sometimes the other way around. -- https://

Re: Blog "about python 3"

2014-01-04 Thread Roy Smith
I wrote: > > I realize I'm taking this statement out of context, but yes, sometimes > > fast is more important than correct. In article <52c8c301$0$29998$c3e8da3$54964...@news.astraweb.com>, Steven D'Aprano wrote: > Fast is never more important than correct. Sure it is. Let's imagine you're b

Re: Blog "about python 3"

2014-01-04 Thread Roy Smith
In article , Rustom Mody wrote: > On Sun, Jan 5, 2014 at 8:50 AM, Roy Smith wrote: > > I wrote: > >> > I realize I'm taking this statement out of context, but yes, sometimes > >> > fast is more important than correct. > > > > In article &l

Re: Blog "about python 3"

2014-01-05 Thread Roy Smith
In article <52c94fec$0$29973$c3e8da3$54964...@news.astraweb.com>, Steven D'Aprano wrote: > How do we tell when software is buggy? We compare what it actually does to > the promised behaviour, or expected behaviour, and if there is a > discrepancy, we call it a bug. We don't compare it to some id

Re: Blog "about python 3"

2014-01-05 Thread Roy Smith
In article , Chris Angelico wrote: > On Sun, Jan 5, 2014 at 2:20 PM, Roy Smith wrote: > > I've got a new sorting algorithm which is guaranteed to cut 10 seconds > > off the sorting time (i.e. $0.10 per package). The problem is, it makes > > a mistake 1% of the time

Re: Blog "about python 3"

2014-01-05 Thread Roy Smith
Chris Angelico wrote: > Can you really run a business by not caring about your customers? http://snltranscripts.jt.org/76/76aphonecompany.phtml -- https://mail.python.org/mailman/listinfo/python-list

Re: gotta love radio buttons

2014-01-05 Thread Roy Smith
In article <8dca57e8-8258-4020-9788-987af332b...@googlegroups.com>, eneskri...@gmail.com wrote: I don't use tkinter, but here's what I can figure out from looking at your code and http://effbot.org/tkinterbook/variable.htm > var = [] > while i < self.something: > var.append(IntVar()) >

Re: Postfix conditionals

2014-01-05 Thread Roy Smith
In article , Göktu€ Kayaalp wrote: >py> for i in [False]: >... break if not i Python is not Perl. -- https://mail.python.org/mailman/listinfo/python-list

Re: django question

2014-01-05 Thread Roy Smith
In article , Tim Chase wrote: > Integration is one of the things that Django does particularly well: > out of the box, you get a web framework, database abstraction (ORM), > templating, out-of-the-box functionality, and PHENOMENAL > documentation. The others just bring the web-framework to the t

Re: "More About Unicode in Python 2 and 3"

2014-01-05 Thread Roy Smith
In article , Chris Angelico wrote: > One time I implemented Oauth manually rather than using a library Me too. You have my sympathy. What a mess. -- https://mail.python.org/mailman/listinfo/python-list

Re: "More About Unicode in Python 2 and 3"

2014-01-05 Thread Roy Smith
In article , Mark Janssen wrote: > I honestly think Python3 will have to be regressed despite all the > [obscenity elided] about how "everyone's moving to Python 3 now". This forum has seen a lot honest disagreement about issues, sometimes hotly debated. That's OK. Sometimes the discussion

Re: "More About Unicode in Python 2 and 3"

2014-01-05 Thread Roy Smith
In article , Chris Angelico wrote: > It can't be both things. It's either bytes or it's text. I've never used Python 3, so forgive me if these are naive questions. Let's say you had an input stream which contained the following hex values: $ hexdump data 000 d7 a8 a3 88 96 95 That's E

Re: "More About Unicode in Python 2 and 3"

2014-01-05 Thread Roy Smith
In article , Tim Chase wrote: > On 2014-01-05 23:24, Roy Smith wrote: > > $ hexdump data > > 000 d7 a8 a3 88 96 95 > > > > That's EBCDIC for "Python". What would I write in Python 3 to read > > that file and print it back out as utf-8 en

Re: django question

2014-01-06 Thread Roy Smith
In article , CM wrote: > On Sunday, January 5, 2014 4:50:55 PM UTC-5, Roy Smith wrote: > > > One of the things we try to do is put as little in the views as > > possible. Views should be all about accepting and validating request > > parameters, and generating

Re: the Gravity of Python 2

2014-01-08 Thread Roy Smith
As somebody who is still firmly in the 2.x world, I'm worried about the idea of a 2.x fork. While I have my doubts that 3.x was a good idea, the fact is, it's here. Having the community fractured between the two camps is not good. Let's say I'm somebody who wants to contribute some OSS. I h

Recover handle to shadowed builtin?

2014-01-08 Thread Roy Smith
I'm working with ipython's pylab mode, which replaces the builtin sum() with the one from numpy: In [105]: sum Out[105]: Is there any way to recover a reference to the builtin sum()? --- Roy Smith r...@panix.com -- https://mail.python.org/mailman/listinfo/python-list

Re: Recover handle to shadowed builtin?

2014-01-08 Thread Roy Smith
In article , Roy Smith wrote: >I'm working with ipython's pylab mode, which replaces the builtin sum() = >with the one from numpy: >[...] >Is there any way to recover a reference to the builtin sum()? Sigh. I figured this out myself. What you want is __builtins__.sum .

Re: the Gravity of Python 2

2014-01-08 Thread Roy Smith
In article , Kevin Walzer wrote: > I haven't updated my Python apps to 3.x because there's nothing in 3.x > that offers benefits to my users. I almost found a reason to move to Python 3 today. Then I got smacked. I had a datetime. I needed a unix timestamp. People need to go back and fort

Re: the Gravity of Python 2

2014-01-08 Thread Roy Smith
In article , Chris Angelico wrote: > Why not simply use a UTC datetime instead of a naive one? [Pet peeve of mine: uses of "simple" or "just" to imply that something is easy, when it's not. "Why not just get the Arabs and the Jews to be friends?" "Why not simply find a safe way to store nuc

Re: the Gravity of Python 2

2014-01-08 Thread Roy Smith
In article , Chris Angelico wrote: > On Thu, Jan 9, 2014 at 1:25 PM, Roy Smith wrote: > > Because it's easy to get a naive one. You call datetime.utcnow(). If > > utcnow() returned an aware datetime, that's probably what we would be > > using. Why didn&

Re: the Gravity of Python 2

2014-01-08 Thread Roy Smith
In article , Ben Finney wrote: > Chris Angelico writes: > > > On Thu, Jan 9, 2014 at 1:25 PM, Roy Smith wrote: > > > Because it's easy to get a naive one. You call datetime.utcnow(). If > > > utcnow() returned an aware datetime, that's probably what we

Re: the Gravity of Python 2

2014-01-08 Thread Roy Smith
In article , Chris Angelico wrote: > On Thu, Jan 9, 2014 at 2:35 PM, Roy Smith wrote: > >> Yes, it *is* simple. It *is* easy. I've been working with pure-UTC > >> times (either called time_t, or TIMESTAMP WITH TIME ZONE, or even just > >> float) for decades.

Re: the Gravity of Python 2

2014-01-09 Thread Roy Smith
In article , Chris Angelico wrote: > What can you (Roy), with your use-case, achieve with datetime that > you can't achieve (at least reasonably easily) with a timestamp? As I'm mentioned several times, when you print a datetime, you get something that's human friendly. When you print a time

Re: the Gravity of Python 2

2014-01-09 Thread Roy Smith
In article , Chris Angelico wrote: > Actually, the nearest parallel to Unicode is probably "use UTC > everywhere", which makes for a superb internal representation and > transmission format, but bugs most human beings :) It is, by the way, the solution that the aviation industry has adopted.

Re: the Gravity of Python 2

2014-01-09 Thread Roy Smith
In article , Ben Finney wrote: > Kushal Kumaran writes: > > > Ben Finney writes: > > > > > Kushal Kumaran writes: > > > > > >> Roy Smith writes: > > >> > How, in Python, do you get an aware UTC datetime object? > >

Re: the Gravity of Python 2

2014-01-09 Thread Roy Smith
On Thursday, January 9, 2014 9:57:57 AM UTC-5, Chris Angelico wrote: > And months are more > complicated still, so it's probably easiest to use strftime: > > >>> time.strftime("%Y%m",time.gmtime(ts)) > > '201401' strftime is a non-starter at far as "easy" goes. I don't know about you, but I

Re: the Gravity of Python 2

2014-01-09 Thread Roy Smith
I wrote: > Recipes are a cop-out On Thursday, January 9, 2014 11:30:31 AM UTC-5, Mark Lawrence wrote: > So all of the itertools recipes should be part of the Python module and > not in more-itertools on pypi? Certainly, the recipes that are documented on the official itertools page, yes. -- htt

Re: the Gravity of Python 2

2014-01-09 Thread Roy Smith
On Thursday, January 9, 2014 3:35:05 PM UTC-5, Chris Angelico wrote: > In fact, I've given end users the ability to enter strftime strings (eg > to construct a filename), and it's worked just fine. I assume you realize that "../../../../../../../../../../../../../../../../etc/passwd" is a valid

Monkeypatching a staticmethod?

2014-01-09 Thread Roy Smith
This is kind of surprising. I'm running Python 2.7.1. I've got a class with a staticmethod that I want to monkeypatch with a lambda: -- class Foo: @staticmethod def x(): return 1 Foo.x = lambda: 2 print Foo.x() --

Re: Time zones and why they change so damned often (was: the Gravity of Python 2)

2014-01-10 Thread Roy Smith
In article , Peter Pearson wrote: > Around 30 years ago, the Wall Street Journal ran an opinion piece > advocating the abandonment of time zones and the unification of the > globe into a single glorious time zone. After enumerating the > efficiencies to be achieved by this system, the writer b

Re: Open Question - I'm a complete novice in programming so please bear with me...Is python equivalent to C, C++ and java combined?

2014-01-11 Thread Roy Smith
In article <18b67e59-39d1-41e2-8977-b1c449b13...@googlegroups.com>, pintreo mardi wrote: > Hi, I've just begun to learn programming, I have an open question for the > group: > Is the Python language an all in one computer language which could replace C, > C++, Java etc.. I only ask becuase I a

Re: How to get Mac address of ethernet port?

2014-01-11 Thread Roy Smith
In article , "James Harris" wrote: > "Andriy Kornatskyy" wrote in message > news:mailman.5329.1389450993.18130.python-l...@python.org... > > Sam, > > > > How about this? > > > > from uuid import getnode as get_mac > > '%012x' % get_mac() > > AIUI that will return a mac address even if there i

<    5   6   7   8   9   10   11   12   13   14   >