Re: Unicode humor

2013-05-10 Thread Ned Batchelder
On 5/10/2013 11:06 AM, jmfauth wrote: On 8 mai, 15:19, Roy Smith wrote: Apropos to any of the myriad unicode threads that have been going on recently: http://xkcd.com/1209/ -- This reflects a lack of understanding of Unicode. jmf And this reflects a lack of a sense of humor. :) --N

Re: Python for philosophers

2013-05-11 Thread Ned Batchelder
On 5/11/2013 4:03 PM, Citizen Kant wrote: Hi, this could be seen as an extravagant subject but that is not my original purpose. I still don't know if I want to become a programmer or not. At this moment I'm just inspecting the environment. I'm making my way to Python (and OOP in general) from

Re: Message passing syntax for objects | OOPv2

2013-05-12 Thread Ned Batchelder
On 5/8/2013 10:39 PM, Mark Janssen wrote: ...The field needs re-invented and re-centered.[...] For anyone who want to be involved. See the wikiwikiweb -- a tool that every programmer should know and use -- and these pages: ComputerScienceVersionTwo and ObjectOrientedRefactored. I've never un

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

2013-05-12 Thread Ned Batchelder
On 5/12/2013 7: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 - """ # -*- coding: utf-8 -*- from __future__ import unicode_li

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

2013-05-13 Thread Ned Batchelder
On 5/13/2013 1:26 PM, Fábio Santos wrote: On 13 May 2013 11:04, "Alister" > wrote: > this looks to me like an issue with operator precidence > > you code is evaluating as (Not x) == y > rather than not (x == y) I can say for sure that the precedence is as ex

Re: Python for philosophers

2013-05-15 Thread Ned Batchelder
On 5/11/2013 4:03 PM, Citizen Kant wrote: Don't get me wrong. I can see the big picture and the amazing things that programmers write on Python, it's just that my question points to the lowest level of it's existence. Sometimes a cigar is just a cigar. Python is a tool, it does what you tell

Re: spilt question

2013-05-16 Thread Ned Batchelder
On 5/16/2013 11:00 AM, loial wrote: I want to split a string so that I always return everything BEFORE the LAST underscore HELLO_.lst # should return HELLO HELLO_GOODBYE_.ls # should return HELLO_GOODBYE I have tried with rsplit but cannot get it to work. Any help app

Re: Please help with Threading

2013-05-20 Thread Ned Batchelder
On 5/20/2013 6:09 AM, Chris Angelico wrote: Referencing a function's own name in a default has to have one of these interpretations: 1) It's a self-reference, which can be used to guarantee recursion even if the name is rebound 2) It references whatever previously held that name before this def

Re: Myth Busters: % "this old style of formatting will eventually be removed from the language"

2013-05-21 Thread Ned Batchelder
On 5/21/2013 10:26 PM, Carlos Nepomuceno wrote: I was looking for something else and just found what I think is the place where I was first exposed to the myth[1]: "Since str.format() is quite new, a lot of Python code still uses the % operator. However, because this old style of formatting wi

Re: PEP 378: Format Specifier for Thousands Separator

2013-05-22 Thread Ned Batchelder
On 5/21/2013 11:38 PM, Carlos Nepomuceno wrote: From:steve+comp.lang.pyt...@pearwood.info >Subject: Re: PEP 378: Format Specifier for Thousands Separator >Date: Wed, 22 May 2013 03:08:54 + >To:python-list@python.org [...] >>So, the only alternative to have "'%,d' % x" rendering the thousan

Re: PEP 378: Format Specifier for Thousands Separator

2013-05-22 Thread Ned Batchelder
On 5/22/2013 10:58 AM, Steven D'Aprano wrote: On Wed, 22 May 2013 05:45:12 -0500, Skip Montanaro wrote: I didn't mean to create a tempest in a teapot. I was away from comp.lang.python, python-bugs, and python-dev for a few years. In particular, I didn't ever see the aforementioned thread fro

Re: Simple algorithm question - how to reorder a sequence economically

2013-05-24 Thread Ned Batchelder
On 5/24/2013 6:52 AM, Steven D'Aprano wrote: On Fri, 24 May 2013 01:14:45 -0700, Peter Brooks wrote: What is the easiest way to reorder a sequence pseudo-randomly? import random random.shuffle(sequence) The sequence is modified in place, so it must be mutable. Lists are okay, tuples are not.

Re: How to get an integer from a sequence of bytes

2013-05-27 Thread Ned Batchelder
On 5/27/2013 10:45 AM, Mok-Kong Shen wrote: From an int one can use to_bytes to get its individual bytes, but how can one reconstruct the int from the sequence of bytes? The next thing in the docs after int.to_bytes is int.from_bytes: http://docs.python.org/3.3/library/stdtypes.html#int.from_

Re: Getting a callable for any value?

2013-05-29 Thread Ned Batchelder
On 5/29/2013 1:46 PM, Croepha wrote: Is there anything like this in the standard library? class AnyFactory(object): def __init__(self, anything): self.product = anything def __call__(self): return self.product def __repr__(self): return "%s.%s(%r)" % (self.__class__.__module__, self.__class__._

Re: How to get an integer from a sequence of bytes

2013-05-30 Thread Ned Batchelder
On 5/30/2013 2:26 PM, Mok-Kong Shen wrote: Am 27.05.2013 17:30, schrieb Ned Batchelder: On 5/27/2013 10:45 AM, Mok-Kong Shen wrote: From an int one can use to_bytes to get its individual bytes, but how can one reconstruct the int from the sequence of bytes? The next thing in the docs after

Re: PyWart: The problem with "print"

2013-06-02 Thread Ned Batchelder
On 6/2/2013 2:18 PM, Rick Johnson wrote: On Sunday, June 2, 2013 12:49:02 PM UTC-5, Dan Sommers wrote: On Mon, 03 Jun 2013 03:20:52 +1000, Chris Angelico wrote: On Mon, Jun 3, 2013 at 3:04 AM, Rick Johnson [...] Or use the logging module. It's easy to get going quickly (just call logging.bas

Re: Output from to_bytes

2013-06-02 Thread Ned Batchelder
On 6/2/2013 3:09 PM, Mok-Kong Shen wrote: Am 28.05.2013 17:35, schrieb Grant Edwards: On 2013-05-26, Mok-Kong Shen wrote: I don't understand why with the code: for k in range(8,12,1): print(k.to_bytes(2,byteorder='big')) one gets the following output: b'\x00\x08' b'\x0

Re: Bools and explicitness [was Re: PyWart: The problem with "print"]

2013-06-04 Thread Ned Batchelder
On 6/4/2013 12:19 PM, Rick Johnson wrote: On Jun 4, 11:00 am, Chris Angelico wrote: You know, if you want a language with strict type declarations and extreme run-time efficiency, there are some around. I don't like declaring types everywhere, i hate it. I prefer duck typed languages, HOWEVER

Re: Changing filenames from Greeklish => Greek (subprocess complain)

2013-06-10 Thread Ned Batchelder
On Monday, June 10, 2013 3:48:08 PM UTC-4, jmfauth wrote: > - > > > > A coding scheme works with three sets. A *unique* set > of CHARACTERS, a *unique* set of CODE POINTS and a *unique* > set of ENCODED CODE POINTS, unicode or not. > > The relation between the set of characters and the set

Re: [Python-Dev] [RELEASED] Python 3.3.0 alpha 1

2012-03-05 Thread Ned Batchelder
On 3/5/2012 2:54 AM, Georg Brandl wrote: On behalf of the Python development team, I'm happy to announce the first alpha release of Python 3.3.0. This is a preview release, and its use is not recommended in production settings. Python 3.3 includes a range of improvements of the 3.x series, as w

Re: Can I use functions while defining paths?

2017-09-04 Thread Ned Batchelder
On 9/4/17 4:08 AM, Andrej Viktorovich wrote: > Hello, > > Trying to import my made module to python with helper function: > > import os.path.join > ("D","pyth_nonsens","workspace_python","PyhonTutorial","reader") > > > import os.path.join ("D","pyth_nonsens","workspace_python","PyhonTut

Re: Run python module from console

2017-09-05 Thread Ned Batchelder
On 9/5/17 11:16 AM, Stefan Ram wrote: > Andrej Viktorovich writes: >> I suppose I can run python module by passing module as param for executable: >> python.exe myscr.py >> But how to run script when I'm inside of console and have python prompt: The Python console isn't meant for ad-hoc execution

Re: A question on modification of a list via a function invocation

2017-09-05 Thread Ned Batchelder
On 9/5/17 1:02 PM, Steve D'Aprano wrote: > On Tue, 5 Sep 2017 11:37 pm, Gregory Ewing wrote: > >> Dennis Lee Bieber wrote: >>> Pascal, probably Modula-2, Visual BASIC are closer to the C++ reference >>> semantics, in that the definition of a function declares how the >>> argument(s) are passed. >>

Re: A question on modification of a list via a function invocation

2017-09-05 Thread Ned Batchelder
On 9/5/17 1:28 PM, Chris Angelico wrote: > On Wed, Sep 6, 2017 at 3:15 AM, Ned Batchelder wrote: >> On 9/5/17 1:02 PM, Steve D'Aprano wrote: >>> On Tue, 5 Sep 2017 11:37 pm, Gregory Ewing wrote: >>> >>>> Dennis Lee Bieber wrote: >>>>>

Re: Using Python 2

2017-09-08 Thread Ned Batchelder
On 9/8/17 6:12 AM, Leam Hall wrote: > I've read comments about Python 3 moving from the Zen of Python. I'm a > "plain and simple" person myself. Complexity to support what CompSci > folks want, which was used to describe some of the Python 3 changes, > doesn't help me get work done. I've heard a

Re: Using Python 2

2017-09-08 Thread Ned Batchelder
On 9/8/17 10:23 AM, Leam Hall wrote: > On 09/08/2017 09:57 AM, Ned Batchelder wrote: >> I've heard a lot of FUD about the Python 3 transition, but this one is >> new to me.  What is it that CompSci folks want that developers don't >> want, that ruined Python 3?

Re: The Incredible Growth of Python (stackoverflow.blog)

2017-09-10 Thread Ned Batchelder
On 9/10/17 10:46 AM, Rick Johnson wrote: > The stain of Python3's violent and radical changes to the > core philosophy of the language may never be washed clean, > and although we might have survived Python3 _eventually_, > type-hints is like a wooden stake driven into the heart of > this community

Re: The Incredible Growth of Python (stackoverflow.blog)

2017-09-12 Thread Ned Batchelder
On 9/12/17 7:40 AM, Chris Angelico wrote: > On Tue, Sep 12, 2017 at 9:34 PM, Leam Hall wrote: >> On 09/12/2017 07:27 AM, Chris Angelico wrote: >>> On Tue, Sep 12, 2017 at 9:20 PM, Leam Hall wrote: Hey Chris, This is an area the Python community can improve on. Even I would enc

Re: Old Man Yells At Cloud

2017-09-17 Thread Ned Batchelder
On 9/16/17 1:38 AM, Steve D'Aprano wrote: /rant on So apparently everyone who disagrees that Python should be more like Javascript is an old greybeard fuddy-duddy yelling "Get off my lawn!" to the cool kids -- and is also too stupid to know how dumb they are. "Hi, I've been programming in Pytho

Re: How to get Nose to run doctests from my Markdown documentation?

2017-09-20 Thread Ned Batchelder
On 9/20/17 10:07 AM, Skip Montanaro wrote: I routinely include doctests as a source of test cases in my nose runs, but I want to also coax it to check the examples in my Markdown files. Is there a way to do this? If I explicitly give a Markdown file on the command line, nose complains: Unable to

Re: How to get Nose to run doctests from my Markdown documentation?

2017-09-20 Thread Ned Batchelder
On 9/20/17 11:17 AM, Skip Montanaro wrote: There are tools for getting doctests out of .rst files. Is it an option to use .rst instead of .md? Given the existence proof of md working as an extension (see my previous follow-up), my guess is that it more-or-less supports just about any nearly-pla

Re: errors with json.loads

2017-09-20 Thread Ned Batchelder
On 9/20/17 8:22 PM, Bill wrote: Apparenty an \xa0 byte corresponds to a "non-breaking space". What sort of white space characters are allowed in a json file ( tabs and newlines?)?  Just curious. These things can be looked up.  From RFC 7159 (https://tools.ietf.org/html/rfc7159): Insign

Re: errors with json.loads

2017-09-21 Thread Ned Batchelder
On 9/20/17 10:35 PM, Bill wrote: Ned Batchelder wrote: On 9/20/17 8:22 PM, Bill wrote: Apparenty an \xa0 byte corresponds to a "non-breaking space". What sort of white space characters are allowed in a json file ( tabs and newlines?)?  Just curious. These things can be looked

Re: errors with json.loads

2017-09-21 Thread Ned Batchelder
On 9/21/17 12:18 PM, john polo wrote: Bill, Thanks for the reply. I wasn't sure how to get Python 2 through the cmd or IPython, so I went through ArcGIS, but it's mostly the same result: >>> file = open('books.json','r') >>> text = file.read() >>> text = json.loads(text) After the file.read

Re: Assertions

2017-09-21 Thread Ned Batchelder
On 9/21/17 12:29 PM, Tobiah wrote: Are these completely equivalent? def foo(thing): assert(thing > 0), "Thing must be greater than zero" def foo(thing): if not (thing > 0): raise AssertionError("Thing must be greater than zero") Other than the fact that the assertion can

Re: Beginners and experts (Batchelder blog post)

2017-09-23 Thread Ned Batchelder
On 9/23/17 2:52 PM, Leam Hall wrote: On 09/23/2017 02:40 PM, Terry Reedy wrote: https://nedbatchelder.com//blog/201709/beginners_and_experts.html Great post. Yup. Thanks for the link. I often have that "I bet Fred> doesn't get frustrated." thing going. Nice to know Ned bangs his head now and

Re: [Tutor] beginning to code

2017-09-25 Thread Ned Batchelder
On 9/25/17 8:24 AM, Steve D'Aprano wrote: On Mon, 25 Sep 2017 08:05 pm, Antoon Pardon wrote: Pass by reference doesn't imply being able to write a swap function. Really. Do you have a counter-example? A swap function as possible in pascal requires two conditions. 1) Pass by reference 2) Co

Re: [Tutor] beginning to code

2017-09-25 Thread Ned Batchelder
On 9/25/17 9:15 AM, Antoon Pardon wrote: Op 25-09-17 om 14:53 schreef Ned Batchelder: On 9/25/17 8:24 AM, Steve D'Aprano wrote: On Mon, 25 Sep 2017 08:05 pm, Antoon Pardon wrote: Pass by reference doesn't imply being able to write a swap function. Really. Do you have a counter-exa

Re: Grumpy-pants spoil-sport [was Re: [Tutor] beginning to code]

2017-09-25 Thread Ned Batchelder
On 9/25/17 12:29 PM, Steve D'Aprano wrote: Regardless of whether I'm using Python, Swift, Java, C, Pascal or Scheme, if I write something like: x = Parrot(name="Polly") (using Python syntax for simplicity) and somebody tries to tell me that the value of x is anything but a Parrot instance named

Re: TypeError with map with no len()

2017-09-25 Thread Ned Batchelder
On 9/25/17 12:44 PM, john polo wrote: Python List, I am trying to make practice data for plotting purposes. I am using Python 3.6. The instructions I have are import matplotlib.pyplot as plt import math import numpy as np t = np.arange(0, 2.5, 0.1) y1 = map(math.sin, math.pi*t) plt.plot(t,y1)

Re: [Tutor] beginning to code

2017-09-25 Thread Ned Batchelder
On 9/25/17 5:32 AM, Antoon Pardon wrote: Can you explain, what you mean by "Pass-By-Reference" as far a I understand, pass by reference means that the parameter of the function becomes an alias of the argument, so that if the entity is mutated through one name that mutation is visible through the

Re: Grumpy-pants spoil-sport [was Re: [Tutor] beginning to code]

2017-09-25 Thread Ned Batchelder
On 9/25/17 10:20 PM, Steve D'Aprano wrote: On Tue, 26 Sep 2017 02:54 am, Ned Batchelder wrote: [...] We've been asked nicely by the list mod to stop :) --Ned. -- https://mail.python.org/mailman/listinfo/python-list

Re: Real Programmers Write Docs

2017-09-27 Thread Ned Batchelder
On 9/27/17 6:55 PM, Rob Gaddi wrote: Anyone have any good references on using Sphinx to generate a mix of autogenerated API docs and hand-written "Yeah, but this is what you DO with it" docs?  Free is good but I'm happy to drop money on books if they're worthwhile. I can offer you an exampl

Re: newb question about @property

2017-09-30 Thread Ned Batchelder
On 9/30/17 5:47 PM, Bill wrote: I spent a few hours experimenting with @property. To my mind it seems like it would be preferable to just define (override) instance methods __get__(), __set__(), and possibly __del__(), as desired, as I could easily provide them with "ideal" customization. Am I

Re: newb question about @property

2017-09-30 Thread Ned Batchelder
On 9/30/17 7:18 PM, Bill wrote: Ned Batchelder wrote: On 9/30/17 5:47 PM, Bill wrote: I spent a few hours experimenting with @property. To my mind it seems like it would be preferable to just define (override) instance methods __get__(), __set__(), and possibly __del__(), as desired, as I

Re: The "loop and a half"

2017-10-04 Thread Ned Batchelder
On 10/4/17 7:37 AM, Stefan Ram wrote: bartc writes: Note that your reverse-indentation style is confusing! In Python, indentation can be significant. Sometimes, some lines in Python must be indented by 0. This dictates that Python code cannot be indented in posts to differentiate

Re: "comprehend" into a single value

2017-10-08 Thread Ned Batchelder
On 10/8/17 1:00 AM, Andrew Z wrote: and how about adding "IF" into the mix ? as in : a=0 dict= {10: ['a',1,'c'], 20: ['d',2,'f']} for i in dict: p+= 10 if dict[i][1] in [1,2,3,4,5] else 0 can i "squish" "for" and "if" together ? or will it be too perl-ish ?     sum(10 for v in dict.val

Re: Is there a way to globally set the print function separator?

2017-10-09 Thread Ned Batchelder
On 10/9/17 12:22 PM, John Black wrote: I want sep="" to be the default without having to specify it every time I call print. Is that possible? There isn't a way to change the default for print(sep="") globally. Generally when you want better control over the output, you use string formatti

Re: about 'setattr(o, name, value)' and 'inspect.signature(f)'

2017-10-10 Thread Ned Batchelder
On 10/10/17 11:00 AM, Stefan Ram wrote: xieyuheng writes: 1. 'setattr(o, name, value)' can be used for what kind of objects ? It takes three objects as arguments. The first object should have an attribute named by the value of »name« that should allow this attribute to be set to »

Re: An endless loop

2017-10-15 Thread Ned Batchelder
On 10/15/17 9:59 AM, bartc wrote: On 15/10/2017 12:20, Chris Angelico wrote: On Sun, Oct 15, 2017 at 9:15 PM, bartc wrote: I assume you're talking about the while-loop (because on my machine, it hangs just using 'from turtle...' or 'import turtle'). (Machine was screwed up I think, as I ha

Re: how to read in the newsreader

2017-10-16 Thread Ned Batchelder
On 10/16/17 12:31 AM, Andrew Z wrote: i'm typing without thinking. Sorry. Let me try again. I subscribed to python-list@python.org. That has 0 spam ( as far as i can see), but i can only get a digest. You can choose to get individual messages from Python-List. --Ned. -- https://mail.python.o

Re: why del is not a function or method?

2017-10-16 Thread Ned Batchelder
On 10/16/17 12:16 PM, Oren Ben-Kiki wrote: That doesn't explain why `del` isn't a method though. Intuitively, `my_dict.delete(some_key)` makes sense as a method. Of course, you could also make the same case for `len` being a method... and personally I think it would have been cleaner that way in

Re: Strange behavior in string interpolation of constants

2017-10-16 Thread Ned Batchelder
On 10/16/17 7:39 PM, מיקי מונין wrote: Hello, I am working on an article on python string formatting. As a part of the article I am researching the different forms of python string formatting. While researching string interpolation(i.e. the % operator) I noticed something weird with string lengt

Re: why del is not a function or method?

2017-10-16 Thread Ned Batchelder
On 10/16/17 9:06 PM, bartc wrote: On 17/10/2017 01:53, Steve D'Aprano wrote: On Tue, 17 Oct 2017 03:16 am, Oren Ben-Kiki wrote: That doesn't explain why `del` isn't a method though. `del` cannot be a method or a function, because the argument to `del` is the name of the variable, not the

Re: [RELEASE] Python 3.7.0a2 is now available for testing

2017-10-17 Thread Ned Batchelder
On 10/17/17 3:35 PM, Ned Deily wrote: Python 3.7.0a2 is the second of four planned alpha previews of Python 3.7, the next feature release of Python. During the alpha phase, Python 3.7 remains under heavy development: additional features will be added and existing features may be modified or dele

Re: Let's talk about debuggers!

2017-10-25 Thread Ned Batchelder
On 10/25/17 9:07 AM, Thomas Jollans wrote: Hi, I just wanted to know what tools everyone used for debugging Python applications - scripts / backend / desktop apps / notebooks / whatever. Apart from the usual dance with log files and strategically inserted print() calls, that is. Of course we al

Re: Just a quick question about main()

2017-10-27 Thread Ned Batchelder
On 10/27/17 2:05 PM, ROGER GRAYDON CHRISTMAN wrote: While teaching my introductory course in Python, I occasionally see submissions containing the following two program lines, even before I teach about functions and modules: if __name__ = '__main__': ... main() When I ask about it, I hear thin

Re: Coding style in CPython implementation

2017-10-28 Thread Ned Batchelder
On 10/28/17 3:00 PM, Stefan Ram wrote: =?UTF-8?B?zqPPhM6tz4bOsc69zr/PgiDOo8+Jz4bPgc6/zr3Or86/z4U=?= writes: What I wanted to ask is, is there a particular reason for not choosing I am not a CPython developer, but here are my 2 cents about the possibilities: if (variable == NULL) { ...

Re: Coding style in CPython implementation

2017-10-28 Thread Ned Batchelder
On 10/28/17 4:26 PM, Stefan Ram wrote: Ned Batchelder writes: On 10/28/17 3:00 PM, Stefan Ram wrote: =?UTF-8?B?zqPPhM6tz4bOsc69zr/PgiDOo8+Jz4bPgc6/zr3Or86/z4U=?= writes: What I wanted to ask is, is there a particular reason for not choosing definition of »NULL«. »NULL« is not part of

Re: Invoking return through a function?

2017-10-29 Thread Ned Batchelder
On 10/29/17 10:18 AM, Alberto Riva wrote: Hello, I'm wondering if there is a way of writing a function that causes a return from the function that called it. To explain with an example, let's say that I want to exit my function if a dict does not contain a given key. I could write: def test

Re: Invoking return through a function?

2017-10-29 Thread Ned Batchelder
On 10/29/17 3:09 PM, Alberto Riva wrote: On 10/29/2017 02:13 PM, Rick Johnson wrote: Alberto Riva wrote: Rick Johnson wrote: Alberto Riva wrote: [...] In a language like Lisp Python is nothing like Lisp, and for good reason! I would disagree with this. Actually, it's the most Lisp- like

Re: How to join elements at the beginning and end of the list

2017-10-31 Thread Ned Batchelder
On 10/31/17 11:29 AM, Neil Cerutti wrote: On 2017-10-31, Ganesh Pal wrote: Here is my solution values = '||' + '||'.join(map(str, value_list)) + '||' values '||1||2||3||4||56||s||' I am joining the elements at the beginning and end of the list using '+' operator any other solution, this is

Re: How to join elements at the beginning and end of the list

2017-10-31 Thread Ned Batchelder
On 10/31/17 12:29 PM, Stefan Ram wrote: Ned Batchelder writes: However you solve it, do yourself a favor and write a function to encapsulate it: It is always a good solution to encapsulate a pattern into a function. So I agree that this is a good suggestion. But just for the sole

Re: The syntax of replacement fields in format strings

2017-11-01 Thread Ned Batchelder
On 10/31/17 12:45 PM, John Smith wrote: If we keep the current implementation as is, perhaps the documentation should at least be altered ? John, it looks like you are responding to a Python-Dev message, but on this list, somehow... --Ned. -- https://mail.python.org/mailman/listinfo/python-l

Re: Code Snippets

2017-11-01 Thread Ned Batchelder
On 11/1/17 1:25 PM, Stefan Ram wrote: I started to collect some code snippets: Sleep one second __import__( "time" ).sleep( 1 ) Get current directory __import__( "os" ).getcwd() Get a random number __import__( "random" ).random() And so on. You get the idea. However, rep

Re: Report on non-breaking spaces in posts

2017-11-01 Thread Ned Batchelder
On 10/31/17 1:23 PM, Stefan Ram wrote: Ok, here's a report on me seing non-breaking spaces in posts in this NG. I have written this report so that you can see that it's not my newsreader that is converting something, because there is no newsreader involved. You've worded this as if

String changing size on failure?

2017-11-01 Thread Ned Batchelder
From David Beazley (https://twitter.com/dabeaz/status/925787482515533830): >>> a = 'n' >>> b = 'ñ' >>> sys.getsizeof(a) 50 >>> sys.getsizeof(b) 74 >>> float(b) Traceback (most recent call last):   File "", line 1, in ValueError: could not convert string to flo

Re: String changing size on failure?

2017-11-01 Thread Ned Batchelder
On 11/1/17 4:17 PM, MRAB wrote: On 2017-11-01 19:26, Ned Batchelder wrote:   From David Beazley (https://twitter.com/dabeaz/status/925787482515533830):   >>> a = 'n'   >>> b = 'ñ'   >>> sys.getsizeof(a) 50   >>> sy

Re: replacing `else` with `then` in `for` and `try`

2017-11-01 Thread Ned Batchelder
On 11/1/17 5:12 PM, Alexey Muranov wrote: Hello, what do you think about the idea of replacing "`else`" with "`then`" in the contexts of `for` and `try`? It seems clear that it should be rather "then" than "else." Compare also "try ... then ... finally" with "try ... else ... finally". Cur

Re: replacing `else` with `then` in `for` and `try`

2017-11-01 Thread Ned Batchelder
On 11/1/17 5:29 PM, Chris Angelico wrote: On Thu, Nov 2, 2017 at 8:23 AM, Ned Batchelder wrote: On 11/1/17 5:12 PM, Alexey Muranov wrote: Hello, what do you think about the idea of replacing "`else`" with "`then`" in the contexts of `for` and `try`? It seems clear that

Re: replacing `else` with `then` in `for` and `try`

2017-11-06 Thread Ned Batchelder
On 11/6/17 8:05 AM, Jon Ribbens wrote: On 2017-11-06, Chris Angelico wrote: If you start with the assumption that "intuitively obvious" doesn't actually mean "intuitively obvious" but actually means something completely different, then your statement definitely means something non-contradictory

Re: Ideas about how software should behave

2017-11-07 Thread Ned Batchelder
On 11/7/17 5:48 PM, Ben Finney wrote: Ian Kelly writes: Nowadays I realize and accept that this is preposterous. You cannot criticize an idea without also criticizing the people who are attached to that idea. Maybe so. Does that mean we must not criticise ideas? Later in your message you say

Re: Ideas about how software should behave

2017-11-08 Thread Ned Batchelder
On 11/8/17 5:22 PM, Ben Finney wrote: Jon Ribbens writes: On 2017-11-08, Ben Finney wrote: I also think Jon had cause to bristle somewhat at the characterisation. I don't think Jon was attacked by Steve's remark, but I do sympathise with the instinct to feel a criticism as an attack. Steve

Re: Ideas about how software should behave

2017-11-10 Thread Ned Batchelder
On 11/8/17 3:05 PM, Marko Rauhamaa wrote: Jon Ribbens : It is my experience of this group/list that if one disagrees with any of you, Steve and Chris, you all rally round and gang up on that person to insult and belittle them. This makes the atmosphere quite hostile, and it would be quite remark

Re: Ideas about how software should behave

2017-11-10 Thread Ned Batchelder
On 11/8/17 10:18 PM, Ben Finney wrote: How many paragraphs of close parsing are we going to twist ourselves through, just to avoid saying, "Yeah, sorry, that went a bit far.  I didn't want to alienate you in the pursuit of a demonstration of my own correctness." I don't have any aim of avoiding

Re: Ideas about how software should behave

2017-11-10 Thread Ned Batchelder
On 11/10/17 6:03 PM, Ben Finney wrote: Ned Batchelder writes: On 11/8/17 10:18 PM, Ben Finney wrote: What has been made clear to me is that we have a long way to go in pursuit of allowing ideas to be held at arm's length, discussed and criticised, with respect and compassion for one an

Re: How to modify this from Python 2.x to v3.4?

2017-11-11 Thread Ned Batchelder
On 11/11/17 6:56 AM, jf...@ms4.hinet.net wrote: I learned python start from using v3.4 and never has any v2.x experience. There is a Pypi project "ctypesgen" I like to use, but it seems is for v2.x. (un)Fortunately I found one of its branch on github which announced is for Python3, but strangel

Re: from xx import yy

2017-11-12 Thread Ned Batchelder
On 11/12/17 9:17 PM, bvdp wrote: I'm having a conceptual mind-fart today. I just modified a bunch of code to use "from xx import variable" when variable is a global in xx.py. But, when I change/read 'variable' it doesn't appear to change. I've written a bit of code to show the problem: mod1.p

Re: Should constants be introduced to Python?

2017-11-16 Thread Ned Batchelder
On 11/16/17 1:16 AM, Saeed Baig wrote: Hey guys I am thinking of perhaps writing a PEP to introduce constants to Python. Something along the lines of Swift’s “let” syntax (e.g. “let pi = 3.14”). Since I’m sort of new to this, I just wanted to ask: - Has a PEP for this already been written? If

Re: How to Generate dynamic HTML Report using Python

2017-11-19 Thread Ned Batchelder
On 11/19/17 8:40 PM, Stefan Ram wrote: mradul dhakad writes: I am new to python . I am trying to generate Dynamic HTML report using Pyhton based on number of rows selected from query .Do any one can suggest some thing for it. main.py import sqlite3 conn = sqlite3.connect( ':memory:' ) c =

Re: How to Generate dynamic HTML Report using Python

2017-11-21 Thread Ned Batchelder
On 11/20/17 9:50 AM, Stefan Ram wrote: Ned Batchelder writes: Also, why set headers that prevent the Python-List mailing list from archiving your messages? I am posting to a Usenet newsgroup. I am not aware of any "Python-List mailing list". I am posting specifically to

Re: Benefits of unicode identifiers (was: Allow additional separator in identifiers)

2017-11-24 Thread Ned Batchelder
On 11/24/17 5:26 PM, Richard Damon wrote: Have you tried using U+2010 (HYPHEN) ‐. It is in the class XID_CONTINUE (in fact it is in XID_START) so should be available. U+2010 isn't allowed in Python 3 identifiers. The rules for identifiers are here: https://docs.python.org/3/reference/lexical

Re: Compile Python 3 interpreter to force 2-byte unicode

2017-11-25 Thread Ned Batchelder
On 11/25/17 5:05 PM, wojtek.m...@gmail.com wrote: Hi, my goal is to obtain an interpreter that internally uses UCS-2. Such a simple code should print 65535: import sys print sys.maxunicode This is enabled in Windows, but I want the same in Linux. What options have I pass to the configure

Re: I have framework on python with pyunit, facing below issue while executing test case

2017-11-27 Thread Ned Batchelder
On 11/27/17 8:13 AM, jaya.bir...@gmail.com wrote: Please let me know anyone aware about the issue Traceback (most recent call last): File "testrunner.py", line 447, in testrunner_obj.main() File "testrunner.py", line 433, in main self.result() File "testrunner.py", line 310, in result result =

Re: While, If, Count Statements

2017-11-27 Thread Ned Batchelder
On 11/27/17 7:54 AM, Cai Gengyang wrote: Input : count = 0 if count < 5: print "Hello, I am an if statement and count is", count while count < 10: print "Hello, I am a while and count is", count count += 1 Output : Hello, I am an if statement and count is 0 Hello, I am a while and c

Re: connect four (game)

2017-11-27 Thread Ned Batchelder
On 11/27/17 1:57 PM, bartc wrote: On 27/11/2017 17:41, Chris Angelico wrote: On Tue, Nov 28, 2017 at 2:14 AM, bartc wrote: JPEG uses lossy compression. The resulting recovered data is an approximation of the original. Ah but it is a perfect representation of the JPEG stream. Any given compre

Re: How to use a regexp here

2017-12-04 Thread Ned Batchelder
On 12/4/17 4:36 AM, Cecil Westerhof wrote: I have a script that was running perfectly for some time. It uses: array = [elem for elem in output if 'CPU_TEMP' in elem] But because output has changed, I have to check for CPU_TEMP at the beginning of the line. What would be the best way to impl

Re: How to use a regexp here

2017-12-04 Thread Ned Batchelder
On 12/4/17 9:13 AM, Rick Johnson wrote: Perhaps it's not politically correct for me to say this, but i've never been one who cared much about political correctness, so i'm just going to say it... Cecil, feel free to ignore the rest of Rick's message.  His messages are famous for their outrageo

Re: why won't slicing lists raise IndexError?

2017-12-04 Thread Ned Batchelder
On 12/4/17 8:03 PM, Rick Johnson wrote: On Monday, December 4, 2017 at 6:13:19 PM UTC-6, Chris Angelico wrote: [...] Ahhh, I see how it is. You didn't run the code, ergo you don't understand it. Makes perfect sense. :) Being that Terry didn't offer any declarations or defintions for his

Re: why won't slicing lists raise IndexError?

2017-12-04 Thread Ned Batchelder
On 12/4/17 9:31 PM, Rick Johnson wrote: On Monday, December 4, 2017 at 7:47:20 PM UTC-6, Ned Batchelder wrote: [...] Here are details filled in: $ python3.6 Python 3.6.3 (default, Oct 4 2017, 06:03:25) [GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.37)] on darwin

Re: why won't slicing lists raise IndexError?

2017-12-05 Thread Ned Batchelder
On 12/4/17 10:41 PM, Rick Johnson wrote: I think we've demonstrated the slicing semantics well. Indeed. And i never questioned this aspect. I merely wanted to inform the lurkers that the else-clause was handling a non-action, and therefore, could be omitted. Your original statement sounded lik

Re: f-string

2017-12-05 Thread Ned Batchelder
On 12/5/17 7:16 PM, Steve D'Aprano wrote: compile('f"{spam} {eggs}"', '', 'single') $ python3.6 Python 3.6.3 (default, Oct  4 2017, 06:03:25) [GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.37)] on darwin Type "help", "copyright", "credits" or "license" for more information.

Re: why won't slicing lists raise IndexError?

2017-12-06 Thread Ned Batchelder
After a certain point, the only thing you can do with a troll is ignore them. --Ned. -- https://mail.python.org/mailman/listinfo/python-list

Re: Stackoverflow question: Is there a built-in identity function in Python?

2017-12-07 Thread Ned Batchelder
On 12/7/17 1:28 PM, Ethan Furman wrote: The simple answer is No, and all the answers agree on that point. It does beg the question of what an identity function is, though. My contention is that an identity function is a do-nothing function that simply returns what it was given: --> identity(

Re: Stackoverflow question: Is there a built-in identity function in Python?

2017-12-07 Thread Ned Batchelder
On 12/7/17 2:41 PM, Ethan Furman wrote: On 12/07/2017 11:23 AM, Ned Batchelder wrote: On 12/7/17 1:28 PM, Ethan Furman wrote: --> identity('spam', 'eggs', 7) ('spam', 'eggs', 7) I don't see why this last case should hold.  Why does the functi

Re: why won't slicing lists raise IndexError?

2017-12-08 Thread Ned Batchelder
On 12/7/17 9:02 PM, Python wrote: Can you please explain to me Really, you just have to ignore him. --Ned. -- https://mail.python.org/mailman/listinfo/python-list

Re: How to use a regexp here

2017-12-08 Thread Ned Batchelder
On 12/4/17 4:36 AM, Cecil Westerhof wrote: > I have a script that was running perfectly for some time. It uses: > array = [elem for elem in output if 'CPU_TEMP' in elem] > > But because output has changed, I have to check for CPU_TEMP at the > beginning of the line. What would be the best way

Re: How to use a regexp here

2017-12-08 Thread Ned Batchelder
On 12/4/17 9:13 AM, Rick Johnson wrote: > Perhaps it's not politically correct for me to say this, but > i've never been one who cared much about political > correctness, so i'm just going to say it... Cecil, feel free to ignore the rest of Rick's message.â His messages are famous for their outra

Re: f-string

2017-12-08 Thread Ned Batchelder
On 12/5/17 7:16 PM, Steve D'Aprano wrote: > compile('f"{spam} {eggs}"', '', 'single') $ python3.6 Python 3.6.3 (default, Octâ 4 2017, 06:03:25) [GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.37)] on darwin Type "help", "copyright", "credits" or "license" for more information.

Re: Automated distribution building tools to support SpamBayes

2017-12-15 Thread Ned Batchelder
On 12/15/17 2:03 PM, Skip Montanaro wrote: SpamBayes (http://www.spambayes.org/) has languished for quite awhile, in part because nobody is around who can put together a Windows installer. Unfortunately, most users are on Windows and have to work around problems caused by the march of time and co

  1   2   3   4   5   6   7   8   9   >