Re: [Tutor] Installing Python v3 on a laptop Windows 10

2019-06-15 Thread eryk sun
On 6/15/19, Alan Gauld via Tutor wrote: > On 15/06/2019 22:23, Ken Green wrote: > >> I understood there is a preferable method >> of installing Python into Windows. I pray >> tell on how about to do it, gentlemen. > > It depends a bit on which python distribution you use, > there are several. > >

Re: [Tutor] Case Insensitive Globing

2019-05-19 Thread eryk sun
On 5/19/19, Alan Gauld via Tutor wrote: > > Hmm, odd. My NTFS filesystems on Windows all appear to be case > sensitive. For example I have a photo editor that saves its files > with a jpg extension but the files from my camera all end in JPG. > So I always end up with two copies - the original fil

Re: [Tutor] How arguments to the super() function works?

2019-05-19 Thread eryk sun
On 5/19/19, Arup Rakshit wrote: > > class Dad: > def can_i_take_your_car(self): > print("No...") > > class Mom(Dad): > def can_i_take_your_car(self): > print("Asking your dad...") > > class Victor(Mom, Dad): > def can_i_take_your_car(self): > print("Asking mom..

Re: [Tutor] Case Insensitive Globing

2019-05-19 Thread eryk sun
On 5/18/19, Steven D'Aprano wrote: > > That means that, like Windows file systems FAT and NTFS, file names are > case-insensitive: files "Foo", "foo" and "FOO" are all considered the > same. But unlike Windows, the file system preserves the case of the file > as you created it, so if you created i

Re: [Tutor] What is this code doing? What is it?

2019-05-12 Thread eryk sun
On 5/12/19, Alan Gauld via Tutor wrote: > > They are both very powerful ways of constructing output strings with > data inserted. {} and format() has a few extra tricks once you get > into advanced uses, but % style does most of the same things (and > has the advantage of being used in other langu

Re: [Tutor] Exception not working as expected?

2019-02-28 Thread eryk sun
On 2/28/19, Chip Wachob wrote: > > Python 2.7 & Windows and also Linux are the platforms being used. Running > the code from the command line / terminal as python except.py. Note that > it does work properly in Linux. So I'm guessing I need to test for a > different exception along with the K

Re: [Tutor] ANSI / VT100 Escape Codes in Windows 7 Environment

2019-02-27 Thread eryk sun
On 2/27/19, Alan Gauld via Tutor wrote: > On 27/02/2019 18:28, Chip Wachob wrote: >> Windows 7 vintage machine this morning. > > Caveat: I have no direct experience on Windows 7 - I jumped > from XP to Windows 8... Also I haven't used ANSIO codes in > Windows since the heady days of Windows 98! Bu

Re: [Tutor] ANSI / VT100 Escape Codes in Windows 7 Environment

2019-02-27 Thread eryk sun
On 2/27/19, Chip Wachob wrote: > > I've been spending the morning looking at different solutions. Many of > them seem to involve either including yet aother module, or, worse (IMHO) a > C library that will 'emulate' the ANSI escape sequences, API calls, etc. To support virtual-terminal sequences

Re: [Tutor] What is the best way for a program suite to know where it is installed?

2018-10-22 Thread eryk sun
On 10/22/18, boB Stepp wrote: > > Importing the various program modules/module contents is > no issue. Where I believe I need to know the paths to things are to > get to data folders, config files, and occasionally utility programs > that I have written that are on my hard drive, but not copied t

Re: [Tutor] what does the forward slash mean in this function signature?

2018-10-15 Thread eryk sun
On Mon, Oct 15, 2018 at 6:00 AM Albert-Jan Roskam wrote: > > In Python 3.6 (Windows) I often see a forward slash in a function signature, > see below. > What does it mean? I vaguely remember reading something about new > possbilities in > python 3, something like "def foo(x, *, y)". Perhaps it's

Re: [Tutor] calling printf() in a C language DLL using ctypes.CDLL

2018-05-08 Thread eryk sun
On Wed, May 9, 2018 at 1:30 AM, Brad M wrote: > > If you want to know where your program went when something went wrong or > when it triggers a if condition, how do you do it? Look into use the logging module [1] and debuggers [2], either dedicated like Winpdb or in an IDE such as PyCharm. [1]:

Re: [Tutor] calling printf() in a C language DLL using ctypes.CDLL

2018-05-08 Thread eryk sun
On Tue, May 8, 2018 at 9:39 AM, Brad M wrote: > > I compile this by typing this in the command line: > cl /LD /I C:\python\include helloworld.c C:\python\libs\python36.lib You're not using Python's C API, so you only need `cl /LD helloworld.c`. > However, this doesn't print anything on the pytho

Re: [Tutor] Python C extension - which method?

2018-05-07 Thread eryk sun
On Mon, May 7, 2018 at 9:57 AM, Michael C wrote: > Sorry I don't understand your suggestion. > > Use "ctypes.CDLL" and "ctypes.WinDLL" > > this works, > mydll = cdll.LoadLibrary('test.dll') > print(mydll.sum(3,2)) > > and this doens't > mydll = cdll('test.dll') > print(mydll.sum(3,2)) > > What's t

Re: [Tutor] passing values and C pointers

2018-05-06 Thread eryk sun
On Sun, May 6, 2018 at 2:17 AM, Brad M wrote: > > Say I have an array of values, say addresses or int produced by a c module/ > c function that's in a DLL , how do I pass that array back to > the python code? C arrays are passed and returned automatically as pointers to the first element. The arr

Re: [Tutor] Python C extension - which method?

2018-05-06 Thread eryk sun
On Sun, May 6, 2018 at 12:49 AM, Brad M wrote: > If I may ask, what's the difference between these two? > > 1) > import ctypes > hello = ctypes.WinDLL('hello', use_last_error=True) > > 2) > from ctypes import cdll > hello = cdll.LoadLibrary('hello.dll') Use ctypes.CDLL and ctypes.WinDLL instead o

Re: [Tutor] running a .py file from the comand line

2018-04-02 Thread eryk sun
On Mon, Apr 2, 2018 at 8:53 AM, Alan Gauld via Tutor wrote: > > Try > > python c:\Users\Rex\"ascii keys.py" > > Note the quotes to cater for the space. > >> python: can't open file 'Ascii': [errno2] no such file or directory > > The space confuses windows CMD, so it thinks you have > two files c

Re: [Tutor] Virtual environment question

2018-03-12 Thread eryk sun
On Tue, Mar 13, 2018 at 1:31 AM, Jim wrote: > On 03/12/2018 04:04 AM, eryk sun wrote: >> >> On Mon, Mar 12, 2018 at 12:44 AM, Jim wrote: >>> >>> home = /usr/bin >>> include-system-site-packages = false >> >> [...] >>> >>>

Re: [Tutor] Virtual environment question

2018-03-12 Thread eryk sun
On Mon, Mar 12, 2018 at 12:44 AM, Jim wrote: > > home = /usr/bin > include-system-site-packages = false [...] > resp = opener.open(request, timeout=self._timeout) > File "/usr/lib/python3.5/urllib/request.py", line 466, in open This is normal. Virtual environments are not isolated from the

Re: [Tutor] When is and isn't "__file__" set?

2018-01-12 Thread eryk sun
On Fri, Jan 12, 2018 at 5:22 PM, Albert-Jan Roskam wrote: > On Jan 11, 2018 03:47, Steven D'Aprano wrote: >> >> Modules which are loaded from a .dll or .so binary file also should have >> __file__ set. > > And .pyd? I would hope so A .pyd is a Windows DLL (i.e. PE/COFF shared library). The .pyd

Re: [Tutor] Why does os.path.realpath('test_main.py') give different results for unittest than for testing statement in interpreter?

2018-01-10 Thread eryk sun
On Wed, Jan 10, 2018 at 12:59 PM, Albert-Jan Roskam wrote: > > I tried: from os.path import _getfullpathname _getfullpathname(r"H:") > 'h:\\path\\to\\folder' import os os.getcwd() > 'h:\\path\\to\\folder' > > I expected h:\ to be \\server\share\foo. You called _getfullpathname

Re: [Tutor] Why does os.path.realpath('test_main.py') give different results for unittest than for testing statement in interpreter?

2018-01-09 Thread eryk sun
On Tue, Jan 9, 2018 at 2:48 PM, Albert-Jan Roskam wrote: > > I think that it would be a great enhancement if os.realpath would return the > UNC path if > given a mapped drive in Windows, if needed as extended path (prefixed with > "\\?\UNC\"). > That's something I use all the time, unlike symlin

Re: [Tutor] Why does os.path.realpath('test_main.py') give different results for unittest than for testing statement in interpreter?

2018-01-08 Thread eryk sun
On Sun, Jan 7, 2018 at 10:51 AM, Albert-Jan Roskam wrote: > > On Jan 7, 2018 09:08, Steven D'Aprano wrote: >> >> realpath() returns the canonical path of the given filename. It doesn't >> try to locate some actual existing file. > > I always thought that os.path.realpath is the Python equivalent

Re: [Tutor] ctypes wintypes

2017-10-06 Thread eryk sun
On Fri, Oct 6, 2017 at 11:05 PM, Michael C wrote: > For this read process memory, if I am trying compose a LPCVOID > lpBaseAddress, am I not making a variable that equals to mbi.BaseAddress, > and then making a pointer pointing to it? > > start_address = mbi.BaseAddress > LPCVOID = ctypes.byref(

Re: [Tutor] ctypes wintypes

2017-10-06 Thread eryk sun
On Fri, Oct 6, 2017 at 10:26 PM, Michael C wrote: > > base = mbi.BaseAddress > buffer = ctypes.c_int32() > buffer_pointer = ctypes.byref(buffer) > ReadProcessMemory = Kernel32.ReadProcessMemory > > if ReadProcessMemory(Process, base, buffer_pointer, mbi.RegionSize, None): > print('buffer i

Re: [Tutor] ctypes wintypes

2017-10-06 Thread eryk sun
On Fri, Oct 6, 2017 at 10:06 PM, Michael C wrote: > like this? > > buffer = ctypes.byref(ctypes.create_string_buffer(4)) No, the buffer is the array created by create_string_buffer, which you pass byref(). In the following example I create a `test` buffer that contains "spam", and I use the pseud

Re: [Tutor] ctypes wintypes

2017-10-06 Thread eryk sun
On Fri, Oct 6, 2017 at 9:12 PM, Michael C wrote: > > How do I create a buffer, or rather, is a buffer just a variable? A buffer is a block of memory for an I/O operation. For example, if you need to read a 4-byte (32-bit) integer at an address in another process, the 'buffer' could be ctypes.c_in

Re: [Tutor] ctypes wintypes

2017-10-06 Thread eryk sun
On Fri, Oct 6, 2017 at 7:43 PM, Michael C wrote: > Sorry but I dont understand this line: > > mbi = MEMORY_BASIC_INFORMATION() > > This creates a instance of the class? Yes, and this allocates sizeof(MEMORY_BASIC_INFORMATION) bytes at addressof(mbi), which you pass to a function by reference via

Re: [Tutor] ctypes wintypes

2017-10-06 Thread eryk sun
On Fri, Oct 6, 2017 at 7:26 PM, Michael C wrote: > > I started out with what you gave me: > [...] > > I am trying to acquire "lpMinimumApplicationAddress" and > "lpMaximumApplicationAddress" from system_info, so I did this, > >>code > Kernel32 = ctypes.WinDLL('kernel32', use_last_error=True) > Ker

Re: [Tutor] ctypes wintypes

2017-10-05 Thread eryk sun
On Thu, Oct 5, 2017 at 8:27 PM, Michael C wrote: > > How do I see the values of each field? This doesn't work. > > print(PMEMORY_BASIC_INFORMATION.Protect) Create an instance of MEMORY_BASIC_INFORMATION and pass a pointer to it via byref(). For example, the following queries the region of memory

Re: [Tutor] ctypes wintypes

2017-10-05 Thread eryk sun
On Tue, Oct 3, 2017 at 10:30 PM, Michael C wrote: > > I am trying to create SYSTEM_INFO structure and MEMORY_BASIC_INFORMATION > structure First, avoid relying on constants, enumerations, and structures published on MSDN. It's not always right. Get the SDK and use the header files instead. MEMOR

Re: [Tutor] logging to cmd.exe

2017-09-26 Thread eryk sun
On Tue, Sep 26, 2017 at 7:35 AM, Mats Wichmann wrote: > On 09/26/2017 05:22 AM, Albert-Jan Roskam wrote: > >> Rather than change your code can you change the codepage with the chcp >> command? > > the way chcp takes effect is problematic for this: > > "Programs that you start after you assign a ne

Re: [Tutor] logging to cmd.exe

2017-09-26 Thread eryk sun
> cmd.exe can use cp65001 aka utf8??? CMD is a Unicode application that for the most part uses WinAPI wide-character functions, including the console API functions (as does Python 3.6+). There are a few exceptions. CMD uses the console codepage when decoding batch files (line by line, so you can c

Re: [Tutor] Percentage of installations without setuptools (Was if __name__=='__main__' ...)

2017-08-11 Thread eryk sun
On Fri, Aug 11, 2017 at 6:27 PM, Alan Gauld via Tutor wrote: > On 11/08/17 19:13, Chris Warrick wrote: > >> False since Python 3.4/2.7.9. ensurepip installs Python on every new >> Python install. > > Sorry Chris, that's not making sense? Do you mean ensurepip > installs setuptools on every install

Re: [Tutor] How does len() compute length of a string in UTF-8, 16, and 32?

2017-08-10 Thread eryk sun
On Fri, Aug 11, 2017 at 2:34 AM, Cameron Simpson wrote: > > In files however, the default encoding for text files is 'utf-8': Python > will read the file's bytes as UTF-8 data and will write Python string > characters in UTF-8 encoding when writing. The default encoding for source files is UTF-8.

Re: [Tutor] setup.py "script" vs "console_scripts" Was: if __name__=='main' vs entry points: What to teach new comers?

2017-08-09 Thread eryk sun
On Wed, Aug 9, 2017 at 11:32 PM, Alan Gauld via Tutor wrote: > On 09/08/17 22:15, Steven D'Aprano wrote: >> >> This is the critical factor. How can you use *by default* something that >> is *NOT* supplied by default? > > I have to agree with Steven here. Any mature language should > ship with all

Re: [Tutor] How does len() compute length of a string in UTF-8, 16, and 32?

2017-08-07 Thread eryk sun
On Tue, Aug 8, 2017 at 3:20 AM, Cameron Simpson wrote: > > As you note, the 16 and 32 forms are (6 + 1) times 2 or 4 respectively. This > is because each encoding has a leading byte order marker to indicate the big > endianness or little endianness. For big endian data that is \xff\xfe; for > litt

Re: [Tutor] Difference(s) betweenPython 3 static methods with and without @staticmethod?

2017-08-06 Thread eryk sun
On Sun, Aug 6, 2017 at 11:35 PM, boB Stepp wrote: > > I see no difference in result, whether I use the @staticmethod decorator or > not. While a staticmethod and a function are both descriptors [1], a staticmethod is basically a no-op descriptor. Its __get__ method always returns its unbound cal

Re: [Tutor] setup.py "script" vs "console_scripts" Was: if __name__=='main' vs entry points: What to teach new comers?

2017-08-04 Thread eryk sun
On Fri, Aug 4, 2017 at 10:15 AM, Thomas Güttler wrote: > Am 04.08.2017 um 02:50 schrieb Ben Finney: > >> Because Distutils implements only ‘scripts’, and that's not capable >> enough for what people need so Setuptools implements entry points. >> >> In other words: One of them is in the standard li

Re: [Tutor] setup.py "script" vs "console_scripts" Was: if __name__=='main' vs entry points: What to teach new comers?

2017-08-03 Thread eryk sun
On Thu, Aug 3, 2017 at 4:22 PM, Chris Warrick wrote: > > Simple: `scripts` are legacy. `entry_points` are the new thing. > There’s also a third approach: gui_scripts entry_points, which work > the same way on Linux/*nix, but on Windows, it means that running your > script by opening the created .e

Re: [Tutor] if __name__=='main' vs entry points: What to teach new comers?

2017-08-02 Thread eryk sun
On Wed, Aug 2, 2017 at 4:06 PM, Wolfgang Maier wrote: > On 08/02/2017 04:57 PM, Steven D'Aprano wrote: > >> I have a module with a main() function and an "if __name__ == ..." >> guard. Under what circumstances is that not sufficient, and I would want >> console_scripts? > > If you install things u

Re: [Tutor] What is meaning of "/" in "pow(x, y, z=None, /)"?

2017-08-02 Thread eryk sun
On Wed, Aug 2, 2017 at 1:06 AM, boB Stepp wrote: > I had typed help(pow) in the interpreter and got: > > > py3: help(pow) > Help on built-in function pow in module builtins: > > pow(x, y, z=None, /) > Equivalent to x**y (with two arguments) or x**y % z (with three arguments) > > Some type

Re: [Tutor] pythonic ascii decoding!

2017-07-31 Thread eryk sun
On Mon, Jul 31, 2017 at 3:39 PM, bruce wrote: > > So, is there a quick/dirty approach I can use to simply strip out the > "non-ascii" chars. I know, this might not be the "best/pythonic" way, > and that it might result in loss of some data/chars, but I can live > with it for now. Ignore or replac

Re: [Tutor] Python __del__ method

2017-07-11 Thread eryk sun
On Wed, Jul 12, 2017 at 12:07 AM, eryk sun wrote: > On Tue, Jul 11, 2017 at 2:47 PM, Jia Yue Kee > wrote: >> >> Case 2: If I were to run the code in "Interactive Mode", the following >> output will be obtained: >> >>>>> x = Robot("Tik

Re: [Tutor] Python __del__ method

2017-07-11 Thread eryk sun
On Tue, Jul 11, 2017 at 2:47 PM, Jia Yue Kee wrote: > > Case 2: If I were to run the code in "Interactive Mode", the following output > will be obtained: > x = Robot("Tik-Tok") > Tik-Tok has been created! y = Robot("Jenkins") > Jenkins has been created! z = x z > <__main__.Rob

Re: [Tutor] Probably a silly question: how to install lxml?

2017-07-05 Thread eryk sun
On Thu, Jul 6, 2017 at 1:51 AM, Steven D'Aprano wrote: > > I dunno, to me it sounds like it *didn't* work, not if it is printing > red error messages at the end. What do they say? lxml should install from a wheel (e.g. lxml-3.8.0-cp36-cp36m-win_amd64.whl). There's nothing to build, so the most li

Re: [Tutor] call key on_press event multiple times when key is held down

2017-07-04 Thread eryk sun
On Tue, Jul 4, 2017 at 8:50 AM, Carlton Banks wrote: > I am using pynput for keyboard events You could use an event that enables a recording loop. The on_press and on_release callbacks of the Listener [1] would set() and clear() this event, respectively. For

Re: [Tutor] Python Image Library

2017-05-17 Thread eryk sun
On Thu, May 18, 2017 at 1:58 AM, Michael C wrote: > when I run this, while it's called test.pyw, this pops up > > from PIL import Image > > im = Image.open('1.bmp') > im.show() Ok, I stand corrected. It's something weird, and most likely due to Windows support here being an afterthought throw in

Re: [Tutor] Python Image Library

2017-05-17 Thread eryk sun
On Wed, May 17, 2017 at 10:33 PM, Michael C wrote: > On Wed, May 17, 2017 at 3:30 PM, eryk sun wrote: > >> You're probably running a .py script that's associated with py.exe or >> python.exe. These executables create a new console (i.e. an instance >> of the

Re: [Tutor] Python Image Library

2017-05-17 Thread eryk sun
On Wed, May 17, 2017 at 8:24 PM, Michael C wrote: > from PIL import Image > > im = Image.open('pic.bmp') > im.show() > > I ran this code and it not only opened the picture in paint, which is what > I want, but it also opens a CMD.exe console window! how do I prevent that from > happening? You're

Re: [Tutor] Subtract a 1D Array from a 2D Array

2017-05-13 Thread eryk sun
On Sat, May 13, 2017 at 1:33 PM, Stephen P. Molnar wrote: > I am using Python 3.6 in Anaconda3 Spyder IDE. > > I have two arrays: > > X Y Z > a > 0 0 0 > 2.059801 0 0 > -1.2031263.402953

Re: [Tutor] Hi all: How do I save a file in a designated folder?

2017-05-02 Thread eryk sun
On Tue, May 2, 2017 at 6:09 PM, Michael C wrote: > screenshot.save("\test\missed.png") You probably know that "\t" represents a tab in a string literal, but there's something about working with a path that causes people to overlook this. Windows won't overlook it. Control characters, i.e. charact

Re: [Tutor] [ctypes-users] Press ESC to exit()

2017-05-01 Thread eryk sun
On Tue, May 2, 2017 at 3:03 AM, Michael C wrote: > holy cow The code for a global keyboard hook is a bit complex - mostly because I had to use ctypes (properly instead of an unreliable hack). Normally an application has one or more windows and a message loop, in which case there's no need for suc

Re: [Tutor] [ctypes-users] Press ESC to exit()

2017-05-01 Thread eryk sun
On Mon, May 1, 2017 at 6:28 PM, Michael C wrote: > Hi all, I found out that one way to press ESC to kill the script was to use > my previous > script language, AutoHotKey and this is how it works: > > AutoHotKey code > ## function that kills the window with title '*Python 3.6.1 Shell*' > > kill()

Re: [Tutor] Difference between %f and %F string formatting?

2017-04-26 Thread eryk sun
On Thu, Apr 27, 2017 at 2:19 AM, Tim Peters wrote: > [boB Stepp ] > >> I cannot find any discernible >> difference between '%f' % and '%F' % >> . Is there any or do they duplicate >> functionality? If the latter, why are there two ways of doing the >> same thing? > > They differ only in the ca

Re: [Tutor] Sets question

2017-04-26 Thread eryk sun
On Thu, Apr 27, 2017 at 1:34 AM, Phil wrote: > I did try {int(num)} but that resulted in an error that said something along > the lines of int not being iterable. I'll have another look at that idea. That exception indicates you probably used set(int(num)) instead of either {int(num)} or set([int

Re: [Tutor] Sets question

2017-04-26 Thread eryk sun
On Thu, Apr 27, 2017 at 12:33 AM, Phil wrote: > Another question I'm afraid. > > If I want to remove 1 from a set then this is the answer: > > set([1,2,3]) - set([1]) You can also use set literals here, with the caveat that {} is ambiguous, and Python chooses to make it an empty dict instead of a

Re: [Tutor] classproperty for Python 2.7 (read-only enough)

2017-04-19 Thread eryk sun
On Wed, Apr 19, 2017 at 10:19 AM, Peter Otten <__pete...@web.de> wrote: > Steven D'Aprano wrote: > >> As I said, I haven't had a chance to try Peter's code, so it's possible >> that he's solved all these problems. I'm judging by previous > > No, my simple code only "works" for read-only properties

Re: [Tutor] Count for loops

2017-04-11 Thread eryk sun
On Wed, Apr 12, 2017 at 4:03 AM, boB Stepp wrote: > > I have not used the decimal module (until tonight). I just now played > around with it some, but cannot get it to do an exact conversion of > the number under discussion to a string using str(). Pass a string to the constructor: >>> d =

Re: [Tutor] Count for loops

2017-04-11 Thread eryk sun
On Wed, Apr 12, 2017 at 3:40 AM, boB Stepp wrote: > > I have to say I am surprised by this as well as the OP. I knew that > str() in general makes a nice printable representation The single-argument str() constructor calls the object's __str__ method (or __repr__ if __str__ isn't defined). In Py

Re: [Tutor] reading files in Python 3

2017-03-31 Thread eryk sun
On Thu, Mar 30, 2017 at 8:45 PM, Mats Wichmann wrote: > Yeah, fun. You need to escape the \ that the idiot MS-DOS people chose > for the file path separator. Because \ is treated as an escape character. The COMMAND.COM shell inherited command-line switches (options) that use slash from TOPS-10 b

Re: [Tutor] reading files in Python 3

2017-03-30 Thread eryk sun
On Thu, Mar 30, 2017 at 8:47 PM, Zachary Ware wrote: > In this case, the problem is the bogus Unicode escape that you > inadvertently included in your path: `\Us...`. To fix it, either use a > 'raw' string (`r"C:\Users\..."`) or use forward slashes rather than > backslashes, which Windows is happ

Re: [Tutor] subprocess.Popen / proc.communicate issue

2017-03-30 Thread eryk sun
On Thu, Mar 30, 2017 at 10:51 PM, Cameron Simpson wrote: > This suggests that .communicate uses Threads to send and to gather data > independently, and that therefore the deadlock situation may not arise. For Unix, communicate() uses select or poll. It uses threads on Windows. Either way it avoid

Re: [Tutor] Exponential function

2017-02-14 Thread eryk sun
On Tue, Feb 14, 2017 at 11:01 PM, Alan Gauld via Tutor wrote: > To compute it if you don't know x in advance then yes, > use something like > > value = 10**x > > But if you know the value in advance you can write it in > a more compact form as: > > value = 1e5 # or 3e7 or whatever... 10**5 is an

Re: [Tutor] Python-list thread: int vs. float

2017-02-12 Thread eryk sun
On Sat, Feb 11, 2017 at 8:53 PM, boB Stepp wrote: > > I suspect Eryk had set a normal 's' as an identifier for the character > code sequence that produces the non-ASCII output, but forgot to show > us that step. But I could be mistaken. Sorry, I forgot to show the assignment of the string "௧꘢୩"

Re: [Tutor] Python-list thread: int vs. float

2017-02-11 Thread eryk sun
On Sat, Feb 11, 2017 at 8:06 AM, Steven D'Aprano wrote: > Valid digits for integers include 0 through 9 in decimal Note that Python 3 uses the Unicode database to determine the decimal value of characters, if any. It's not limited to the ASCII decimal digits 0-9. For example: >>> s '௧꘢୩'

Re: [Tutor] Test for type(object) == ???

2017-02-11 Thread eryk sun
On Sat, Feb 11, 2017 at 7:35 AM, boB Stepp wrote: > Has this PEP been implemented yet? I am running Python 3.5.2 and it > appears not to work. Also, in "What's New In Python 3.6" > (https://docs.python.org/3/whatsnew/3.6.html) I did not see a mention > of it. You can see in the document header

Re: [Tutor] Test for type(object) == ???

2017-02-10 Thread eryk sun
On Sat, Feb 11, 2017 at 6:22 AM, boB Stepp wrote: > On Fri, Feb 10, 2017 at 11:49 PM, eryk sun wrote: > >> It's from the function's __text_signature__. >> >> >>> repr.__text_signature__ >> '($module, obj, /)' >> >>

Re: [Tutor] Test for type(object) == ???

2017-02-10 Thread eryk sun
On Sat, Feb 11, 2017 at 3:22 AM, boB Stepp wrote: > > py3: help(repr) > Help on built-in function repr in module builtins: > > repr(obj, /) > Return the canonical string representation of the object. > > For many object types, including most builtins, eval(repr(obj)) == obj. > > Question:

Re: [Tutor] Test for type(object) == ???

2017-02-10 Thread eryk sun
On Sat, Feb 11, 2017 at 4:32 AM, boB Stepp wrote: > > This bit got me experimenting. Since the integer "5" is an integer > object instance, I am wondering why I can't do: > > py3: 5.__repr__() > File "", line 1 > 5.__repr__() > ^ > SyntaxError: invalid syntax > > , but I can do

Re: [Tutor] Test for type(object) == ???

2017-02-10 Thread eryk sun
On Sat, Feb 11, 2017 at 1:34 AM, boB Stepp wrote: > I was playing around with type() tonight. If I type (pun intended), I get: > > py3: type(5) > `type` is a metaclass that either creates a new class (given 3 arguments: name, bases, and dict) or returns a reference to the class of an existing o

Re: [Tutor] sort() method and non-ASCII

2017-02-05 Thread eryk sun
On Sun, Feb 5, 2017 at 10:30 PM, boB Stepp wrote: > I was looking at http://unicode.org/charts/ Because they called them > charts, so did I. I'm assuming that despite this organization into > charts, each and every character in each chart has its own unique > hexadecimal code to designate each c

Re: [Tutor] sort() method and non-ASCII

2017-02-04 Thread eryk sun
On Sun, Feb 5, 2017 at 3:52 AM, boB Stepp wrote: > Does the list sort() method (and other sort methods in Python) just go > by the hex value assigned to each symbol to determine sort order in > whichever Unicode encoding chart is being implemented? list.sort uses a less-than comparison. What you

Re: [Tutor] Best Python 3 module to create simple text editor in Windows command prompt?

2017-02-02 Thread eryk sun
On Fri, Feb 3, 2017 at 2:22 AM, boB Stepp wrote: > What would be the best Python 3 module to best assist me in controlling > the command prompt window display, font colors, positioning the cursor > dynamically, etc.? Try using curses [1]. Christoph Gohlke has a port for Windows Python based on th

Re: [Tutor] ReadableInt

2016-12-30 Thread eryk sun
On Fri, Dec 30, 2016 at 4:46 PM, Albert-Jan Roskam wrote: > > Remember I only intend to use it while debugging the given script. Have you tried hooking sys.displayhook? > Why does the call to str() below return '1' and not 'one'? Should I implement > __new__ > because int is immutable? You can

Re: [Tutor] Open a libreoffice calc file in Python

2016-12-22 Thread eryk sun
On Thu, Dec 22, 2016 at 4:20 PM, boB Stepp wrote: > > Both you and Eryk seem to be speaking in terms of using > subprocess.Popen() directly. So I think I need some clarification. > At > https://docs.python.org/3/library/subprocess.html#using-the-subprocess-module > it says: > > "The recommended

Re: [Tutor] Open a libreoffice calc file in Python

2016-12-21 Thread eryk sun
On Thu, Dec 22, 2016 at 4:50 AM, wrote: > BTW, the array form is Popen's default mode; sensibly you need to _ask_ to > use a shell string with shell=True, because that is harder and more fragile. Without shell=True, args as a string on POSIX is generally an error because it will look for the ent

Re: [Tutor] Trouble Launching Python

2016-12-21 Thread eryk sun
On Tue, Dec 20, 2016 at 7:12 PM, George Fischhof wrote: > 2016-12-19 23:38 GMT+01:00 Joseph Olugbohunmi via Tutor : > > this is a Microsoft visual c++ redistributable is missing from system. > I found this stackoverflow link which seems to describing a solution > > http://stackoverflow.com/questio

Re: [Tutor] Trouble Launching Python

2016-12-20 Thread eryk sun
On Mon, Dec 19, 2016 at 10:38 PM, Joseph Olugbohunmi via Tutor wrote: > Hello,Good day, I installed Python 3.5.2 on my Windows 8.1 PC and then I > tried launching > IDLE as well as the Interpreter but I got a message that > api-ms-win-crt-runtime-l1-1-0.dll was > missing. I downloaded and instal

Re: [Tutor] Q regarding external program calling

2016-11-07 Thread eryk sun
On Sun, Nov 6, 2016 at 9:09 AM, Alan Gauld via Tutor wrote: > On 06/11/16 01:44, Clayton Kirkwood wrote: >> Looked all over, but haven't found the answer. If I have a (windows) program >> which I wish to start, even shell scripts, and possibly capture the output >> from, how do I do that? > > Othe

Re: [Tutor] Python 3.5 installation beside Python 2.3 on Windows 7

2016-10-22 Thread eryk sun
On Sun, Oct 23, 2016 at 1:39 AM, Pierre-Michel Averseng wrote: > Le 22/10/2016 à 20:00, tutor-requ...@python.org a écrit : > >> Do I have to completely uninstall Python 2.7.1 and then install Python >> 3.5.2? Or can I still install Python 3.5.2 keeping Python 2.7.1 untouched >> on my laptop? > > F

Re: [Tutor] using python shell program on windows

2016-10-14 Thread eryk sun
On Fri, Oct 14, 2016 at 4:52 PM, Peter Otten <__pete...@web.de> wrote: > > python -m pip install timesheet > > on the commandline should take care of the details. On my (Linux) machine > this also installed a script that I can invoke on the command line with > > $ timesheet start foo bar > Started

Re: [Tutor] help with Numpy

2016-09-21 Thread eryk sun
On Wed, Sep 21, 2016 at 10:35 PM, Oscar Benjamin wrote: > I would have given the same advice a year or so ago. It's worth noting > though that the situation with pip, wheel etc has improved significantly > recently. It's now straightforward to pip install Numpy, scipy, matplotlib > and many others

Re: [Tutor] Python IDLE for Windows 10, 64-bit

2016-09-21 Thread eryk sun
On Wed, Sep 21, 2016 at 9:21 PM, Alan Gauld via Tutor wrote: > On Windows it is usually installed by default at: > > %PYTHONDIR%/Lib/idelib/idle.bat With Python 3, you can run the package as a script: pythonw -m idlelib Python 2: pythonw -m idlelib.idle

Re: [Tutor] help with Numpy

2016-09-21 Thread eryk sun
On Wed, Sep 21, 2016 at 2:53 PM, Paul Dentinger wrote: > > I need Numpy and Scipy and may need matplotlib. So I tried to call Numpy and > it > can't be found. So I go online and find Numpy and download it. Read the following docs on Python packaging and pip: https://pip.pypa.io https://packag

Re: [Tutor] Python IDLE for Windows 10, 64-bit

2016-09-21 Thread eryk sun
On Wed, Sep 21, 2016 at 3:14 PM, Aaron Rose wrote: > I'm looking for a link for Python IDLE for Windows 10, 64-bit. Can't seem to > find > the right link on python.org. Could someone kindly point me in the right > direction? Python's installer has an option to install IDLE. Here's the link fo

Re: [Tutor] @property for old style classes vs new style classes

2016-09-15 Thread eryk sun
On Thu, Sep 15, 2016 at 9:48 PM, monik...@netzero.net wrote: > But why var is in class __dict__? > Does @property make it a class attribute? An instance of `property` is a data descriptor, i.e. it implements the __get__, __set__, and __delete__ methods of the descriptor protocol. A non-data descr

Re: [Tutor] @property for old style classes vs new style classes

2016-09-15 Thread eryk sun
On Thu, Sep 15, 2016 at 4:40 AM, monik...@netzero.net wrote: > class GetSet(): > > def __init__(self, value): > self.attrval = value > > @property > def var(self): > print "getting the var attribute" > return self.attrval > @var.setter > def var(self,val

Re: [Tutor] __init__

2016-08-30 Thread eryk sun
On Tue, Aug 30, 2016 at 9:09 AM, Alan Gauld via Tutor wrote: > new() that sets up the memory then calls init(). So init is > only used to initialise the object after it has been > constructed. __new__ and __init__ are called by the metaclass __call__ method. __init_ is called if __new__ returns a

Re: [Tutor] Where is win32print in Windows 10 Pro

2016-08-12 Thread eryk sun
On Thu, Aug 11, 2016 at 2:44 PM, Joaquin Alzola wrote: > >>import win32print >>ImportError: No module named win32print > > That module doesn't exist on your python path > > 'pywin32' is its canonical name. > > http://sourceforge.net/projects/pywin32/ I'm not certain what's meant in the above, but

Re: [Tutor] command to determine of python 32 or 64 bit?

2016-08-10 Thread eryk sun
On Wed, Aug 10, 2016 at 4:27 AM, Garry Willgoose wrote: > I have a number of binary libraries that are dependent on whether the > precompiled python > distribution (eg. Enthought, ActiveState, etc) in which they are installed > are compiled with > 32 or 64 bit. Is there any reliable way to dete

Re: [Tutor] (no subject)

2016-07-25 Thread eryk sun
On Tue, Jul 26, 2016 at 4:39 AM, DiliupG wrote: > I am reading in a list of file names with the following code. > > def get_filelist(self): > "" > app = QtGui.QApplication(sys.argv) > a = QtGui.QFileDialog.getOpenFileNames() > > filelist = [] > if a:

Re: [Tutor] (no subject)

2016-07-25 Thread eryk sun
On Mon, Jul 25, 2016 at 10:28 AM, Steven D'Aprano wrote: > I know that Linux and Mac OS X both use UTF-8 for filenames, and so support > all > of Unicode. But Windows, I'm not sure. It might be localised to only use > Latin-1 > (Western European) or similar. Windows filesystems (e.g. NTFS, ReFS

Re: [Tutor] (no subject)

2016-07-25 Thread eryk sun
On Fri, Jul 22, 2016 at 7:38 AM, DiliupG wrote: > I am using Python 2.7.12 on Windows 10 > > filename = u"මේක තියෙන්නේ සිංහලෙන්.txt" > Unsupported characters in input That error message is from IDLE. I'm not an expert with IDLE, so I don't know what the following hack potentially breaks, but it d

Re: [Tutor] Quote and double quotes opens up File Explorer in Windows 10

2016-07-09 Thread eryk sun
On Sat, Jul 9, 2016 at 2:22 PM, Ken G. wrote: > Hi: In gradually moving over my Python programs (2.7.6) to Windows 10 and > using Geany 1.27 to modify or write up a program there, it is noted that > whenever I typed in a quote (') or double quote ("), Windows 10 File > Explorer opens up. I end up

Re: [Tutor] iterators

2016-07-04 Thread eryk sun
On Mon, Jul 4, 2016 at 9:56 PM, Danny Yoo wrote: > So the extra trailing comma in a 1-tuple parenthesized expression is > just there to make it different looking, to disambiguate it from the > use of parentheses for expression grouping. The comma is the distinguishing element of non-empty tuple l

Re: [Tutor] Why are expressions not allowed as parameters in function definition statements?

2016-06-18 Thread eryk sun
On Sun, Jun 19, 2016 at 4:04 AM, Danny Yoo wrote: > >> def f((x,y), z): > ... print x, y, z > ... >> f([1, 2], 3) > 1 2 3 Note that Python 3 doesn't support tuple parameter unpacking. See PEP 3113: https://www.python.org/dev/peps/pep-3113 ___ Tu

Re: [Tutor] capture output from a subprocess while it is being produced

2016-06-14 Thread eryk sun
On Tue, Jun 14, 2016 at 8:03 PM, Albert-Jan Roskam wrote: > > proc = Popen("ls -lF", cwd=cwd, shell=True, stdout=PIPE, stderr=PIPE) Don't use shell=True if you can avoid it. "ls" isn't a shell command. Use ['ls', '-lF']. The child process probably buffers its output when stdout isn't a termi

Re: [Tutor] Howto display progress as cmd is being executed via subprocess ?

2016-06-14 Thread eryk sun
On Mon, Jun 13, 2016 at 4:50 PM, Ramanathan Muthaiah wrote: > > subprocess.check_output([cmd], stderr=subprocess.STDOUT, shell=True) > ... > how to combine the progressbar and subprocess code snippets to show the > progress as the cmd is being executed. check_output waits for the process to exit,

Re: [Tutor] int(1.99...99) = 1 and can = 2

2016-05-01 Thread eryk sun
On Sun, May 1, 2016 at 1:02 AM, boB Stepp wrote: > > py3: 1. > 2.0 > py3: 1.999 > 1.999 ... > It has been many years since I did problems in converting decimal to > binary representation (Shades of two's-complement!), but I am under > the (apparently mistake

Re: [Tutor] Fwd: Newbie trying to get pip run on windows 7

2016-04-20 Thread eryk sun
On Tue, Apr 19, 2016 at 11:26 PM, Gustavo Davis via Tutor wrote: > But for some reason after I made the changes and saved them they wont > run. I mean once I go to the file and right click on them and click run > the cmd prompt pops up for a moment and then it just closes down and the > pip mo

  1   2   >