please let me know if this is the case.
Otherwise, what do you think about it?
PEP 463 proposes a short syntax for this use case:
http://legacy.python.org/dev/peps/pep-0463/
I'm not sure what became of it.
--
Ned Batchelder, http://nedbatchelder.com
--
https://mail.python.org/mailman/lis
)
>>>s[0]
'e'
>>>s.startswith('e')
True
>>>s.isdigit()
False
You could certainly implement a StringSlice object that worked like
this. Store the string, the start and end indexes. Override
__getitem__ to adjust indexes and slice endpoints, imp
or, at least show them one!
--
Ned Batchelder, http://nedbatchelder.com
--
https://mail.python.org/mailman/listinfo/python-list
er powers is by squaring based on the binary
representation of the exponent. It's explained here:
http://stackoverflow.com/a/101613/14343
So even if Python is actually calculating the value, it's only doing 75
multiplications or so.
--
Ned Batchelder, http://nedbatchelder.com
-
On 4/11/2013 9:57 PM, Mark Janssen wrote:
Okay peeps, I'm re-opening this thread, because despite being hijacked
by naysayers, the merit of the underlying idea I think still has not
been communicated or perceived adequately.
Mark, this proposal is out of place on a Python list, because it
propo
On 4/16/2013 12:02 PM, Rodrick Brown wrote:
I came across this article which sums up some of the issues I have
with modern programming languages. I've never really looked at
Javascript for anything serious or Node itself but I found this
article really informational.
"The "Batteries included"
On 4/17/2013 12:10 PM, 8 Dihedral wrote:
Serhiy Storchaka於 2013年4月17日星期三UTC+8下午5時35分07秒寫道:
17.04.13 07:57, Larry Hudson написав(ла):
So using a list comprehension you can do it in two lines:
def get_rule(num):
bs = bin(num)[2:]
return [0] * (8 - len(bs)) + [int(i) for i in bs]
On 4/18/2013 9:24 PM, Mark Janssen wrote:
One of the nice things about OOP is it means so many different things to
different people. All of whom believe with religious fervor that they
know the true answer.
Here's a simple rule to resolve the ambiguity. Whoever publishes
first, gets to claim
On 4/18/2013 10:30 PM, Mark Janssen wrote:
Okay, professor is it, master? What is your provenance anyway?
I'm not a professor, I'm a software engineer. I'm just trying to help.
You've made statements that strike me as half-informed. You're trying to
unify concepts that perhaps can't or sho
On 4/19/2013 12:16 PM, Steven D'Aprano wrote:
On Fri, 19 Apr 2013 12:02:00 -0400, Roy Smith wrote:
PS: a great C++ interview question is, "What's the difference between a
class and a struct?" Amazing how few self-professed C++ experts have no
clue.
I'm not a C++ expert, but I am an inquiring
On 4/20/2013 1:12 PM, jmfauth wrote:
In a previous post,
http://groups.google.com/group/comp.lang.python/browse_thread/thread/6aec70817705c226#
,
Chris “Kwpolska” Warrick wrote:
“Is Unicode support so hard, especially in the 21st century?”
--
Unicode is not really complicate and it works ver
On 4/20/2013 1:09 PM, Jason Friedman wrote:
I have a file such as:
$ cat my_data
Starting a new group
a
b
c
Starting a new group
1
2
3
4
Starting a new group
X
Y
Z
Starting a new group
I am wanting a list of lists:
['a', 'b', 'c']
['1', '2', '3', '4']
['X', 'Y', 'Z']
[]
I wrote this:
-
On 4/24/2013 1:08 PM, Daniel Kersgaard wrote:
Today, being the last day of lectures at school, my instructor ran briefly
through Tkninter and GUIs. I'd been looking forward to this particular lesson
all semester, but when I got home and copied a sample program from my textbook
verbatim, IDLE
On 4/29/2013 3:30 PM, Peter Rowat wrote:
This must be a trivial question:
I have "import numpy as np" in the python startup file.
A file called mod1.py contains "def myfn..."
and inside myfn there is a call to, say, "np.convolve".
Interactively:
python
(numpy imported as np)
import
On 5/1/2013 5:20 PM, Tony the Tiger wrote:
On Mon, 29 Apr 2013 10:47:46 +0100, cl wrote:
raw = os.path.join(directory, self.getNameNoExtension()) +
".html"
file = open(raw, "w")
file.write("".join(html).encode('utf-8'))
file.close()
This works for
On 4/29/2013 5:47 AM, c...@isbd.net wrote:
If I understand correctly the encode() is saying that it can't
understand the data in the html because there's a character 0xc3 in it.
I *think* this means that the é is encoded in UTF-8 already in the
incoming data stream (should be as my system is who
56 pm, Ben Finney <[EMAIL PROTECTED]> wrote:
> Howdy all,
>
> Ned Batchelder has been maintaining the nice simple tool 'coverage.py'
> http://nedbatchelder.com/code/modules/coverage.html> for
> measuring unit test coverage.
>
> On the same site, Ned includes doc
On Wednesday, February 15, 2017 at 8:34:45 AM UTC-5, Wolfgang Maier wrote:
> On 15.02.2017 13:42, poseidon wrote:
> > On 15/02/17 12:16, Wolfgang Maier wrote:
> >> On 15.02.2017 10:33, poseidon wrote:
> >>> In /usr/lib/python3.6/site-packages I wrote a file tau4.pth. It contains
> >>> the line
> >>
On Thursday, March 30, 2017 at 4:59:03 PM UTC-4, Boylan, Ross wrote:
> https://docs.python.org/3/reference/expressions.html#displays-for-lists-sets-and-dictionaries
> describes the syntax for comprehensions as
> comprehension ::= expression comp_for
> comp_for ::= [ASYNC] "for" target_list "
On Saturday, April 29, 2017 at 4:20:06 PM UTC-4, Erik wrote:
> It seems a little onerous that I have to put the key checks in several
> places and implement each of those APIs manually again (and keep on top
> of that if dict() grows some new methods that involve setting items). Is
> there a co
On Tuesday, May 2, 2017 at 11:49:37 PM UTC-4, larry@gmail.com wrote:
> On Tue, May 2, 2017 at 7:01 PM, Erik wrote:
> > On 02/05/17 23:28, Larry Martell wrote:
>
> Anyone have any thoughts on how I can monitor the variables' memory
> usage as the script runs?
> >>>
> >>>
> >>> Th
On Tuesday, May 2, 2017 at 11:45:39 AM UTC-4, oliver wrote:
> The documentation for typing.TypeVar gives these two examples:
>
> T = TypeVar('T') # Can be anything
> A = TypeVar('A', str, bytes) # Must be str or bytes
>
> I was suprised to find out that the following does not work, exce
On Wednesday, May 3, 2017 at 8:40:09 AM UTC-4, larry@gmail.com wrote:
> On Wed, May 3, 2017 at 8:29 AM, Ned Batchelder wrote:
> > On Tuesday, May 2, 2017 at 11:49:37 PM UTC-4, larry@gmail.com wrote:
> >> On Tue, May 2, 2017 at 7:01 PM, Erik wrote:
> >> > On
On Wednesday, May 3, 2017 at 6:22:28 PM UTC-4, larry@gmail.com wrote:
> On Wed, May 3, 2017 at 6:15 PM, Terry Reedy wrote:
> > On 5/3/2017 8:40 AM, Larry Martell wrote:
> >>
> >> On Wed, May 3, 2017 at 8:29 AM, Chris Angelico wrote:
> >>>
> >>> On Wed, May 3, 2017 at 10:12 PM, Larry Martell
On Wednesday, May 3, 2017 at 8:09:59 PM UTC-4, Steve D'Aprano wrote:
> On Thu, 4 May 2017 09:30 am, Ned Batchelder wrote:
>
> > Functions, classes, and modules can also be referred to by a number of
> > variables:
> >
> > def foo(): pass
> > b
On Friday, May 12, 2017 at 6:02:58 AM UTC-4, Steve D'Aprano wrote:
> One of the more controversial aspects of the Python ecosystem is the Python
> docs. Some people love them, and some people hate them and describe them as
> horrible.
>
I have a number of ideas for improving the docs, but I think
On Wednesday, May 17, 2017 at 5:48:30 AM UTC-4, Cem Karan wrote:
> On May 16, 2017, at 12:36 PM, rzed wrote:
>
> > On Friday, May 12, 2017 at 6:02:58 AM UTC-4, Steve D'Aprano wrote:
> >> One of the more controversial aspects of the Python ecosystem is the Python
> >> docs. Some people love them,
On Thursday, June 8, 2017 at 11:10:49 AM UTC-4, Siva Kumar S wrote:
> Dear members,
>
> how to install wikipedia 1.4 package in python 2.7 above without PIP.
Why don't you want to use pip?
You can probably just download the .tar.gz, unpack it, and run:
python setup.py install
but pip will
On Wednesday, June 14, 2017 at 7:06:39 PM UTC-4, justin walters wrote:
> JSON and Python dictionaries have nearly the exact same syntax. That's why
> working with
> JSON in Python is such a joy! :)
>
> You can paste any valid JSON into a Python REPL and it will be interpreted
> as a Python diction
On Thursday, June 15, 2017 at 5:55:07 AM UTC-4, Gregory Ewing wrote:
> Chris Angelico wrote:
> > There've been a number of attempts, over the years, to make a
> > sandboxed Python interpreter, where you can run untrusted code. But if
> > Python came with a JS interpreter, it would be possible to ru
On Thursday, June 22, 2017 at 11:07:36 AM UTC-4, bream...@gmail.com wrote:
> On Wednesday, June 21, 2017 at 11:58:03 PM UTC+1, Steve D'Aprano wrote:
> > On Thu, 22 Jun 2017 08:23 am, breamoreboy wrote:
> >
> > > Don't you know that Lawrence D’Oliveiro has been banned from the mailing
> > > list
>
On Tuesday, June 27, 2017 at 1:41:22 AM UTC-4, Ben S. wrote:
> As I observed v3.6.1 installs (on Windows 7) in addition to the core python
> engine a second program "Python Launcher".
>
> As far as I read this component seems to be not necessary since it only aims
> to facilitate the handling wi
On Thursday, June 29, 2017 at 10:04:30 AM UTC-4, Grant Edwards wrote:
> I've forked a copy of https://github.com/Roguelazer/muttdown and have
> been adding a few features and fixing a few bugs. It's meant to be
> installed using setup tools, and then invoked via /usr/bin/muttdown
> which looks lik
On Thursday, July 13, 2017 at 10:59:52 AM UTC-4, Pavol Lisy wrote:
> On 7/13/17, Steve D'Aprano wrote:
>
> > [1] Actually, CPython's lists initially quadruple the size of the array, up
> > to a
> > certain point, and then switch to doubling. This ensures that small lists
> > have
> > even fewer e
On 7/29/17 5:12 AM, ttopolew...@gmail.com wrote:
> Hello,
> I'm wondering what do You think about some default logging that can become a
> part of the Python language and part of the development workflow.
>
> I would see it as develop in debug mode untill debug is removed intentionally.
> It would
On 8/4/17 7:42 PM, Jon Forrest wrote:
> On 8/4/2017 4:34 PM, gst wrote:
>> 'two' is a so called constant or literal value .. (of that
>> function).
>>
>> Why not attach it, as a const value/object, to the function itself ?
>> So that a new string object has not to be created each time the
>> functi
On 8/5/17 11:23 AM, Tim Daneliuk wrote:
> On 08/04/2017 07:00 PM, Chris Angelico wrote:
>> Again, don't stress about exactly when objects get
>> disposed of; it doesn't matter.
>
> Respectfully, I disagree strongly. Objects get build on the heap and
> persist even when they go out of scope until s
On 8/5/17 5:41 PM, Tim Daneliuk wrote:
> On 08/05/2017 11:16 AM, Ned Batchelder wrote:
>> It uses
>> reference counting, so most objects are reclaimed immediately when their
>> reference count goes to zero, such as at the end of local scopes.
> Given this co
On 8/10/17 4:47 AM, Hartmut Goebel wrote:
> Hello,
>
> Is there some tool or online-service which can check patches if they
> contain white-space-only changes and all test-wrapping changes?
>
> One of the projects I'm maintaining (pyinstaller) wants to forbid
> changes of theses types. If we could
On 8/11/17 6:37 AM, Python wrote:
> Marko Rauhamaa wrote:
>> Python :
>>
>>> Marko Rauhamaa wrote:
>>> I didn't disagree with any of these statements about __hash__, but only
>>> your statement about id and __eq__:
>>>
id() is actually an ideal return value of __hash__(). The only
criter
On 8/14/17 2:21 PM, Mok-Kong Shen wrote:
> I ran the attached program and got the following output:
>
> [1, 2, 3]
> [3, 6, 9]
>
> I don't understand why the modification doesn't work in the case of
> test() but does work in the case of test1().
>
> Thanks for your help in advance.
>
> M. K. Shen
>
On 8/14/17 3:21 PM, Mok-Kong Shen wrote:
> Am 14.08.2017 um 20:50 schrieb Ned Batchelder:
>> On 8/14/17 2:21 PM, Mok-Kong Shen wrote:
>>> I ran the attached program and got the following output:
>>>
>>> [1, 2, 3]
>>> [3, 6, 9]
>>>
>>&
/nedbatchelder.com/text/names1.html
It answers precisely these questions.
--Ned.
>
> M. K. Shen
>>
>> On Mon, 14 Aug 2017 at 16:06 Mok-Kong Shen
>> wrote:
>>
>>> Am 14.08.2017 um 21:53 schrieb Ned Batchelder:
>>>> On 8/14/17 3:21 PM, Mok-Kong Shen wro
On 8/16/17 5:06 PM, Mok-Kong Shen wrote:
> Am 15.08.2017 um 20:47 schrieb Larry Hudson:
> [snip]
>>> === test2() code ==
>>> def test2(alist): ss ─┬─> [1, 2, 3]
>>> alist ─┘
>>> -
>>>
On Thu, Aug 17, 2017 at 8:29 AM, Mok-Kong Shen wrote:
> Anyway, while
> any new user of a programming language certainly can be expected to
> take good efforts to learn a lot of new stuffs, I suppose it's good
> for any practical programming language to minimize the cases of
> surprises for those
On 8/24/17 10:42 AM, Stefan Ram wrote:
> i = 0
> while True: print( f"{ i }:{ id( i )}" ); i = i + 1
>
> This loop prints increasing ids while i is less than
> 257, and then it starts to print alternating ids.
>
> So this seems to indicate that temporary objects are
> created for large inte
On 8/25/17 12:10 AM, Paul Rubin wrote:
> Steve D'Aprano writes:
>> Did __next__ cache the most recently generated value?
> No but if they're going to change stuff, they might as well actually
> improve it instead of just renaming it to break code gratutiously.
The vast majority of iteration has n
On 11/25/17 5:05 PM, wojtek.m...@gmail.com wrote:
> Hi, my goal is to obtain an interpreter that internally
> uses UCS-2. Such a simple code should print 65535:
>
>import sys
>print sys.maxunicode
>
> This is enabled in Windows, but I want the same in Linux.
> What options have I pass to th
On 11/27/17 7:54 AM, Cai Gengyang wrote:
> Input :
>
> count = 0
>
> if count < 5:
>print "Hello, I am an if statement and count is", count
>
> while count < 10:
>print "Hello, I am a while and count is", count
>count += 1
>
> Output :
>
> Hello, I am an if statement and count is 0
> He
On 11/27/17 8:13 AM, jaya.bir...@gmail.com wrote:
> Please let me know anyone aware about the issue
>
>
> Traceback (most recent call last):
> File "testrunner.py", line 447, in
> testrunner_obj.main()
> File "testrunner.py", line 433, in main
> self.result()
> File "testrunner.py", line 310, in r
On 11/27/17 1:57 PM, bartc wrote:
> On 27/11/2017 17:41, Chris Angelico wrote:
>> On Tue, Nov 28, 2017 at 2:14 AM, bartc wrote:
>>> JPEG uses lossy compression. The resulting recovered data is an
>>> approximation of the original.
>>
>> Ah but it is a perfect representation of the JPEG stream. Any
On 11/25/17 5:05 PM, wojtek.m...@gmail.com wrote:
> Hi, my goal is to obtain an interpreter that internally
> uses UCS-2. Such a simple code should print 65535:
>
>import sys
>print sys.maxunicode
>
> This is enabled in Windows, but I want the same in Linux.
> What options have I pass to th
801 - 852 of 852 matches
Mail list logo