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

2017-12-07 Thread Nathan Ernst
There is a built-in identity function in Python. The function is called 'id'. See https://docs.python.org/3/library/functions.html#id Note that this will not behave the same across different Python runtimes. e.g. CPython, IronPython or Jython all implement this differently. An example: Python 3.5

Re: mssql date format

2016-09-12 Thread Nathan Ernst
Note that this issue is mentioned in the pymssql FAQ: http://pymssql.org/en/stable/faq.html#pymssql-does-not-unserialize-date-and-time-columns-to-datetime-date-and-datetime-time-instances Regards, Nathan On Mon, Sep 12, 2016 at 8:29 PM, Dennis Lee Bieber wrote: > On Tue, 13 Sep 2016 00:52:59 +0

Re: Where is the documentation for ','?

2016-09-16 Thread Nathan Ernst
The grammar and what it represents is defined at https://docs.python.org/3/reference/expressions.html#expression-lists Regards On Sep 16, 2016 9:59 PM, "Peng Yu" wrote: > OK. But it is documented somewhere in python doc? > > On Fri, Sep 16, 2016 at 9:48 PM, Lawrence D’Oliveiro > wrote: > > On

Re: xlsxwriter considering worksheet.write as tuple ???

2016-09-26 Thread Nathan Ernst
On Mon, Sep 26, 2016 at 6:00 PM, MRAB wrote: > On 2016-09-26 23:03, M2 wrote: > >> Hello >> The program is designed to collect different statistics from servers >> across the network and populate in excel sheet. >> Library : xlsxwriter.0.9.3 >> >> Below is the Snip of code being used >> #! /usr/b

Re: xlsxwriter considering worksheet.write as tuple ???

2016-09-26 Thread Nathan Ernst
Mohan Mohta wrote: > > > On Monday, September 26, 2016 at 6:56:20 PM UTC-5, Nathan Ernst wrote: > > >> On Mon, Sep 26, 2016 at 6:00 PM, MRAB > wrote: > > >> > > >> > On 2016-09-26 23:03, M2 wrote: > > >> > > > >> >&g

Re: cx_freeze_zipimporter_instance

2016-11-01 Thread Nathan Ernst
No, because you've not provided anything resembling a question or a problem. Please provide a minimal example set of code that exposes the problem you are encountering, and describe the problem you are having. And note that we will not write code for you if it ends up looking like a homework proble

Re: Best way to go about embedding python

2016-11-13 Thread Nathan Ernst
In regards to performance of Lua vs Python, I don't have enough (near zero experience) with Lua to comment there. But in regards to embedding in a game, the only experience I have w/ Python being embedded is while working on modding Civilization IV. What I saw there just made me nauseous. The rea

Re: help on "from deen import *" vs. "import deen"

2016-11-17 Thread Nathan Ernst
I would also toss in there: never name a script test.py. Causes nothing but trouble, at least in python2. On Nov 17, 2016 8:01 PM, wrote: > Steven D'Aprano at 2016/11/17 4:04:04PM wrote: > > The most important thing you should learn from this thread is: > > > > - avoid using "from module import

Unexpected PendingDeprecationWarning

2016-11-22 Thread Nathan Ernst
I'm using Python 3.5.2, and the following code (when invoked) causes a PendingDeprecationWarning when used in a unit test: def identity(x): return x def adjacent_difference(seq, selector=identity): i = iter(seq) l = selector(next(i)) while True: r = selector(next(i)) yield r - l

Re: Unexpected PendingDeprecationWarning

2016-11-22 Thread Nathan Ernst
(i)) yield r - l l = r except StopIteration: return On Tue, Nov 22, 2016 at 9:02 PM, MRAB wrote: > On 2016-11-23 02:50, Nathan Ernst wrote: > >> I'm using Python 3.5.2, and the following code (when invoked) causes a >> PendingDeprecationWarning w

Re: Unexpected PendingDeprecationWarning

2016-11-22 Thread Nathan Ernst
Thanks, ChrisA On Tue, Nov 22, 2016 at 9:24 PM, Chris Angelico wrote: > On Wed, Nov 23, 2016 at 2:14 PM, Nathan Ernst > wrote: > > I was not aware of that PEP. > > > > The logic in my function is exactly as desired, so to squelch the > warning, > > I mere

Re: NameError

2016-11-23 Thread Nathan Ernst
I don't see anything in that output resembling an error, just a few warnings that some features may no be available. Have you tried importing pygame after you did that? That's what'll prove one way or another that it worked. Regards, Nate On Wed, Nov 23, 2016 at 10:48 PM, Cai Gengyang wrote: >

Re: printing funny symbols within spyder ide

2016-11-25 Thread Nathan Ernst
You're attempting to print out control characters most of which have no visible representation. For "\7", at least if you're running from bash, and not in an IDE, you should get an audible bell. All decimal ordinals below 32 are control You can find a list of the symbols here: http://en.cppreferen

Re: The Case Against Python 3

2016-11-26 Thread Nathan Ernst
Sure, what if the input used a double quote instead of single, cursory glance looks like it might vulnerable. (Not trying to be argumentative here) On Nov 26, 2016 7:21 PM, "Steve D'Aprano" wrote: > On Sun, 27 Nov 2016 11:25 am, Chris Angelico wrote: > > > On Sun, Nov 27, 2016 at 11:13 AM, Stev

Re: The Case Against Python 3

2016-11-26 Thread Nathan Ernst
You're right. Didn't look closely enough at it in my phone. Still don't think i'd recommend this in a general solution, though. You effectively have to white-list code snippets. Not very useful. On Nov 26, 2016 7:51 PM, "Michael Torrie" wrote: > On 11/26/

Re: Asyncio -- delayed calculation

2016-11-28 Thread Nathan Ernst
To be fair, in other languages, such as C# or C++ with similar mechanisms, if you don't ask for the result from an async or future task, there's no guarantee the async task will be executed at all unless (or until) you ask for the result. C++'s futures even give an explicit flag indicating you want

Re: python 2.7.12 on Linux behaving differently than on Windows

2016-12-05 Thread Nathan Ernst
Rather than argue about what is/should be allowed by a filesystem, this defines what is allowed on NTFS (default for modern Windows systems): https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx One can complain about whether or not something should be allowed, but, you'

Re: python 2.7.12 on Linux behaving differently than on Windows

2016-12-05 Thread Nathan Ernst
Ifyou're running on Windows 10, at least, you can soon purge that memory. command.com doesn't exist (may never have existed on Win2k, XP, Vista, 7, 8, 8.1 or 10). If I try and run either "command" or "command.com" from Win10, both say command cannot be found. IIRC, command.com was a relic of Win9x

Re: Detect Linux Runlevel

2016-12-05 Thread Nathan Ernst
OT, but I'm curious, do they explain *why* it's wrong and give an alternative, or just outright deride it as "the wrong way". I ask because I've read similar complaints about the community around systemd, but as it rarely affects me personally, I've never bothered to care. On Mon, Dec 5, 2016 at 8

Re: python 2.7.12 on Linux behaving differently than on Windows

2016-12-06 Thread Nathan Ernst
One other consideration in regards to globbing in the argument list: there's a static limit to the byte length of argv. On windows, it's 8191 bytes (I'm assuming a null-terminator brings that to 8192, which is a weird 2**13). For Linux, as of kernal 2.6.25, apparently, the limit is 131072 bytes, an

Re: python 2.7.12 on Linux behaving differently than on Windows

2016-12-08 Thread Nathan Ernst
With a case-sensitive file system, how do you search only for 'harry', not knowing what combinations of upper and lower case have been used? (It's a good thing Google search isn't case sensitive!) On Linux, I'd do "find . -iname harry". A lot, but not all, of the tools usually have options to igno

Re: Choosing a Python IDE. what is your Pythonish recommendation? I do not know what to choose.

2017-01-05 Thread Nathan Ernst
Have you looked into Visual Studio Code (https://code.visualstudio.com/)? I've not used it extensively, and only on Windows, but it's an open source IDE originated by MS that purportedly works on Windows, Linux & OS X. It does have pretty decent Python support (haven't tried debugging, but syntax

Re: How coding in Python is bad for you

2017-01-27 Thread Nathan Ernst
I used to manually reformat unfamiliar C++ by hand, if for no other reason in that it forced me to read the code and somewhat comprehend what was going on. Now, I've lost my patience and use clang-format, a great & highly configurable tool. I also use vim for Python & C++ coding, so I also rely upo

Re: What are your opinions on .NET Core vs Python?

2017-01-30 Thread Nathan Ernst
I mostly agree with this On Mon, Jan 30, 2017 at 7:18 PM, Joseph L. Casale wrote: > > C# hardly seems any better than Java to me as far as a language goes. > > Which sounds pretty good to me, they are both high performance, mature > and rich languages. > > > Being forced into working with classe

Re: CSV

2017-02-22 Thread Nathan Ernst
One other thing besides the issues noted with filename - newline is set to a space. It should be set to an empty string. See: https://docs.python.org/3/library/csv.html#id3 Regards, Nate On Wed, Feb 22, 2017 at 3:52 PM, wrote: > On Wednesday, February 22, 2017 at 5:55:47 PM UTC, Braxton Alfred

Re: Who are the "spacists"?

2017-03-18 Thread Nathan Ernst
My issue with using spaces instead of tabs, is that, as mentioned earlier in the thread, everyone has their own preferences on indentation. I've worked on teams where different developers used 2, 3 & 4 spaces as indentation. Obviously, if you're using spaces, several of the members will be unhappy.

Re: Who are the "spacists"?

2017-03-18 Thread Nathan Ernst
I don't generally align stuff, either, but if you're going to, use spaces. On Sat, Mar 18, 2017 at 4:55 PM, Chris Angelico wrote: > On Sun, Mar 19, 2017 at 8:50 AM, Nathan Ernst > wrote: > > My rule of thumb: tabs for indentation, spaces for alignment (i.e. trying > &g

Re: Who are the "spacists"?

2017-03-18 Thread Nathan Ernst
On Sat, Mar 18, 2017 at 4:44 PM, ROGER GRAYDON CHRISTMAN wrote: > Just a couple minor notes from my experience: > > 1) > Some of the course management software I use doesn't like me typing tab > characters. > When I want to post sample code into a course page using this software, > tabs > are eit

Re: Who are the "spacists"?

2017-03-18 Thread Nathan Ernst
I want a tab to be inserted, by default. If I want something else, I'll change the configuration. On Sat, Mar 18, 2017 at 6:38 PM, Marko Rauhamaa wrote: > Nathan Ernst : > > > Tabs rectify this issue as you can configure them to appear how you > > like to see your code wi

Re: Recompilation of Python3.6.x

2017-03-22 Thread Nathan Ernst
I would also add a link to the dependency's project page, in case building from source is necessary. You don't always have root, and you're not always building with the system supplied compiler. There are a lot of situations that may require building from source. Far too many to even bother to en

Re: Two variable dictionary comprehension

2017-04-03 Thread Nathan Ernst
I was a bit surprised when I looked at the language reference for 3.6.x. I expected there'd be a direct link to comprehensions, but there's not. You have to know what you're looking for: 6.2.5: List Displays 6.2.6: Set Displays 6.2.7: Dictionary Displays And, then, click on the appropriate eleme

Re: Which directory should requests and openpyxl modules be installed to?

2017-04-03 Thread Nathan Ernst
Hi Pauline, It depends largely on whether you want to (and have sufficient permissions) to install for all users or just yourself. If, on *nix, you're installing site-wide (for all users), typically you'd do: "sudo pip install " (for python 2) or "sudo pip3 install " (for python 3). If you're in

Re: Which directory should requests and openpyxl modules be installed to?

2017-04-03 Thread Nathan Ernst
If you've installed into Program Files, then you're on Windows, and you've installed for all users. Start a command prompt by right-clicking on the start icon, then selecting "Command Prompt (Admin)". This should work on Windows 8.x and Windows 10. Windows 7, you may need to navigate through Progra

Re: Which directory should requests and openpyxl modules be installed to?

2017-04-03 Thread Nathan Ernst
Hi Pauline, I was able to infer you're on Windows, but not which version. Try right-clicking on the start menu to start a command prompt as an administrator (I'm not sure that was available in Windows 7, and I don't have access to a Win7 box currently to verify). Failing that, you should be able t

Re: Two variable dictionary comprehension

2017-04-03 Thread Nathan Ernst
ke a web request, parse JSON or XML, handle datetimes). Remember: Python comes with batteries included. -Nate On Mon, Apr 3, 2017 at 5:09 PM, Deborah Swanson wrote: > Nathan Ernst wrote, on April 03, 2017 1:59 PM > > > > I was a bit surprised when I looked at the language refer

Re: Python and the need for speed

2017-04-11 Thread Nathan Ernst
I used to write Python modules in C++. Well, more accurately, wrapped already-written C++ APIs to expose to Python using Boost Python. This wasn't due to performance issues, but to avoid reimplementing APIs. That said, I believe Python gets a bad wrap in regards to performance for a variety of re

Re: Python and the need for speed

2017-04-11 Thread Nathan Ernst
goto is a misunderstood and much misaligned creature. It is a very useful feature, but like nearly any programming construct can be abused. Constructs like 'break', 'continue' or 'next' in languages like Python or C/C++ are goto's with implied labels. As Mikhail said, goto's can be great to break

Re: Python and the need for speed

2017-04-11 Thread Nathan Ernst
I think that's fair (and I had intended to mention it). Although, I'm curious how threading with IO compares to using async/awai (I've not experience with async/await in Python, just in C#). Regards, Nate On Tue, Apr 11, 2017 at 8:04 PM, MRAB wrote: > On 2017-04-12 01:28,

Re: Goto Considered Harmful [was Re: Python and the need for speed]

2017-04-13 Thread Nathan Ernst
Thank you for that Alan Kay quote. Brightened up my day. Since you also mentioned COBOL, and this is a thread about "goto", reminded me of the single most abhorrent thing I ever saw in COBOL (I had to convert a single COBOL batch process to ASP.Net as an intern back in 2003-4). "MOVE NEXT SENTENCE"

Re: Unable to use Python IDLE after downloading the application

2017-04-17 Thread Nathan Ernst
Off topic, but I find it a little annoying that the default Windows installer links to the 32-bit installer (and there's no adjacent 64-bit installer link) - you have to dive into various links to get the 64-bit installer. Seeing as 64-bit Windows is now the norm, it should be the default. (It is p

Re: Bigotry (you win, I give up)

2017-04-19 Thread Nathan Ernst
I've likewise mostly been ignoring this thread as it has gotten out of control. At a few jobs ago, I was nearly daily involved with interviewing candidates. Initially, I was point on "culture fit". i.e. how would the potential employee react to having a phone thrown at them (it happened - I worked

Re: How to port a python package to a embedded system

2017-04-25 Thread Nathan Ernst
As previously asked: what board are you using? There might be a simple response to your issue, but you've yet to state the board you're using. You will not get any useful responses until you answer this very, very simple question. If you can't "pip install", you'll probably have to build from sour

Re: packaging python code

2017-05-09 Thread Nathan Ernst
I've used bbfreeze on linux, but that's been ~8 years ago. Don't know about the current state of the project. Regards, Nate On Tue, May 9, 2017 at 9:42 PM, MrJean1 wrote: > > > Is there any way to pack my .py with all required libraries and create a > self running package? Something like buildi

Re: How to install Python package from source on Windows

2017-05-15 Thread Nathan Ernst
Deborah, I get the feeling you don't understand the architecture/implementation of Python. The (C)Python interpreter is written in C. A number of the built-in modules are least partially written in C. As such, C is a natural integration point for extensions. Many, many third-party extensions are

Re: Overriding methods on a per instance basis

2017-05-15 Thread Nathan Ernst
There is another way to do it, but it's not pretty, and I don't recommend it: >>> class Foo: ... pass ... >>> from functools import partial >>> f = Foo() >>> def hello(self, arg): ... print("hello", arg) ... >>> f.hello = partial(hello, f) >>> f.hello("world") hello world This basically re

Re: How to install Python package from source on Windows

2017-05-16 Thread Nathan Ernst
MS used to, I'm not sure if they still do, provide a separate C++ SDK that included the compiler, but not the full IDE. It was still quite a large download at ~128MB. But, it included only the command-line compiler, linker & std lib. Starting with VS2017, the ABI is supposedly stable going foward

Re: Error

2017-06-28 Thread Nathan Ernst
Not sure if this is the cause of your error, but the value for the variable "user" is misspelled according to the preceding comment. "admim" vs "admin" (not the M instead of an N at the end). Regards, Nathan On Wed, Jun 28, 2017 at 3:08 PM, Ken R. Lewis wrote: > Hello! > > I am running a script

Re: About the implementation of del in Python 3

2017-07-06 Thread Nathan Ernst
In Python, "==" is not a reference equality operator (and I hate Java for their misuse of the operator), so I absolutely disagree with using the Java description to describe Python's "==" operator, primarily because, well, it's wrong. Simple example: With Python 3.5.2 (should hold for any version

Re: Test 0 and false since false is 0

2017-07-07 Thread Nathan Ernst
You'd be better off using the builtin "isinstance" function, e.g.: isinstance(x, int). This also has the added benefit of working nicely with inheritance (isinstance returns true if the actual type is derived from the classinfo passed as the second argument). See https://docs.python.org/3/library/f

Re: About the implementation of del in Python 3

2017-07-07 Thread Nathan Ernst
gt;>> n = 4000; m = 4000; n is m True >>> n = 4000 >>> m = 4000 >>> n is m False >>> On Fri, Jul 7, 2017 at 2:29 AM, Dan Wissme wrote: > Le 06/07/2017 à 20:56, Nathan Ernst a écrit : > >> In Python, "==" is not a reference equal

Re: Where is python and idle?

2017-07-21 Thread Nathan Ernst
Check your user folder. For me, on my PC, python is installed at C:\Users\nernst\AppData\Local\Programs\Python Regards, Nate On Fri, Jul 21, 2017 at 9:24 AM, Brian Case wrote: > I am running windows 10 version 1703 as administrator on a Dell Inspiron > 15 laptop. > > I downloaded and installed

Re: Reading the documentation

2017-08-24 Thread Nathan Ernst
You passed a string to "math.floor", not anything resembling a numeric type. Try using an actual float, int or Decimal: Python 3.5.2 (default, Nov 17 2016, 17:05:23) [GCC 5.4.0 20160609] on linux Type "help", "copyright", "credits" or "license" for more information. >>> from math import floor >>>