Re: Differences of "!=" operator behavior in python3 and python2 [ bug? ]

2013-05-12 Thread Rotwang
On 13/05/2013 00:40, Ian Kelly wrote: On Sun, May 12, 2013 at 5:23 PM, Mr. Joe wrote: I seem to stumble upon a situation where "!=" operator misbehaves in python2.x. Not sure if it's my misunderstanding or a bug in python implementation. Here's a demo code to reproduce the behavior - The != o

Re: Default Value

2013-06-21 Thread Rotwang
On 21/06/2013 18:01, Rick Johnson wrote: [stuff] It isn't clear to me from your posts what exactly you're proposing as an alternative to the way Python's default argument binding works. In your version of Python, what exactly would happen when I passed a mutable argument as a default value

Re: Default Value

2013-06-21 Thread Rotwang
On 21/06/2013 19:26, Rick Johnson wrote: On Friday, June 21, 2013 12:47:56 PM UTC-5, Rotwang wrote: It isn't clear to me from your posts what exactly you're proposing as an alternative to the way Python's default argument binding works. In your version of Python, what exactly wo

Re: Default Value

2013-06-21 Thread Rotwang
On 22/06/2013 02:15, Rick Johnson wrote: On Friday, June 21, 2013 6:40:51 PM UTC-5, Rotwang wrote: On 21/06/2013 19:26, Rick Johnson wrote: [...] I didn't ask what alternative methods of handling default argument binding exist (I can think of several, but none of them strikes me as prefe

Re: Default Value

2013-06-21 Thread Rotwang
On 22/06/2013 03:18, Chris Angelico wrote: On Sat, Jun 22, 2013 at 12:01 PM, Rotwang wrote: class hashablelist(list): ... def __hash__(self): ... return hash(tuple(self)) There's a vulnerability in that definition: a=hashablelist((1,[],3)) a [1, [], 3] {a:1} Traceback

Re: Default Value

2013-06-22 Thread Rotwang
On 22/06/2013 03:01, I wrote: On 22/06/2013 02:15, Rick Johnson wrote: [...] This is what should happen: py> def foo(arg=[]): ... arg.append(1) ... print(arg) ... py> foo() [1] py> foo() [1] py> foo() [1] Yes, Yes, YES! That is intuiti

Re: Default Value

2013-06-22 Thread Rotwang
On 22/06/2013 19:49, Rick Johnson wrote: On Saturday, June 22, 2013 12:19:31 PM UTC-5, Rotwang wrote: On 22/06/2013 02:15, Rick Johnson wrote: IS ALL THIS REGISTERING YET? DO YOU UNDERSTAND? No, I don't. These two special cases are not sufficient for me to determine what semantics yo

Re: What is the semantics meaning of 'object'?

2013-06-23 Thread Rotwang
On 23/06/2013 18:29, Steven D'Aprano wrote: On Sat, 22 Jun 2013 23:40:53 -0600, Ian Kelly wrote: [...] Can you elaborate or provide a link? I'm curious to know what other reason there could be for magic methods to behave differently from normal methods in this regard. It's an efficiency opti

Re: What is the semantics meaning of 'object'?

2013-06-24 Thread Rotwang
On 24/06/2013 07:31, Steven D'Aprano wrote: On Mon, 24 Jun 2013 02:53:06 +0100, Rotwang wrote: On 23/06/2013 18:29, Steven D'Aprano wrote: On Sat, 22 Jun 2013 23:40:53 -0600, Ian Kelly wrote: [...] Can you elaborate or provide a link? I'm curious to know what other reason

Re: What is the semantics meaning of 'object'?

2013-06-26 Thread Rotwang
On 25/06/2013 23:57, Chris Angelico wrote: On Wed, Jun 26, 2013 at 8:38 AM, Mark Janssen wrote: Combining integers with sets I can make a Rational class and have infinite-precision arithmetic, for example. Combining two integers lets you make a Rational. Python integers are already infinite-p

Re: Default scope of variables

2013-07-04 Thread Rotwang
Sorry to be OT, but this is sending my pedantry glands haywire: On 04/07/2013 08:06, Dave Angel wrote: On 07/04/2013 01:32 AM, Steven D'Aprano wrote: Well, if I ever have more than 63,000,000 variables[1] in a function, I'll keep that in mind. [1] Based on empirical eviden

Re: Default scope of variables

2013-07-04 Thread Rotwang
On 05/07/2013 02:24, Steven D'Aprano wrote: On Thu, 04 Jul 2013 17:54:20 +0100, Rotwang wrote: [...] Anyway, none of the calculations that has been given takes into account the fact that names can be /less/ than one million characters long. Not in *my* code they don't!!! *wi

Re: Explain your acronyms (RSI?)

2013-07-06 Thread Rotwang
On 06/07/2013 20:38, Terry Reedy wrote: "rms has crippling RSI" (anonymous, as quoted by Skip). I suspect that 'rms' = Richard M Stallman (but why lower case? to insult him?). I 'know' that RSI = Roberts Space Industries, a game company whose Kickstarter project I supported. Whoops, wrong contex

Re: Simple recursive sum function | what's the cause of the weird behaviour?

2013-07-06 Thread Rotwang
On 06/07/2013 19:43, Joshua Landau wrote: On 6 July 2013 13:59, Russel Walker wrote: Since I've already wasted a thread I might as well... Does this serve as an acceptable solution? def supersum(sequence, start=0): result = type(start)() for item in sequence: try:

Re: Simple recursive sum function | what's the cause of the weird behaviour?

2013-07-06 Thread Rotwang
On 06/07/2013 21:10, Rotwang wrote: [...] It's not quite clear to me what the OP's intentions are in the general case, but calling supersum(item, start) seems odd - for example, is the following desirable? >>> supersum([[1], [2], [3]], 4) 22 I would have thought that t

Re: Explain your acronyms (RSI?)

2013-07-06 Thread Rotwang
On 06/07/2013 21:11, Stefan Behnel wrote: Rotwang, 06.07.2013 21:51: On 06/07/2013 20:38, Terry Reedy wrote: "rms has crippling RSI" (anonymous, as quoted by Skip). [...] Let us try Google. Type in RSI and it offers 'RSI medications' as a choice. Sound good, as it wi

Re: Unexpected results comparing float to Fraction

2013-07-29 Thread Rotwang
On 29/07/2013 17:40, Ian Kelly wrote: On Mon, Jul 29, 2013 at 10:20 AM, Chris Angelico wrote: On Mon, Jul 29, 2013 at 5:09 PM, MRAB wrote: I'm surprised that Fraction(1/3) != Fraction(1, 3); after all, floats are approximate anyway, and the float value 1/3 is more likely to be Fraction(1, 3)

Re: Unexpected results comparing float to Fraction

2013-07-29 Thread Rotwang
On 29/07/2013 17:20, Chris Angelico wrote: On Mon, Jul 29, 2013 at 5:09 PM, MRAB wrote: I'm surprised that Fraction(1/3) != Fraction(1, 3); after all, floats are approximate anyway, and the float value 1/3 is more likely to be Fraction(1, 3) than Fraction(6004799503160661, 18014398509481984).

Re: Script that converts between indentation and curly braces in Python code

2013-07-31 Thread Rotwang
On 31/07/2013 14:55, Chris Angelico wrote: [...] Since the braced version won't run anyway, how about a translation like this: def foo(): print("""Hello, world!""") for i in range(5): foo() return 42 --> 0-def foo(): 4-print("""Hello, 0-world!""") 4-for i in range(5):

Strange threading behaviour

2012-06-21 Thread Rotwang
Hi all, I'm using Python 2.7.2 on Windows 7 and a module I've written is acting strangely. I can reproduce the behaviour in question with the following: --- begin bugtest.py --- import threading, Tkinter, os, pickle class savethread(threading.Thread): def __init__(self, value): th

Re: Strange threading behaviour

2012-06-21 Thread Rotwang
On 21/06/2012 18:07, Dave Angel wrote: On 06/21/2012 11:19 AM, Rotwang wrote: Hi all, I'm using Python 2.7.2 on Windows 7 and a module I've written is acting strangely. I can reproduce the behaviour in question with the following: --- begin bugtest.py --- import threading, Tkinter,

Re: Strange threading behaviour

2012-06-21 Thread Rotwang
On 21/06/2012 18:37, Dennis Lee Bieber wrote: On Thu, 21 Jun 2012 16:19:41 +0100, Rotwang declaimed the following in gmane.comp.python.general: import threading, Tkinter, os, pickle class savethread(threading.Thread): def __init__(self, value): threading.Thread.__init__(self

cPickle - sharing pickled objects between scripts and imports

2012-06-23 Thread Rotwang
Hi all, I have a module that saves and loads data using cPickle, and I've encountered a problem. Sometimes I want to import the module and use it in the interactive Python interpreter, whereas sometimes I want to run it as a script. But objects that have been pickled by running the module as a

Re: cPickle - sharing pickled objects between scripts and imports

2012-06-23 Thread Rotwang
On 23/06/2012 17:13, Peter Otten wrote: Rotwang wrote: Hi all, I have a module that saves and loads data using cPickle, and I've encountered a problem. Sometimes I want to import the module and use it in the interactive Python interpreter, whereas sometimes I want to run it as a script

Re: cPickle - sharing pickled objects between scripts and imports

2012-06-23 Thread Rotwang
On 23/06/2012 18:31, Dave Angel wrote: On 06/23/2012 12:13 PM, Peter Otten wrote: Rotwang wrote: Hi all, I have a module that saves and loads data using cPickle, and I've encountered a problem. Sometimes I want to import the module and use it in the interactive Python interpreter, wh

Re: cPickle - sharing pickled objects between scripts and imports

2012-06-25 Thread Rotwang
On 24/06/2012 00:17, Steven D'Aprano wrote: On Sat, 23 Jun 2012 19:14:43 +0100, Rotwang wrote: The problem is that if the object was pickled by the module run as a script and then unpickled by the imported module, the unpickler looks in __main__ rather than mymodule for the object's

Re: ANN: Celery 3.0 (chiastic slide) released!

2012-07-07 Thread Rotwang
On 07/07/2012 19:26, Ask Solem wrote: === Celery 3.0 (Chiastic Slide) Released! === Does this have anything to do with the Autechre album? -- I have made a thing that superficially resembles music: http://soundc

Re: lambda in list comprehension acting funny

2012-07-12 Thread Rotwang
On 12/07/2012 04:59, Steven D'Aprano wrote: On Wed, 11 Jul 2012 08:41:57 +0200, Daniel Fetchinson wrote: funcs = [ lambda x: x**i for i in range( 5 ) ] Here's another solution: from functools import partial funcs = [partial(lambda i, x: x**i, i) for i in range(5)] Notice that the arguments

Re: Sudden doubling of nearly all messages

2012-07-22 Thread Rotwang
On 21/07/2012 19:16, Rick Johnson wrote: [...] It's due to the new Google Groups interface. They started forcing everyone to use the new buggy version about a week ago EVEN THOUGH the old interface is just fine. I disagree - the old interface was dreadful and needed fixing. The new one is m

Re: Getting started with IDLE and Python - no highlighting and no execution

2012-08-05 Thread Rotwang
On 06/08/2012 00:46, PeterSo wrote: I am just starting to learn Python, and I like to use the editor instead of the interactive shell. So I wrote the following little program in IDLE # calculating the mean data1=[49, 66, 24, 98, 37, 64, 98, 27, 56, 93, 68, 78, 22, 25, 11] def mean(data):

Re: Getting started with IDLE and Python - no highlighting and no execution

2012-08-05 Thread Rotwang
On 06/08/2012 02:01, Matthew Barnett wrote: On 06/08/2012 01:58, MRAB wrote: On 06/08/2012 01:09, Rotwang wrote: On 06/08/2012 00:46, PeterSo wrote: I am just starting to learn Python, and I like to use the editor instead of the interactive shell. So I wrote the following little program in

Re: [newbie] A question about lists and strings

2012-08-10 Thread Rotwang
On 10/08/2012 10:59, Peter Otten wrote: [...] If you have understood the above here's a little brain teaser: a = ([1,2,3],) a[0] += [4, 5] Traceback (most recent call last): File "", line 1, in TypeError: 'tuple' object does not support item assignment a[0] What are the contents of a[

Re: Confused compare function :)

2012-12-05 Thread Rotwang
On 06/12/2012 00:19, Bruno Dupuis wrote: [...] Another advice: never ever except XXXError: pass at least log, or count, or warn, or anything, but don't pass. Really? I've used that kind of thing several times in my code. For example, there's a point where I have a list of strings and I

Re: Confused compare function :)

2012-12-06 Thread Rotwang
On 06/12/2012 08:49, Bruno Dupuis wrote: On Thu, Dec 06, 2012 at 04:32:34AM +, Steven D'Aprano wrote: On Thu, 06 Dec 2012 03:22:53 +0000, Rotwang wrote: On 06/12/2012 00:19, Bruno Dupuis wrote: [...] Another advice: never ever except XXXError: pass at least log, or coun

Re: Confused compare function :)

2012-12-06 Thread Rotwang
On 06/12/2012 04:32, Steven D'Aprano wrote: On Thu, 06 Dec 2012 03:22:53 +0000, Rotwang wrote: [...] Is there a problem with either of the above? If so, what should I do instead? They're fine. Never, ever say that people should never, ever do something. *cough* Thanks. -- I

String concatenation benchmarking weirdness

2013-01-11 Thread Rotwang
Hi all, the other day I 2to3'ed some code and found it ran much slower in 3.3.0 than 2.7.2. I fixed the problem but in the process of trying to diagnose it I've stumbled upon something weird that I hope someone here can explain to me. In what follows I'm using Python 2.7.2 on 64-bit Windows 7

Re: String concatenation benchmarking weirdness

2013-01-11 Thread Rotwang
On 11/01/2013 20:16, Ian Kelly wrote: On Fri, Jan 11, 2013 at 12:03 PM, Rotwang wrote: Hi all, the other day I 2to3'ed some code and found it ran much slower in 3.3.0 than 2.7.2. I fixed the problem but in the process of trying to diagnose it I've stumbled upon something weird t

Using arguments in a decorator

2012-04-20 Thread Rotwang
Hi all, here's a problem I don't know how to solve. I'm using Python 2.7.2. I'm doing some stuff in Python which means I have cause to call functions that take a while to return. Since I often want to call such a function more than once with the same arguments, I've written a decorator to elim

Re: why () is () and [] is [] work in other way?

2012-04-20 Thread Rotwang
On 20/04/2012 20:10, dmitrey wrote: I have spent some time searching for a bug in my code, it was due to different work of "is" with () and []: () is () True [] is [] False (Python 2.7.2+ (default, Oct 4 2011, 20:03:08) [GCC 4.6.1] ) Is this what it should be or maybe yielding unified resu

Re: Appending to []

2012-04-20 Thread Rotwang
On 20/04/2012 21:03, Jan Sipke wrote: Can you explain why there is a difference between the following two statements? a = [] a.append(1) print a [1] print [].append(1) None append is a method of the list object []. Methods, in general, both do something to the objects of which they are a

Re: Using arguments in a decorator

2012-04-20 Thread Rotwang
On 20/04/2012 17:10, Jon Clements wrote: On Friday, 20 April 2012 16:57:06 UTC+1, Rotwang wrote: Hi all, here's a problem I don't know how to solve. I'm using Python 2.7.2. I'm doing some stuff in Python which means I have cause to call functions that take a while to r

Re: Using arguments in a decorator

2012-04-21 Thread Rotwang
On 21/04/2012 09:36, Steven D'Aprano wrote: [...] Here is how I would write the above. import functools def memoise(func): """Decorator to memoise a function.""" cache = {} @functools.wraps(func) def inner(*args, **kwargs): # Make sure keyword args are always look

Re: from calendar import* doesn't import everything

2012-04-24 Thread Rotwang
On 25/04/2012 00:42, Kiuhnm wrote: On 4/25/2012 1:18, Rotwang wrote: Sorry if this is a stupid question, but what is up with this: >>> from calendar import* >>> Calendar Traceback (most recent call last): File "", line 1, in Calendar NameError: name 'Cal

Re: Some posts do not show up in Google Groups

2012-05-01 Thread Rotwang
On 01/05/2012 07:12, Frank Millman wrote: [...] I have had a look at this before, but there is one thing that Google Groups does that no other reader seems to do, and that is that messages are sorted according to thread-activity, not original posting date. This makes it easy to see what has chan

Re: Python Language Question?

2011-02-27 Thread Rotwang
On 27/02/2011 16:45, Paul Symonds wrote: Can someone give and explanation of what is happening with the following: a,b = 0,1 # this assigns a = 0 and b = 1 while b < 10: ... print b ... a, b = b, a+b ... 1 1 2 3 5 8 a=0 b=1 while b < 1000: ... print b ... a = b ... b = a+b ... 1 2 4 8 1

Re: value of pi and 22/7

2011-03-17 Thread Rotwang
On 17/03/2011 18:49, Ian Kelly wrote: On Thu, Mar 17, 2011 at 11:36 AM, Jeffrey Gaynor wrote: There are fun math questions, for instance, is there a run of a million 1's someplace in the decimal expansion of pi? Maybe so, but we just don't know, since we've only computed the first trillion or

tokenize.untokenize adding line continuation characters

2017-01-16 Thread Rotwang
Here's something odd I've found with the tokenize module: tokenizing 'if x:\n y' and then untokenizing the result adds '\\\n' to the end. Attempting to tokenize the result again fails because of the backslash continuation with nothing other than a newline after it. On the other hand, if the o

Re: tokenize.untokenize adding line continuation characters

2017-01-17 Thread Rotwang
On Tuesday, January 17, 2017 at 11:11:27 AM UTC, Peter Otten wrote: > Rotwang wrote: > > > Here's something odd I've found with the tokenize module: tokenizing 'if > > x:\ny' and then untokenizing the result adds '\\\n' to the end. > > At

Re: Getting globals of the caller, not the defining module

2013-11-12 Thread Rotwang
On 12/11/2013 01:57, Terry Reedy wrote: On 11/11/2013 7:02 AM, sg...@hotmail.co.uk wrote: (Sorry for posting through GG, I'm at work.) On Monday, November 11, 2013 11:25:42 AM UTC, Steven D'Aprano wrote: Suppose I have a function that needs access to globals: # module A.py def spam(): g

Re: Getting globals of the caller, not the defining module

2013-11-14 Thread Rotwang
On 11/11/2013 12:02, sg...@hotmail.co.uk wrote: (Sorry for posting through GG, I'm at work.) On Monday, November 11, 2013 11:25:42 AM UTC, Steven D'Aprano wrote: Suppose I have a function that needs access to globals: # module A.py def spam(): g = globals() # this gets globals from A

Re: Method chaining

2013-11-23 Thread Rotwang
On 22/11/2013 11:26, Steven D'Aprano wrote: A frequently missed feature is the ability to chain method calls: x = [] x.append(1).append(2).append(3).reverse().append(4) => x now equals [3, 2, 1, 4] This doesn't work with lists, as the methods return None rather than self. The class needs to be

Re: Method chaining

2013-11-23 Thread Rotwang
On 23/11/2013 19:53, Rotwang wrote: [...] That's pretty cool. However, I can imagine it would be nice for the chained object to still be an instance of its original type. How about something like this: [crap code] The above code isn't very good - it will only work on types whose c

Re: Method chaining

2013-11-23 Thread Rotwang
On 24/11/2013 00:28, Rotwang wrote: [...] This solves some of the problems in my earlier effort. It keeps a copy of the original object, Sorry, I meant that it keeps a reference to the original object. -- https://mail.python.org/mailman/listinfo/python-list

Re: Method chaining

2013-11-24 Thread Rotwang
On 24/11/2013 14:27, Steven D'Aprano wrote: On Sat, 23 Nov 2013 19:53:32 +0000, Rotwang wrote: On 22/11/2013 11:26, Steven D'Aprano wrote: A frequently missed feature is the ability to chain method calls: [...] chained([]).append(1).append(2).append(3).reverse().append(4) =>

Re: Got a Doubt ! Wanting for your Help ! Plz make it ASAP !

2013-11-27 Thread Rotwang
On 27/11/2013 08:31, Antoon Pardon wrote: Op 27-11-13 09:19, Chris Angelico schreef: [...] Do you mean standard British English, standard American English, standard Australian English, or some other? Does that significantly matter or are you just looking for details you can use to disagree? A

Re: Why is there no natural syntax for accessing attributes with names not being valid identifiers?

2013-12-04 Thread Rotwang
On 04/12/2013 20:07, Piotr Dobrogost wrote: [...] Unless we compare with what we have now, which gives 9 (without space) or 10 (with space): x = obj.'value-1' x = getattr(obj, 'value-1') That is not a significant enough savings to create new syntax. Well, 9 characters is probably significa

Re: Why is there no natural syntax for accessing attributes with names not being valid identifiers?

2013-12-06 Thread Rotwang
On 06/12/2013 16:51, Piotr Dobrogost wrote: [...] I thought of that argument later the next day. Your proposal does unify access if the old obj.x syntax is removed. As long as obj.x is a very concise way to get attribute named 'x' from object obj it's somehow odd that identifier x is treated n

Re: One liners

2013-12-07 Thread Rotwang
On 07/12/2013 12:41, Jussi Piitulainen wrote: [...] if tracks is None: tracks = [] Sorry to go off on a tangent, but in my code I often have stuff like this at the start of functions: tracks = something if tracks is None else tracks or, in the case where I don't intend for the

Re: Managing Google Groups headaches

2013-12-07 Thread Rotwang
On 07/12/2013 16:08, Roy Smith wrote: In article <31f1bb84-1432-446c-a7d4-79ce16f2a...@googlegroups.com>, wxjmfa...@gmail.com wrote: It is on this level the FSR fails. What is "FSR"? I apologize if this was explained earlier in the thread and I can't find the reference. It's the Flexible

Re: One liners

2013-12-07 Thread Rotwang
On 07/12/2013 16:25, Steven D'Aprano wrote: On Sat, 07 Dec 2013 16:13:09 +0000, Rotwang wrote: On 07/12/2013 12:41, Jussi Piitulainen wrote: [...] if tracks is None: tracks = [] Sorry to go off on a tangent, but in my code I often have stuff like this at the start of func

Re: Understanding decorator and class methods

2014-01-08 Thread Rotwang
On 08/01/2014 19:56, axis.of.wea...@gmail.com wrote: can someone please explain why the following works, in contrast to the second example? def decorator(func): def on_call(*args): print args return func(args) return on_call class Foo: @decorator def bar(s

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

2014-01-12 Thread Rotwang
On 12/01/2014 05:58, Chris Angelico wrote: [...] (BTW, is there no better notation than six nested for/range for doing 6d6? I couldn't think of one off-hand, but it didn't really much matter anyway.) If you're willing to do an import, then how about this: >>> from itertools import product >>>

Re: Guessing the encoding from a BOM

2014-01-17 Thread Rotwang
On 17/01/2014 18:43, Tim Chase wrote: On 2014-01-17 09:10, Mark Lawrence wrote: Slight aside, any chance of changing the subject of this thread, or even ending the thread completely? Why? Every time I see it I picture Inspector Clouseau, "A BOM!!!" :) In discussions regarding BOMs, I regular

Re: Try-except-finally paradox

2014-01-30 Thread Rotwang
On 30/01/2014 06:33, Andrew Berg wrote: On 2014.01.29 23:56, Jessica Ross wrote: I found something like this in a StackOverflow discussion. def paradox(): ... try: ... raise Exception("Exception raised during try") ... except: ... print "Except after try" ...

Re: 1 > 0 == True -> False

2014-01-30 Thread Rotwang
On 30/01/2014 12:49, Dave Angel wrote: [...] For hysterical reasons, True and False are instances of class bool, which is derived from int. So for comparison purposes False==0 and True==1. But in my opinion, you should never take advantage of this, except when entering obfuscation cont

Re: 1 > 0 == True -> False

2014-01-30 Thread Rotwang
On 30/01/2014 23:36, Joshua Landau wrote: On 30 January 2014 20:38, Chris Angelico wrote: Why is tuple unpacking limited to the last argument? Is it just for the parallel with the function definition, where anything following it is keyword-only? You're not the first person to ask that: http:

Re: Removal of iterable unpacking in function calls

2014-01-30 Thread Rotwang
On 31/01/2014 00:21, Ben Finney wrote: Rotwang writes: On a vaguely-related note, does anyone know why iterable unpacking in calls was removed in Python 3? This is explained in the PEP which described its removal http://www.python.org/dev/peps/pep-3113/>, especially http://www.python.

Re: generator slides review and Python doc (+/- text bug)

2014-02-03 Thread Rotwang
On 03/02/2014 13:59, wxjmfa...@gmail.com wrote: [...] I noticed the same effect with the Python doc since ? (long time). Eg. The Python Tutorial appears as The Python Tutorial¶ with a visible colored "¶", 'PILCROW SIGN', blueish in Python 3, red in Python 2.7.6. Hint: try clicking the ¶. --

Re: generator slides review and Python doc (+/- text bug)

2014-02-03 Thread Rotwang
On 03/02/2014 18:37, wxjmfa...@gmail.com wrote: [...] Hint: try clicking the ¶. I never was aware of this "feature". Is it deliverate? Do you mean deliberate? Of course it is. It gives to me the feeling of a badly programmed html page, especially if this sign does correspond to an eol!

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

2014-02-10 Thread Rotwang
On 10/02/2014 18:45, Rick Johnson wrote: [...] 3. Implicit introspection is evil, i prefer all references to a callable's names to result in a CALL to that callable, not an introspection! So, for example, none of isinstance(x, myclass) map(myfunc, range(10)) x = p

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: 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: retur

Re: Explanation of list reference

2014-02-17 Thread Rotwang
On 17/02/2014 06:21, Steven D'Aprano wrote: On Mon, 17 Feb 2014 11:54:45 +1300, Gregory Ewing wrote: [...] [1] Mathematicians tried this. "Everything is a set!" Yeah, right... No, that's okay. You only get into trouble when you have self-referential sets, like "the set of all sets that don't

Re: Import order question

2014-02-18 Thread Rotwang
On 18/02/2014 21:44, Rick Johnson wrote: [...] Are you telling me you're willing to search through a single file containing 3,734 lines of code (yes, Tkinter) looking for a method named "destroy" of a class named "OptionMenu" (of which three other classes contain a method of the same exact name!

Re: Import order question

2014-02-18 Thread Rotwang
On 18/02/2014 23:41, Rick Johnson wrote: On Tuesday, February 18, 2014 5:28:21 PM UTC-6, Rotwang wrote: [snipped material restored for context] On 18/02/2014 21:44, Rick Johnson wrote: [...] Are you telling me you're willing to search through a single file containing 3,734 lines of

Re: property confusion

2014-02-21 Thread Rotwang
On 21/02/2014 18:58, K Richard Pixley wrote: Could someone please explain to me why the two values at the bottom of this example are different? Python-3.3 if it makes any difference. Is this a difference in evaluation between a class attribute and an instance attribute? Yes, see below. --r

Re: Import order question

2014-03-10 Thread Rotwang
On 18/02/2014 23:28, Rotwang wrote: [...] I have music software that's a single 9K-line Python module, which I edit using Notepad++ or gedit. Incidentally, in the time since I wrote the above I've started using Sublime Text 3, following somebody on c.l.p's recommendation (I a

Scoping rules for class definitions

2014-04-04 Thread Rotwang
Hi all. I thought I had a pretty good grasp of Python's scoping rules, but today I noticed something that I don't understand. Can anyone explain to me why this happens? >>> x = 'global' >>> def f1(): x = 'local' class C: y = x return C.y >>> def f2(): x = 'local' cl

Re: Scoping rules for class definitions

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

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

2014-05-04 Thread Rotwang
On 04/05/2014 15:16, Steven D'Aprano wrote: On Sun, 04 May 2014 20:03:35 +1200, Gregory Ewing wrote: Steven D'Aprano wrote: If it were a class method, you would call it by MyBaseClass.__new__() rather than explicitly providing the cls argument. But that wouldn't be any good, because the base

Re: Values and objects

2014-05-11 Thread Rotwang
On 11/05/2014 04:11, Steven D'Aprano wrote: [...] And try running this function in both 2.7 and 3.3 and see if you can explain the difference: def test(): if False: x = None exec("x = 1") return x I must confess to being baffled by what happens in 3.3 with this example. Neithe

Re: Values and objects

2014-05-11 Thread Rotwang
On 11/05/2014 19:40, Ned Batchelder wrote: On 5/11/14 9:46 AM, Rotwang wrote: On 11/05/2014 04:11, Steven D'Aprano wrote: [...] And try running this function in both 2.7 and 3.3 and see if you can explain the difference: def test(): if False: x = None exec("x = 1"

Re: Newbie: static typing?

2013-08-06 Thread Rotwang
On 06/08/2013 11:07, Rui Maciel wrote: Joshua Landau wrote: Unless you have a very good reason, don't do this [i.e. checking arguments for type at runtime and raising TypeError]. It's a damn pain when functions won't accept my custom types with equivalent functionality -- Python's a duck-typed

Re: back with more issues

2013-08-12 Thread Rotwang
On 12/08/2013 06:54, Dave Angel wrote: [...] This function makes no sense to me. A function should have three well-defined pieces: what are its parameters, what does it do, what are its side-effects, and what does it return. No! A function should have *four* well-defined pieces: what are its

Weird ttk behaviour

2013-09-16 Thread Rotwang
Hi all, I've just started trying to learn how to use ttk, and I've discovered something that I don't understand. I'm using Python 3.3.0 in Linux Mint 15. Suppose I create the following module: # begin tkderp.py import tkinter as tk import tkinter.messagebox as _ from tkinter import ttk from

Re: Weird ttk behaviour

2013-09-17 Thread Rotwang
On 16/09/2013 19:43, Serhiy Storchaka wrote: 16.09.13 19:28, Rotwang написав(ла): On Windows 7 (sys.version is '3.3.0 (v3.3.0:bd8afb90ebf2, Sep 29 2012, 10:57:17) [MSC v.1600 64 bit (AMD64)]') there's no problem; f() works fine in the first place. Does anybody know what

Re: Weird ttk behaviour

2013-09-17 Thread Rotwang
On 16/09/2013 23:34, Chris Angelico wrote: On Tue, Sep 17, 2013 at 2:28 AM, Rotwang wrote: If I then uncomment those two lines, reload the module and call f() again (by entering tkderp.reload(tkderp).f()), the function works like it was supposed to in the first place: two warnings, no

Re: Weird ttk behaviour

2013-09-17 Thread Rotwang
On 17/09/2013 12:32, Chris Angelico wrote: [...] If reloading and doing it again makes things different, what happens if you simply trigger your code twice without reloading? I've no idea if it'll help, it just seems like an attack vector on the problem, so to speak. Thanks for the suggestion

Re: Weird ttk behaviour

2013-09-17 Thread Rotwang
On 17/09/2013 15:35, Chris Angelico wrote: On Wed, Sep 18, 2013 at 12:25 AM, Rotwang wrote: In fact, if I replace tkderp with this: # begin tkderp.py import tkinter as tk _root = tk.Tk() _root.withdraw() # end tkderp.py then simply importing tkderp before tkderp2 is enough to make the

Re: lambda - strange behavior

2013-09-20 Thread Rotwang
On 20/09/2013 16:21, Kasper Guldmann wrote: I was playing around with lambda functions, but I cannot seem to fully grasp them. I was running the script below in Python 2.7.5, and it doesn't do what I want it to. Are lambda functions really supposed to work that way. How do I make it work as I int

Re: dynamic function parameters for **kwargs

2013-09-20 Thread Rotwang
On 20/09/2013 16:51, bab mis wrote: Hi , I have a function as below: def func(**kwargs): ... ... args="a='b',c='d'" i want to call func(args) so that my function call will take a var as an parameter. it fails with an error "typeError: fun() takes exactly 0 arguments (1 given)

Re: python function parameters, debugging, comments, etc.

2013-10-01 Thread Rotwang
On 01/10/2013 23:54, Chris Friesen wrote: I've got a fair bit of programming experience (mostly kernel/POSIX stuff in C). I'm fairly new to python though, and was hoping for some advice. Given the fact that function parameters do not specify types, when you're looking at someone else's code

Re: python function parameters, debugging, comments, etc.

2013-10-02 Thread Rotwang
On 02/10/2013 11:15, Oscar Benjamin wrote: On 2 October 2013 00:45, Rotwang wrote: So the upside of duck-typing is clear. But as you've already discovered, so is the downside: Python's dynamic nature means that there's no way for the interpreter to know what kind of arguments

Re: I am never going to complain about Python again

2013-10-10 Thread Rotwang
On 10/10/2013 16:51, Neil Cerutti wrote: [...] Mixed arithmetic always promotes to the wider type (except in the case of complex numbers (Ha!)). r == c is equivalent to r == abs(c), which returns the magintude of the complex number. What? >>> -1 == -1 + 0j True >>> -1 == abs(-1 + 0j) False >

Re: converting letters to numbers

2013-10-16 Thread Rotwang
On 14/10/2013 06:02, Steven D'Aprano wrote: On Sun, 13 Oct 2013 20:13:32 -0700, Tim Roberts wrote: def add(c1, c2): % Decode c1 = ord(c1) - 65 c2 = ord(c2) - 65 % Process i1 = (c1 + c2) % 26 % Encode return chr(i1+65) Python uses # for comments, not %

Passing a frame to pdb.Pdb.set_trace

2014-06-24 Thread Rotwang
Hi all, I've found something weird with pdb and I don't understand it. I want to define a function mydebugger() which starts the debugger in the caller's frame. The following is copied from IDLE with Python 2.7.3 (I've since tried it with 3.3.0 and the same thing happens): Python 2.7.3 (defau

Re: Passing a frame to pdb.Pdb.set_trace

2014-06-25 Thread Rotwang
On 24/06/2014 20:10, Rotwang wrote: Hi all, I've found something weird with pdb and I don't understand it. I want to define a function mydebugger() which starts the debugger in the caller's frame. The following is copied from IDLE with Python 2.7.3 (I've since tried it wit

Re: Awsome Python - chained exceptions

2013-02-20 Thread Rotwang
On 20/02/2013 11:50, Steven D'Aprano wrote: [...alternatives to Google...] Or if your ISP provides Usenet access, you can use a News client to read it via comp.lang.python, or gmane.comp.python.general. And if it doesn't, you can get free Usenet access that includes most of the text-only gro

Re: Is Python "venerable"?

2013-02-20 Thread Rotwang
On 20/02/2013 03:53, Barry W Brown wrote: [...] Homer Simpson put it accurately last night. "I used to be with it when I was younger. But it moved and now what I am with is no longer it." Sorry to be pedantic, but the quote you're thinking of is from Abe Simpson: http://www.youtube.com/watc

Re: Do you feel bad because of the Python docs?

2013-02-26 Thread Rotwang
On 26/02/2013 12:54, Steven D'Aprano wrote: One week ago, "JoePie91" wrote a blog post challenging the Python community and the state of Python documentation, titled: "The Python documentation is bad, and you should feel bad". http://joepie91.wordpress.com/2013/02/19/the-python-documentation-is

  1   2   >