10.05.13 15:19, Robert Kern написав(ла):
I'd be curious to see in-the-wild instances of the anti-pattern that you
are talking about, then.
Many (if not most) GUI frameworks use this pattern.
button = Button("text")
button.setForegroundColor(...)
button.setBackgoundColor(...)
bu
28.05.13 11:17, Chris Angelico написав(ла):
On Tue, May 28, 2013 at 6:10 PM, Fábio Santos wrote:
Just to clarify, I am suggesting to have the unchanged messages in
tracebacks, but having some methods in the exception to get the exception
and message localised. Just like repr() and str() are dir
30.05.13 23:46, Skip Montanaro написав(ла):
Am I missing something about how io.StringIO works? I thought it was
a more-or-less drop-in replacement for StringIO.StringIO.
io.StringIO was backported from Python 3. It is a text (unicode) stream.
cStringIO.StringIO is a binary stream and StringI
31.05.13 12:55, Peter Otten написав(ла):
Serhiy Storchaka wrote:
30.05.13 23:46, Skip Montanaro написав(ла):
Am I missing something about how io.StringIO works? I thought it was
a more-or-less drop-in replacement for StringIO.StringIO.
io.StringIO was backported from Python 3. It is a text
05.06.13 11:09, Chris Angelico написав(ла):
Oh, and I changed the root password, since the current one was sent in
clear text across the internet. Nikos, the new password has been
stored in /home/nikos/new_password - you should be able to access that
using your non-root login. I recommend you cha
06.06.13 12:45, Chris Angelico написав(ла):
For the "accept any object that has a next() method" sorts of rules, I
don't know of any really viable system that does that usefully. The
concept of implementing interfaces in Java comes close, but the class
author has to declare that it's implementing
06.06.13 15:01, Paul Volkov написав(ла):
Where can I submit little mistakes in Python documantation?
http://bugs.python.org/
--
http://mail.python.org/mailman/listinfo/python-list
11.06.13 07:11, Roy Smith написав(ла):
In article ,
Roel Schroeven wrote:
new_songs, old_songs = [], []
[(new_songs if s.is_new() else old_songs).append(s) for s in songs]
Thanks kind of neat, thanks.
I'm trying to figure out what list gets created and discarded. I think
it's [None] * le
11.06.13 01:50, Chris Angelico написав(ла):
On Tue, Jun 11, 2013 at 6:34 AM, Roy Smith wrote:
new_songs = [s for s in songs if s.is_new()]
old_songs = [s for s in songs if not s.is_new()]
Hmm. Would this serve?
old_songs = songs[:]
new_songs = [songs.remove(s) or s for s in songs if s.is_new
11.06.13 06:02, Steven D'Aprano написав(ла):
On Mon, 10 Jun 2013 19:36:44 -0700, rusi wrote:
And so languages nowadays tend to 'protect' against this feature.
Apart from Erlang, got any other examples?
C#? At least local variable can't shadow other local variable in outer
scope (and it look
12.06.13 09:32, Phil Connell написав(ла):
On 12 Jun 2013 01:36, "Roy Smith" mailto:r...@panix.com>>
wrote:
> Well, continuing down this somewhat bizarre path:
>
> new_songs, old_songs = [], []
> itertools.takewhile(
> lambda x: True,
> (new_songs if s.is_new() else old_songs).append
12.06.13 10:26, Peter Otten написав(ла):
@contextmanager
def my_urlopen(url):
resp = urlopen(url)
yield io.TextIOWrapper(resp.fp)
with urlopen(url) as resp:
yield io.TextIOWrapper(resp)
Note that last bugfix releases (i.e. 3.3.1) are needed. There was a
13.06.13 05:41, Tim Chase написав(ла):
-hg: last I checked, can't do octopus merges (merges with more than
two parents)
+git: can do octopus merges
Actually it is possible in Mercurial. I just have made a merge of two
files in CPython test suite (http://bugs.python.org/issue18048).
--
http
14.07.13 06:09, Chris Angelico написав(ла):
Incidents like this are a definite push, but my D&D campaign is
demanding my attention right now, so I haven't made the move.
Are you role-playing Chaos Mage [1]?
[1] http://www.dandwiki.com/wiki/Chaos_Mage_(3.5e_Class)
--
http://mail.python.org/mai
16.07.13 15:04, Chris Angelico написав(ла):
Piece of extreme oddity, this.
help(sys.float_info)
... lots of other info ...
| max_exp
| DBL_MAX_EXP -- maximum int e such that radix**(e-1) is representable
|
| min_exp
| DBL_MIN_EXP -- minimum int e such that radix**(e-1) is
18.07.13 20:04, Terry Reedy написав(ла):
On 7/18/2013 3:29 AM, Aseem Bansal wrote:
About reading comp.lang.python can you suggest how to read it and
reply?
To read this list as a newsgroup use news.gmane.org. The difference
between the mailing list interface and newsgroup interface is that the
19.07.13 19:22, Steven D'Aprano написав(ла):
I also expect that the string replace() method will be second fastest,
and re.sub will be the slowest, by a very long way.
The string replace() method is fastest (at least in Python 3.3+). See
implementation of html.escape() etc.
--
http://mail.p
19.07.13 21:08, Skip Montanaro написав(ла):
Serhiy> The string replace() method is fastest (at least in Python 3.3+). See
Serhiy> implementation of html.escape() etc.
I trust everybody knows by now that when you want to use regular
expressions you should shell out to Perl for the best performance
20.07.13 14:16, Joshua Landau написав(ла):
On 19 July 2013 18:29, Serhiy Storchaka wrote:
The string replace() method is fastest (at least in Python 3.3+). See
implementation of html.escape() etc.
def escape(s, quote=True):
if quote:
return s.translate(_escape_map_full
20.07.13 23:22, pablobarhamal...@gmail.com написав(ла):
e = math.e
count = -1
for x in range(hidden_num):
temp = 0
for y in range(input_num):
count += 1
temp += inputs[y] * h_weight[count]
hidden[
20.07.13 20:03, Joshua Landau написав(ла):
Still, it seems to me that it should be optimizable for sensible
builtin types such that .translate is significantly faster, as there's
no theoretical extra work that .translate *has* to do that .replace
does not, and .replace also has to rebuild the str
21.07.13 14:29, Joshua Landau написав(ла):
On 21 July 2013 08:44, Serhiy Storchaka wrote:
20.07.13 20:03, Joshua Landau написав(ла):
Still, it seems to me that it should be optimizable for sensible
builtin types such that .translate is significantly faster, as there's
no theoretical
24.07.13 21:15, Chris Angelico написав(ла):
To my mind, exposing UTF-16
surrogates to the application is a bug to be fixed, not a feature to
be maintained.
Python 3 uses code points from U+DC80 to U+DCFF (which are in surrogates
area) to represent undecodable bytes with surrogateescape error h
28.07.13 22:59, Roy Smith написав(ла):
The input is an 8.8 Mbyte file containing about 570,000 lines (11,000
unique strings).
Repeat you tests with totally unique lines.
The full profiler dump is at the end of this message, but the gist of
it is:
Profiler affects execution time. In partic
29.07.13 19:09, MRAB написав(ла):
I'm surprised that Fraction(1/3) != Fraction(1, 3); after all, floats
are approximate anyway, and the float value 1/3 is more likely to be
Fraction(1, 3) than Fraction(6004799503160661, 18014398509481984).
>>> def approximate_fraction(f):
prev_numer, numer
29.07.13 20:19, Ian Kelly написав(ла):
On Mon, Jul 29, 2013 at 5:49 AM, Joshua Landau wrote:
Also, couldn't Counter just extend from defaultdict?
It could, but I expect the C helper function in 3.4 will be faster
since it doesn't even need to call __missing__ in the first place.
I'm surpris
29.07.13 14:49, Joshua Landau написав(ла):
I find it hard to agree that counter should be optimised for the
unique-data case, as surely it's much more oft used when there's a point
to counting?
Different methods are faster for different data. LBYL approach is best
for the mostly unique data ca
31.07.13 06:45, Musical Notation написав(ла):
Is there any script that converts indentation in Python code to curly braces?
The indentation is sometime lost when I copy my code to an application or a
website.
Look at the pindent.py script.
--
http://mail.python.org/mailman/listinfo/python-li
On 27.06.12 17:34, Christian Tismer wrote:
That's why I was unhappy with py3's missing flexibility.
Excessive flexibility is amorphism.
--
http://mail.python.org/mailman/listinfo/python-list
On 27.06.12 14:22, Stefan Behnel wrote:
For comparison, the revival of the "u" string prefix in Py3.3 is a simple
change in the parser grammar that's easy to maintain but that has a huge
impact on the Py3 compatibility of code that accepts to drop support for
Py2.5 and earlier (as well as Py3.[01
On 28.06.12 00:14, Terry Reedy wrote:
Another prediction: people who code Python without reading the manual,
at least not for new features, will learn about 'u' somehow (such as by
reading this list) and may do either of the following, both of which are
bad.
1. They will confuse themselves by th
The project page is at:
http://code.google.com/p/pymud
Any information is greatly appreciated.
Do you mean https://github.com/benthomasson/pymud,
http://pymud.blogspot.com/ or http://sourceforge.net/projects/pymud/ ?
--
http://mail.python.org/mailman/listinfo/python-list
On 29.06.12 17:44, Littlefield, Tyler wrote:
On 6/29/2012 2:14 AM, Serhiy Storchaka wrote:
The project page is at:
http://code.google.com/p/pymud
Any information is greatly appreciated.
Do you mean
No, I mean http://code.google.com/p/pymud
Then you probably should choose another name
On 01.07.12 07:25, contro opinion wrote:
i have installed tk ,how to use tkinker in python3.2?
You must install tk-dev (or whatever it's called on your system) before
Python building (don't forget to rerun configure).
--
http://mail.python.org/mailman/listinfo/python-list
On 15.07.12 19:50, Rick Johnson wrote:
We must NEVER present "if" in such confusing manner as ExampleA.
## EXAMPLE C ##
py> if bool(money) == True:
... do_something()
--
http://mail.python.org/mailman/listinfo/python-list
On 23.07.12 18:49, Steven D'Aprano wrote:
⤠for <=
⥠for >=
I insist on the use of ⩽ and ⩾ too.
--
http://mail.python.org/mailman/listinfo/python-list
On 05.08.12 09:30, Steven D'Aprano wrote:
If you are working in a tight loop, you can do this:
if VERBOSE_FLAG:
for item in loop:
print(DEBUG_INFORMATION)
do_actual_work(item)
else:
for item in loop:
do_actual_work(item)
Or this:
if VERBOSE_FLAG:
def d
On 06.08.12 20:02, Dieter Maurer wrote:
Serhiy Storchaka writes:
On 05.08.12 09:30, Steven D'Aprano wrote:
If you are working in a tight loop, you can do this:
if VERBOSE_FLAG:
for item in loop:
print(DEBUG_INFORMATION)
do_actual_work(item)
else:
for it
On 02.09.12 06:15, Ramchandra Apte wrote:
It converts to *pure* C/C++ *without* using Python or its API so that it can be
the same speed as C/C++
How is it implemented long integers?
--
http://mail.python.org/mailman/listinfo/python-list
On 02.09.12 12:52, Peter Otten wrote:
Ian Kelly wrote:
Rewriting the example to use locale.strcoll instead:
sorted(li, key=functools.cmp_to_key(locale.strcoll))
There is also locale.strxfrm() which you can use directly:
sorted(li, key=locale.strxfrm)
Hmm, and with locale.strxfrm Python
On 30.08.12 09:55, Steven D'Aprano wrote:
And Python's solution uses those: UCS-2, UCS-4, and UTF-8.
I see that this misconception widely spread. In fact Python 3.3 uses
four kinds of ready strings.
* ASCII. All codes <= U+007F.
* UCS1. All codes <= U+00FF, at least one code > U+007F.
* UCS2
On 02.09.12 23:38, Serhiy Storchaka wrote:
Indexing is O(0) for any string.
Typo. O(1)
--
http://mail.python.org/mailman/listinfo/python-list
On 03.09.12 04:42, Steven D'Aprano wrote:
If you are *seriously* interested in debugging why string code is slower
for you, you can start by running the full suite of Python string
benchmarks: see the stringbench benchmark in the Tools directory of
source installations, or see here:
http://hg.py
On 03.09.12 04:54, Steven D'Aprano wrote:
This means that Python 3.3 will no longer have surrogate pairs.
Am I right?
As Terry said, basically, yes. Python 3.3 does not need in surrogate
pairs, but does not prevent their creation. You can create a surrogate
code (U+D800..U+DFFF) intentionall
On 03.09.12 09:15, Peter Otten wrote:
wxjmfa...@gmail.com wrote:
Le dimanche 2 septembre 2012 14:01:18 UTC+2, Serhiy Storchaka a écrit :
Hmm, and with locale.strxfrm Python 3.3 20% slower than 3.2.
With a memory gain = 0 since my text contains non-latin-1 characters!
I can't confirm
On 03.09.12 16:29, Christian Heimes wrote:
Am 03.09.2012 14:32, schrieb Marco:
Does anyone have an example of utilisation?
The opener argument is a new 3.3 feature. For example you can use the
feature to implement exclusive creation of a file to avoid symlink attacks.
Or you can use new dir_
On 27.08.12 22:17, Ian Kelly wrote:
May I
suggest an alternate approach? Internally tag each set or dict with a
"version", which is just a C int. Every time the hash table is
modified, increment the version. When an iterator is created, store
the current version on the iterator. When the iter
On 04.09.12 04:13, Steven D'Aprano wrote:
Why does the open builtin need this added complexity? Why not just call
os.open directly? Or for more complex openers, just call the opener
directly?
What is the rationale for complicating open instead of telling people to
just call their opener directly
On 03.09.12 15:32, Marco wrote:
Does anyone have an example of utilisation?
http://bugs.python.org/issue13424
--
http://mail.python.org/mailman/listinfo/python-list
On 07.09.12 15:53, Ramyasri Dodla wrote:
> I am brand new to python. checking over basic stuff. I came across the
> problem while doing so. If any body aware of the problem, kindly respond me.
>
> >>> 5/10
> 0
> >>> - 5/10
> -1
>
> The second case also should yield a 'zero' but it is giving a
On 09.09.12 08:47, Donald Stufft wrote:
If you don't need to retain order you can just use a set,
Only if elements are hashable.
--
http://mail.python.org/mailman/listinfo/python-list
On 27.09.12 09:08, Chris Angelico wrote:
LAMP usually means PHP these days. There's a lot of that around.
And Cyrillic Р means Ruby. :-P
--
http://mail.python.org/mailman/listinfo/python-list
On 27.09.12 12:33, Steven D'Aprano wrote:
Nevertheless, I think there is something here. The consequences are nowhere
near as dramatic as jmf claims, but it does seem that replace() has taken a
serious performance hit. Perhaps it is unavoidable, but perhaps not.
If anyone else can confirm simila
On 27.09.12 18:06, Ian Kelly wrote:
I understand ISO 8859-15 (Latin-9) to be the preferred Latin character
set for French, as it includes the Euro sign as well as a few
characters that are not in Latin-1 but are nonetheless infrequently
found in French.
Even for Latin-9 Python 3.3 can be a litt
On 15.10.12 16:05, Ulrich Eckhardt wrote:
I need a little nudge in the right direction, as I'm misunderstanding
something concerning string literals in Python 2 and 3. In Python 2.7,
b'' and '' are byte strings, while u'' is a unicode literal. In Python
3.2, b'' is a byte string and '' is a unico
On 15.10.12 17:04, Chris Angelico wrote:
> On Tue, Oct 16, 2012 at 12:55 AM, Debashish Saha wrote:
>> how to insert random error in a programming?
>
> how to ask question good in forumming?
> http://www.catb.org/~esr/faqs/smart-questions.html
>
> But here's one way to do it:
>
> raise
> random
Chris Angelico's suggestion:
>>> bitcount = bytes(bin(i).count("1") for i in range(256))
>>> t = Timer('sum(number.to_bytes((number.bit_length() + 7) // 8,'
... '"little").translate(bitcount))',
... setup='from __main__ import bitcount; number=2**10001-1')
>>> min(t.repeat(number=1, repeat=7)
On 25.11.12 12:19, kobayashi wrote:
Under platform that has fixed pitch font,
I want to get a "screen" length of a multibyte string
--- sample ---
s1 = u"abcdef"
s2 = u"あいう" # It has same "screen" length as s1's.
print len(s1) # Got 6
print len(s2) # Got 3, but I want get 6.
--
Ab
On 19.12.12 17:40, Chris Angelico wrote:
Interestingly, IDLE on my Windows box can't handle the bolded
characters very well...
s="\U0001d407\U0001d41e\U0001d425\U0001d425\U0001d428,
\U0001d430\U0001d428\U0001d42b\U0001d425\U0001d41d!"
print(s)
Traceback (most recent call last):
File "", li
07.02.12 00:06, Matej Cepl написав(ла):
> return seq[int(random.random() * len(seq))]
>
> doesn't seem like something so terrible (and maintenance intense). :)
_choice('abc') returns 'a' with probability P('a') =
1501199875790165/4503599627370496 = 1/3 - 1/13510798882111488 and 'b' with
probabi
08.02.12 22:15, Terry Reedy написав(ла):
To make a repeating rotator is only a slight adjustment:
k = n - len(seq)
while True:
i = k
while i < n:
yield seq[i]
i += 1
for i in range(n, len(seq)):
yield seq[i]
while True:
fo
18.02.12 20:58, SherjilOzair написав(ла):
Has it been considered to add shell features to python, such that it can be
used as a default shell, as a replacement for bash, etc.
I'm sure everyone would agree that doing this would make the terminal very
powerful.
What are your views on this?
Lo
25.02.12 02:37, MRAB написав(ла):
We already have arbitrarily long ints, so there could be a special
infinite int singleton (actually, 2 of them, one positive, the other
negative).
float('inf') and float('-inf').
--
http://mail.python.org/mailman/listinfo/python-list
15.03.12 16:19, Kiuhnm написав(ла):
> Ok, so they're mandatory, but I was mainly talking of design. Why are they
> needed?
http://python-history.blogspot.com/2011/07/karin-dewar-indentation-and-colon.html
--
http://mail.python.org/mailman/listinfo/python-list
16.03.12 18:45, Steven D'Aprano написав(ла):
If f is a function which normally takes (for the sake of the argument)
one argument, then f would call the function with no arguments (which may
return a curried function, or may apply default arguments, or perhaps
raise an exception). So how would you
16.03.12 23:02, Chris Rebert написав(ла):
On Fri, Mar 16, 2012 at 1:57 PM, Serhiy Storchaka wrote:
lambda:f
Doesn't help; wouldn't the lambda be implicitly called?
No, the lambda is only for declaration. I prefer to use braces for
lambda syntax, it will be fine with '
28.03.12 21:13, Heiko Wundram написав(ла):
Reading from stdin/a file gets you bytes, and
not a string, because Python cannot automagically guess what format the
input is in.
In Python3 reading from stdin gets you string. Use sys.stdin.buffer.raw
for access to byte stream. And reading from file
06.04.12 08:28, rusi написав(ла):
All this mess would vanish if the string-literal-starter and ender
were different.
[You dont need to escape a open-paren in a lisp sexp]
But you need to escape an escape symbol.
--
http://mail.python.org/mailman/listinfo/python-list
06.04.12 16:22, rusi написав(ла):
Yes. I hand it to you that I missed the case of explicitly unbalanced
strings.
But are not such cases rare?
No, unfortunately. }:-(
For example code such as:
print '"'
print str(something)
print '"'
could better be written as
print '"%s"' % str(something)
16.04.12 00:07, Kiuhnm написав(ла):
path = path.replace('\\', '')
If you think that it is too complicated:
path = re.sub('', '', path)
--
http://mail.python.org/mailman/listinfo/python-list
This was the original intention, i.e. 'format' preferred over '%' but
even the core developers have backtracked on this issue. If I could
remember the thread it was on I'd give you a reference, but I haven't
the faintest idea as to which mailing list it was on. I'm certain that
other subscribers w
[] is []
False
id([]) == id([])
True
>>> id([1]) == id([2])
True
;)
--
http://mail.python.org/mailman/listinfo/python-list
29.04.12 19:05, Peter Pearson написав(ла):
Hey, guys, am I the only one here who can't even guess what
this code does? When did Python become so obscure?
This isn't Python at all. It's Ruby.
--
http://mail.python.org/mailman/listinfo/python-list
On 15.05.12 09:29, Ian Kelly wrote:
In Python 3 you can pass the argument newline='\r\n' to the open
function when you open the file. I don't know of anything comparable
in Python 2.
io.open supports "newline" argument.
--
http://mail.python.org/mailman/listinfo/python-list
On 30.05.12 14:54, Thomas Rachel wrote:
There is a 3rd one: use r'[ ' + '\u3000' + ']'. Not very nice to read,
but should do the trick...
Or r'[ %s]' % ('\u3000',).
--
http://mail.python.org/mailman/listinfo/python-list
On 16.06.12 20:36, jmfauth wrote:
u'a'
'a'
ur'a'
'a'
Please, never use u'' in new Python 3 code. This is only for
compatibility with Python 2. And Python 2 does not support ru''.
--
http://mail.python.org/mailman/listinfo/python-list
08.09.17 20:34, Stephen Michell пише:
I chair ISO/IEC/JTC1/SC22/WG23 Programming Language Vulnerabilities. We publish
an international technical report, ISO IEC TR 24772 Guide to avoiding
programming language vulnerabilities through language selection use. Annex D in
this document addresses vu
16.09.17 00:45, Terry Reedy пише:
On 9/15/2017 3:36 PM, Tim Chase wrote:
Looking through docs, I was unable to tease out whether there's a
prescribed behavior for the results of defining a dictionary with the
same keys multiple times
d = {
"a": 0,
"a": 1,
"a": 2,
}
30.10.17 12:10, Kirill Balunov пише:
Sometime ago I asked this question at SO [1], and among the responses
received was paragraph:
- `zip` re-uses the returned `tuple` if it has a reference count of 1 when
the `__next__` call is made.
- `map` build a new `tuple` that is passed to the mapped
02.11.17 12:10, Steve D'Aprano пише:
Occasionally it is useful to loop over a bunch of stuff in the interactive
interpreter, printing them as you go on a single line:
for x in something():
print(x, end='')
If you do that, the prompt overwrites your output, and you get a mess:
py> for x i
26.11.17 01:59, Terry Reedy пише:
On 11/25/2017 5:12 PM, Chris Angelico wrote:
On Sun, Nov 26, 2017 at 9:05 AM, 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,
26.11.17 21:46, wojtek.m...@gmail.com пише:
On Sunday, November 26, 2017 at 1:00:19 AM UTC+1, Terry Reedy wrote:
You must be trying to compile 2.7. There may be Linux distributions
that compile this way.
You're right, I need 2.7. Any hint which distro has got these settings?
UCS-2 is used b
07.01.18 22:33, Chris Angelico пише:
On Mon, Jan 8, 2018 at 7:13 AM, Thomas Jollans wrote:
On 07/01/18 20:55, Chris Angelico wrote:
Under what circumstances would you want "x != y" to be different from
"not (x == y)" ?
In numpy, __eq__ and __ne__ do not, in general, return bools.
a = np.ar
11.01.18 13:03, Steven D'Aprano пише:
I'd like to draw something with turtle, then generate a SVG file from it.
Is this possible?
If not, is there something I can do which lets me plot lines, shapes and
curves and output to SVG?
You can translate the following Tcl/Tk recipe to Python/Tkinter:
20.01.18 10:32, Steven D'Aprano пише:
I want an error handler that falls back on Latin-1 for anything which
cannot be decoded. Is this the right way to write it?
def latin1_fallback(exception):
assert isinstance(exception, UnicodeError)
start, end = exception.start, exception.end
05.02.18 10:14, Ian Kelly пише:
On Mon, Feb 5, 2018 at 12:35 AM, Frank Millman wrote:
So I have 2 questions -
1. Is there any particular reason why '|' is not supported?
'|' is the set union operation, roughly equivalent to the set.union
method. Dicts don't have a union operation. If they di
05.02.18 02:35, Larry Hastings пише:
On behalf of the Python development community, I'm happy to announce the
availability of Python 3.4.8 and Python 3.5.5.
Both Python 3.4 and 3.5 are in "security fixes only" mode. Both
versions only accept security fixes, not conventional bug fixes, and
bo
22.02.18 14:29, Chris Angelico пише:
Not overly misleading; the point of it is to show how trivially easy
it is to memoize a function in Python. For a fair comparison, I'd like
to see the equivalent Julia code: the function, unchanged, with
something around the outside of it to manage caching and
01.03.18 04:46, Rick Johnson пише:
On Wednesday, February 28, 2018 at 5:02:17 PM UTC-6, Chris Angelico wrote:
Here's one example: reference cycles. When do they get detected?
Taking a really simple situation:
class Foo:
def __init__(self):
self.self = self
*shudders*
Can you p
02.03.18 02:49, Rick Johnson пише:
This is true, but it does not answer the challenge directly
because function CRs are a consequence of Python _internals_
*NOT* consequences of a custom class written by a programmer
which references itself _explicitly_.
This doesn't matter. You question was "C
03.03.21 01:24, Chris Angelico пише:
> On Wed, Mar 3, 2021 at 10:22 AM Mirko via Python-list
> wrote:
>>
>> Am 02.03.2021 um 23:09 schrieb Stestagg:
>>> Ignoring the question about this feature being particularly useful, it
>>
>> It is useful because "assert" is primarily (if not purely and
>> exc
01.03.21 23:59, Cameron Simpson пише:
> On 28Feb2021 23:47, Alan Gauld wrote:
>> On 28/02/2021 00:17, Cameron Simpson wrote:
>>> BUT... It also has a __iter__ value, which like any Box iterates over
>>> the subboxes. For MDAT that is implemented like this:
>>>
>>> def __iter__(self):
>>>
11.03.21 20:31, Chris Angelico пише:
>> assert(expensive_computation())
>
> Do you have any asserts like that, or is that a purely theoretical
> complaint? I have never once seen anything that costly - usually it'll
> be something like checking a length (and this isn't C's strlen, since
> Python c
12.04.21 19:01, Andreas R Maier пише:
> Hi,
> I have written some classes that represent immutable views on collections
> (see "immutable-views" package on Pypi).
>
> Currently, these view classes inherit from the abstract collection classes
> such as Mapping, Sequence, Set. However, they implem
13.04.21 15:47, Peter Otten пише:
> As to the | operator, maybe it could be added to Mapping?
The | operator returns a new instance, but constructor is not a part of
the Mapping interface. You cannot make a general implementation, and
making __or__ an abstract method will break all existing Mappin
23.07.21 11:20, Bartosz Golaszewski пише:
> I'm working on a Python C extension and I would like to expose a
> custom enum (as in: a class inheriting from enum.Enum) that would be
> entirely defined in C.
I think that it would be much easier to define it in Python, and then
either import a Python
03.08.21 13:03, Bartosz Golaszewski пише:
> Just a follow-up: this is how I did it eventually:
I think it can be simpler.
1. No need to create the __main__ module. You can just create a dict. If
some attributes are required (e.g. __name__) it is easy to set them in
the Python code (__name__ = 'py
18.09.21 03:54, MRAB пише:
> static PyMethodDef customdict_methods[] = {
> ...
> {"__class_getitem__", (PyCFunction)Py_GenericAlias, METH_CLASS |
> METH_O | METH_COEXIST, PyDoc_STR("See PEP 585")},
> ...
> };
>
>
> Note the flags: METH_CLASS says that it's a class method and
> METH_COEXIST sa
18.09.21 09:40, Marco Sulla пише:
> Ooook. I have a question. Why is this code not present in
> dictobject.c? Where are the dict annotations implemented?
In dictobject.c.
--
https://mail.python.org/mailman/listinfo/python-list
19.09.21 05:59, MRAB пише:
> On 2021-09-18 16:09, Serhiy Storchaka wrote:
>> "(PyCFunction)" is redundant, Py_GenericAlias already has the right
>> type. Overuse of casting to PyCFunction can hide actual bugs.
>>
> I borrowed that from listobject.c, which
1 - 100 of 274 matches
Mail list logo