There's a whole matrix of these and I'm wondering why the matrix is
currently sparse rather than implementing them all. Or rather, why we
can't stack them as:
class foo(object):
@classmethod
@property
def bar(cls, ...):
...
Essentially the permutation are, I think:
{'unadorned'|abc.abstract}{'normal'|static|class}{method|property|non-callable
attribute}.
concreteness
implicit first arg
type
name
comments
{unadorned}
{unadorned}
method
def foo():
exists now
{unadorned} {unadorned} property
@property
exists now
{unadorned} {unadorned} non-callable attribute
x = 2
exists now
{unadorned} static
method @staticmethod
exists now
{unadorned} static property @staticproperty
proposing
{unadorned} static non-callable attribute {degenerate case -
variables don't have arguments}
unnecessary
{unadorned} class
method @classmethod
exists now
{unadorned} class property @classproperty or @classmethod;@property
proposing
{unadorned} class non-callable attribute {degenerate case - variables
don't have arguments}
unnecessary
abc.abstract {unadorned} method @abc.abstractmethod
exists now
abc.abstract {unadorned} property @abc.abstractproperty
exists now
abc.abstract {unadorned} non-callable attribute
@abc.abstractattribute or @abc.abstract;@attribute
proposing
abc.abstract static method @abc.abstractstaticmethod
exists now
abc.abstract static property @abc.staticproperty
proposing
abc.abstract static non-callable attribute {degenerate case -
variables don't have arguments} unnecessary
abc.abstract class method @abc.abstractclassmethod
exists now
abc.abstract class property @abc.abstractclassproperty
proposing
abc.abstract class non-callable attribute {degenerate case -
variables don't have arguments} unnecessary
I think the meanings of the new ones are pretty straightforward, but in
case they are not...
@staticproperty - like @property only without an implicit first
argument. Allows the property to be called directly from the class
without requiring a throw-away instance.
@classproperty - like @property, only the implicit first argument to the
method is the class. Allows the property to be called directly from the
class without requiring a throw-away instance.
@abc.abstractattribute - a simple, non-callable variable that must be
overridden in subclasses
@abc.abstractstaticproperty - like @abc.abstractproperty only for
@staticproperty
@abc.abstractclassproperty - like @abc.abstractproperty only for
@classproperty
--rich
At the moment, the array module of the standard library allows to
create arrays of different numeric types and to initialize them from
an iterable (eg, another array).
What's missing is the possiblity to specify the final size of the
array (number of items), especially for large arrays.
I'm thinking of suffix arrays (a text indexing data structure) for
large texts, eg the human genome and its reverse complement (about 6
billion characters from the alphabet ACGT).
The suffix array is a long int array of the same size (8 bytes per
number, so it occupies about 48 GB memory).
At the moment I am extending an array in chunks of several million
items at a time at a time, which is slow and not elegant.
The function below also initializes each item in the array to a given
value (0 by default).
Is there a reason why there the array.array constructor does not allow
to simply specify the number of items that should be allocated? (I do
not really care about the contents.)
Would this be a worthwhile addition to / modification of the array module?
My suggestions is to modify array generation in such a way that you
could pass an iterator (as now) as second argument, but if you pass a
single integer value, it should be treated as the number of items to
allocate.
Here is my current workaround (which is slow):
def filled_array(typecode, n, value=0, bsize=(1<<22)):
"""returns a new array with given typecode
(eg, "l" for long int, as in the array module)
with n entries, initialized to the given value (default 0)
"""
a = array.array(typecode, [value]*bsize)
x = array.array(typecode)
r = n
while r >= bsize:
x.extend(a)
r -= bsize
x.extend([value]*r)
return x
Dear all,
I guess this is so obvious that someone must have suggested it before:
in list comprehensions you can currently exclude items based on the if
conditional, e.g.:
[n for n in range(1,1000) if n % 4 == 0]
Why not extend this filtering by allowing a while statement in addition to
if, as in:
[n for n in range(1,1000) while n < 400]
Trivial effect, I agree, in this example since you could achieve the same by
using range(1,400), but I hope you get the point.
This intuitively understandable extension would provide a big speed-up for
sorted lists where processing all the input is unnecessary.
Consider this:
some_names=["Adam", "Andrew", "Arthur", "Bob", "Caroline","Lancelot"] #
a sorted list of names
[n for n in some_names if n.startswith("A")]
# certainly gives a list of all names starting with A, but .
[n for n in some_names while n.startswith("A")]
# would have saved two comparisons
Best,
Wolfgang
While I was implementing JSON-JWS (JSON web signatures), a format
which in Python 3 has to go from bytes > unicode > bytes > unicode
several times in its construction, I notice I wrote a lot of bugs:
"sha256=b'abcdef1234'"
When I meant to say:
"sha256=abcdef1234"
Everything worked perfectly on Python 3 because the verifying code
also generated the sha256=b'abcdef1234' as a comparison. I would have
never noticed at all unless I had tried to verify the Python 3 output
with Python 2.
I know I'm a bad person for not having unit tests capable enough to
catch this bug, a bug I wrote repeatedly in each layer of the bytes >
unicode > bytes > unicode dance, and that there is no excuse for being
confused at any time about the type of a variable, but I'm not willing
to reform.
Instead, I would like a new string formatting operator tentatively
called 'notbytes': "sha256=%notbytes" % (b'abcdef1234'). It gives the
same error as 'sha256='+b'abc1234' would: TypeError: Can't convert
'bytes' object to str implictly
This is similar to another proposal:
http://mail.python.org/pipermail/python-3000/2008-January/011798.html
Anyway, I was using ast.literal_eval and attempted to use frozenset({...})
as a key in a dictionary, which failed, because frozenset isn't a literal
(though putting frozenset in the environment would be a security risk). I
am currently working around this with tuples, but I'd like a literal for
representing frozensets as well. I also use frozensets elsewhere in the
code in ways similar to Raymond's original suggestion.
Perhaps something like f{...} for declaring frozenset( comprehension)?
literals?
I thought this may be of interest to some people on this list, even if not
strictly an "idea".
I'm working on MacroPy <https://github.com/lihaoyi/macropy>, a little
pure-python library that allows user-defined AST rewrites as part of the
import process (using PEP 302). In short, it makes mucking around with
Python's semantics so easy as to be almost trivial: you write a function
that takes an AST and returns an AST, register it as a macro, and you're
off to the races. To give a sense of it, I just finished implementing
Scala/Groovy style anonymous lambdas:
map(f%(_ + 1), [1, 2, 3])#[2, 3, 4]
reduce(f%(_ + _), [1, 2, 3])#6
...which took about half an hour and 30 lines of code, start to finish.
We're currently working on implementing destructuring-pattern-matching on
objects (i.e. like in Haskell/Scala) and a clone of .NET's LINQ to SQL.
It's still very much a work in progress, but we have a list of pretty cool
macros already done, which shows off what you can do with it. If anyone
else was thinking about messing around with the semantics of the Python
language but was too scared to jump into the CPython internals, this offers
a somewhat easier path.
Hope this was interesting to somebody!
-Haoyi
Hi all,
A while ago, I've developed this library, send2trash (
https://bitbucket.org/hsoft/send2trash ), which can send files to trash
on Mac OS X, Windows, and any platform that conforms to FreeDesktop.
The current version uses ctypes, but earlier versions were straight C
modules.
I was wondering if you think this has a place in the stdlib, maybe as
"shutil.trash()"?
Virgil Dupras
I find it really hard to track proposals, ideas and various deviations in
mailing lists, which is especially actual for lists such as python-ideas. I
bet other people experience this problem too. The typical scenario:
1. You make a proposal
2. The discussion continues
3. Part of the discussion is hijacked
4. Another part brings the problem you haven't seen
5. You don't have time to investigate the problem
6. Discussion continues
7. Thread quickly gets out of scope of daily emails
8. Contact lost
Several week later you remember about the proposal:
9. You open the original proposal to notice a small novel
10. You start to reread
11. Got confused
13. Recall the details
14, Find a way out from irrelevant deviation
15. Encounter the problem
16. Spend what is left to investigate the problem
17. Run out of time
The major problem I have is steps 9-15. Sometimes these take the most of
the time. What would help to make all the collaboration here more
productive are colored view/filters (summaries) for discussions. It would
work like so:
00. The discussion is laid out as a single page
01. You define some aspect of discussion (name the filter)
02. You mark text related to the aspect
03. You save the markings.
04. You insert summaries and TODOs
05. Now you select the aspect
06. Irrelevant parts are grayed out
07. Additionally you can collapse grayed sections
An ability to edit and enhance these filters will allow to devote a small
bits of free time to analyze and summarize the discussion state instead of
requiring a single big piece to reread the whole discussion.
This way you can split the task of dealing with complexity over time, which
I think is more than actual nowadays. IMO this process can be very
beneficial for Python development.
--
anatoly t.
Biggest Fake Conference in Computer Science
We are researchers from different parts of the world and conducted a study on the world’s biggest
bogus computer science conference WORLDCOMP http://sites.google.com/site/worlddump1
organized by Prof. Hamid Arabnia from University of Georgia, USA.
We submitted a fake paper to WORLDCOMP 2011 and again (the same paper with a modified title) to
WORLDCOMP 2012. This paper had numerous fundamental mistakes. Sample statements from that
paper include:
(1). Binary logic is fuzzy logic and vice versa
(2). Pascal developed fuzzy logic
(3). Object oriented languages do not exhibit any polymorphism or inheritance
(4). TCP and IP are synonyms and are part of OSI model
(5). Distributed systems deal with only one computer
(6). Laptop is an example for a super computer
(7). Operating system is an example for computer hardware
Also, our paper did not express any conceptual meaning. However, it was accepted both the times
without any modifications (and without any reviews) and we were invited to submit the final paper
and a payment of $500+ fee to present the paper. We decided to use the fee for better purposes than
making Prof. Hamid Arabnia richer. After that, we received few reminders from WORLDCOMP to pay
the fee but we never responded. This fake paper is different from the two fake papers already published
(see https://sites.google.com/site/worlddump4 for details) in WORLDCOMP.
We MUST say that you should look at the above website if you have any thoughts of participating in
WORLDCOMP. DBLP and other indexing agencies have stopped indexing WORLDCOMP’s proceedings
since 2011 due to its fakeness. See http://www.informatik.uni-trier.de/~ley/db/conf/icai/index.html for
of one of the conferences of WORLDCOMP and notice that there is no listing after 2010. See Section 2 of
http://sites.google.com/site/dumpconf for comments from well-known researchers about
WORLDCOMP.
The status of your WORLDCOMP papers can be changed from scientific to other (i.e., junk or
non-technical) at any time. Better not to have a paper than having it in WORLDCOMP and spoil the
resume and peace of mind forever!
Our study revealed that WORLDCOMP is money making business, using University of Georgia mask, for
Prof. Hamid Arabnia. He is throwing out a small chunk of that money (around 20 dollars per paper
published in WORLDCOMP’s proceedings) to his puppet (Mr. Ashu Solo or A.M.G. Solo) who publicizes
WORLDCOMP and also defends it at various forums, using fake/anonymous names. The puppet uses
fake names and defames other conferences to divert traffic to WORLDCOMP. He also makes anonymous
phone calls and threatens the critiques of WORLDCOMP (See Item 7 of Section 5 of above website). That
is, the puppet does all his best to get a maximum number of papers published at WORLDCOMP to get
more money into his (and Prof. Hamid Arabnia’s) pockets. Prof. Hamid Arabnia makes a lot of tricks. For
example, he appeared in a newspaper to fool the public, claiming him a victim of cyber-attack (see Item
8 in Section 5 of above website).
Monte Carlo Resort (the venue of WORLDCOMP for more than 10 years, until 2012) has refused to
provide the venue for WORLDCOMP’13 because of the fears of their image being tarnished due to
WORLDCOMP’s fraudulent activities. That is why WORLDCOMP’13 is taking place at a different resort.
WORLDCOMP will not be held after 2013.
The draft paper submission deadline is over but still there are no committee members, no reviewers,
and there is no conference Chairman. The only contact details available on WORLDCOMP’s website is
just an email address!
We ask Prof. Hamid Arabnia to publish all reviews for all the papers (after blocking identifiable details)
since 2000 conference. Reveal the names and affiliations of all the reviewers (for each year) and how
many papers each reviewer had reviewed on average. We also ask him to look at the Open Challenge
(Section 6) at https://sites.google.com/site/moneycomp1 and respond if he has any professional values.
Sorry for posting to multiple lists. Spreading the word is the only way to stop this bogus conference.
Please forward this message to other mailing lists and people.
We are shocked with Prof. Hamid Arabnia and his puppet’s activities at
http://worldcomp-fake-bogus.blogspot.com Search Google using the keyword worldcomp fake for
additional links.
Consider the following:
assert \
1 == 0, \
"error"
It will produce:
Traceback (most recent call last):
File "foo.py", line 3, in <module>
"error"
AssertionError: error
The information about the statement which produced the exception is lost.
Instead I would expect:
Traceback (most recent call last):
File "foo.py", line 1, in <module>
assert \
1 == 0, \
"error"
AssertionError: error
Not sure how easy this is to implement but I think it would be a good
enhancement.
Thoughts?
--- Giampaolo
https://code.google.com/p/pyftpdlib/https://code.google.com/p/psutil/https://code.google.com/p/pysendfile/