Re: Working with the set of real numbers

2014-02-13 Thread Chris Angelico
On Fri, Feb 14, 2014 at 5:37 PM, Gregory Ewing wrote: > Chris Angelico wrote: >> >> Even adding to your requirements that it have an ℵ₁ Hz bus (which, by >> the way, I *totally* want - the uses are endless), it would take a >> >> finite amount of time to assign to x the "next number", ergo your >>

Re: Working with the set of real numbers

2014-02-13 Thread Gregory Ewing
Chris Angelico wrote: Even adding to your requirements that it have an ℵ₁ Hz bus (which, by the way, I *totally* want - the uses are endless), it would take a finite amount of time to assign to x the "next number", ergo your algorithm can't guarantee to finish in finite time. If it's a quantum

Re: Working with the set of real numbers

2014-02-13 Thread Devin Jeanpierre
On Thu, Feb 13, 2014 at 11:47 AM, Marko Rauhamaa wrote: > Chris Angelico : > >> On Fri, Feb 14, 2014 at 1:00 AM, Marko Rauhamaa wrote: >>> Well, if your idealized, infinite, digital computer had ℵ₁ bytes of RAM >>> and ran at ℵ₁ hertz and Python supported transfinite iteration, you >>> could easi

Re: Working with the set of real numbers

2014-02-13 Thread Gregory Ewing
Dave Angel wrote: Actually, the particular example you use can be done. When printing the infinite sum of two infinite decimal streams, you can simply hold back whenever you get one or more nines. But you only have a finite amount of space for keeping track of how many nines you've seen, so

Re: singleton ... again

2014-02-13 Thread Gregory Ewing
Ethan Furman wrote: Say you have a class that represents serial ports or your computer. You should get the same object every time you ask for SerialPort(2). No, you shouldn't ask for SerialPort(2) at all, you should call get_serial_port(2). Then you won't be fooled into thinking that you're cr

Re: singleton ... again

2014-02-13 Thread Gregory Ewing
Steven D'Aprano wrote: Of course it can happen by accident. It's happened to me, where I've accidentally called NoneType() (which raises, rather than returning a new instance). Well, "unlikely to happen by accident", then. -- Greg -- https://mail.python.org/mailman/listinfo/python-list

Re: singleton ... again

2014-02-13 Thread Gregory Ewing
Steven D'Aprano wrote: On Wed, 12 Feb 2014 23:04:32 +1300, Gregory Ewing wrote: If you really want to make sure nobody creates another instance by accident, delete the class out of the namespace after instantiating it. That does not work. It is trivial to get the type from an instance: I sa

Re: better and user friendly IDE recommended?

2014-02-13 Thread Rustom Mody
On Friday, February 14, 2014 2:57:13 AM UTC+5:30, Martin Schöön wrote: > Den 2013-09-17 skrev rusi > > On Wednesday, September 11, 2013 7:44:04 PM UTC+5:30, > > mnishpsyched wrote: > >> Hey i am a programmer but new to python. Can anyone guide > >> me in knowing which is a better IDE used to dev

Problem importing libraries installed with PIP in Eclipse

2014-02-13 Thread Renato
Hi guys, I'm using Python 2.7.5 64 bits and I have a problem when importing libraries that were installed via PIP when importing them inside Eclipse (version 4.3.1). Outside Eclipse (directly in Python's shell) everything works fine, here is an example: >>> import numpy

Re: A curious bit of code...

2014-02-13 Thread Ned Batchelder
On 2/13/14 9:45 PM, forman.si...@gmail.com wrote: For the record I wasn't worried about the performance. ;-) It was for Tkinter event strings not markup tags. I'm glad this was the time winner! "key and key[0] == '<' and key[-1] == '>'" Cheers to the folks who did the timings (and saved me

Pythonwin forum?

2014-02-13 Thread John Doe
What's the best place for asking questions about the Pythonwin IDE? I'm a novice programmer, so in an effort to be more clear I'm talking about the program at this path on my hard drive... C:\Python27\Lib\site-packages\pythonwin\Pythonwin.exe It appears to be an editor and a compiler. I have

Re: A curious bit of code...

2014-02-13 Thread forman . simon
For the record I wasn't worried about the performance. ;-) It was for Tkinter event strings not markup tags. I'm glad this was the time winner! "key and key[0] == '<' and key[-1] == '>'" Cheers to the folks who did the timings (and saved me from the trouble!) Last but not least... s[::len(s

Re: How to begin

2014-02-13 Thread Ben Finney
Ryan Gonzalez writes: > Read the Python reference. I know it's long, but it saves you trouble > of accidentally reinventing the wheel. Hmm, the language reference is targeted at people *implementing* Python, not people who are learning to use it (though it is valuable for them also). It would be

Re: A curious bit of code...

2014-02-13 Thread Ethan Furman
On 02/13/2014 01:24 PM, Roy Smith wrote: Emile van Sebille wrote: But I didn't see this one: s[::len(s)-1] I love it. I need to add this to my list of Python trivia questions. Great interview question: What does this do? What is its weakness? How would you fix it? -- ~Ethan~ -- htt

Re: A curious bit of code...

2014-02-13 Thread Terry Reedy
On 2/13/2014 1:37 PM, forman.si...@gmail.com wrote: I ran across this and I thought there must be a better way of doing it, but then after further consideration I wasn't so sure. if key[:1] + key[-1:] == '<>': ... if key[:1] == '<' and key[-1:] == '>: ... is the obvious choice to me. If th

Re: How to begin

2014-02-13 Thread Ryan Gonzalez
On 02/13/2014 07:18 AM, weixixiao wrote: http://www.codecademy.com I have learned the basic rules of Python in this website. What should I do next?where to go? I download the Pycharm the free version and I think I dunno how to use it except a "Hello world" Read the Python reference. I know

Re: Welcome to the Internet. No one here likes you. (was: Newcomer Help)

2014-02-13 Thread Larry Martell
On Thu, Feb 13, 2014 at 12:49 PM, John Ladasky wrote: > On Thursday, February 13, 2014 8:32:46 AM UTC-8, larry@gmail.com wrote: > >> This reminds me of post that was circulating in the early 90's: >> >> Welcome to the Internet. >> >> No one here likes you. >> >> We're going to offend, insult,

Re: Working with the set of real numbers

2014-02-13 Thread Marko Rauhamaa
Rotwang : > But my point was that it can't carry out those ℵ₁ discrete steps in > finite time (assuming that time is real-valued), because there's no > way to embed them in any time interval without changing their order. I'd have to think so I take your word for it. Marko -- https://mail.pytho

Re: How to begin

2014-02-13 Thread Ben Finney
Cameron Simpson writes: > On 13Feb2014 05:18, weixixiao <7441...@gmail.com> wrote: > > I have learned the basic rules of Python in this website. > > What should I do next?where to go? > > It helps to have something you want done. > > Find something small you'd like to do. Do it in Python. Good a

Re: singleton ... again

2014-02-13 Thread Grant Edwards
On 2014-02-13, Roy Smith wrote: > I envision SerialPort being a thin layer on top of a bunch of > OS-specific system calls to give them a pythonic interface. Yep, that's pretty much what pyserial is http://pyserial.sourceforge.net/ > Things like is_shutdown() and set_bit_rate() presumably t

Re: A curious bit of code...

2014-02-13 Thread Ethan Furman
On 02/13/2014 02:13 PM, Chris Angelico wrote: On Fri, Feb 14, 2014 at 8:33 AM, Ethan Furman wrote: Oh, it's not that bad! All you have to do is handle the edge case of an empty string: s[::len(s)-1 if s else True] And the edge case of the one-character string. Oops, my description should

Re: Working with the set of real numbers

2014-02-13 Thread Rotwang
On 13/02/2014 22:00, Marko Rauhamaa wrote: Rotwang : for x in continuum(0, max(1, y)): # Note: x is not traversed in the < order but some other # well-ordering, which has been proved to exist. if x * x == y: return x [...]

Re: How to begin

2014-02-13 Thread Cameron Simpson
On 13Feb2014 05:18, weixixiao <7441...@gmail.com> wrote: > http://www.codecademy.com > > I have learned the basic rules of Python in this website. > What should I do next?where to go? > I download the Pycharm the free version and I think I dunno how to use it > except a "Hello world" It helps t

Re: Wait... WHAT?

2014-02-13 Thread Michael Torrie
On 02/13/2014 10:46 AM, eneskri...@gmail.com wrote: > Can we please revert back to the original problem? > def save(): > target = open ("save.swroc", 'w') > target.write([counter, loop, number_of_competitors, competitors]) ^ Have you tried to run th

Re: A curious bit of code...

2014-02-13 Thread Chris Angelico
On Fri, Feb 14, 2014 at 8:33 AM, Ethan Furman wrote: > Oh, it's not that bad! All you have to do is handle the edge case of an > empty string: > > s[::len(s)-1 if s else True] > > *ducks and runs* And the edge case of the one-character string. Also, it's been noted that calling the built-in func

Re: Working with the set of real numbers

2014-02-13 Thread Marko Rauhamaa
Rotwang : >> for x in continuum(0, max(1, y)): >> # Note: x is not traversed in the < order but some other >> # well-ordering, which has been proved to exist. >> if x * x == y: >> return x > > [...] > > More importantly, though, such

Re: PyWart: More surpises via "implict conversion to boolean" (and other steaming piles!)

2014-02-13 Thread Ian Kelly
On Feb 12, 2014 9:16 PM, "Steven D'Aprano" wrote: > > On Tue, 11 Feb 2014 07:36:34 -0800, Travis Griggs wrote: > > > On Feb 10, 2014, at 10:30 PM, Steven D'Aprano > > wrote: > > > > > >>>1. Parenthesis should not be required for parameter- less > >>>functions. > >> > >> Of course they sho

Re: A curious bit of code...

2014-02-13 Thread Ethan Furman
On 02/13/2014 01:01 PM, Chris Angelico wrote: On Fri, Feb 14, 2014 at 7:55 AM, Emile van Sebille wrote: On 2/13/2014 11:59 AM, Zachary Ware wrote: In a fit of curiosity, I did some timings: Snip of lots of TMTOWTDT/TIMTOWTDI/whatever... timed examples :) But I didn't see this one: s[::le

Re: A curious bit of code...

2014-02-13 Thread Roy Smith
In article , Serhiy Storchaka wrote: > 13.02.14 21:59, Zachary Ware написав(ла): > > don't use re for simple stuff (because while it may be very fast, it's > > dominated by attribute lookup and function call overhead), > > And the time of re variant depends on the size of input. That'

Re: A curious bit of code...

2014-02-13 Thread Serhiy Storchaka
13.02.14 21:59, Zachary Ware написав(ла): don't use re for simple stuff (because while it may be very fast, it's dominated by attribute lookup and function call overhead), And the time of re variant depends on the size of input. -- https://mail.python.org/mailman/listinfo/python-list

Re: A curious bit of code...

2014-02-13 Thread Zachary Ware
On Thu, Feb 13, 2014 at 3:31 PM, Chris Angelico wrote: > On Fri, Feb 14, 2014 at 8:19 AM, Zachary Ware > wrote: >> Also, uglier than sin itself. > > Hey hey, no need to insult our lovely trigonometric functions! Here's your sine... -- Zach -- https://mail.python.org/mailman/listinfo/python-li

Re: A curious bit of code...

2014-02-13 Thread Roy Smith
In article , Chris Angelico wrote: > On Fri, Feb 14, 2014 at 8:19 AM, Zachary Ware > wrote: > > Also, uglier than sin itself. > > Hey hey, no need to insult our lovely trigonometric functions! This newsgroup is taylor made for that kind of abuse. -- https://mail.python.org/mailman/listinfo/p

Re: Python(x,y) interferes with earlier Numpy installation

2014-02-13 Thread Martin Schöön
Den 2014-02-13 skrev beliav...@aol.com : > I fixed the problem by reinstalling Numpy. Good. Just one note since I happened to look into updating Python(x,y) at work today and stumbled on this: The Python(x,y) guys recommend that one removes other Python installations prior to installing Python(x,

Re: A curious bit of code...

2014-02-13 Thread Chris Angelico
On Fri, Feb 14, 2014 at 8:19 AM, Zachary Ware wrote: > Also, uglier than sin itself. Hey hey, no need to insult our lovely trigonometric functions! ChrisA -- https://mail.python.org/mailman/listinfo/python-list

Re: Working with the set of real numbers

2014-02-13 Thread Rotwang
What's this? A discussion about angels dancing on a the head of a pin? Great, I'm in. On 13/02/2014 14:00, Marko Rauhamaa wrote: Oscar Benjamin : This isn't even a question of resource constraints: a digital computer with infinite memory and computing power would still be limited to working w

Re: better and user friendly IDE recommended?

2014-02-13 Thread Martin Schöön
Den 2013-09-17 skrev rusi : > On Wednesday, September 11, 2013 7:44:04 PM UTC+5:30, > mnishpsyched wrote: >> Hey i am a programmer but new to python. Can anyone guide >> me in knowing which is a better IDE used to develop web >> related apps that connect to DB using python? > > Just saw this > h

Re: singleton ... again

2014-02-13 Thread Chris Angelico
On Fri, Feb 14, 2014 at 8:13 AM, Robert Kern wrote: > We don't use `is None` instead of `== None` for the speed. We use it for > robustness. We don't want arbitrary __eq__()s to interfere with our sentinel > tests. If None weren't a singleton that we could use as such a sentinel, > we'd make one.

Re: A curious bit of code...

2014-02-13 Thread Emile van Sebille
On 2/13/2014 1:10 PM, Chris Angelico wrote: On Fri, Feb 14, 2014 at 8:06 AM, Peter Otten <__pete...@web.de> wrote: For the record: s = "x" s[::len(s)-1] Traceback (most recent call last): File "", line 1, in ValueError: slice step cannot be zero And that, my friends, is a classic exampl

Re: A curious bit of code...

2014-02-13 Thread Roy Smith
In article , Emile van Sebille wrote: > On 2/13/2014 11:59 AM, Zachary Ware wrote: > > In a fit of curiosity, I did some timings: > > Snip of lots of TMTOWTDT/TIMTOWTDI/whatever... timed examples :) > > But I didn't see this one: > > s[::len(s)-1] > > Emile I love it. I need to add this to

Re: A curious bit of code...

2014-02-13 Thread Zachary Ware
On Thu, Feb 13, 2014 at 3:01 PM, Neil Cerutti wrote: > On 2014-02-13, Zachary Ware wrote: >> C:\tmp>py -m timeit -s "key = ''" "key[0] == '<' and key[-1] == '>'" >> Traceback (most recent call last): >> File "P:\Python34\lib\timeit.py", line 292, in main >> x = t.timeit(number) >> File "P

Re: A curious bit of code...

2014-02-13 Thread Zachary Ware
On Thu, Feb 13, 2014 at 2:55 PM, Emile van Sebille wrote: > On 2/13/2014 11:59 AM, Zachary Ware wrote: >> >> In a fit of curiosity, I did some timings: > > > Snip of lots of TMTOWTDT/TIMTOWTDI/whatever... timed examples :) > > But I didn't see this one: > > s[::len(s)-1] It's not great, around 0.

Re: A curious bit of code...

2014-02-13 Thread Mark Lawrence
On 13/02/2014 21:01, Neil Cerutti wrote: On 2014-02-13, Zachary Ware wrote: In a fit of curiosity, I did some timings: 'and'ed indexing: C:\tmp>py -m timeit -s "key = ''" "key[0] == '<' and key[-1] == '>'" 100 loops, best of 3: 0.35 usec per loop C:\tmp>py -m timeit -s "key = 'py -m time

Re: singleton ... again

2014-02-13 Thread Robert Kern
On 2014-02-13 20:03, Chris Angelico wrote: On Fri, Feb 14, 2014 at 2:24 AM, Roy Smith wrote: In article , Chris Angelico wrote: On Thu, Feb 13, 2014 at 10:50 PM, Ned Batchelder wrote: I still don't see it. To convince me that a singleton class makes sense, you'd have to explain why by v

Re: A curious bit of code...

2014-02-13 Thread Chris Angelico
On Fri, Feb 14, 2014 at 8:06 AM, Peter Otten <__pete...@web.de> wrote: > For the record: > s = "x" s[::len(s)-1] > Traceback (most recent call last): > File "", line 1, in > ValueError: slice step cannot be zero And that, my friends, is a classic example of a Python exception that oug

Re: A curious bit of code...

2014-02-13 Thread Peter Otten
Chris Angelico wrote: > On Fri, Feb 14, 2014 at 7:55 AM, Emile van Sebille wrote: >> On 2/13/2014 11:59 AM, Zachary Ware wrote: >>> >>> In a fit of curiosity, I did some timings: >> >> >> Snip of lots of TMTOWTDT/TIMTOWTDI/whatever... timed examples :) >> >> But I didn't see this one: >> >> s[::l

Re: A curious bit of code...

2014-02-13 Thread Chris Angelico
On Fri, Feb 14, 2014 at 7:55 AM, Emile van Sebille wrote: > On 2/13/2014 11:59 AM, Zachary Ware wrote: >> >> In a fit of curiosity, I did some timings: > > > Snip of lots of TMTOWTDT/TIMTOWTDI/whatever... timed examples :) > > But I didn't see this one: > > s[::len(s)-1] AAAR

Re: A curious bit of code...

2014-02-13 Thread Neil Cerutti
On 2014-02-13, Zachary Ware wrote: > In a fit of curiosity, I did some timings: > > 'and'ed indexing: > > C:\tmp>py -m timeit -s "key = ''" "key[0] == '<' and key[-1] == '>'" > 100 loops, best of 3: 0.35 usec per loop > > C:\tmp>py -m timeit -s "key = ' 100 loops, best of 3: 0.398 usec per

Re: Python(x,y) interferes with earlier Numpy installation

2014-02-13 Thread beliavsky
I fixed the problem by reinstalling Numpy. -- https://mail.python.org/mailman/listinfo/python-list

Re: A curious bit of code...

2014-02-13 Thread Emile van Sebille
On 2/13/2014 11:59 AM, Zachary Ware wrote: In a fit of curiosity, I did some timings: Snip of lots of TMTOWTDT/TIMTOWTDI/whatever... timed examples :) But I didn't see this one: s[::len(s)-1] Emile -- https://mail.python.org/mailman/listinfo/python-list

Re: Using a subclass for __dict__

2014-02-13 Thread Chris Angelico
On Fri, Feb 14, 2014 at 7:44 AM, Roy Smith wrote: > In article , > Chris Angelico wrote: > >> http://gatherer.wizards.com/Pages/Card/Details.aspx?multiverseid=244695 > > That seems badly specified. What if you kill a cyclops? Or a beholder? That matter was dealt with by Doug Beyer in response

Re: How to begin

2014-02-13 Thread Chris Angelico
On Fri, Feb 14, 2014 at 4:34 AM, John Ladasky wrote: > On Thursday, February 13, 2014 7:06:03 AM UTC-8, pete suchsland wrote: > >> if x = 99: > > Surely, Pete, you meant to write "if x == 99:" ? Maybe. Or maybe he wanted the OP to do stuff that would result in exceptions, since exceptions are a w

Re: Using a subclass for __dict__

2014-02-13 Thread Roy Smith
In article , Chris Angelico wrote: > http://gatherer.wizards.com/Pages/Card/Details.aspx?multiverseid=244695 That seems badly specified. What if you kill a cyclops? Or a beholder? -- https://mail.python.org/mailman/listinfo/python-list

Re: A curious bit of code...

2014-02-13 Thread Tim Chase
On 2014-02-13 10:37, forman.si...@gmail.com wrote: > I ran across this and I thought there must be a better way of doing > it, but then after further consideration I wasn't so sure. > > Some possibilities that occurred to me: > > if key.startswith('<') and key.endswith('>'): ... This is my fav

Re: Using a subclass for __dict__

2014-02-13 Thread Chris Angelico
On Fri, Feb 14, 2014 at 7:07 AM, Demian Brecht wrote: > *Throws keyboard across the office* > > FFS. I could have SWORN I tried that (because I /know/ that a class is > an instance of its metaclass :/). An instance of looking at something > far too long without a fresh set of eyes. This is why we

Re: A curious bit of code...

2014-02-13 Thread Chris Angelico
On Fri, Feb 14, 2014 at 6:32 AM, Mark Lawrence wrote: >> There will be an exception only if it is zero-length. But good >> point! That's a pretty sneaky way to avoid checking for a >> zero-length string. Is it a popular idiom? >> > > I hope not. The use of slicing rather than indexing to avoid pr

Re: XML parsing ExpatError with xml.dom.minidom at line 1, column 0

2014-02-13 Thread MRAB
On 2014-02-13 20:10, Peter Otten wrote: ming wrote: Hi, i've a Python script which stopped working about a month ago. But until then, it worked flawlessly for months (if not years). A tiny self-contained 7-line script is provided below. i ran into an XML parsing problem with xml.dom.minido

Re: XML parsing ExpatError with xml.dom.minidom at line 1, column 0

2014-02-13 Thread Peter Otten
ming wrote: > Hi, > i've a Python script which stopped working about a month ago. But until > then, it worked flawlessly for months (if not years). A tiny > self-contained 7-line script is provided below. > > i ran into an XML parsing problem with xml.dom.minidom and the error > message is in

Re: Using a subclass for __dict__

2014-02-13 Thread Demian Brecht
On Thu, Feb 13, 2014 at 11:10 AM, Peter Otten <__pete...@web.de> wrote: > I don't really understand what you are trying to do in the gist, perhaps you > want > > Even though you've already answered my q

Re: Working with the set of real numbers

2014-02-13 Thread Chris Angelico
On Fri, Feb 14, 2014 at 6:47 AM, Marko Rauhamaa wrote: > My assumption was you could execute ℵ₁ statements per second. That > doesn't guarantee a finite finish time but would make it possible. That > is because > >ℵ₁ * ℵ₁ = ℵ₁ = ℵ₁ * 1 Hmm. I never actually covered this stuff in grade school

Re: A curious bit of code...

2014-02-13 Thread Zachary Ware
On Thu, Feb 13, 2014 at 12:37 PM, wrote: > I ran across this and I thought there must be a better way of doing it, but > then after further consideration I wasn't so sure. > > if key[:1] + key[-1:] == '<>': ... > > > Some possibilities that occurred to me: > > if key.startswith('<') and key.

Re: singleton ... again

2014-02-13 Thread Chris Angelico
On Fri, Feb 14, 2014 at 2:24 AM, Roy Smith wrote: > In article , > Chris Angelico wrote: > >> On Thu, Feb 13, 2014 at 10:50 PM, Ned Batchelder >> wrote: >> > I still don't see it. To convince me that a singleton class makes sense, >> > you'd have to explain why by virtue of the class's very na

Re: A curious bit of code...

2014-02-13 Thread Marko Rauhamaa
Peter Otten <__pete...@web.de>: > Personally, I'm willing to spend the few extra milliseconds and use > the foolproof third. Speaking of foolproof, what is this "key?" Is it an XML start tag, maybe? Then, how does your test fare with, say, which is equivalent to Marko -- https://m

Re: A curious bit of code...

2014-02-13 Thread Ethan Furman
On 02/13/2014 11:43 AM, Peter Otten wrote: forman.si...@gmail.com wrote: I ran across this and I thought there must be a better way of doing it, but then after further consideration I wasn't so sure. if key[:1] + key[-1:] == '<>': ... Some possibilities that occurred to me: if key.sta

Python(x,y) interferes with earlier Numpy installation

2014-02-13 Thread beliavsky
I am running Python 2.7.5 on Windows 7 and installed Numpy, which worked. Then I installed Python(x,y) from a file Python(x,y)-2.7.5.2.exe, and now running the script from numpy import array, size, shape, min, max, sum a = array([1, 2, 3]) print shape(a) gives the error messages Traceback (most

Re: A curious bit of code...

2014-02-13 Thread Neil Cerutti
On 2014-02-13, Peter Otten <__pete...@web.de> wrote: > forman.si...@gmail.com wrote: > The first is too clever for my taste. > > The second is fast and easy to understand. It might attract > "improvements" replacing the slice with an index, but I trust > you will catch that with your unit tests ;)

Re: singleton ... again

2014-02-13 Thread Chris Angelico
On Fri, Feb 14, 2014 at 6:03 AM, Roy Smith wrote: > In article , > Ethan Furman wrote: >> >> You mean use the Borg pattern instead of the Singleton pattern? As far as I >> can tell they are two shades of the same >> thing. Are there any drastic differences between the two? Besides one >> havi

Re: Working with the set of real numbers

2014-02-13 Thread Marko Rauhamaa
Chris Angelico : > On Fri, Feb 14, 2014 at 1:00 AM, Marko Rauhamaa wrote: >> Well, if your idealized, infinite, digital computer had ℵ₁ bytes of RAM >> and ran at ℵ₁ hertz and Python supported transfinite iteration, you >> could easily do reals: >> >> for x in continuum(0, max(1, y)): > >

Re: A curious bit of code...

2014-02-13 Thread Ethan Furman
On 02/13/2014 11:17 AM, Neil Cerutti wrote: On 2014-02-13, forman.si...@gmail.com wrote: I ran across this and I thought there must be a better way of doing it, but then after further consideration I wasn't so sure. if key[:1] + key[-1:] == '<>': ... Some possibilities that occurred to me:

Re: A curious bit of code...

2014-02-13 Thread Peter Otten
forman.si...@gmail.com wrote: > I ran across this and I thought there must be a better way of doing it, > but then after further consideration I wasn't so sure. > > if key[:1] + key[-1:] == '<>': ... > > > Some possibilities that occurred to me: > > if key.startswith('<') and key.endswith(

Re: A curious bit of code...

2014-02-13 Thread Roy Smith
In article , Ethan Furman wrote: > On 02/13/2014 11:09 AM, Mark Lawrence wrote: > > > > All I can say is that if you're worried about the speed of a single line of > > code like the above then you've got > > problems. Having said that, I suspect that using an index to extract a > > single cha

Re: A curious bit of code...

2014-02-13 Thread Mark Lawrence
On 13/02/2014 19:25, Neil Cerutti wrote: On 2014-02-13, Ethan Furman wrote: On 02/13/2014 11:09 AM, Mark Lawrence wrote: All I can say is that if you're worried about the speed of a single line of code like the above then you've got problems. Having said that, I suspect that using an index to

XML parsing ExpatError with xml.dom.minidom at line 1, column 0

2014-02-13 Thread ming
Hi, i've a Python script which stopped working about a month ago. But until then, it worked flawlessly for months (if not years). A tiny self-contained 7-line script is provided below. i ran into an XML parsing problem with xml.dom.minidom and the error message is included below. The weird

Re: A curious bit of code...

2014-02-13 Thread Neil Cerutti
On 2014-02-13, forman.si...@gmail.com wrote: > I ran across this and I thought there must be a better way of > doing it, but then after further consideration I wasn't so > sure. > > if key[:1] + key[-1:] == '<>': ... > > Some possibilities that occurred to me: > > if key.startswith('<') and ke

Re: A curious bit of code...

2014-02-13 Thread Neil Cerutti
On 2014-02-13, Ethan Furman wrote: > On 02/13/2014 11:09 AM, Mark Lawrence wrote: >> All I can say is that if you're worried about the speed of a >> single line of code like the above then you've got problems. >> Having said that, I suspect that using an index to extract a >> single character has

Re: Working with the set of real numbers

2014-02-13 Thread Chris Angelico
On Fri, Feb 14, 2014 at 1:00 AM, Marko Rauhamaa wrote: > Well, if your idealized, infinite, digital computer had ℵ₁ bytes of RAM > and ran at ℵ₁ hertz and Python supported transfinite iteration, you > could easily do reals: > > def real_sqrt(y): > for x in continuum(0, max(1, y)): >

Re: A curious bit of code...

2014-02-13 Thread Ethan Furman
On 02/13/2014 11:20 AM, Ethan Furman wrote: On 02/13/2014 11:09 AM, Mark Lawrence wrote: All I can say is that if you're worried about the speed of a single line of code like the above then you've got problems. Having said that, I suspect that using an index to extract a single character has

Re: A curious bit of code...

2014-02-13 Thread Alain Ketterlin
forman.si...@gmail.com writes: > I ran across this and I thought there must be a better way of doing > it, but then after further consideration I wasn't so sure. > > if key[:1] + key[-1:] == '<>': ... > > Some possibilities that occurred to me: > > if key.startswith('<') and key.endswith('>'):

Re: PyWart: More surpises via "implict conversion to boolean" (and other steaming piles!)

2014-02-13 Thread Chris Angelico
On Fri, Feb 14, 2014 at 1:58 AM, Roy Smith wrote: > In article , > Chris Angelico wrote: > >> Whether it's a module-level function, a bound method, a closure, or a >> callable object, a zero-arg function in Python always has some kind of >> implicit state. > > Sometimes, it has a *lot* of implic

Re: A curious bit of code...

2014-02-13 Thread Ethan Furman
On 02/13/2014 11:09 AM, Mark Lawrence wrote: All I can say is that if you're worried about the speed of a single line of code like the above then you've got problems. Having said that, I suspect that using an index to extract a single character has to be faster than using a slice, but I haven

Re: singleton ... again

2014-02-13 Thread Tim Delaney
On 13 February 2014 20:00, Piet van Oostrum wrote: > Ben Finney writes: > > Make that “somewhere” a module namespace, and you effectively have a > > Singleton for all practical purposes. So yes, I see the point of it; but > > we already have it built in :-) > > There is a use case for a singleto

Re: Using a subclass for __dict__

2014-02-13 Thread Peter Otten
Demian Brecht wrote: > Using bases in a metaclass, I've been able to easily figure out when > an attribute is being added to an instance of a class. However, what > I'm /actually/ looking to do is to intercept when attributes are being > added to a class (not an instance of). I thought that I'd be

Re: A curious bit of code...

2014-02-13 Thread Mark Lawrence
On 13/02/2014 18:37, forman.si...@gmail.com wrote: I ran across this and I thought there must be a better way of doing it, but then after further consideration I wasn't so sure. if key[:1] + key[-1:] == '<>': ... Some possibilities that occurred to me: if key.startswith('<') and key.en

Re: A curious bit of code...

2014-02-13 Thread Ethan Furman
On 02/13/2014 10:37 AM, forman.si...@gmail.com wrote: I ran across this and I thought there must be a better way of doing it, but then after further consideration I wasn't so sure. if key[:1] + key[-1:] == '<>': ... Some possibilities that occurred to me: if key.startswith('<') and key

Re: singleton ... again

2014-02-13 Thread Roy Smith
In article , Ethan Furman wrote: > On 02/13/2014 09:57 AM, Roy Smith wrote: > > In article , > > Ethan Furman wrote: > > > >> Say you have a class that represents serial ports or your computer. You > >> should get the same object every time you ask > >> for SerialPort(2). > > > > Why? Certa

Re: A curious bit of code...

2014-02-13 Thread Roy Smith
In article <4cc09129-43ee-4205-a24c-03f92b594...@googlegroups.com>, forman.si...@gmail.com wrote: > I ran across this and I thought there must be a better way of doing it, but > then after further consideration I wasn't so sure. > > if key[:1] + key[-1:] == '<>': ... > > > Some possibilitie

Re: singleton ... again

2014-02-13 Thread Ethan Furman
On 02/13/2014 09:57 AM, Roy Smith wrote: In article , Ethan Furman wrote: Say you have a class that represents serial ports or your computer. You should get the same object every time you ask for SerialPort(2). Why? Certainly, you should get objects which refer to the same physical port.

A curious bit of code...

2014-02-13 Thread forman . simon
I ran across this and I thought there must be a better way of doing it, but then after further consideration I wasn't so sure. if key[:1] + key[-1:] == '<>': ... Some possibilities that occurred to me: if key.startswith('<') and key.endswith('>'): ... and: if (key[:1], key[-1:]) == ('<

Re: Wait... WHAT?

2014-02-13 Thread MRAB
On 2014-02-13 17:46, eneskri...@gmail.com wrote: Can we please revert back to the original problem? def save(): > target = open ("save.swroc", 'w') This opens the file for writing text (assuming you're using Python 3). > target.write([counter, loop, number_of_competitors

Re: Newcomer Help

2014-02-13 Thread Grant Edwards
On 2014-02-13, Larry Martell wrote: > 9) Don't ever use the term "cyberspace" (only William Gibson gets to > say that, and even he hasn't really used it for two or three books > now). Likewise, you prove yourself a marketing-hype victim if you ever > use the term "surfing". 9b) And don't use an

Re: singleton ... again

2014-02-13 Thread Roy Smith
In article , Ethan Furman wrote: > Say you have a class that represents serial ports or your computer. You > should get the same object every time you ask > for SerialPort(2). Why? Certainly, you should get objects which refer to the same physical port. So: port_a = SerialPort(2) port_b

Re: Wait... WHAT?

2014-02-13 Thread eneskristo
Can we please revert back to the original problem? def save(): target = open ("save.swroc", 'w') target.write([counter, loop, number_of_competitors, competitors]) def load(): the_array = list(open("save.swroc", 'r')) the_array = target counter = the_a

Welcome to the Internet. No one here likes you. (was: Newcomer Help)

2014-02-13 Thread John Ladasky
On Thursday, February 13, 2014 8:32:46 AM UTC-8, larry@gmail.com wrote: > This reminds me of post that was circulating in the early 90's: > > Welcome to the Internet. > > No one here likes you. > > We're going to offend, insult, abuse, and belittle the living hell out > of you. And when you

Re: singleton ... again

2014-02-13 Thread Ethan Furman
On 02/13/2014 03:50 AM, Ned Batchelder wrote: On 2/13/14 4:00 AM, Piet van Oostrum wrote: Ben Finney writes: Gregory Ewing writes: Roy Smith wrote: It looks to me like he's trying to implement a classic Gang of Four singleton pattern. Which I've never really seen the point of in Python,

Re: How to begin

2014-02-13 Thread John Ladasky
On Thursday, February 13, 2014 7:06:03 AM UTC-8, pete suchsland wrote: > if x = 99: Surely, Pete, you meant to write "if x == 99:" ? -- https://mail.python.org/mailman/listinfo/python-list

Community standards of behaviour (was: Newcomer Help)

2014-02-13 Thread Ben Finney
Larry Martell writes: > On Thu, Feb 13, 2014 at 11:22 AM, Rustom Mody wrote: […] > > I suggest > > 1. You focus on your goal -- learning python or whatever is the larger > > personal goal of which learning python is a part > > 2. A bullet-proof vest > > This reminds me of post that was circula

Re: Working with the set of real numbers

2014-02-13 Thread Ben Finney
Oscar Benjamin writes: > I think Chris' statement above is pretty clear. I disagree, as explained. > Also I didn't find the original statement confusing I'm happy for you. > and it is a reasonable point to make. Yes, and I was not addressing that. -- \ “It is well to remember tha

Re: Newcomer Help

2014-02-13 Thread Larry Martell
On Thu, Feb 13, 2014 at 11:22 AM, Rustom Mody wrote: > > This is Usenet. You'll learn much here and you'll find a bunch of rude people. > > No you are not going to crash your plane but you will likely crash your > python-learning attempts if you give an occasional asshole more importance > than is

Re: Newcomer Help

2014-02-13 Thread Rustom Mody
On Thursday, February 13, 2014 8:52:51 PM UTC+5:30, Walter Hughey wrote: > I am addressing this to the entire site - I thinks. And this will be my final > answer on this subject. > It remains to be seen if I remain on this site or tell all good bye. > For the most part, the few people who resp

Using a subclass for __dict__

2014-02-13 Thread Demian Brecht
Hey all, Using bases in a metaclass, I've been able to easily figure out when an attribute is being added to an instance of a class. However, what I'm /actually/ looking to do is to intercept when attributes are being added to a class (not an instance of). I thought that I'd be able to do so by pa

RE: imperative mood in docstrings

2014-02-13 Thread bagrat lazaryan
thank you all! bagratte -- https://mail.python.org/mailman/listinfo/python-list

  1   2   >