Re: Problem while doing a cat on a tabbed file with pexpect

2012-01-15 Thread Steven D'Aprano
t;> x.expect([pexpect.TIMEOUT, "% "]) > 1 >>>> x.before > 'cat me.txt\r\r\nA B C\r\n' Unfortunately I can't replicate the same behaviour, however my setup is different. I'm using pexpect2.3 on Linux, and I tried it using bash and

Re: THAT WHAT NEED EXPECT FROM OPERATORS OF PYTHON. (e-mail get by the list moderator)

2012-01-15 Thread Steven D'Aprano
e a question, or are you just dumping a lot of noise in one post? -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: subprocess.Popen strange bhaviour

2012-01-18 Thread Steven D'Aprano
it to do and the process ends. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: unzip function?

2012-01-18 Thread Steven D'Aprano
function, to match zip. Just create your own utility function. Not everything needs to be a built-in. def unzip(iterable): return zip(*iterable) Hardly seems worthwhile. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: unzip function?

2012-01-18 Thread Steven D'Aprano
On Wed, 18 Jan 2012 11:20:00 -0500, Devin Jeanpierre wrote: > On Wed, Jan 18, 2012 at 10:27 AM, Steven D'Aprano > wrote: >>> That zip (*sorted... >>> >>> does the unzipping. >>> >>> But it's less than intuitively obvious. >> >

Re: Installing Python on CentOS 6 - a big pain

2012-01-18 Thread Steven D'Aprano
On Wed, 18 Jan 2012 10:00:47 -0800, John Nagle wrote: > This sort of thing is why Python is losing market share. Only on Planet Nagle. Do you have any evidence that Python actually *is* losing market share, or are you just trolling? -- Steven -- http://mail.python.org/mail

Re: Installing Python on CentOS 6 - a big pain

2012-01-18 Thread Steven D'Aprano
agine how much effort would be involved. And I can't fathom why John imagines that this is Python's fault. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Installing Python on CentOS 6 - a big pain

2012-01-19 Thread Steven D'Aprano
On Thu, 19 Jan 2012 20:43:23 +1100, Chris Angelico wrote: > On Thu, Jan 19, 2012 at 3:36 PM, Steven D'Aprano > wrote: >> With all the tools installed, it's a matter of a few minutes effort to >> build from scratch: [...] > Now, granted, this was Debian and I can&#

Re: verify the return value of a function

2012-01-20 Thread Steven D'Aprano
t but would be happy with a tuple or some other sequence. Worse than isinstance is testing for an exact type: if type(x) is list # worse than isinstance(x, list) although of course, there are times where you need to break the rules. > In diagnostics and tests like the OP's there should be > no problem. Agreed. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Is a with on open always necessary?

2012-01-20 Thread Steven D'Aprano
or the quickest and dirtiest scripts, I recommend always using either the "with file as" idiom, or explicitly closing the file. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: can some one help me with my code. thanks

2012-01-20 Thread Steven D'Aprano
ecycling bin". It is also a standard term used in statistics as a noun, a verb, and adjective, e.g.: http://stackoverflow.com/questions/5581023/r-graphing-binned-data -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Tab-completion in tutorial

2012-01-21 Thread Steven D'Aprano
oing something wrong? -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: while True or while 1

2012-01-21 Thread Steven D'Aprano
P 3 (to 6) >>3 JUMP_ABSOLUTE3 >>6 LOAD_CONST 0 (None) 9 RETURN_VALUE py> dis(compile('while True: pass', '', 'exec')) 1 0 SETUP_LOOP 3 (to 6) >>3 JUMP_ABSOLUTE3 >>6 LOAD_CONST 0 (None) 9 RETURN_VALUE Or perhaps they just like the look of "while 1". -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: access address from object and vice versa

2012-01-21 Thread Steven D'Aprano
is a good thing, because it makes a whole class of bugs and security vulnerabilities impossible in Python. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: access address from object and vice versa

2012-01-21 Thread Steven D'Aprano
On the other hand, presumably this means that Jython objects need an extra field to store the ID, so the CPython approach is a space optimization. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: PEP: add __sum__ method

2012-01-22 Thread Steven D'Aprano
detailed justification before making it +1. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Looking under Python's hood: Will we find a high performance or clunky engine?

2012-01-23 Thread Steven D'Aprano
the bottleneck. But it is extremely unlikely that copying even a few thousands lines around memory will be slower than reading them from disk in the first place. Unless you expect to be handling truly large files, you've got more important things to optimize before wasting time

Re: Floating point calculation problem

2013-02-02 Thread Steven D'Aprano
Michael Torrie wrote: > def squeeze_duck (duck): > // return the quack > return duck.squeeze() I'm curious, what language were you thinking of when you wrote the comment using // instead of # ? -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: How does help() indent doc strings?

2013-02-03 Thread Steven D'Aprano
This my very long epilogue string which goes on for several lines. Like this. py> print textwrap.dedent(prepare(epilogue)) This my very long epilogue string which goes on for several lines. Like this. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: __getattr__ Confusion

2013-02-03 Thread Steven D'Aprano
;m guessing you meant that Python raised a perfectly normal exception, like Traceback (most recent call last): ... NameError: name 'self' is not defined If you pay attention to the exception messages that Python prints for you, you will not only find it easier to debug your code

Re: Formatting a column's value output

2013-02-03 Thread Steven D'Aprano
de people into two groups with no overlap: - useful, nice, friendly people - trolls and other low-lives But no, even the worst scum have some redeeming features, and so we're left with difficult subjective judgements, and nobody can agree whether or not Person X should be pushed into

Re: __getattr__ Confusion

2013-02-04 Thread Steven D'Aprano
__nonzero__ a special >> case? > > Unfortunately the situation is a bit more complex. Classic classes (like > Tkinter.Frame) behave differently from newstyle classes (subclasses of > object): [...] > So Steven is wrong here. Peter is correct -- I've been using Python 3 too much, and comple

Re: error in except

2013-02-04 Thread Steven D'Aprano
for 3 minutes, which is possibly overkill.) But either way, I don't think RuntimeError is the right exception to use. I expect that a socket error would be more relevant. > except: > raise What this does is: "Unconditionally catch anything. Then raise it again." Don'

LBYL vs EAFP

2013-02-04 Thread Steven D'Aprano
middle of my code rather than silently do the wrong thing. I don't like this idea because, even if it fails, it is better to fail earlier than later. Comments, thoughts and opinions please. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: LBYL vs EAFP

2013-02-04 Thread Steven D'Aprano
On Tue, 05 Feb 2013 10:38:41 +1100, Chris Angelico wrote: > On Tue, Feb 5, 2013 at 10:16 AM, Steven D'Aprano > wrote: >> A third option is not to check x at all, and hope that it will blow up >> at some arbitrary place in the middle of my code rather than silently >>

Re: LBYL vs EAFP

2013-02-04 Thread Steven D'Aprano
hics application that expects an object with a "draw" method: pencil.draw() paintbrush.draw() crayon.draw() six_shooter.draw() # bang, you've just shot yourself in the foot So I lean very strongly to some sort of explicit check ahead of time. I'm just not sure *what sort* of

Re: LBYL vs EAFP

2013-02-04 Thread Steven D'Aprano
On Tue, 05 Feb 2013 16:20:19 +1100, Chris Angelico wrote: > On Tue, Feb 5, 2013 at 3:52 PM, Steven D'Aprano > wrote: >> There's also the principle that it is best to raise an exception as >> early as possible. It's easier to track down errors at the point

Re: LBYL vs EAFP

2013-02-05 Thread Steven D'Aprano
Pete Forman wrote: > Steven D'Aprano writes: >>> I want to check that a value is a number. [...] >> I'm leaning towards an isinstance check [...] > BTW what if the value is Not-a-Number? ;-) Nothing different, and hopefully exactly what the caller expects. As f

Decimal 0**0

2013-02-05 Thread Steven D'Aprano
quot; to return 1, although languages can define a separate "powr" function to return a NAN. http://en.wikipedia.org/wiki/Exponentiation#Zero_to_the_power_of_zero I suspect this is a bug in Decimal's interpretation of the standard. Can anyone comment? -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Opinion on best practice...

2013-02-05 Thread Steven D'Aprano
let's make everything global! I would not hesitate to use Python, or some other high-level language like Ruby, over bash for anything non-trivial that I cared about. It might not be as terse and compact as a well-written bash script, but that's a *good* thing, and a poorly-written bash sc

Re: each process only has one main thread ,right ?

2013-02-06 Thread Steven D'Aprano
ocess IS one main thread", or whether there is in fact a difference. But, yes, each process is equivalent to a single thread. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Recording live video stream from IP camera issue

2013-02-06 Thread Steven D'Aprano
u are on Linux, try this: - rename the file *without* the .avi at the end; - at the shell command line, give the command "file name-of-your-video-file" and see what the file command thinks it contains. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Opinion on best practice...

2013-02-06 Thread Steven D'Aprano
he code. If you say "Anything that isn't parsable is automatically sent to the shell", it doesn't sound too bad. But when you say "Unparseable junk is implicitly treated as code and sent off to be executed by something which traditionally tends to be forgiving of syntax errors and has the ability to turn your file system into so much garbage", it sounds a tad less appealing. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Plotting syntax

2013-02-06 Thread Steven D'Aprano
... then always slice on the boundary to the left of the given number: slice [0:4] => |0|1|2|3| slice [5:8] => |5|6|7| The only tricky part is remembering to count from zero instead of one. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: urllib2 FTP Weirdness

2013-02-06 Thread Steven D'Aprano
e firewall. If bypassing the firewall makes the issue go away, then go and yell at your network admins until they fix it. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Opinion on best practice...

2013-02-06 Thread Steven D'Aprano
On Thu, 07 Feb 2013 16:28:17 +1100, Chris Angelico wrote: > On Thu, Feb 7, 2013 at 10:46 AM, Steven D'Aprano > wrote: >> Dennis Lee Bieber wrote: >>> Though that is the nice feature of REXX*... Anything that wasn't >>> parsable as a REXX stateme

Re: Curious to see alternate approach on a search/replace via regex

2013-02-07 Thread Steven D'Aprano
timing code, my guess is that you are doing it wrong. Timing code is tricky, which is why I always show my work. If I get it wrong, someone will hopefully tell me. Otherwise, I might as well be making up the numbers. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Opinion on best practice...

2013-02-07 Thread Steven D'Aprano
Chris Angelico wrote: > On Thu, Feb 7, 2013 at 5:50 PM, Steven D'Aprano > wrote: >> On Thu, 07 Feb 2013 16:28:17 +1100, Chris Angelico wrote: >> >>> You misunderstand. It's actually a very simple rule. Python follows C's >>> principle of accept

Re: Opinion on best practice...

2013-02-07 Thread Steven D'Aprano
ake a typo when assigning to a variable, Python will go ahead and create a new variable. But if you make a typo when *calling* a function, or try to call something that doesn't exist, you get an exception, not silently pushing the typo off to some other process to be executed. -- Steven -- ht

Re: Decimal 0**0

2013-02-07 Thread Steven D'Aprano
Tim Roberts wrote: > Steven D'Aprano wrote: >> >>Does anyone have an explanation why Decimal 0**0 behaves so differently >>from float 0**0? >>... >>I am familiar with the arguments for treating 0**0 as 0, or undefined, but >>thought that except for sp

Re: Curious to see alternate approach on a search/replace via regex

2013-02-07 Thread Steven D'Aprano
rh wrote: > On Fri, 08 Feb 2013 09:45:41 +1100 > Steven D'Aprano wrote: > >> rh wrote: >> >> > I am using 2.7.3 and I put the re.compile outside the function and >> > it performed faster than urlparse. I don't print out the data. >>

Re: Curious to see alternate approach on a search/replace via regex

2013-02-07 Thread Steven D'Aprano
Ian Kelly wrote: > On Thu, Feb 7, 2013 at 4:59 PM, Steven D'Aprano > wrote: >> Oh, one last thing... pulling out "re.compile" outside of the function >> does absolutely nothing. You don't even compile anything. It basically >> looks up that a compile

Re: Implicit conversion to boolean in if and while statements

2013-02-07 Thread Steven D'Aprano
. (essentially, non-empty values). Prior to Python 3, the special method __bool__ was spelled __nonempty__, which demonstrates Python's philosophy towards duck-typing bools. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: PyWart: Namespace asinitiy and the folly of the global statement

2013-02-08 Thread Steven D'Aprano
ere > are",__builtins__.len(self.some_list),"members in this list, > namely:",__builtins__.repr(self.some_list)) Pardon me, but since __builtins__ is a global, you have to say: globals.__builtins__.print("screw this for a game of soldiers") or equivalent. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Implicit conversion to boolean in if and while statements

2013-02-08 Thread Steven D'Aprano
Rick Johnson wrote: > On Monday, July 16, 2012 7:43:47 PM UTC-5, Steven D'Aprano wrote: Really Rick? Digging out a post from nearly seven months ago? You must really be bored silly. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Curious to see alternate approach on a search/replace via regex

2013-02-08 Thread Steven D'Aprano
uot;s[ai]t" doesn't take that much work, it's only six characters and very simple. Applying it to: "sazsid"*100 + "sat" on the other hand may be a tad expensive. Sweeping generalities about the cost of compiling regexes versus searching with them are risky. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: PyWart: Namespace asinitiy and the folly of the global statement

2013-02-08 Thread Steven D'Aprano
ut you really shouldn't assume others suffer under that same affliction. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Is Python programming language?

2013-02-08 Thread Steven D'Aprano
a clock", just because it has a clock app. Yes, you can use your iPad to tell the time, and that makes it a clock. But it's not *just* a clock, and Python is not *just* a scripting language. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Is Python programming language?

2013-02-08 Thread Steven D'Aprano
gmspro wrote: > One said, Python is not programming language, rather scripting language, > is that true? I forgot to mention, there is a FAQ about this: http://docs.python.org/2/faq/general.html#what-is-python-good-for -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Implicit conversion to boolean in if and while statements

2013-02-08 Thread Steven D'Aprano
time, and designed the language to encourage the use of protocols like this, instead of insisting on the slavish application of obj.method syntax. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Implicit conversion to boolean in if and while statements

2013-02-08 Thread Steven D'Aprano
MRAB wrote: > On 2013-02-08 07:22, Steven D'Aprano wrote: >> Prior to Python 3, the special method __bool__ was spelled __nonempty__, >> which demonstrates Python's philosophy towards duck-typing bools. >> > Incorrect, it was spelled __nonzero__. Oops, s

Re: Implicit conversion to boolean in if and while statements

2013-02-08 Thread Steven D'Aprano
Rick Johnson wrote: > On Friday, February 8, 2013 9:16:42 AM UTC-6, Steven D'Aprano wrote: >> Rick Johnson wrote: >> >> > GvR has always been reluctant to incorporate full OOP machinery for >> > some reason. >> >> Python is a fully object orien

Re: LangWart: Method congestion from mutate multiplicty

2013-02-08 Thread Steven D'Aprano
much everyone has implemented it a dozen times or more in their own projects, and you start to agitate for it to be added to the builtins so that there is *one* implementation, done *right*, that everyone can use. And then you get told that Guido's time machine has struck again, because Pytho

Re: Alternatives to Splunk?

2013-02-09 Thread Steven D'Aprano
st for system administration, not programming languages. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Coercing one object to type of another

2013-02-09 Thread Steven D'Aprano
u need coerce? What are you actually trying to accomplish? If you have two numbers, normally you would just do arithmetic on them and let Python do any coercion needed. And if you have a number and something else, you can't magically turn non-numbers into numbers. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: LangWart: Method congestion from mutate multiplicty

2013-02-10 Thread Steven D'Aprano
Why am I not surprised that Rick's knowledge of Ruby is no deeper than his knowledge of Python? -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: LangWart: Method congestion from mutate multiplicty

2013-02-10 Thread Steven D'Aprano
Rick Johnson wrote: > On Friday, February 8, 2013 9:36:52 PM UTC-6, Steven D'Aprano wrote: >> Rick Johnson wrote: >> >> > The solution is simple. Do not offer the "copy-mutate" methods and >> > force all mutation to happen in-place: >>

Re: Implicit conversion to boolean in if and while statements

2013-02-10 Thread Steven D'Aprano
over-allocated mutable set object. If set literals created immutable frozensets, there would be some nice opportunities for the compiler to optimize this use-case. So, in Python 4000, my vote is for set literals { } to create frozensets, and if you want a mutable set, you have to use the set() type direc

Re: __class__ and type() implementation details in CPython

2013-02-10 Thread Steven D'Aprano
ls - how does class > identification with type() work? According to CPython's sources it looks > like there is a "marker" of actual object's class associated with each > PyObject - _typeobject struct, which is used to identify the class by > type(). Am I right? I

Re: LangWart: Method congestion from mutate multiplicty

2013-02-10 Thread Steven D'Aprano
Chris Angelico wrote: > On Sun, Feb 10, 2013 at 10:29 PM, Steven D'Aprano > wrote: >> "inserted" is called addition, together with list slicing when needed. >> >> newlist = [item_to_insert] + oldlist >> newlist = oldlist[0:5] + [item_to_insert] + oldl

Re: LangWart: Method congestion from mutate multiplicty

2013-02-10 Thread Steven D'Aprano
it doesn't have one yet. I'm not sure what you mean by "unified object model", but I'm pretty sure that Python has one. Everything is an object, with a single[1] hierarchy of classes. [1] Python 3 only. In Python 2, you have types, and you have old-style classes, and they are separate. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: LangWart: Method congestion from mutate multiplicty

2013-02-10 Thread Steven D'Aprano
not made of smaller elbow joints made of tinier elbow joints made of even tinier elbow joints made of ... -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: LangWart: Method congestion from mutate multiplicty

2013-02-10 Thread Steven D'Aprano
Dennis Lee Bieber wrote: > On Mon, 11 Feb 2013 01:29:30 +1100, Steven D'Aprano > declaimed the following in > gmane.comp.python.general: > >> >> Oh dear. Chris was being sarcastic. I thought that, even if the sarcasm >> wasn't obvious, his "Oo

Re: LangWart: Method congestion from mutate multiplicty

2013-02-10 Thread Steven D'Aprano
that the difference between "true" OOP and everything else is the presence of an initial capital letter. Thank you Rick for your deep insight. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: LangWart: Method congestion from mutate multiplicty

2013-02-10 Thread Steven D'Aprano
Rick Johnson wrote: > On Sunday, February 10, 2013 5:29:54 AM UTC-6, Steven D'Aprano wrote: >> Rick wrote: >> And you have missed my point, which is that reversed(), and sorted(), >> were not added to the language on a whim, but because they were >> request

Re: LangWart: Method congestion from mutate multiplicty

2013-02-10 Thread Steven D'Aprano
e a copy > of ANY data structure only to simply iterate over it; be it forwards or > backwards or sideways". Aren't you the fool who wants to remove reversed() and have people write: [quote] reversed = list(seq).reverse() Oh yes, you are the fool. And me the bigger fool for li

Re: Error in reading and writing CSV format file in python

2013-02-11 Thread Steven D'Aprano
next() raises StopIteration when there is nothing else to return. py> it = iter([1, 2, 3]) py> it.next() 1 py> it.next() 2 py> it.next() 3 py> it.next() Traceback (most recent call last): File "", line 1, in StopIteration You have reached the end of the file and there is nothing else for the CSV reader to return, so it raises StopIteration. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: How to Send a Tweet from Python? I can read, but not post.

2013-02-11 Thread Steven D'Aprano
icated python-twitter or tweepy forum, or if those projects are too small to have a dedicated forum, by asking the creator of the packages for assistance. If you do get an answer somewhere else, please reply here with the solution to help future developers who are searching for an answer to the sa

Awsome Python - chained exceptions

2013-02-11 Thread Steven D'Aprano
ntionally suppressing the __context__: py> try: ... len(None) ... except TypeError: ... raise ValueError('bad value') from None # Python 3.3 ... Traceback (most recent call last): File "", line 4, in ValueError: bad value You can read more about exception chaining here: http://www.python.org/dev/peps/pep-3134/ http://www.python.org/dev/peps/pep-0409/ -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: UnicodeEncodeError when not running script from IDE

2013-02-12 Thread Steven D'Aprano
If I manually change the terminal's encoding to Western European ISO 8859-1, I get some moji-bake: py> print(c) è¦ I can't replicate the exception you give, so I assume it is specific to Windows. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Python3 exec locals - this must be a FAQ

2013-02-12 Thread Steven D'Aprano
ide a function it doesn't seem to work. One of the two classic blunders: - Never get involved in a land war in Asia; - Never go against a Sicilian when death is on the line; - Never test locals() outside of a function and extrapolate the behaviour to inside a function! -- Steven -- h

Re: UnicodeEncodeError when not running script from IDE

2013-02-12 Thread Steven D'Aprano
haracters. E.g. ASCII only knows about 127 characters out of the million-plus that Unicode deals with. Latin-1 can handle close to 256 different characters. If you have a say in the matter, always use UTF-8, since it can handle the full set of Unicode characters in the most efficient manner. -- S

Re: Python Makefiles... are they possible?

2013-02-12 Thread Steven D'Aprano
thing quite rare, but I suppose that depends on how often you run make. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Python Makefiles... are they possible?

2013-02-13 Thread Steven D'Aprano
Roy Smith wrote: > In article <[email protected]>, > Steven D'Aprano wrote: > >> On Tue, 12 Feb 2013 20:06:35 -0500, Roy Smith wrote: >> >> > One thing we do in our Makefiles is "find . -name '*.pyc' | xargs

Re: Awsome Python - chained exceptions

2013-02-13 Thread Steven D'Aprano
a forward compatible print >> function is by /importing/ the feature. >> >>from future import print_function > >>>> import __future__ >>>> __future__.print_function > _Feature((2, 6, 0, 'alpha', 2), (3, 0, 0, 'alpha', 0), 65536) &

Re: Suggested feature: slice syntax within tuples (or even more generally)?

2013-02-13 Thread Steven D'Aprano
that you can do this: s = (1:2) # Like slice(1, 2). print alist[s] print blist[s] # reuse the slice object print clist[s] you can replace the line s = (1:2) to a call to slice, and still reuse the slice object. So I don't understand what the syntactic sugar gains you. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Suggested feature: slice syntax within tuples (or even more generally)?

2013-02-14 Thread Steven D'Aprano
t; s[7::, 9] (slice(7, None, None), 9) I feel all giddy inside... By the way, Go-lang also has slices, but they're more like views into an array than Python's slice objects. http://blog.golang.org/2011/01/go-slices-usage-and-internals.html This is not germane to your question, I

Python trademark under attack -- the PSF needs your help

2013-02-14 Thread Steven D'Aprano
in the name, etc. your evidence will be helpful in defeating this attempted grab of the Python name. You can also testify to the fact that when you read or hear of the name "Python" in relation to computers and the Internet, you think of Python the programming language. Thank you. -- S

Re: Python trademark under attack -- the PSF needs your help

2013-02-15 Thread Steven D'Aprano
of doing something trivially easy which anyone can do, such as googling "python", trust me, the PSF has already done it. The PSF is looking for the sort of help that they can't get by typing into a search engine. If anyone can help, that's great. If you can't help, then

Re: multiple 2.7.3 versions?

2013-02-15 Thread Steven D'Aprano
ack this 'fix'. [...] > Can someone explain how this 'fix' is leaking out onto his machine? The major Linux distros, including Ubuntu, tend to release their own bug fixes independently to official Python releases. I guess that the fix your colleague is seeing is from Ubuntu

Re: Python trademark under attack -- the PSF needs your help

2013-02-15 Thread Steven D'Aprano
pple doesn't mean they aren't a serious vendor in their space. > My advice: don't mention their name or their domain in any of your blog > posts etc., and definitely don't link to them. This would be the "there's no such thing as bad publicity" theory. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: python math problem

2013-02-15 Thread Steven D'Aprano
", only slower. + Should I test for absolute error, or relative error? + If relative error, how do I deal with values around zero where division is likely to introduce excessive rounding error? + Not to mention the risk of dividing by zero. - And how do I deal with INFs? py> x =

Python trademark - A request for civility

2013-02-15 Thread Steven D'Aprano
uring this dispute. Abuse and threats just bring the Python community into disrepute. http://pyfound.blogspot.com/2013/02/asking-for-civility-during-our.html -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Comparing types

2013-02-17 Thread Steven D'Aprano
e.SRE_Pattern) The second is guaranteed to work even if the _sre module disappears, is renamed, or otherwise changes in any way. # Safe. PatternType = type(re.compile(".")) isinstance(my_pattern, PatternType) -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Can someone tell me what kinds of questions should be asked in this list and what kinds in the tutor section?

2013-02-17 Thread Steven D'Aprano
since we know he's infallible, but if he's too old and set in his ways for email, perhaps Rick would be almost as good. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Differences creating tuples and collections.namedtuples

2013-02-18 Thread Steven D'Aprano
nitialization > api. That might be a reason that people give, but it's a bad reason from the perspective of interface contracts, duck-typing and the LSP. Of course, these are not the *only* perspectives. There is no rule that states that one must always obey the interface contracts of one's parent class. But if you don't, you will be considered an "ill-behaved" subclass for violating the promises made by your type. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Differences creating tuples and collections.namedtuples

2013-02-18 Thread Steven D'Aprano
Oscar Benjamin wrote: > On 19 February 2013 00:18, Steven D'Aprano > wrote: >> Terry Reedy wrote: >>> On 2/18/2013 6:47 AM, John Reid wrote: > [snip] >>>> Is this a problem with namedtuples, ipython or just a feature? >>> >>> With

Re: First attempt at a Python prog (Chess)

2013-02-18 Thread Steven D'Aprano
gives you access to .Net arrays, although of course that is not standard Python: http://www.ironpython.info/index.php/Typed_Arrays_in_IronPython -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Differences creating tuples and collections.namedtuples

2013-02-19 Thread Steven D'Aprano
unpacking > and repacking the arguments. It might not be obvious to the casual reader, but despite the leading underscore, _make is part of the public API for namedtuple: http://docs.python.org/2/library/collections.html#collections.namedtuple -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Differences creating tuples and collections.namedtuples

2013-02-19 Thread Steven D'Aprano
n.org/2/library/collections.html#collections.namedtuple -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Differences creating tuples and collections.namedtuples

2013-02-19 Thread Steven D'Aprano
unpacking > and repacking the arguments. It might not be obvious to the casual reader, but despite the leading underscore, _make is part of the public API for namedtuple: http://docs.python.org/2/library/collections.html#collections.namedtuple -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Differences creating tuples and collections.namedtuples

2013-02-19 Thread Steven D'Aprano
unpacking > and repacking the arguments. It might not be obvious to the casual reader, but despite the leading underscore, _make is part of the public API for namedtuple: http://docs.python.org/2/library/collections.html#collections.namedtuple -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Python problem

2013-02-19 Thread Steven D'Aprano
ood luck! > I need this right now. > Thanks for your time. > > I need this ASAP Then you better get started straight away then. Turn off Facebook and Twitter and do some real work. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Data Tree urgent help!!!!!!

2013-02-20 Thread Steven D'Aprano
.split()) > > So I was wondering why you used Name. I'm wondering why you used map. apple, pear, dog, cat, fork, spoon = "apple pear dog cat fork spoon".split() :-) -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Data Tree urgent help!!!!!!

2013-02-20 Thread Steven D'Aprano
se my monkey-patch easily: py> reload(__builtin__) py> map(str, "apple, pear, dog".split()) ['apple,', 'pear,', 'dog'] -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Awsome Python - chained exceptions

2013-02-20 Thread Steven D'Aprano
ws client, there are various free ones available, starting with Thunderbird. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Confusing math problem

2013-02-22 Thread Steven D'Aprano
On Fri, 22 Feb 2013 08:23:27 +1100, Chris Angelico wrote: > and you can cast out 1's in binary to find out if it's a > multiple of 1, too. O_o I wanna see the numbers that aren't a multiple of 1. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Confusing math problem

2013-02-22 Thread Steven D'Aprano
integer exponentiation and floating point exponentiation are more frequently different than not. (8105 of the calculations differ, 1696 of them are the same.) -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Differences creating tuples and collections.namedtuples

2013-02-22 Thread Steven D'Aprano
On Tue, 19 Feb 2013 22:38:32 -0500, Terry Reedy wrote: > On 2/18/2013 7:18 PM, Steven D'Aprano wrote: >> Terry Reedy wrote: >> >>> On 2/18/2013 6:47 AM, John Reid wrote: >>> >>>> I was hoping namedtuples could be used as replacements for tuples &g

Re: subclassable types

2013-02-22 Thread Steven D'Aprano
TypeError: cannot derive from IronPython.Runtime.XRange because it is sealed > Also: can you use introspection to find out whether a type is valid as a > base type? I don't believe so, but welcome correction. I would just try. If it succeeds, it will succeed, otherwise it will raise TypeError. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

<    85   86   87   88   89   90   91   92   93   94   >