Re: Encrypt python files

2015-05-05 Thread Steven D'Aprano
On Wednesday 06 May 2015 16:37, Palpandi wrote: > Hi, > > What are the ways to encrypt python files? The same as the ways to encrypt any other file. Your encryption program shouldn't care whether you are encrypting text files, JPEGs, mp3 audio files, executable binary code, Python scripts, or

Re: Throw the cat among the pigeons

2015-05-06 Thread Steven D'Aprano
On Wednesday 06 May 2015 15:58, Ian Kelly wrote: > On Tue, May 5, 2015 at 7:27 PM, Steven D'Aprano > wrote: >> Only the minimum is statistically useful. > > I disagree. The minimum tells you how fast the code *can* run, under > optimal circumstances. The

Re: Encrypt python files

2015-05-06 Thread Steven D'Aprano
On Wednesday 06 May 2015 17:23, Palpandi wrote: > On Wednesday, May 6, 2015 at 12:07:13 PM UTC+5:30, Palpandi wrote: >> Hi, >> >> What are the ways to encrypt python files? > > No, I just want to hide the scripts from others. Why, are you ashamed of your code? Python is free, open source softw

Re: Encrypt python files

2015-05-06 Thread Steven D'Aprano
discussion of their internals: http://nedbatchelder.com/blog/200804/the_structure_of_pyc_files.html -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Bitten by my C/Java experience

2015-05-06 Thread Steven D'Aprano
as a unary prefix operator: py> - --- +++ + - - + -- +++ --- 999 -999 Is that ugly, horrible code that nobody in their right mind would use in production? Absolutely. But the compiler can and should accept it, and linters (or human reviewers) should warn about it. -- Steven -- ht

Re: PEP idea: On Windows, subprocess should implicitly support .bat and .cmd scripts by using FindExecutable from win32 API

2015-05-06 Thread Steven D'Aprano
On Thursday 07 May 2015 12:19, Chris Angelico wrote: > On Thu, May 7, 2015 at 10:58 AM, Dave Angel wrote: >> There's nothing Windows-specific about that behaviour. In Linux, there >> are >> bash commands that can only be run by using shell=True. Fortunately >> Popen didn't make the mistake of p

Re: Is this unpythonic?

2015-05-08 Thread Steven D'Aprano
experienced pythonista react on seeing this when reviewing my > code? I would change it to z=None *unless* you actually required the list to be mutated, e.g. if you were using it as a cache. Does z have to be a list? Could you use an empty tuple instead? def x(y, z=()): ... -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Why is array.array('u') deprecated?

2015-05-08 Thread Steven D'Aprano
F-8 uses 1-4 bytes per character * UTF-16 uses 2 or 4 bytes per character while UTF-32 is fixed-width (4 bytes per character). So you could try faking it with a 32-bit array and filling it with string.encode('utf-32'). -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: To pickle or not to pickle

2015-05-08 Thread Steven D'Aprano
d spend the extra effort to build in support for at least pickle, JSON and plists, and let the user decide what they prefer. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Is this unpythonic?

2015-05-08 Thread Steven D'Aprano
situation where I pass in a > dictionary instead of a list, so that would not work. Why wouldn't it work? If it worked with an empty list, it will probably work with an empty tuple instead. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: functions, optional parameters

2015-05-08 Thread Steven D'Aprano
as an ordinary value, you can create your own private sentinel value: _SENTINEL = object() def spam(eggs=_SENTINEL): if eggs is _SENTINEL: eggs = something_else -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: functions, optional parameters

2015-05-08 Thread Steven D'Aprano
On Sat, 9 May 2015 01:48 am, Ian Kelly wrote: > On May 8, 2015 9:26 AM, "Steven D'Aprano" < > [email protected]> wrote: >> >> Do you think that Python will re-compile the body of the function every > time >> you call it? Setting

Re: functions, optional parameters

2015-05-08 Thread Steven D'Aprano
On Sat, 9 May 2015 02:02 am, Chris Angelico wrote: > On Sat, May 9, 2015 at 1:48 AM, Ian Kelly wrote: >> On May 8, 2015 9:26 AM, "Steven D'Aprano" >> wrote: >>> >>> Do you think that Python will re-compile the body of the function every >>

Re: Delivery Status Notification (Failure)

2015-05-08 Thread Steven D'Aprano
r dealing with misuse of email??? I see the original email didn't separate the body of the message from the user's signature with a '-- ' either. WILL THEIR CRIMES NEVER END/?? *wink* -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: functions, optional parameters

2015-05-08 Thread Steven D'Aprano
On Sat, 9 May 2015 03:49 am, Chris Angelico wrote: > On Sat, May 9, 2015 at 3:36 AM, Steven D'Aprano > wrote: >> On Sat, 9 May 2015 02:02 am, Chris Angelico wrote: >>> Aside from constructing two closures in the same context and proving >>> that their __code__

Re: SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape

2015-05-08 Thread Steven D'Aprano
possibly get a SyntaxError at compile time because the path is too long. You must have made other changes at the same time, such as using a raw string r'C: ... \Users\ ...'. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Jython from bathc file?

2015-05-09 Thread Steven D'Aprano
on't remember .bat syntax, but perhaps it is something like this? CLASSPATH=$CLASSPATH:$RDBASE/Code/JavaWrappers/gmwrapper/org.RDKit.jar; jython -Djava.library.path=$RDBASE/Code/JavaWrappers/gmwrapper myscript.py And that's it. Does that work? Any Windows users like to comment? -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape

2015-05-09 Thread Steven D'Aprano
ried to open a file, but the file doesn't exist. They're a little bit different, don't you agree? -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: functions, optional parameters

2015-05-09 Thread Steven D'Aprano
iven that we don't, and only have one or the other, using early binding is much more sensible. This is the point where some people try to suggest some sort of complicated, fragile, DWIM heuristic where the compiler tries to guess whether the user actually wants the default to use early or late binding, based on what the expression looks like. "0 is an immutable int, use early binding; [] is a mutable list, use late binding." sort of thing. Such a thing might work well for the obvious cases, but it would be a bugger to debug and work-around for the non-obvious cases when it guesses wrong -- and it will. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: functions, optional parameters

2015-05-09 Thread Steven D'Aprano
On Sun, 10 May 2015 01:33 pm, Chris Angelico wrote: > On Sun, May 10, 2015 at 12:45 PM, Steven D'Aprano > wrote: >> This is the point where some people try to suggest some sort of >> complicated, fragile, DWIM heuristic where the compiler tries to guess >> whethe

Re: functions, optional parameters

2015-05-09 Thread Steven D'Aprano
On Sun, 10 May 2015 01:35 pm, Rustom Mody wrote: > On Sunday, May 10, 2015 at 8:16:07 AM UTC+5:30, Steven D'Aprano wrote: >> I predict that the majority of the time, late binding would just be a >> pointless waste of time: >> >> def process_string(thestr, start=0,

Calling a function is faster than not calling it?

2015-05-10 Thread Steven D'Aprano
that calling eval() on a string was slow, as it has to parse and compile the source code into byte code before it can evaluate it, but this is pre-compiled and shouldn't have that overhead. So what's going on? -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Calling a function is faster than not calling it?

2015-05-10 Thread Steven D'Aprano
g eval(code, ns) takes about 1.6 times as long as calling the function; calling eval(code) without providing a namespace takes about 3.2 times as long. That's roughly consistent with the results I'm getting. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Calling a function is faster than not calling it?

2015-05-10 Thread Steven D'Aprano
On Sun, 10 May 2015 08:34 pm, Christian Gollwitzer wrote: > Am 10.05.15 um 11:58 schrieb Steven D'Aprano: >> Why is calling a function faster than bypassing the function object and >> evaluating the code object itself? And not by a little, but by a lot? >> >>

Re: anomaly

2015-05-10 Thread Steven D'Aprano
want to > override a builtin within your own namespace, who are we to stop you? > Besides, it's still available as __builtins__.int (unless you've also > overridden that). Don't use __builtins__ that is a private implementation detail. The correct way to access the built-in namespace explicitly is: import __builtin__ # Python 2 import builtins # Python 3 -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Instead of deciding between Python or Lisp for a programming intro course...What about an intro course that uses *BOTH*? Good idea?

2015-05-10 Thread Steven D'Aprano
to know about the syntax. *wink* The point is, syntax can be *too* minimal, as well as too heavyweight. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Calling a function is faster than not calling it?

2015-05-10 Thread Steven D'Aprano
On Mon, 11 May 2015 07:08 am, BartC wrote: > On 10/05/2015 10:58, Steven D'Aprano wrote: >> from timeit import Timer >> >> def func(): >> a = 2 >> b = 3 >> c = 4 >> return (a+b)*(a-b)/(a*c + b*c) >> >> >>

Re: Why does unicode-escape decode escape symbols that are already escaped?

2015-05-10 Thread Steven D'Aprano
spectively, but str->str and bytes->bytes codecs are useful to. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: anomaly

2015-05-10 Thread Steven D'Aprano
On Monday 11 May 2015 10:57, zipher wrote: > I guess everyone expects this behavior since Python implemented this idea > of "everything is an object", but I think this branch of OOP (on the > branch of the Tree of Programming Languages) has to be chopped off. The > idea of everything is an object

Re: Confessions of a Python fanboy

2015-05-10 Thread Steven D'Aprano
On Monday 11 May 2015 11:46, zipher wrote: > By having methods like len() in your built-in namespace when it's really > only relevant to objects that are types of containers, you blur one > primary component of OOP: encapsulation. Gosh, one would almost think that Python's concept of OOP wasn't

Re: anomaly

2015-05-10 Thread Steven D'Aprano
On Monday 11 May 2015 10:14, Mark Rosenblitt-Janssen wrote: > In case the example given at the start of the thread wasn't > interesting enough, it also works in the other direction: > class str(int): pass > str('2') > 2 #<- an integer!!! Thank the gods that you're around to poi

Re: anomaly

2015-05-11 Thread Steven D'Aprano
ly everything can be redefined. Or one can take a middle-road, where certain syntactic elements, and a very small number of constant values, are made keywords, and everything else is free to be redefined. There's no a priori reason for any of those choices. But there are reasons. -- Steven

Re: Feature Request: Reposition Execution

2015-05-11 Thread Steven D'Aprano
rong. >> > > os.kill() > > then in your process, handle the exception, and do whatever you think is > worthwhile. Are you suggesting that the app sends itself a signal? Is that even allowed? -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: anomaly

2015-05-11 Thread Steven D'Aprano
hey don't invalidate the fact that "consenting adults" is a basic design principle of Python. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: anomaly

2015-05-11 Thread Steven D'Aprano
On Tue, 12 May 2015 12:23 am, zipher wrote: > On Monday, May 11, 2015 at 1:11:26 AM UTC-5, Steven D'Aprano wrote: >> On Monday 11 May 2015 10:57, zipher wrote: >> > I guess everyone expects this behavior since Python implemented this >> > idea of "everything i

Re: anomaly

2015-05-11 Thread Steven D'Aprano
) We need better tools which extend our abilities to write bug-free code, and those tools are new programming languages and code analysis tools. They put us in control, they don't take it away. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: anomaly

2015-05-11 Thread Steven D'Aprano
d. Yes, I'm sure that from where you are floating around in space way beyond the stratosphere, we must all look like feeble-minded ants. http://www.joelonsoftware.com/articles/fog000018.html But at least we know what is valid Python and what isn't. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Instead of deciding between Python or Lisp for a programming intro course...What about an intro course that uses *BOTH*? Good idea?

2015-05-11 Thread Steven D'Aprano
e to C... -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: anomaly

2015-05-11 Thread Steven D'Aprano
On Tue, 12 May 2015 06:48 am, Mel Wilson wrote: > On Tue, 12 May 2015 02:35:23 +1000, Steven D'Aprano wrote: > >> On Mon, 11 May 2015 11:37 pm, Mel Wilson wrote: >> >>> On Sun, 10 May 2015 14:12:44 -0500, boB Stepp wrote: >>> >>>> I have

Re: anomaly

2015-05-12 Thread Steven D'Aprano
orst consequences (no seg faults), but otherwise you're trusted to look after yourself. To give an analogy, you can consent to having a boxing match, with rules, a referee, and clear limits on what force is permissible, but you cannot legally consent to a duel to the death. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Instead of deciding between Python or Lisp for a programming intro course...What about an intro course that uses *BOTH*? Good idea?

2015-05-12 Thread Steven D'Aprano
ned to show (rather than tell) the differences between printing a result and returning a result, and how they effect re-usability of software components and function chaining. Using a procedural language is *perfect* for that, since you can highlight the differences: function foo(n:int): int; begin

uPy Unicode [was Re: Instead of deciding between Python or Lisp blah blah blah]

2015-05-12 Thread Steven D'Aprano
t a link to that? I must have missed it. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Updating a package on PyPi, testing and etiquette

2015-05-12 Thread Steven D'Aprano
wish people wouldn't say that. They're different languages in the same sense that American English and British English are different languages. I prefer to emphasise the 98% similarities by calling them different dialects than the 2% differences -- especially since it has turned out to be far easier and more practical to write hybrid 2.x + 3.x code than anyone imagined back in the Python 3000 days. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Instead of deciding between Python or Lisp for a programming intro course...What about an intro course that uses *BOTH*? Good idea?

2015-05-12 Thread Steven D'Aprano
o generate webpages on the fly" lead to PHP. "I want to write interactive fiction and text-based games" lead to Inform. And so forth. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: anomaly

2015-05-12 Thread Steven D'Aprano
On Wednesday 13 May 2015 02:22, Skip Montanaro wrote: > I did find this interesting blog post about encapsulation and > test-driven development: > > https://jasonmbaker.wordpress.com/2009/01/08/enemies-of-test-driven- development-part-i-encapsulation/ > > I found the author's perspective interes

Re: Feature Request: Reposition Execution

2015-05-13 Thread Steven D'Aprano
On Wednesday 13 May 2015 17:27, Christian Gollwitzer wrote: > A clean way to exit your script could be to raise an exception. It > should propagate to the toplevel and halt your script. However it is not > possible to back and resume the execution. while True: try: run_script() # May

Re: Basic misunderstanding on object creation

2015-05-13 Thread Steven D'Aprano
. I agree with that. It takes two to be offended: one to give offense, and one to take it. Nobody can force you to be offended. Either Tim or Terry could have refused to take offense. Instead of asking a rhetorical question about people acting like dicks, Andrew could have thought "Terry's response sounds a bit dickish, but he probably didn't mean it to come across as rude"; instead of defending his choice of words in a patronising tone Terry could have said "Hmmm, yes my response did make me sound a bit rude, but that wasn't intended". (Unless of course it was intended to be rude. But perhaps that is too obvious to need saying.) *wink* -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Looking for direction

2015-05-13 Thread Steven D'Aprano
d data in a dict for row in myList: account, staff = row[0:2] key = (account, staff) # Put them in a tuple. if key in processed: # We've already seen this combination. processed[key][3] += row[3] # Add the quantities. else: # Never seen this combination before. processed[key] = row newlist = list(processed.values()) Does that help? -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Instead of deciding between Python or Lisp for a programming intro course...What about an intro course that uses *BOTH*? Good idea?

2015-05-13 Thread Steven D'Aprano
as. >> >> LISP is also the reason why we're cursed with the terrible name >> "lambda" for anonymous functions rather than something more mnemonic >> (like "function"). > > No, you haven't understood, padawan. Lambda *is* the function, not it's > definition. Perhaps you will understand what I mean by that, perhaps you > won't. It's subtle. Subtle like a kick to the head. Mark, you seem to be labouring under the delusion that we don't agree with you because we "boneheads" don't understand what you are talking about. That's wrong. We understand what you are talking about. We don't agree with you because half of your thesis is wrong and the other half is not even wrong. If you wish to change our minds, you're going to have to demonstrate objective, verifiable facts and not just allude to how your ideas are too subtle and clever for us. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Survey -- Move To Trash function in Python?

2015-05-14 Thread Steven D'Aprano
feature-freeze and could gain no more functionality? -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Survey -- Move To Trash function in Python?

2015-05-14 Thread Steven D'Aprano
On Fri, 15 May 2015 01:49 am, Grant Edwards wrote: > On 2015-05-14, Steven D'Aprano > wrote: > >> I'd like to do a little survey, and get a quick show of hands. >> >> How many people have written GUI or text-based applications or >> scripts where a &q

Re: a python pitfall

2015-05-14 Thread Steven D'Aprano
inconsistent with everything else in Python) and get it wrong: people assume that function defaults are late binding, but they are not. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Survey -- Move To Trash function in Python?

2015-05-14 Thread Steven D'Aprano
On Fri, 15 May 2015 03:32 am, Dave Farrance wrote: > Steven D'Aprano wrote: > >>I'd like to do a little survey, and get a quick show of hands. >> >>How many people have written GUI or text-based applications or scripts >>where a "Move file to trash&q

Re: Survey -- Move To Trash function in Python?

2015-05-14 Thread Steven D'Aprano
On Fri, 15 May 2015 01:59 am, Chris Angelico wrote: > On Fri, May 15, 2015 at 1:49 AM, Grant Edwards > wrote: >> On 2015-05-14, Steven D'Aprano >> wrote: >> >>> I'd like to do a little survey, and get a quick show of hands. >>> >>> H

Re: Survey -- Move To Trash function in Python?

2015-05-14 Thread Steven D'Aprano
mplemented at the application layer (desktop management being an application for these purposes). As far as the file system is concerned, it is just a file rename, or very occasionally if the implementation is lousy, a copy followed by delete. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Building CPython

2015-05-15 Thread Steven D'Aprano
... having said all that... how do you know that these issues are bottlenecks that eliminating them would speed up the code by any significant amount? -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Building CPython

2015-05-15 Thread Steven D'Aprano
artificial benchmark, involving creating and throwing away many strings as fast as possible without doing any work with them, and from this has built this fantasy in his head that Python is not compliant with the Unicode spec and is logically, mathematically broken. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Building CPython

2015-05-15 Thread Steven D'Aprano
who knows what side-effects the __get__ method might have. How much time would it save? Probably very little. After all, unless the method call itself did bugger-all work, the time to create the method object is probably insignificant. But it's a possible optimization. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Minimising stack trace

2015-05-15 Thread Steven D'Aprano
way to make this a >> lot shorter. Now I ‘lose’ interesting information because of the length >> of the stack trace. > > <http://www.catb.org/~esr/faqs/smart-questions.html> There ought to be a website that explains how to give smart answers. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Building CPython

2015-05-15 Thread Steven D'Aprano
-time, and takes no more time than foo.cheese but in Python's case it has to be resolved at run-time, so if you care about speed, you should try to avoid long chains of dots in performance critical loops. E.g. instead of: for x in sequence: foo.bar.baz.foobar.spam.eggs.cheese(x) you can write: cheese = foo.bar.baz.foobar.spam.eggs.cheese for x in sequence: cheese(x) -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Building CPython

2015-05-16 Thread Steven D'Aprano
most people; Also, at least with Python's implementation, a couple of mixed blessings: ± closures are closed against modification; ± internals of the closure are strictly private; -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Building CPython

2015-05-16 Thread Steven D'Aprano
On Sat, 16 May 2015 11:59 pm, Marko Rauhamaa wrote: > Steven D'Aprano : > >> A couple more negatives: >> >> - no such thing as inheritance; > > Untrue. My simple Scheme object system (125 lines incl. documentation) Ah yes, I've seen Javascript code lik

Re: Rule of order for dot operators?

2015-05-16 Thread Steven D'Aprano
eading the first example as character replacement first and title > capitalization second, and the second example as title capitalization > first and character replacement second. > > Does python perform the dot operators from left to right or according to > a rule of order (i.e., multiplication/division before add/subtract)? Left to right. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Rule of order for dot operators?

2015-05-16 Thread Steven D'Aprano
s? >> Noobie > > What? Where? When? Why? How? I'm pretty sure you've been on the Internet for long enough to know what "noobie", "n00b", "newbie" etc mean. But just in case you need help: http://lmgtfy.com/?q=noobie -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Python 3: yum is dead, long live dnf!

2015-05-17 Thread Steven D'Aprano
As part of Red Hat's move to Python 3, yum is officially deprecated and replaced by dnf: http://dnf.baseurl.org/2015/05/11/yum-is-dead-long-live-dnf/ Quote: Yum would not survive the “Python 3 as default” Fedora initiative meanwhile DNF is able to run on Python 2 and Python 3.

Re: Python 3: yum is dead, long live dnf!

2015-05-18 Thread Steven D'Aprano
On Mon, 18 May 2015 08:18 pm, alister wrote: > On Mon, 18 May 2015 15:21:05 +1000, Steven D'Aprano wrote: > >> As part of Red Hat's move to Python 3, yum is officially deprecated and >> replaced by dnf: >> >> http://dnf.baseurl.org/2015/05/11

Re: Slices time complexity

2015-05-18 Thread Steven D'Aprano
On Tuesday 19 May 2015 12:20, Rustom Mody wrote: > I must say I am impressed by C#/.Net for making the value/object > distinction first-class all the way from language to VM. I'm not sure what you mean by that. Are you referring to something similar to Java's distinction between native/unboxed t

Re: Slices time complexity

2015-05-19 Thread Steven D'Aprano
On Tuesday 19 May 2015 17:12, Marko Rauhamaa wrote: > Can you get Python without getting a language like C first? Yes. There are a few senses in which C is very important to Python. Python was designed to be a glue language for interoperability with C libraries, so that's a very important sen

Re: Slices time complexity

2015-05-19 Thread Steven D'Aprano
On Tuesday 19 May 2015 15:33, Rustom Mody wrote: > However conceptually/pedagogically making a fundamenal distinction of > timeless | time > value | object > immutable | mutable > expression | statement > function | procedure > > is key to getting programming [and is something that Pascal got bet

Re: Slices time complexity

2015-05-19 Thread Steven D'Aprano
Python. There's not as much Go code in the world as Python code, so that will be far less disruptive. Tell them that Go should be just like Python, otherwise it will confuse users who expect Go slices to behave like Python slices. Do let us know what the Go designers say. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Slices time complexity

2015-05-19 Thread Steven D'Aprano
On Tuesday 19 May 2015 18:39, Marko Rauhamaa wrote: > What I'm saying is that it doesn't matter what semantic description you > give Python constructs as long as the observed behavior is correct. You really think that it doesn't matter which of the following two explanations I give for this beha

Re: Slices time complexity

2015-05-19 Thread Steven D'Aprano
s, that is one of the best explanations for why "references equals pointers" is *not* a good explanation for Python's behaviour. I may have to steal it :-) -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Slices time complexity

2015-05-19 Thread Steven D'Aprano
hon. In C, they are. References in Python are not values at all, so they are not first-class values. Pointers in C are values, and first-class values at that. Arrays, on the other hand, are values but not first-class values in C: you cannot do array assignment, pass an entire array by value, or return an array from a function. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Slices time complexity

2015-05-19 Thread Steven D'Aprano
On Wed, 20 May 2015 12:52 am, Bartc wrote: > "Steven D'Aprano" wrote in message > news:[email protected]... [...] >> I'm sure that lots of things surprise people who assume that every >> language's performance charact

Re: Slices time complexity

2015-05-19 Thread Steven D'Aprano
On Wed, 20 May 2015 01:59 am, Marko Rauhamaa wrote: > Steven D'Aprano : > >> To be useful, explanations ought to give the user *predictive power* >> -- if I calculate 32767 + 1, what will Python do? >> >> Explanation #1 predicts that Python will retur

Re: Slices time complexity

2015-05-19 Thread Steven D'Aprano
On Wed, 20 May 2015 04:19 am, Marko Rauhamaa wrote: > Steven D'Aprano : > >> On Wed, 20 May 2015 01:59 am, Marko Rauhamaa wrote: >>> You're slaying straw men. >> >> "I was wrong, but I don't want to admit it" is not spelled "straw m

Re: Slices time complexity

2015-05-19 Thread Steven D'Aprano
xtensively, so much so that they had a name, "handle". Technically though handles were managed by the Macintosh Toolbox routines, so slightly different from what you are talking about. But in standard Pascal, you certainly could create pointers to pointers. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Slices time complexity

2015-05-19 Thread Steven D'Aprano
On Wed, 20 May 2015 10:31 am, Gregory Ewing wrote: > Steven D'Aprano wrote: >> Chris, that is one of the best explanations for why "references equals >> pointers" is *not* a good explanation for Python's behaviour. > > Many people here seem to have lost s

Re: Rule of order for dot operators?

2015-05-19 Thread Steven D'Aprano
On Wed, 20 May 2015 11:36 am, Ned Batchelder wrote: > Steven and Denis: you were too blunt in your objections. Fair enough. In my defence, I'm from Australia, and we're notorious for calling a spade a bloody shovel. > Be considerate. Be respectful. -- Steven -- https:/

Re: Slices time complexity

2015-05-19 Thread Steven D'Aprano
On Wednesday 20 May 2015 14:30, Marko Rauhamaa wrote: > Steven D'Aprano : > >> There is a little magic elf hiding inside the computer, and when you >> type an expression like '2 + 3', little tiny hammers bang it out in >> Morse Code on the elf'

Re: Slices time complexity

2015-05-19 Thread Steven D'Aprano
On Wednesday 20 May 2015 14:30, Rustom Mody wrote: > And what about Java? > http://stackoverflow.com/questions/166033/value-semantics-and-pointer- semantics Congratulations, you have found yet another example of the Java community's collective delusion and insistence on misusing terms for the ma

Re: Slices time complexity

2015-05-19 Thread Steven D'Aprano
On Wednesday 20 May 2015 15:33, Steven D'Aprano wrote: > Someone sufficiently killed with an abacus Er, *skilled*. -- Steve -- https://mail.python.org/mailman/listinfo/python-list

List semantics [was Re: Slices time complexity]

2015-05-20 Thread Steven D'Aprano
On Wednesday 20 May 2015 16:23, Rustom Mody wrote: > I dont like teaching this. viz that in python > x = [[1,2],[1,2]] > is equal to y defined as > z = [1,2] > y = [z,z] > And although they are equal as in '==' they are not equal as in behavior, > memory usage etc, a fact that can only be elucidat

Re: List semantics [was Re: Slices time complexity]

2015-05-20 Thread Steven D'Aprano
On Wed, 20 May 2015 06:54 pm, Gregory Ewing wrote: > Steven D'Aprano wrote: > >> Code snippet 1: >> >> x = [[1,2],[1,2]] >> >> creates a list bound to the name "x", containing a list containing ints 1 >> and 2, and a second independe

Re: Slices time complexity

2015-05-20 Thread Steven D'Aprano
On Wednesday 20 May 2015 19:56, Bartc wrote: > "Steven D'Aprano" wrote in message > news:[email protected]... > >> The mental gymnastics they go through to force the round peg of pass-by- >> sharing object semantics into the f

Re: Slices time complexity

2015-05-21 Thread Steven D'Aprano
On Thursday 21 May 2015 05:51, Mario Figueiredo wrote: > On Wed, 20 May 2015 03:07:03 +1000, Steven D'Aprano > wrote: [...] >>But, really... if you're serious about dealing with huge arrays of data, >>you want something like numpy, not Python lists. > > You

Re: Find if a file existing within 1000s of folder/sub-folder - each file has a unique presence

2015-05-21 Thread Steven D'Aprano
On Thursday 21 May 2015 15:34, [email protected] wrote: > So I was trying to dir /s /b using python. > Now since the file's path name is computed using other part of the code, I > am feeding in a variable here and somehow it does not seem to work.. :( > > Intent is to run following command fr

Re: Slices time complexity

2015-05-21 Thread Steven D'Aprano
On Thu, 21 May 2015 11:34 pm, bartc wrote: > On Thursday, 21 May 2015 06:19:39 UTC+1, Steven D'Aprano wrote: >> On Wednesday 20 May 2015 19:56, Bartc wrote: > >> What you *shouldn't* do is implement your own argument convention, > > (That's exactly wha

Ah Python, you have spoiled me for all other languages

2015-05-22 Thread Steven D'Aprano
l for a DVD player, there would be a button to turn the volume up, skip to the next chapter, and turn subtitles off; and another button to change the language to French and return to the menus; but no way to just mute the sound. [1] Anything that good has got to be either illegal, immoral, or

Re: Ah Python, you have spoiled me for all other languages

2015-05-22 Thread Steven D'Aprano
false is falsey, and Boolean(false) is falsey, new Boolean(false) is truthy: js> arr = [false, Boolean(false), new Boolean(false)]; false,false,false js> for (i = 0; i < arr.length; ++i) { > print(arr[i]); > if (arr[i]) {print("Surprise!")} } false false false Surprise!

Re: Ah Python, you have spoiled me for all other languages

2015-05-23 Thread Steven D'Aprano
n build) Let's try again: py> c = u'\U0001' # a single code point py> len(c) 2 I'm not saying that it is impossible to have a correct Unicode implemention using UTF-16, but I've never seen one. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Ah Python, you have spoiled me for all other languages

2015-05-23 Thread Steven D'Aprano
he purposes of espionage and mass surveillance. I also don't see any reason why national governments would give up their existing certification powers. > The governments would also offer to certify anybody in the world free of > charge. Why would they do that? -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Ah Python, you have spoiled me for all other languages

2015-05-23 Thread Steven D'Aprano
On Sat, 23 May 2015 11:35 pm, Ned Batchelder wrote: > On Saturday, May 23, 2015 at 9:01:29 AM UTC-4, Steven D'Aprano wrote: >> On Sat, 23 May 2015 10:33 pm, Thomas 'PointedEars' Lahn wrote: >> >> > If only characters were represented as sequenc

Re: Human Rights and Justice in Islam

2015-05-24 Thread Steven D'Aprano
it to be hijacked about arguments about religion. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Ah Python, you have spoiled me for all other languages

2015-05-24 Thread Steven D'Aprano
On Sun, 24 May 2015 02:53 am, Marko Rauhamaa wrote: > Steven D'Aprano : > >> On Sat, 23 May 2015 10:44 pm, Marko Rauhamaa wrote: >>> Here's an idea: an authentication is considered valid if it is >>> vouched for by the United States, China, Russia *and* t

Re: mix-in classes

2015-05-24 Thread Steven D'Aprano
ose one can create a method in the parent class, that runs the mixin > methods in the same order as in the inheritance list, but would there be a > better way for Python to enforce such a practice so as not to create class > anarchy? (A problem for another topic.) Try strait: https://pypi.python.org/pypi/strait -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Documentaion of dunder methods

2015-05-25 Thread Steven D'Aprano
have been unable to find it. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: a more precise distance algorithm

2015-05-25 Thread Steven D'Aprano
0255787 alternate: 767.3916150255789 hypot: 767.3916150255787 which shows that: (1) It's not hard to find mismatches; (2) It's not obvious which of the three methods is more accurate. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Documentaion of dunder methods

2015-05-25 Thread Steven D'Aprano
On Tue, 26 May 2015 12:17 pm, Steven D'Aprano wrote: > In other words, dunder methods are reserved for use by the core developers > for the use of the Python interpreter. Er, that's easy to misinterpret. Let me try rewording: You should not invent new dunder methods. And

Re: Creating a reliable sandboxed Python environment

2015-05-26 Thread Steven D'Aprano
On Tuesday 26 May 2015 12:24, [email protected] wrote: > I am writing a web service that accepts Python programs as input, runs the > provided program with some profiling hooks, and returns various > information about the program's runtime behavior. To do this in a safe > manner, I need to be ab

<    72   73   74   75   76   77   78   79   80   81   >