Re: The binding operator, and what gets bound to what

2014-12-05 Thread Ned Batchelder
ecent call last): File "", line 1, in NameError: name 'a' is not defined >>> def f(): ... global a ... for a in range(10): ... pass ... >>> f() >>> a 9 This also means that you can do odd things like: for self.foo in range(10): or: for my_li

Re: The binding operator, and what gets bound to what

2014-12-05 Thread Ned Batchelder
On 12/5/14 7:34 AM, Steven D'Aprano wrote: Ned Batchelder wrote: On 12/5/14 4:53 AM, Steven D'Aprano wrote: Oh, I learned something new: strictly speaking, this is implementation- dependent and not guaranteed to work in the future! def func(): global math import math

Re: Tabs for indentation & Spaces for alignment in Python 3?

2014-12-05 Thread Ned Batchelder
ough about differing indent widths that they need to use tabs so they can each have their own way, then you probably have bigger collaboration issues. Use four spaces, and be done with it. Agree with your team members on how your code will look, then innovate on the important things. --

Re: Tabs for indentation & Spaces for alignment in Python 3?

2014-12-05 Thread Ned Batchelder
considering trying to maintain code using a mix of tabs and spaces like that. That's a nightmare. -- Ned Batchelder, http://nedbatchelder.com -- https://mail.python.org/mailman/listinfo/python-list

Re: Tabs for indentation & Spaces for alignment in Python 3?

2014-12-05 Thread Ned Batchelder
cters deep, and that is akin to trying to define the value of PI to be 3. So you've started by trying to use tabs so that people can choose the indentation width they like, and ended up with a strict rule that you cannot change the size of tabs. -- Ned Batchelder, http://nedbatchelder.com -- https://mail.python.org/mailman/listinfo/python-list

Re: Tabs for indentation & Spaces for alignment in Python 3?

2014-12-05 Thread Ned Batchelder
On 12/5/14 10:04 PM, Michael Torrie wrote: On 12/05/2014 07:31 PM, Ned Batchelder wrote: This is a perfect example! The code (with tabs as >--- and leading spaces as .) is: >---if (!list_empty(pending)) >--->---ret = list_first_entry(pending, struct

Re: Python Iterables struggling using map() built-in

2014-12-07 Thread Ned Batchelder
t a list comprehension to make result? OK, let's try this: result = map(next, iters) Oops, another infinite loop on Py3, right, because map is lazy, so the StopIteration doesn't happen until the tuple() call. OK, try this: result = list(map(next, iters)) Nope, still infi

Re: Maintaining Maximum Line Length When Using Tabs Instead of Spaces?

2014-12-07 Thread Ned Batchelder
27;s solving your problem. I'm curious why you care about the "79 characters" part of PEP8 if you don't care about the "use spaces" part of PEP8. -- Ned Batchelder, http://nedbatchelder.com -- https://mail.python.org/mailman/listinfo/python-list

Re: How to detect that a function argument is the default one

2014-12-10 Thread Ned Batchelder
On 12/10/14 11:10 AM, Jean-Michel Pichavant wrote: self.mass = (mass is None and radius**2) or mass When will this idiom die? We've had actual if-expressions for a while now: self.mass = radius**2 if mass is None else mass -- Ned Batchelder, http://nedbatchelder.com --

Re: Python console rejects an object reference, having made an object with that reference as its name in previous line

2014-12-14 Thread Ned Batchelder
have gone wrong - 'soup' has been defined as an object made of file 'EcologicalPyramid.html I hope you can help me on this point. For complex code experiments, it's better to put the code in a file, and run the file. But if you do want to use the interactive interpreter, enter code carefully, and watch out for the error messages. -- Ned Batchelder, http://nedbatchelder.com -- https://mail.python.org/mailman/listinfo/python-list

Re: Portable code: ‘from __future__ import unicode_literals’ a good idea?

2014-12-15 Thread Ned Batchelder
mmendation that's good for 99% of code may not work for you. Be flexible. Do what works. -- Ned Batchelder, http://nedbatchelder.com -- https://mail.python.org/mailman/listinfo/python-list

Re: Bug? Feature? setattr(foo, '3', 4) works!

2014-12-19 Thread Ned Batchelder
, the normal error raised would be TypeError and not SyntaxError; I'd like to suggest special-casing this so that using getattr(), setattr(), and hasattr() in this way raise SyntaxError instead as I think that will be less astonishing. Thoughts? Thanks, Cem Karan Can you explain why you think it is important that setattr(obj, '3', 3) raise an error at all? Yes, it surprised you, but there are many aspects of Python that are surprising. That's not a bad thing in and of itself. Did this cause a real problem in your code? Is there a way that allowing non-identifier attribute names will be harmful? -- Ned Batchelder, http://nedbatchelder.com -- https://mail.python.org/mailman/listinfo/python-list

Re: what is wrong with d.clear()?

2014-12-22 Thread Ned Batchelder
27;setdefault', 'update', 'values'] d.clear() This cleared the contents of d, which is also sys.modules, so you have clobbered sys.modules. This will make many things stop working in Python. Traceback (most recent call last): File "", line 1, in d Traceback (most recent call last): File "", line 1, in quit() Traceback (most recent call last): File "", line 1, in Like all of these things. -- Ned Batchelder, http://nedbatchelder.com -- https://mail.python.org/mailman/listinfo/python-list

Re: question on string object handling in Python 2.7.8

2014-12-24 Thread Ned Batchelder
= ‘h’ #or b = ‘hh’ Testing cmd: python -m cProfile test.py So what is wrong here? B has one more malloc than A but is faster than B? Thanks, Dave -- Ned Batchelder, http://nedbatchelder.com -- https://mail.python.org/mailman/listinfo/python-list

Re: missing os.lchmod, os.lchflags

2014-12-24 Thread Ned Batchelder
plain why a platform has or doesn't have lchmod, but "man lchmod" might fail for you also, as it does for me on Ubuntu. -- ~Ethan~ [1] https://docs.python.org/2/library/os.html#os.lchmod -- Ned Batchelder, http://nedbatchelder.com -- https://mail.python.org/mailman/listinfo/python-list

Re: String character encoding when converting data from one type/format to another

2015-01-07 Thread Ned Batchelder
thing: #sample code line for binary encoding into string output s_values += "0x" + str(l_data[J][I]).encode("hex").replace("\\", "") + ", " TIA Jacob Kruger Blind Biker Skype: BlindZA "Roger Wilco wants to welcome you...to the space janitor's closet..." -- Ned Batchelder, http://nedbatchelder.com -- https://mail.python.org/mailman/listinfo/python-list

Re: Why does argparse return None instead of [] if an append action isn't used?

2015-01-09 Thread Ned Batchelder
, but I've used: for b in options.bar or (): do_stuff(b) -- Ned Batchelder, http://nedbatchelder.com -- https://mail.python.org/mailman/listinfo/python-list

Re: annoying doctest problem

2015-01-12 Thread Ned Batchelder
ore detail here: http://nedbatchelder.com/blog/200811/things_i_dont_like_about_doctest.html -- Ned Batchelder, http://nedbatchelder.com -- https://mail.python.org/mailman/listinfo/python-list

Re: How to "wow" someone new to Python

2015-01-19 Thread Ned Batchelder
spell-correct.html I used it as a walk-through example for a presentation about Python at the DevDays conference: http://nedbatchelder.com/text/devdays.html The second half of the presentation is a 25-line nano-templating engine which shows off some other good characteristics of the

Re: An object is an instance (or not)?

2015-01-27 Thread Ned Batchelder
Because, from my own study of Python, I've came to realize that the distinction between objects and instances of objects actually exists. In Python, class objects cannot participate in OOP, only their instances. What does "participate in OOP" mean? This is why I say that even in P

Re: An object is an instance (or not)?

2015-01-27 Thread Ned Batchelder
;>> Sub.func() TypeError: func() missing 1 required positional argument: 'self' But somehow I think you knew the answer to all these questions and were instead being snarky. I am not being snarky, I'm trying to understand where our mutual incomprehension lies. -- Ned Batchelder, http://nedbatchelder.com -- https://mail.python.org/mailman/listinfo/python-list

Re: how to parse sys.argv as dynamic parameters to another function?

2015-01-30 Thread Ned Batchelder
parameter to the function? If so, then: fun(*sys.argv) Robert, this will work, but keep in mind that sys.argv is a list of strings, always. If your function is expecting integers, you will have to do an explicit conversion somewhere. -- Ned Batchelder, http://nedbatchelder.com -- https

Re: __next__ and StopIteration

2015-02-09 Thread Ned Batchelder
e fine. Also, look into how you are posting, the code is nearly mangled. :( -- Ned Batchelder, http://nedbatchelder.com -- https://mail.python.org/mailman/listinfo/python-list

Re: __next__ and StopIteration

2015-02-09 Thread Ned Batchelder
On 2/9/15 2:24 PM, Ned Batchelder wrote: On 2/9/15 2:14 PM, Charles Hixson wrote: I'm trying to write a correct iteration over a doubly indexed container, and what I've got so far is:def __next__ (self): for rowinrange(self._rows): for col in range(

Re: Working with the set of real numbers

2014-02-12 Thread Ned Batchelder
On 2/12/14 5:55 AM, wxjmfa...@gmail.com wrote: The fascinating aspect of this FSR lies in its mathematical absurdity. jmf Stop. -- Ned Batchelder, http://nedbatchelder.com -- https://mail.python.org/mailman/listinfo/python-list

Re: singleton ... again

2014-02-12 Thread Ned Batchelder
ually lie and return the same instance over and over. It makes them impossible to test: your unit tests all act on the same object, there's no way to start over with a fresh object. If you only want one object, create just one, and use it everywhere. -- Ned Batchelder, http://ne

Re: singleton ... again

2014-02-13 Thread Ned Batchelder
object for the next time it's needed. But that's different than a class which pretends to make instances but actually always returns the same instance. -- Ned Batchelder, http://nedbatchelder.com -- https://mail.python.org/mailman/listinfo/python-list

Re: A curious bit of code...

2014-02-13 Thread Ned Batchelder
to the folks who did the timings (and saved me from the trouble!) Last but not least... s[::len(s)-1] omg!!? ;-D If you aren't worried about performance, why are you choosing your code based on which is the fastest? There are other characteristics (clarity, flexibility, robustness,

Re: Explanation of list reference

2014-02-14 Thread Ned Batchelder
Python refer to values. Thinking in terms of memory locations might just confuse things. This is my best explanation of the details: http://nedbatchelder.com/text/names.html -- Ned Batchelder, http://nedbatchelder.com -- https://mail.python.org/mailman/listinfo/python-list

Re: Explanation of list reference

2014-02-14 Thread Ned Batchelder
e a list, or it can be something "simple" like an int. This covers all the details, including pictures like Marko's, but with an explanation why we draw the ints inside the boxes: http://nedbatchelder.com/text/names.html -- Ned Batchelder, http://nedbatchelder.com -- https://mail.python.org/mailman/listinfo/python-list

Re: Explanation of list reference

2014-02-14 Thread Ned Batchelder
on, but might help...", or "You can think of it like ...". -- Ned Batchelder, http://nedbatchelder.com -- https://mail.python.org/mailman/listinfo/python-list

Re: Operator precedence table questions

2014-02-15 Thread Ned Batchelder
p left to right, they chain left to right: a + b + c is the same as: (a + b) + c but: a < b < c is not the same as: (a < b) < c -- Ned Batchelder, http://nedbatchelder.com -- https://mail.python.org/mailman/listinfo/python-list

Re: random.sample with large weighted sample-sets?

2014-02-16 Thread Ned Batchelder
ape", 30), ) He turned it into: data = [ (0, 'apple'), (0+20, 'orange'), (0+20+50, 'grape'), ] Each number is the cumulative probability up to but not including the item. -- Ned Batchelder, http://nedbatchelder.com -- https://mail.python.org/mailman/listinfo/python-list

Re: Explanation of list reference

2014-02-16 Thread Ned Batchelder
er to drop out into asm and write shl $3, %eax -- Ned Batchelder, http://nedbatchelder.com -- https://mail.python.org/mailman/listinfo/python-list

Re: Explanation of list reference

2014-02-16 Thread Ned Batchelder
programmer new to Python. The latter category is sometimes the harder to teach, because you have to undo the things they learned about their earlier language X, but which they mistakenly believe to be true about all programming languages. -- Ned Batchelder, http://nedbatchelder.com -- https://mail.python.org/mailman/listinfo/python-list

Re: Does CPython already has Peephole optimizations?

2014-02-17 Thread Ned Batchelder
see a way to disable all those optimizations. I tried filing a bug about it (http://bugs.python.org/issue2506), but it did not win the popular support I had hoped for. -- Ned Batchelder, http://nedbatchelder.com -- https://mail.python.org/mailman/listinfo/python-list

Re: Why is the interpreter is returning a 'reference'?

2014-02-17 Thread Ned Batchelder
it does this. You have to invoke s.upper, with parens: k = [s.upper() for s in k] In Python, a function or method is a first-class object, so "s.upper" is a reference to the method, "s.upper()" is the result of calling the method. -- Ned Batchelder, http://nedbatchelder.com -- https://mail.python.org/mailman/listinfo/python-list

Re: Cross-platform way to get default directory for binary files like console scripts?

2014-02-20 Thread Ned Batchelder
wrong answer, and I don't know what to do if the file you're looking for isn't in that directory. Perhaps the shorter answer is, look in the Python executable directory, then look in the directories on PATH. -- Ned Batchelder, http://nedbatchelder.com -- https://mail.python.org/mailman/listinfo/python-list

Re: Cross-platform way to get default directory for binary files like console scripts?

2014-02-20 Thread Ned Batchelder
'/usr/local/virtualenvs/studygroup/bin/python' >>> os.listdir(os.path.dirname(sys.executable)) ['activate', 'activate.csh', 'activate.fish', 'activate_this.py', 'easy_install', 'easy_install-2.7', 'pip', 'pip-2.7', 'python', 'python2', 'python2.7'] >>> -- Ned Batchelder, http://nedbatchelder.com -- https://mail.python.org/mailman/listinfo/python-list

Re: Cross-platform way to get default directory for binary files like console scripts?

2014-02-20 Thread Ned Batchelder
On 2/20/14 10:55 AM, Oscar Benjamin wrote: On 20 February 2014 15:42, Ned Batchelder wrote: As roundabout and advanced as that code is, it doesn't give the right answer for me. It returns None. On my Mac, after activating a virtualenv: Python 2.7.2 (default, Oct 11 2012, 20:

Re: Can global variable be passed into Python function?

2014-02-21 Thread Ned Batchelder
y work exactly the same as Javascript or Ruby variables. Python's variables are names bound to values. http://nedbatchelder.com/text/names.html has lots more details. -- Ned Batchelder, http://nedbatchelder.com -- https://mail.python.org/mailman/listinfo/python-list

Re: Can global variable be passed into Python function?

2014-02-21 Thread Ned Batchelder
On 2/21/14 9:47 PM, Dennis Lee Bieber wrote: On Fri, 21 Feb 2014 09:59:17 -0800, Travis Griggs declaimed the following: On Feb 21, 2014, at 4:13 AM, Ned Batchelder wrote: Man, do I hate this idea that Python has no variables. It has variables (names associated with values, and the values

Re: Can global variable be passed into Python function?

2014-02-21 Thread Ned Batchelder
On 2/21/14 10:28 PM, Steven D'Aprano wrote: On Fri, 21 Feb 2014 07:13:25 -0500, Ned Batchelder wrote: On 2/21/14 2:23 AM, dieter wrote: Sam writes: I need to pass a global variable into a python function. Python does not really have the concept "variable". What appears t

Re: Can global variable be passed into Python function?

2014-02-27 Thread Ned Batchelder
rest of this thread, that Python *does* have the concept of a variable, it just behaves differently than some other popular programming languages (but exactly the same as some other popular programming languages!) -- Ned Batchelder, http://nedbatchelder.com -- https://mail.python.org/mailman/listinfo/python-list

Re: Can global variable be passed into Python function?

2014-02-28 Thread Ned Batchelder
nderstand: you show an if/elif chain that cannot be expressed as a switch statement (because it uses < ), and then conclude that Python needs a switch statement? That doesn't make any sense. -- Ned Batchelder, http://nedbatchelder.com -- https://mail.python.org/mailman/listinfo/python-list

Re: Can global variable be passed into Python function?

2014-02-28 Thread Ned Batchelder
On 2/28/14 8:08 PM, Mark H. Harris wrote: On Friday, February 28, 2014 6:40:06 PM UTC-6, Ned Batchelder wrote: I don't understand: you show an if/elif chain that cannot be expressed as a switch statement (because it uses < ), and then conclude that Python needs a switch statemen

Re: Tuples and immutability

2014-03-01 Thread Ned Batchelder
uation. All of the solutions are too extreme, and bring their own infelicities, and the actual problems caused by this scenario are vanishingly small. BTW: I also am mystified why you uses ellipses to end your sentences, surely one period would be enough? :) -- Ned Batchelder, h

Re: why indentation should be part of the syntax

2014-03-02 Thread Ned Batchelder
th braces? It's not like there's some engineer at Apple who meant for the code to read like this: if ((err = SSLHashSHA1.update(&hashCtx, &signedParams)) != 0) { goto fail; goto fail; } This looks to me like a poorly handled merge conflict maybe? I wond

Re: Functional programming

2014-03-02 Thread Ned Batchelder
than Haskell. -- Ned Batchelder, http://nedbatchelder.com -- https://mail.python.org/mailman/listinfo/python-list

Re: How security holes happen

2014-03-04 Thread Ned Batchelder
is Python. Skip It's Hy: http://hylang.org -- Ned Batchelder, http://nedbatchelder.com -- https://mail.python.org/mailman/listinfo/python-list

Re: Working with the set of real numbers

2014-03-05 Thread Ned Batchelder
about the FSR, and absurdly seems to think hinting at paper and pencil will convince us he is right. Don't engage with him on this topic. -- Ned Batchelder, http://nedbatchelder.com -- https://mail.python.org/mailman/listinfo/python-list

Re: Critic: New Python Front Page

2014-03-08 Thread Ned Batchelder
he site is on github, and they are taking and resolving issues there: https://github.com/python/pythondotorg/issues -- Ned Batchelder, http://nedbatchelder.com -- https://mail.python.org/mailman/listinfo/python-list

Re: Critic: New Python Front Page

2014-03-08 Thread Ned Batchelder
On 3/8/14 8:31 AM, Ned Batchelder wrote: On 3/8/14 7:44 AM, Nils-Hero Lindemann wrote: Hi, (Please forgive (or correct) my mistakes, i am non native) http://www.python.org/community/sigs/retired/parser-sig/towards-standard/ * Formatting bug * Needs breadcrumb navigation ("Where am i?&qu

Re: Python performance

2014-03-08 Thread Ned Batchelder
of Python. It uses a JIT to produce native code automatically, and can impressively speed up the execution of Python programs. You should give it a try to see if it will help in your situation. -- Ned Batchelder, http://nedbatchelder.com -- https://mail.python.org/mailman/listinfo/python

Re: How is unicode implemented behind the scenes?

2014-03-08 Thread Ned Batchelder
set of code points in the string. It's specified in PEP 393: http://legacy.python.org/dev/peps/pep-0393/ -- Ned Batchelder, http://nedbatchelder.com -- https://mail.python.org/mailman/listinfo/python-list

Re: Balanced trees

2014-03-10 Thread Ned Batchelder
o do with your style. It can be brief and contrarian, which puts people off. Perhaps if you tried to understand the gap and bridge it more, people would be less inclined to think that you were trying to widen the gap. --Ned. Marko -- Ned Batchelder, http://nedbatchelder.com -- h

Re: when to use == and when to use is

2014-03-10 Thread Ned Batchelder
_2. The last sentence seems telling to me: if you don't care if objects are equal, then don't use ==. Of course, a long change of if's to figure out which object you have seems odd to me... --Ned. George -- Ned Batchelder, http://nedbatchelder.com -- https://mail.py

Re: running python 2 vs 3

2014-03-20 Thread Ned Batchelder
efore .pyc files) across versions of Python, so if you want to run from pure .pyc files, you have to be sure to use the same version of Python that produced the files. --Ned. Marko -- Ned Batchelder, http://nedbatchelder.com -- https://mail.python.org/mailman/listinfo/python-list

Re: running python 2 vs 3

2014-03-20 Thread Ned Batchelder
-Linux, python is python3... Yes, and they have been told many times that this was foolish and wrong, but it persists, much to our pain. -- Ned Batchelder, http://nedbatchelder.com -- https://mail.python.org/mailman/listinfo/python-list

Re: running python 2 vs 3

2014-03-20 Thread Ned Batchelder
your Python project, you decide between Python 2 and Python 3 and go all in. Plenty of people have adopted a dual-support strategy, with one code base that supports both Python 2 and Python 3. The six module can help a great deal with this. Marko -- Ned Batchelder, http://ne

Re: running python 2 vs 3

2014-03-20 Thread Ned Batchelder
On 3/20/14 4:42 PM, Marko Rauhamaa wrote: Ned Batchelder : Plenty of people have adopted a dual-support strategy, with one code base that supports both Python 2 and Python 3. The six module can help a great deal with this. I wonder how easy the resulting code is to the eyes and how easy it

Re: running python 2 vs 3

2014-03-20 Thread Ned Batchelder
On 3/20/14 4:59 PM, Marko Rauhamaa wrote: Ned Batchelder : It's an extreme case, but the latest released version of coverage.py supports Python 2.3 through 3.3 with one code base. To do it, there's a compatibility layer (akin to six). Then you stay away from features that aren'

Re: running python 2 vs 3

2014-03-20 Thread Ned Batchelder
On 3/20/14 8:32 PM, Steven D'Aprano wrote: On Thu, 20 Mar 2014 16:26:39 -0400, Ned Batchelder wrote: On 3/20/14 3:07 PM, Eric Jacoboni wrote: Le 20/03/2014 16:21, Marko Rauhamaa a écrit : All tutorials will tell you to start it with #!/usr/bin/env python which will start pytho

Re: running python 2 vs 3

2014-03-20 Thread Ned Batchelder
On 3/20/14 9:06 PM, Ned Batchelder wrote: On 3/20/14 8:32 PM, Steven D'Aprano wrote: On Thu, 20 Mar 2014 16:26:39 -0400, Ned Batchelder wrote: On 3/20/14 3:07 PM, Eric Jacoboni wrote: Le 20/03/2014 16:21, Marko Rauhamaa a écrit : All tutorials will tell you to start it with #

Re: OFF TOPIC Spanish in the USA

2014-03-31 Thread Ned Batchelder
ow squarely in areas that are 1) politically contentious, 2) wildly subjective, 3) none of our areas of expertise. No good can come from continuing. --Ned. Marko -- Ned Batchelder, http://nedbatchelder.com -- https://mail.python.org/mailman/listinfo/python-list

Re: Code style query: multiple assignments in if/elif tree

2014-03-31 Thread Ned Batchelder
of spaces, and docstring-style comments in places that aren't docstrings. These seem like unusual choices. -- Ned Batchelder, http://nedbatchelder.com -- https://mail.python.org/mailman/listinfo/python-list

Re: unicode as valid naming symbols

2014-04-01 Thread Ned Batchelder
characters in PropList.txt to support backwards compatibility Other_ID_Continue - likewise All identifiers are converted into the normal form NFKC while parsing; comparison of identifiers is based on NFKC. ChrisA -- Ned Batchelder, http://nedbatchelder.com -- https://mail.python.org/mailman/listinfo/python-list

Re: Language summit notes

2014-04-12 Thread Ned Batchelder
wrong in those examples. We aren't going to engage in this topic. The previous discussions have always ended the same way. You should refer to those threads if you want to re-acquaint yourself with other people's views on your theory and discourse. --Ned. jmf -- Ned Batche

Re: Martijn Faassen: The Call of Python 2.8

2014-04-14 Thread Ned Batchelder
re of course always welcome to write to JMF privately, although he has never responded to me over that channel. -- Ned Batchelder, http://nedbatchelder.com -- https://mail.python.org/mailman/listinfo/python-list

Re: random.seed question (not reproducing same sequence)

2014-04-15 Thread Ned Batchelder
choice(PRODUCTS), random.choice(range(10))) for r in range(randrange(7))]) The best way to ensure repeatability of random numbers is to avoid the module-level functions, and instead create your own random.Random() instance to generate numbers. Then you can be certain it isn't being use

Re: Martijn Faassen: The Call of Python 2.8

2014-04-15 Thread Ned Batchelder
taken an inventory of dependencies that must support 3.x before other code(s) can be ported? Maybe there could be an on-line questionnaire regarding perceived dependencies? The Python Wall-Of-Shame/Wall-Of-Superpowers shows popular packages, and their Python 3 status: http://pyth

Re: Martijn Faassen: The Call of Python 2.8

2014-04-15 Thread Ned Batchelder
:09) [...] Yeah, that's the wrong way to do it, and they shouldn't have done that. "python" needs to mean Python 2.x for a long time. -- Ned Batchelder, http://nedbatchelder.com -- https://mail.python.org/mailman/listinfo/python-list

Re: Martijn Faassen: The Call of Python 2.8

2014-04-15 Thread Ned Batchelder
On 4/15/14 7:11 PM, Joshua Landau wrote: On 15 April 2014 23:18, Ned Batchelder wrote: On 4/15/14 5:34 PM, Joshua Landau wrote: Arch is on 3.4 *default*. $> python Python 3.4.0 (default, Mar 17 2014, 23:20:09) [...] Yeah, that's the wrong way to do it, and they s

Re: random.seed question (not reproducing same sequence)

2014-04-15 Thread Ned Batchelder
no need to pull in a new implementation. The stdlib module is perfectly willing to give you your own private random number sequence to use. -- Ned Batchelder, http://nedbatchelder.com -- https://mail.python.org/mailman/listinfo/python-list

Re: Help with changes in traceback stack from Python 2.7 to Python 3.x

2014-04-26 Thread Ned Batchelder
7;t realize map accepted a callable of None (TIL!), but it no longer does in Python 3. You'll have to do this a different way. But seriously: just use dict() and be done with it. There's a lot here that can be much simpler if you learn to use Python as it was meant to be

Re: Significant digits in a float?

2014-04-28 Thread Ned Batchelder
at sounds like a pretty clean way: len(str(num).partition(".")[2]), though it also sounds like you understand all of the inaccuracies in that technique. -- Ned Batchelder, http://nedbatchelder.com -- https://mail.python.org/mailman/listinfo/python-list

Re: Significant digits in a float?

2014-04-28 Thread Ned Batchelder
On 4/28/14 2:39 PM, Roy Smith wrote: On Monday, April 28, 2014 12:07:14 PM UTC-4, Ned Batchelder wrote: On 4/28/14 12:00 PM, Roy Smith wrote: 38.0 ==> 0 [...] Is there any clean way to do that? The best I've come up with so far is to str() them and parse the remaining string to

Re: Help with changes in traceback stack from Python 2.7 to Python 3.x

2014-04-28 Thread Ned Batchelder
n. Thanks again for your input. ---Andrew BTW, it's a little easier to follow the threads of conversation if you put your responses after the text you are responding to. This is known as bottom-posting, and is preferred to top-posting as you did here. -- Ned Batchelder, http://ne

Re: [bugs] Last week...

2014-04-29 Thread Ned Batchelder
, post the links here. I know some of us will be interested to follow their progress. We all want to see Python be the best it can be. -- Ned Batchelder, http://nedbatchelder.com -- https://mail.python.org/mailman/listinfo/python-list

Re: where to put global testing value

2014-04-29 Thread Ned Batchelder
tself, but that could possibly lead to import loops. Any ideas? In coverage.py, I used environment variables to control that kind of behavior. -- Ned Batchelder, http://nedbatchelder.com -- https://mail.python.org/mailman/listinfo/python-list

Re: Significant digits in a float?

2014-04-29 Thread Ned Batchelder
a height of exactly 29,000 feet, but to avoid the appearance of an estimate, they reported it as 29,002: http://www.jstor.org/stable/2684102 -- Ned Batchelder, http://nedbatchelder.com -- https://mail.python.org/mailman/listinfo/python-list

Re: Unicode 7

2014-05-02 Thread Ned Batchelder
b1 (default, Dec 16 2013, 21:05:22) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> fine = 1 >>> fine 1 In Python 2 identifiers must be AS

Re: Unicode 7

2014-05-02 Thread Ned Batchelder
n you be more explicit? It seems like you think it isn't fine. Why not? What bothers you about it? Should there be an issue? -- Ned Batchelder, http://nedbatchelder.com -- https://mail.python.org/mailman/listinfo/python-list

Re: Pass variable by reference

2014-05-06 Thread Ned Batchelder
riables, you will have to also say that neither do Javascript, Ruby, Java, PHP, etc. And if Javascript has no variables, what does the var keyword mean? -- Ned Batchelder, http://nedbatchelder.com -- https://mail.python.org/mailman/listinfo/python-list

Re: Pass variable by reference

2014-05-06 Thread Ned Batchelder
On 5/6/14 5:00 PM, Mark H Harris wrote: On 5/6/14 3:31 PM, Ned Batchelder wrote: On 5/6/14 12:42 AM, Gary Herron wrote: This gets confusing, but in fact the most accurate answer is that Python does not have "variables", so there is no such thing as passing "variables" by re

Re: The “does Python have variables?” debate

2014-05-06 Thread Ned Batchelder
On 5/6/14 7:55 PM, Ben Finney wrote: Ned Batchelder writes: This meme bugs me so much. Python has variables. They work differently than variables in C. Which is why it's useful to intervene right at the start when someone comes in with assumptions about “variables”; it's better

Re: Normal dict behavior?

2014-05-07 Thread Ned Batchelder
On 5/7/14 11:06 AM, antoine wrote: Hi, Python 2.7.5 (default, Nov 20 2013, 14:20:58) [GCC 4.7.1] on linux2 Type "help", "copyright", "credits" or "license" for more information. {0.: None, 0:None} {0.0: None} The second item disappeared! Why? I

Re: The “does Python have variables?” debate

2014-05-07 Thread Ned Batchelder
sert foo == bar # FAILS, ‘bar’ == [1, 2, 3] Can we make this concrete by speaking about a specific language? I don't recognize this. I thought we were concerned with beginners incorrectly thinking Python worked like C, but this is nothing like C. -- Ned Batchelder, http://nedbatchel

Re: Values and objects

2014-05-11 Thread Ned Batchelder
Note: The contents of this dictionary should not be modified; changes may not affect the values of local and free variables used by the interpreter. This is a tradeoff of practicality for purity: the interpreter runs faster if you don't make locals() a modifiable dict. -- Ned Batchelder, http://nedbatchelder.com -- https://mail.python.org/mailman/listinfo/python-list

Re: New to Python. For in loops curiosity

2014-05-14 Thread Ned Batchelder
pyiter It's a PyCon talk all about iteration in Python, aimed at new learners. -- Ned Batchelder, http://nedbatchelder.com -- https://mail.python.org/mailman/listinfo/python-list

Re: Can't figure out 'instance has no attribute' error

2014-05-17 Thread Ned Batchelder
ents. Then find all the tab characters in your file and replace them with the proper number of spaces. -- Ned Batchelder, http://nedbatchelder.com -- https://mail.python.org/mailman/listinfo/python-list

Re: using a new computer and bringing needed libraries to it

2014-05-17 Thread Ned Batchelder
Keep that file up-to-date as you add new requirements. -- Ned Batchelder, http://nedbatchelder.com -- https://mail.python.org/mailman/listinfo/python-list

Re: Basic help

2014-05-20 Thread Ned Batchelder
. Can you tell us more about your environment? Many thanks for your assistance. Kind regards Pat -- Ned Batchelder, http://nedbatchelder.com -- https://mail.python.org/mailman/listinfo/python-list

Re: trying to find nose.tools.assert_raises_regexp

2014-05-23 Thread Ned Batchelder
ial.py#L46 You don't have assert_raises_regexp because your unittest module doesn't have assertRaisesRegexp. That method is new in 2.7, but you are using 2.6.5, so it doesn't exist. -- Ned Batchelder, http://nedbatchelder.com -- https://mail.python.org/mailman/listinfo/python-list

Re: Loop thru the dictionary with tuples

2014-05-25 Thread Ned Batchelder
es to unpack". What am I doing wrong? Thank you. You want: for key, value in my_dict.items(): # or .iteritems() Iterating over a dictionary gives you its keys. items() will give you key,value pairs. -- Ned Batchelder, http://nedbatchelder.com -- https://mail.python.org/mailman/listinfo/python-list

Re: confused about the different built-in functions in Python

2014-05-25 Thread Ned Batchelder
ation) are usually defined as methods on the type. This is not a black/white distinction, I'm sure there are interesting counter-examples. But this is the general principle. -- Ned Batchelder, http://nedbatchelder.com -- https://mail.python.org/mailman/listinfo/python-list

Re: Loop thru the dictionary with tuples

2014-05-25 Thread Ned Batchelder
On 5/25/14 10:09 PM, Dave Angel wrote: Ned Batchelder Wrote in message: On 5/25/14 8:55 AM, Igor Korot wrote: Hi, ALL, I have a following data structure: my_dict[(var1,var2,var3)] = None my_dict[(var4,var5,var6)] = 'abc' What I'm trying to do is this: for (key,value) in my_

Re: how avoid delay while returning from C-python api?

2014-05-28 Thread Ned Batchelder
. How did you determine that it was the return that was taking the time? ---- Cheers, Lakshmipathi.G FOSS Programmer. www.giis.co.in -- Ned Batchelder, http://nedbatchelder.com -- https://mail.python.org/mailman/listinfo/python-list

Re: Python 3 is killing Python

2014-06-03 Thread Ned Batchelder
illustrious resident unicode expert? Let's please not have a recounting of other peoples' posts, especially if they are posts we try to minimize. -- Ned Batchelder, http://nedbatchelder.com -- https://mail.python.org/mailman/listinfo/python-list

Re: Is it possible to make a unittest decorator to rename a method from "x" to "testx?"

2013-08-08 Thread Ned Batchelder
On 8/8/13 12:17 PM, adam.pre...@gmail.com wrote: On Thursday, August 8, 2013 3:50:47 AM UTC-5, Peter Otten wrote: Peter Otten wrote: Oops, that's an odd class name. Fixing the name clash in Types.__new__() is left as an exercise... I will do some experiments with a custom test loader since I w

<    1   2   3   4   5   6   7   8   9   >