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

2017-11-06 Thread Random832
I haven't read over every message in the thread, so sorry if this has been suggested before, but how about "if not break:" and "if not except:" as synonyms for the current 'else' clause? They're already keywords, and this sequence of keywords has no current meaning. -- https://mail.python.org/mail

Re: why won't slicing lists raise IndexError?

2017-12-04 Thread Random832
On Mon, Dec 4, 2017, at 13:54, Jason Maldonis wrote: > Is there any background on why that doesn't raise an IndexError? Knowing > that might help me design my extended list class better. For my specific > use case, it would simplify my code (and prevent `if isinstance(item, > slice)` checks) if the

Re: Politeness (was: we want python software)

2017-12-06 Thread Random832
On Wed, Dec 6, 2017, at 11:18, Steve D'Aprano wrote: > You suggested that if he wasn't familiar with free software, his > request that people send him a copy of Python wouldn't look so odd. > Okay, if Python weren't free software, it would be non-free software, > and you are saying that it wouldn't

Re: why won't slicing lists raise IndexError?

2017-12-08 Thread Random832
On Mon, Dec 4, 2017, at 13:54, Jason Maldonis wrote: > Is there any background on why that doesn't raise an IndexError? Knowing > that might help me design my extended list class better. For my specific > use case, it would simplify my code (and prevent `if isinstance(item, > slice)` checks) if the

Re: What is wrong with this regex for matching emails?

2017-12-17 Thread Random832
On Sun, Dec 17, 2017, at 10:46, Chris Angelico wrote: > But if you're trying to *validate* an email address - for instance, if > you receive a form submission and want to know if there was an email > address included - then my recommendation is simply DON'T. You can't > get all the edge cases right

Re: __contains__ classmethod?

2017-12-18 Thread Random832
On Mon, Dec 18, 2017, at 16:25, Tim Chase wrote: > My understanding was that "in" makes use of an available __contains__ > but something seems to preventing Python from finding that. > > What's going on here? Most __ methods have to be an actual method on the class object, which means you have to

Re: What is wrong with this regex for matching emails?

2017-12-19 Thread Random832
On Mon, Dec 18, 2017, at 02:01, Chris Angelico wrote: > Hmm, is that true? I was under the impression that the quoting rules > were impossible to match with a regex. Or maybe it's just that they're > impossible to match with a *standard* regex, but the extended > implementations (including Python'

Re: How to exec a string which has an embedded '\n'?

2017-12-30 Thread Random832
On Sat, Dec 30, 2017, at 23:57, jf...@ms4.hinet.net wrote: > I have a multiline string, something like '''...\nf.write('\n')\n...''' > when pass to exec(), I got > SyntaxError: EOL while scanning string literal > > How to get rid of it? Use \\n for this case, since you want the \n to be interpret

Re: unicode direction control characters

2018-01-02 Thread Random832
On Tue, Jan 2, 2018, at 10:36, Robin Becker wrote: > >> u'\u200e28\u200e/\u200e09\u200e/\u200e1962' > > I guess I'm really wondering whether the BIDI control characters have any > semantic meaning. Most numbers seem to be LTR. > > If I saw u'\u200f12' it seems to imply that the characters should

Re: [OT] Re: has sourceforge exposed the dirty little secret ?

2018-01-07 Thread Random832
On Sun, Jan 7, 2018, at 17:27, Gene Heskett wrote: > > > > 🐍 đŸ’» > > > But here its broken and I am looking at two pairs of vertical boxes > because it is not properly mime'd. If you use chars or gliphs from a > non-default charset, it needs to demarcated with a mime-boundary marker > followed by

Re: [OT] Re: has sourceforge exposed the dirty little secret ?

2018-01-07 Thread Random832
On Sun, Jan 7, 2018, at 17:47, Richard Damon wrote: > But it also says: > > Content-Transfer-Encoding: 7bit > > Which is incorrect, as the message is actually 8bit encoded (since the > Emoji aren't in the first 127 characters, so their UTF-8 encoding isn't > 7-bit. Some software might have mes

Re: [OT] Re: has sourceforge exposed the dirty little secret ?

2018-01-07 Thread Random832
On Sun, Jan 7, 2018, at 18:50, Gene Heskett wrote: > That, now that you mention it, could also effect this as I see it, my > default kmail message body font is hack 14 in deference to the age of my > eyes. > > My system default font is I believe utf-8. That is not a kmail settable > option. But

Re: Can utf-8 encoded character contain a byte of TAB?

2018-01-15 Thread Random832
On Mon, Jan 15, 2018, at 09:35, Peter Otten wrote: > Peng Yu wrote: > > > Can utf-8 encoded character contain a byte of TAB? > > Yes; ascii is a subset of utf8. > > If you want to allow fields containing TABs in a file where TAB is also the > field separator you need a convention to escape the

Re: Help: 64bit python call c and got OSError: exception: access violation writing 0xFFFFFFFF99222A60

2018-01-22 Thread Random832
On Mon, Jan 22, 2018, at 16:00, Jason Qian via Python-list wrote: > Hello! > > I am using ctypes on Windows to interface with a dll and it works fine > on Linux and windows 32-bit python. But, when using 64-bit python, we got > error "exception: access violation writing 0x99222A60". Y

Re: Why does datetime.timedelta only have the attributes 'days' and 'seconds'?

2022-04-19 Thread Random832
On Tue, Apr 19, 2022, at 07:11, Loris Bennett wrote: > I now realise that timedelta is not really what I need. I am interested > solely in pure periods, i.e. numbers of seconds, that I can convert back > and forth from a format such as A timedelta *is* a pure period. A timedelta of one day is 864

Re: Pre-Pre-PEP: The datetime.timedeltacal class

2022-04-19 Thread Random832
On Sat, Apr 16, 2022, at 13:35, Peter J. Holzer wrote: > When adding a timedeltacal object to a datetime, the fields are added > from most to least significant: First a new date is computed by > advancing the number of months specified [TODO: Research how other > systems handle overflow (e.g. 2022-

Re: Exploring terminfo

2021-01-18 Thread Random832
On Fri, Jan 15, 2021, at 13:36, Alan Gauld via Python-list wrote: > That could make a big difference, the putp() function specifically > states that it writes to stdout. I think there is a reasonable argument that this is a deficiency of the curses module. I think that the curses module should A

Re: sqlite3 cannot detect the version of compiled sqlite version at some point in runtime.

2021-01-20 Thread Random832
On Wed, Jan 20, 2021, at 14:54, panfei wrote: > 3. Compile Python 3.9.1 > C_INCLUDE_PATH=/home/felix/.local/sqlite/sqlite-3.34.0/include/ > CPLUS_INCLUDE_PATH=/home/felix/.local/sqlite/sqlite-3.34.0/include/ > LD_RUN_PATH=/home/felix/.local/sqlite/default/lib ./configure > --prefix=/home/felix/.

Re: sqlite3 cannot detect the version of compiled sqlite version at some point in runtime.

2021-01-20 Thread Random832
On Wed, Jan 20, 2021, at 16:45, Random832 wrote: > On Wed, Jan 20, 2021, at 14:54, panfei wrote: > > 3. Compile Python 3.9.1 > > C_INCLUDE_PATH=/home/felix/.local/sqlite/sqlite-3.34.0/include/ > > CPLUS_INCLUDE_PATH=/home/felix/.local/sqlite/sqlite-3.34.0/include/ > &

Re: Response for PING in ircbot.

2021-02-02 Thread Random832
On Sat, Jan 30, 2021, at 11:50, Bischoop wrote: > > Got problem with responding for Ping, tried so many ways to response > and always end up with time out or other error. This time: 1. It looks like you're forgetting to send \n\r 2. i'm not sure if the server ping is guaranteed to have : characte

Re: use set notation for repr of dict_keys?

2021-02-23 Thread Random832
On Sat, Feb 20, 2021, at 15:00, dn via Python-list wrote: > So, the output is not a set (as you say) but nor (as > apparently-indicated by the square-brackets) is it actually a list! To be clear, it is an instance of collections.abc.Set, and supports most binary operators that sets support. I wa

Re: use set notation for repr of dict_keys?

2021-02-24 Thread Random832
On Wed, Feb 24, 2021, at 02:59, Marco Sulla wrote: > On Wed, 24 Feb 2021 at 06:29, Random832 wrote: > > I was surprised, though, to find that you can't remove items directly from > > the key set, or in general update it in place with &= or -= (these > > operators w

Re: What's the best way to minimize the need of run time checks?

2016-08-09 Thread Random832
On Tue, Aug 9, 2016, at 16:51, Juan Pablo Romero MĂ©ndez wrote: > So as the writer of the function you expect the user to read the function > body to determine what is safe to pass or not? How about expecting them to read the docstring? -- https://mail.python.org/mailman/listinfo/python-list

Re: cmd prompt does not recognizes python command on Windows 7

2016-08-10 Thread Random832
On Wed, Aug 10, 2016, at 06:34, eryk sun wrote: > On Wed, Aug 10, 2016 at 4:46 AM, wrote: > > > > i have installed python 3.5 , but the python command is not recognized > > > > C:\Users\sharmaaj>python > > 'python' is not recognized as an internal or external command, > > operable program or batc

Re: Python slang

2016-08-10 Thread Random832
On Wed, Aug 10, 2016, at 07:59, Dennis Lee Bieber wrote: > The use of = also has a long history... FORTRAN (where the comparison > was .EQ.), BASIC (granted, K&K required assignment to start with the > keyword LET, so the use of = was mainly a delimiter between target and > expression being a

Re: Python slang

2016-08-14 Thread Random832
On Wed, Aug 10, 2016, at 19:57, Michael Torrie wrote: > But the grammar must still be a bit complex as sometimes the LHS of the > = is an expression, as well as the RHS. The only place that an *arbitrary* expression (including e.g. = as equality) can appear in the LHS is inside parentheses, otherw

Re: I am new to python. I have a few questions coming from an armature!

2016-08-17 Thread Random832
On Wed, Aug 17, 2016, at 14:27, Terry Reedy wrote: > That particular syntax was not really considered. At least 10 versions > using 'if', 'then', 'else', and other tokens were. > > They all had the problem of requiring a new keyword such as 'then' or > some other innovation. Why not just if(co

Re: saving octet-stream png file

2016-08-19 Thread Random832
On Fri, Aug 19, 2016, at 16:51, Lawrence D’Oliveiro wrote: > On Saturday, August 20, 2016 at 6:03:53 AM UTC+12, Terry Reedy wrote: > > > > An 'octet' is a byte of 8 bits. > > Is there any other size of byte? Not very often anymore. Used to be some systems had 9-bit bytes, and of course a lot of c

Re: saving octet-stream png file

2016-08-19 Thread Random832
On Fri, Aug 19, 2016, at 21:09, Steve D'Aprano wrote: > Depends what you mean by "byte", but the short answer is "Yes". > > In the C/C++ standard, bytes must be at least eight bytes. As the below > FAQ > explains, that means that on machines like the PDP-10 a C++ compiler will > define bytes to be

Re: saving octet-stream png file

2016-08-20 Thread Random832
On Sat, Aug 20, 2016, at 03:50, Marko Rauhamaa wrote: > 2'scomplement arithmetics is quite often taken advantage of in C > programming. Unfortunately, with the castration of signed integers with > the most recent C standards, 2's-complement has been dangerously broken. No part of any version of th

Re: PEP suggestion: Uniform way to indicate Python language version

2016-08-21 Thread Random832
On Mon, Aug 22, 2016, at 01:35, Steven D'Aprano wrote: > Could somebody (the OP?) please explain what is the purpose of this > proposal, what it does, how it works, and when would people use it? I think what he wants is a way for a module which uses features (syntactic or otherwise, but I suppose

Re: PEP suggestion: Uniform way to indicate Python language version

2016-08-21 Thread Random832
On Mon, Aug 22, 2016, at 02:03, Stefan Behnel wrote: > Steven D'Aprano schrieb am 22.08.2016 um 07:35: > > if sys.version < '3': > > import mymodule2 as mymodule > > else: > > import mymodule3 as mymodule > > This condition is going to fail when Python 30.0 comes out. Er, won't it rather

Re: PEP suggestion: Uniform way to indicate Python language version

2016-08-22 Thread Random832
On Mon, Aug 22, 2016, at 08:44, Chris Angelico wrote: > However, I don't think it's particularly necessary. Explicit version > number checks should be very rare, and shouldn't be encouraged. > Instead, encourage feature checks, as Steve gave some examples of. The problem is when you want to write

Re: Does This Scare You?

2016-08-22 Thread Random832
On Mon, Aug 22, 2016, at 08:39, Chris Angelico wrote: > Nope. On Windows, you would try/except it. No, you can't, because the failure mode often isn't "file refuses to open" but "data is written to a serial port". There are myriad other ways > something could fail, and the only correct action is

Re: PEP suggestion: Uniform way to indicate Python language version

2016-08-22 Thread Random832
On Mon, Aug 22, 2016, at 09:21, Steve D'Aprano wrote: > Rather, you just use the features you rely on, document the minimum > supported version, and if somebody is silly enough to try running your > code > under Python 1.4, they'll get a SyntaxError or an exception when you try > to > do something

Re: The dangerous, exquisite art of safely handing user-uploaded files: Tom Eastman (was: Does This Scare You?)

2016-08-22 Thread Random832
On Mon, Aug 22, 2016, at 10:21, Ben Finney wrote: > So yes, filenames from arbitrary sources should be *completely* > untrusted, and never used to access any file on the system. Throw the > entire filename away and make a filename locally, without using any part > of the original name. To be fair,

Re: The dangerous, exquisite art of safely handing user-uploaded files: Tom Eastman (was: Does This Scare You?)

2016-08-22 Thread Random832
On Mon, Aug 22, 2016, at 11:40, Chris Angelico wrote: > Windows has some other issues, including that arbitrary files can > become executable very easily (eg if %PATHEXT% includes its file > extension), and since the current directory is always at the beginning > of your path, this can easily turn

Re: Dynamically import specific names from a module vs importing full module

2016-08-22 Thread Random832
On Mon, Aug 22, 2016, at 16:21, Malcolm Greene wrote: > Python 3.5: Is there a way to dynamically import specific names from a > module vs importing the full module? > > By dynamic I mean via some form of importlib machinery, eg. I'm looking > for the dynamic "from import " equivalent of "import

Re: degrees and radians.

2016-08-23 Thread Random832
On Wed, Aug 24, 2016, at 00:26, Gary Herron wrote: > Perhaps I'm not understanding what you mean by "clunky", but this seems > pretty clean and simple to me. The original post is from 2002, I don't know why it got a reply just now. -- https://mail.python.org/mailman/listinfo/python-list

Re: The order of iterable de-referencing in assignment?

2016-08-24 Thread Random832
On Wed, Aug 24, 2016, at 07:17, Chris Angelico wrote: > Objects/listobject.c:795 > > /* Special cases: >1) lists and tuples which can use PySequence_Fast ops >2) extending self to self requires making a copy first > */ And, of course, it is a special case - a.extend(iter(a

Re: integer's methods

2016-08-27 Thread Random832
On Sat, Aug 27, 2016, at 13:24, Grant Edwards wrote: > Becuase the parser thinks you've entered a floating point number with > a fractional part of "bit_length". 123.+456 doesn't think that the fractional part is "+456". (Of course, the real reason is "because it would be even more annoying to ge

Magic UTF-8/Windows-1252 encodings

2016-08-29 Thread Random832
Directing this to python-list because it's really not on the topic of the idea being discussed. On Mon, Aug 29, 2016, at 05:37, Chris Angelico wrote: > Suppose I come to python-ideas and say "Hey, the MUD community would > really benefit from a magic decoder that would use UTF-8 where > possible,

Re: Magic UTF-8/Windows-1252 encodings

2016-08-29 Thread Random832
On Mon, Aug 29, 2016, at 11:14, Chris Angelico wrote: > Please don't. :) This is something that belongs in the application; > it's somewhat hacky, and I don't see any benefit to it going into the > language. For one thing, I could well imagine making the fallback > encoding configurable (it isn't c

Re: Python slang

2016-09-02 Thread Random832
On Wed, Aug 10, 2016, at 12:19, Random832 wrote: > On Wed, Aug 10, 2016, at 07:59, Dennis Lee Bieber wrote: > > The use of = also has a long history... FORTRAN (where the > > comparison was .EQ.), BASIC (granted, K&K required assignment to > > start with the k

Re: Strange behaviour with numbers in exponential notation

2016-09-02 Thread Random832
On Fri, Sep 2, 2016, at 11:51, Marco Sulla wrote: > >>> 10**26 - 1 > 99 > >>> 1e26 - 1 > 1e+26 > > > Why? Exponential notation creates floating point numbers, which have a limited amount of precision in binary. Specifically (on my system which, as most modern computer

Re: Strange behaviour with numbers in exponential notation

2016-09-02 Thread Random832
On Fri, Sep 2, 2016, at 13:02, Marco Sulla wrote: > On Fri, Sep 2, 2016 at 6:17 PM, Random832 wrote: > > Trying to add 1 gets it rounded off again, and the value is simply > > printed as 1e+26 by default because this is the shortest representation > > that gives the

Re: Strange behaviour with numbers in exponential notation

2016-09-02 Thread Random832
On Fri, Sep 2, 2016, at 15:12, Christian Gollwitzer wrote: > Tradition? All languages I know of treat a number with an exponent as > floating point. Scheme does allow you to give integers (and rationals) in decimal and/or exponential notation with the "#e" prefix. -- https://mail.python.org/mail

Re: What you can do about legalese nonsense on email (was: How to split value where is comma ?)

2016-09-08 Thread Random832
On Thu, Sep 8, 2016, at 18:13, Grant Edwards wrote: > After all, that boilerplate just makes the corporation look stupid and > incompetent. Any email that leaves the corporate network must be > assumed to be visible to world+dog. Anybody who thinks differently is > deluded and should not be allow

Re: How to extend a tuple of tuples?

2016-09-13 Thread Random832
On Mon, Sep 12, 2016, at 17:29, Chris Angelico wrote: > old_id = id(a) > a += something > if id(a) == old_id: > print("We may have an optimization, folks!") > > But that can have false positives. If two objects do not concurrently > exist, they're allowed to have the same ID number. But the t

Re: Oh gods can we get any more off-topic *wink* [was Re: [Python-ideas] Inconsistencies]

2016-09-14 Thread Random832
On Wed, Sep 14, 2016, at 23:12, Steve D'Aprano wrote: > Yes it does. Even an infinitely large flat plane has a horizon almost > identical to the actual horizon. Your link actually doesn't support the latter claim, it goes into some detail on why it wouldn't if it were infinitely large due to gravi

Re: Oh gods can we get any more off-topic *wink* [was Re: [Python-ideas] Inconsistencies]

2016-09-15 Thread Random832
On Thu, Sep 15, 2016, at 15:06, Steve D'Aprano wrote: > No, the horizon would still be horizontal. It merely wouldn't *look* > horizontal, an optical illusion. I guess that depends on your definition of what a horizon is - and what a straight line is, if not the path followed by a beam of light. -

Re: Oh gods can we get any more off-topic *wink* [was Re: [Python-ideas] Inconsistencies]

2016-09-15 Thread Random832
On Thu, Sep 15, 2016, at 15:31, Steve D'Aprano wrote: > Light follows geodesics, not straight lines. What is a straight line on a curved space if not a geodesic? That was actually what I was getting at. -- https://mail.python.org/mailman/listinfo/python-list

Re: What does this zip() code mean?

2016-09-20 Thread Random832
On Tue, Sep 20, 2016, at 09:19, 38016226...@gmail.com wrote: > >>> x = [1, 2, 3] > >>> y = [4, 5, 6] > >>> zipped = zip(x, y) > >>> list(zipped) > [(1, 4), (2, 5), (3, 6)] > >>> x2, y2 = zip(*zip(x, y)) > >>> x == list(x2) and y == list(y2) > True > > My problem is >>> x2, y2 = zip(*zip(x, y)). >

Re: Linear Time Tree Traversal Generator

2016-09-20 Thread Random832
On Tue, Sep 20, 2016, at 22:34, Steve D'Aprano wrote: > I'm afraid I don't understand this. This is a standard binary tree > inorder traversal. Each node is visited once, and there are N nodes, > so I make that out to be O(N) not O(N log N). I'm afraid I can't parse > your final clause: > > "si

Re: Linear Time Tree Traversal Generator

2016-09-20 Thread Random832
On Tue, Sep 20, 2016, at 23:34, Steve D'Aprano wrote: > One of us is badly missing something. The problem is the number of times next is called. Here, it'll be more clear if we wrap the iterator in the original example to print each time next is called. class WrappedIterator(): def __init__(s

Re: Linear Time Tree Traversal Generator

2016-09-21 Thread Random832
On Wed, Sep 21, 2016, at 10:39, ROGER GRAYDON CHRISTMAN wrote: > Which only highlights my disappointment that my tree > traversal itself was O(n log n), unless I gave up on yield. Or you can give up on recursion. Recursive tree traversal is generally associated with passing in a callback in rather

Re: Pasting code into the cmdline interpreter

2016-09-22 Thread Random832
On Thu, Sep 22, 2016, at 09:45, eryk sun wrote: > On Thu, Sep 22, 2016 at 12:40 PM, Gregory Ewing > wrote: > > eryk sun wrote: > >> > >> Actually in a Unix terminal the cursor can also be at > >> the end of a line, but a bug in Python requires pressing Ctrl+D twice > >> in that case. > > > > I wou

Re: Can this be easily done in Python?

2016-09-27 Thread Random832
On Tue, Sep 27, 2016, at 15:58, TUA wrote: > Is the following possible in Python? > > Given how the line below works > > TransactionTerms = 'TransactionTerms' > > > have something like > > TransactionTerms = > > that sets the variable TransactionTerms to its own name as string > representati

Re: Is there a way to change the closure of a python function?

2016-09-28 Thread Random832
On Wed, Sep 28, 2016, at 11:41, Paul Moore wrote: > What "allows side effects" in languages like Haskell is the fact that the > runtime behaviour of the language is not defined as "calculating the > value of the main function" but rather as "making the process that the > main functon defines as an

Re: Expression can be simplified on list

2016-09-29 Thread Random832
On Thu, Sep 29, 2016, at 02:47, Rustom Mody wrote: > Your example is exactly what I am saying; if a type has a behavior in > which all values are always True (true-ish) its a rather strange kind > of bool-nature. For a given type T, if all objects of type T are true (true-ish, truthy, whatever), i

Re: What is a mechanism equivalent to "trace variable w ..." in Tcl for Python?

2016-09-30 Thread Random832
On Fri, Sep 30, 2016, at 14:42, Ned Batchelder wrote: > On Friday, September 30, 2016 at 2:16:10 PM UTC-4, Les Cargill wrote: > > What is an equivalent mechanism in Python? > > There's no way* to hook into "x = 2", but you could hook into "x.a = 2" > if you wanted do, by defining __setattr__ on x'

Re: unintuitive for-loop behavior

2016-09-30 Thread Random832
On Fri, Sep 30, 2016, at 20:46, Gregory Ewing wrote: > What *is* necessary and sufficient is to make each iteration > of the for-loop create a new binding of the loop variable > (and not any other variable!). I don't think that's true. I think this is logic that is excessively tied to the toy exam

Re: segfault using shutil.make_archive

2016-10-06 Thread Random832
On Thu, Oct 6, 2016, at 12:46, Tim wrote: > I need to zip up a directory that's about 400mb. > I'm using shutil.make_archive and I'm getting this response: > > Segmentation fault: 11 (core dumped) > > The code is straightforward (and works on other, smaller dirs): Are you able to make a test

Re: segfault using shutil.make_archive

2016-10-06 Thread Random832
On Thu, Oct 6, 2016, at 13:45, Random832 wrote: > On Thu, Oct 6, 2016, at 12:46, Tim wrote: > > I need to zip up a directory that's about 400mb. > > I'm using shutil.make_archive and I'm getting this response: > > > > Segmentation fault: 11 (core du

Re: A newbie doubt on methods/functions calling

2016-10-06 Thread Random832
On Thu, Oct 6, 2016, at 19:27, Loren Wilton wrote: > So I don't want to WRITE a Python interpreter for the actual mainframe > environment. I want to use an interpreter for an existing environment > (Windows) where there are already a lot of existing libraries. But > since a lot of the data to be an

Re: how to refactor nested for loop into smaller for loop assume each of them independent?

2016-10-08 Thread Random832
On Sat, Oct 8, 2016, at 06:12, BartC wrote: > The OP's code however is a good demonstration of how crazy Python's > original for-range loop was: you need to construct a list of N elements > just to be able to count to N. How many years was it until xrange was > introduced? Python 1.4 had it, an

Re: how to refactor nested for loop into smaller for loop assume each of them independent?

2016-10-08 Thread Random832
On Sat, Oct 8, 2016, at 07:29, Steve D'Aprano wrote: > The oldest version I have access to is the *extremely* primitive 0.9. Not > surprisingly, it doesn't have xrange -- but it lacks a lot of things, > including globals(), map(), named exceptions, "" strings ('' is okay), > exponentiation, and mor

Re: Making IDLE3 ignore non-BMP characters instead of throwing an exception?

2016-10-17 Thread Random832
On Mon, Oct 17, 2016, at 14:20, eryk sun wrote: > You can patch print() to transcode non-BMP characters as surrogate > pairs. For example: > > On Windows this should allow printing non-BMP characters such as > emojis (e.g. U+0001F44C). I thought there was some reason this wouldn't work with tk, o

Re: Why doesn't Python include non-blocking keyboard input function?

2016-10-25 Thread Random832
On Tue, Oct 25, 2016, at 02:39, Steven D'Aprano wrote: > Not really. I think that lots of people think they need it, but > once they write a little utility, they often realise that it's not > that useful. That's just my opinion, and I'm one of those guys who > wrote one: > > http://code.activestat

Re: Calling Bash Command From Python

2016-10-31 Thread Random832
On Mon, Oct 31, 2016, at 10:55, Wildman via Python-list wrote: > I have code using that approach but I am trying to save myself > from having to parse the entire shadow file. Grep will do it > for me if I can get code right. Python already has built-in functions to parse the shadow file. https:/

Re: Immutability of Floats, Ints and Strings in Python

2016-11-28 Thread Random832
On Fri, Nov 25, 2016, at 06:33, Ned Batchelder wrote: > A Python implementation can choose when to reuse immutable objects and > when not to. Reusing a value has a cost, because the values have to > be kept, and then found again. So the cost is only paid when there's > a reasonable chance that the

Re: python 2.7.12 on Linux behaving differently than on Windows

2016-12-05 Thread Random832
On Mon, Dec 5, 2016, at 14:48, Michael Torrie wrote: > Wow. Does that actually work? And work consistently? How would it > handle globs like this: The rules are simpler than you're probably thinking of. There's actually no relationship between globs on the left and on the right. Globs on the lef

Re: python 2.7.12 on Linux behaving differently than on Windows

2016-12-06 Thread Random832
On Mon, Dec 5, 2016, at 21:21, Dennis Lee Bieber wrote: > They are languages in their own right, with their own rules. > > The Windows command prompt being one of the weakest -- it doesn't > support arithmetic and local variables, nor (to my knowledge) looping > constructs. BAT files a

Re: python 2.7.12 on Linux behaving differently than on Windows

2016-12-06 Thread Random832
On Tue, Dec 6, 2016, at 02:01, Larry Hudson via Python-list wrote: > On 12/05/2016 06:51 PM, Nathan Ernst wrote: > > IIRC, command.com was a relic of Win9x running on top of DOS and was a > > 16-bit executable, so inherently crippled (and probably never support by > > the NT kernel). Whereby cmd.ex

Re: python 2.7.12 on Linux behaving differently than on Windows

2016-12-08 Thread Random832
On Thu, Dec 8, 2016, at 01:20, Gregory Ewing wrote: > BartC wrote: > > And globbing doesn't take care of all of it: a Linux program still has > > to iterate over a loop of filenames. The same as on Windows, except the > > latter will need to call a function to deliver the next filename. > > Actu

Re: python 2.7.12 on Linux behaving differently than on Windows

2016-12-08 Thread Random832
On Wed, Dec 7, 2016, at 00:15, Steven D'Aprano wrote: > and the shell expands the metacharacters ? {...} * [...] regardless of > how much > smarts the command itself has. > > There are thousands of programs I might use, and they may implement who > knows > how many different globbing rules: > >

Re: python 2.7.12 on Linux behaving differently than on Windows

2016-12-08 Thread Random832
On Wed, Dec 7, 2016, at 03:50, Peter Otten wrote: > Is there an equivalent to > > # touch -- -r > > on Windows? Doesn't need one - options conventionally start with /, and filenames can't contain /. -- https://mail.python.org/mailman/listinfo/python-list

Re: python 2.7.12 on Linux behaving differently than on Windows

2016-12-08 Thread Random832
On Wed, Dec 7, 2016, at 15:29, Lew Pitcher wrote: > But, point of fact is that the feature to disable globbing is not often > needed. Most Unix programs that accept filenames are happy to accept a > list of filenames. There is not much call for a program to perform it's own > globbing, like is requ

Re: python 2.7.12 on Linux behaving differently than on Windows

2016-12-08 Thread Random832
On Wed, Dec 7, 2016, at 22:41, Steven D'Aprano wrote: > Python's fnmatch lib is a good example. It has, or at least had, no > support for escaping metacharacters. Anyone relying on Python's fnmatch and > glob > modules alone for globbing will be unable to handle legitimate file names. That's not

Re: python 2.7.12 on Linux behaving differently than on Windows

2016-12-08 Thread Random832
On Thu, Dec 8, 2016, at 20:38, Dennis Lee Bieber wrote: > On Thu, 08 Dec 2016 10:37:27 -0500, Random832 > declaimed the following: > >There are other issues, like needing a way to do Windows' version of > >wildcard parsing with all its quirks, or at least some of its qu

Re: Splitting text into lines

2016-12-13 Thread Random832
On Tue, Dec 13, 2016, at 12:25, George Trojan - NOAA Federal wrote: > > > > Are repeated newlines/carriage returns significant at all? What about > > just using re and just replacing any repeated instances of '\r' or '\n' > > with '\n'? I.e. something like > > >>> # the_string is your file all rea

Re: Running python from pty without prompt

2016-12-13 Thread Random832
On Tue, Dec 13, 2016, at 11:01, Michael Torrie wrote: > On 12/13/2016 05:39 AM, Samuel Williams wrote: > > Michael, yes. > > > > FYI, I found out why this works. Pressing Ctrl-D flushes the input > > buffer. If you do this on an empty line, it causes read(...) to return > > 0 which Ruby considers

Re: Running python from pty without prompt

2016-12-13 Thread Random832
On Tue, Dec 13, 2016, at 17:09, Michael Torrie wrote: > On 12/13/2016 10:48 AM, Random832 wrote: > > The problem is there's currently no way to differentiate "interactive > > mode" from "script run on a tty". > > > > You can get similar behavio

Re: Running python from pty without prompt

2016-12-14 Thread Random832
On Tue, Dec 13, 2016, at 19:10, Steve D'Aprano wrote: > Can you show a simple demonstration of what you are doing? > > I'm having difficulty following this thread because I don't know > what "script run on a tty" means. The question is literally about the input/script being the tty and not redire

Re: Running python from pty without prompt

2016-12-14 Thread Random832
On Tue, Dec 13, 2016, at 19:20, Steve D'Aprano wrote: > sys.flags.interactive will tell you whether or not your script was > launched > with the -i flag. > > hasattr(sys, 'ps1') or hasattr(sys, 'ps2') will tell you if you are > running > in the REPL (interactive interpreter). The ps1 and ps2 varia

Re: Best attack order for groups of numbers trying to destroy each other, given a victory chance for number to number attack.

2016-12-15 Thread Random832
On Thu, Dec 15, 2016, at 08:31, Dennis Lee Bieber wrote: > As for my posts disappearing: I run with "X-NoArchive" set. I have from > before Google absorbed DejaNews. Back then, most news-servers expired > posts > on some periodic basis (my ISP tended to hold text groups for 30 days or > so, b

Re: OT - "Soft" ESC key on the new MacBook Pro

2016-12-19 Thread Random832
On Sun, Dec 18, 2016, at 17:03, Gregory Ewing wrote: > mm0fmf wrote: > > +1 for knowing where CTRL should be. > > Bonus +1 for having used an ASR33. > > And it's quite remarkable that the designers of the ASR33 > knew exactly where it would need to be for Emacs users > years later! I think Richard

Re: Simulating int arithmetic with wrap-around

2017-01-04 Thread Random832
On Fri, Dec 30, 2016, at 09:47, Steve D'Aprano wrote: > Again, assume both operands are in range for an N-bit signed integer. > What's > a good way to efficiently, or at least not too inefficiently, do the > calculations in Python? I'd do something like: bit_mask = (1 << bits) - 1 # 0x sign_b

Re: Simulating int arithmetic with wrap-around

2017-01-06 Thread Random832
On Fri, Dec 30, 2016, at 09:47, Steve D'Aprano wrote: > Again, assume both operands are in range for an N-bit signed integer. > What's > a good way to efficiently, or at least not too inefficiently, do the > calculations in Python? I'd do something like: bit_mask = (1 << bits) - 1 # 0x sign_b

Re: Extended ASCII

2017-01-13 Thread Random832
On Fri, Jan 13, 2017, at 17:24, D'Arcy Cain wrote: > I thought I was done with this crap once I moved to 3.x but some > Winblows machines are still sending what some circles call "Extended > ASCII". I have a file that I am trying to read and it is barfing on > some characters. For example: >

Re: Open (txt) editor and get its content

2018-04-19 Thread Random832
On Thu, Apr 19, 2018, at 03:39, zljubi...@gmail.com wrote: > Is there any other option for getting interactive multi line input from user. If you don't need a full-featured text editor, you could build a simple input popup with the Textbox widget in tkinter. -- https://mail.python.org/mailman/li

Can't drop files on python scripts in a fresh installation of Windows 10 and Python 3.7

2018-09-02 Thread Random832
Python itself runs fine, but when I try to drop a file on a script it just doesn't work. If I try to regsvr32 the shell extension, it says: The module "c:\windows\pyshellext.amd64.dll" failed to load. There was no indication of any problem until this. Apparently it is linked against "VCRUNTIME

Can't drop files on python scripts in a fresh installation of Windows

2018-09-05 Thread Random832
Python itself runs fine, but when I try to drop a file on a script it just doesn't work. If I try to regsvr32 the shell extension, it says: The module "c:\windows\pyshellext.amd64.dll" failed to load. There was no indication of any problem until this. Apparently it is linked against "VCRUNTIME140

Re: List of Functions

2016-03-28 Thread Random832
On Mon, Mar 28, 2016, at 19:40, Steven D'Aprano wrote: > Not to mention "Monad". I don't think *anyone* knows what a Monad is ;-) A monad is just a monoid in the category of endofunctors; what's the problem? Well, someone had to say it. -- https://mail.python.org/mailman/listinfo/python-list

Re: [stdlib-sig] Can imaplib be improved?

2016-03-29 Thread Random832
I'd posted this to stdlib-...@python.org without realizing that that list is mostly dead. On Thu, Mar 24, 2016, at 22:33, Random832 wrote: > I assume that everyone who has ever used imaplib is familiar with how > painful its output format is to deal with. I am wondering if anyone els

Re: [stdlib-sig] Can imaplib be improved?

2016-03-29 Thread Random832
On Tue, Mar 29, 2016, at 14:45, Grant Edwards wrote: > I think giving up on backwards compatiblity and starting from scratch > is the best idea. > > I like imaplib2 > > https://pypi.python.org/pypi/imaplib2 > https://github.com/bcoe/imaplib2 > https://sourceforge.net/projects/imaplib2/ > > imapc

Re: Threading is foobared?

2016-03-29 Thread Random832
On Tue, Mar 29, 2016, at 19:54, Rob Gaddi wrote: > Just read on Usenet instead of through the mailing list. That way > you can accept broken threading as a given rather than wonder why it's > happening in a particular case. It's a given everywhere. Any thread that contains a sufficient number of

Re: Suggestion: make sequence and map interfaces more similar

2016-03-29 Thread Random832
On Tue, Mar 29, 2016, at 20:56, Chris Angelico wrote: > The map contract is this: > > x = StrangeDict() > x[123] = 456 > ... > assert x[123] == 456 > > Your mapping does violate the map contract. So, you can put *anything* in that "..."? x = dict() x[123] = 456 x[123] = 789 assert x[123] == 456

Re: Suggestion: make sequence and map interfaces more similar

2016-03-30 Thread Random832
On Wed, Mar 30, 2016, at 01:43, Steven D'Aprano wrote: > This is not an argument about dicts being mutable, because clearly they > aren't. This is an argument about key:value pairs being stable. "Stable" > doesn't mean "immutable". If you change the value associated with a key > directly, then i

Re: Suggestion: make sequence and map interfaces more similar

2016-03-30 Thread Random832
This discussion is getting a bit distracted from the original request. Let's look at it from a higher level. What is being requested, regardless of if you call it a "map interface" or whatever, is a single way, for sequences and maps... broadly, anything with a __getitem__, to iterate over all val

  1   2   3   4   5   6   7   8   >