right."
This is the 'other' type of 'multiple assignment'
a,b,c = 1,2,3
Order matters here too.
a,a[1] = [1,2],3
a
# [1,3]
# but
a[1], a = 3, [1,2]
will either fail or modify what a was previously bound to before
rebinding a to [1,2].
--
Terry Jan Reedy
--
http://ma
sions, can be passed to
functions as an argument, and can have options passed as arguments
instead of with terrible syntax hacks.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
ks in Py2 also) or without further change after 2to3. Then
encourage author to advertise fact and add Py3 classifier if listed in PyPI.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
t finished? Has the
bluetooth spec changed since then?
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
e the
tutorial says this somewhere too. Read both, along with the first 5
chanpter of the Library reference.
If you want code executed when you call the function, put it in the body
that is executed when you call the function
def f(lst = None):
if lst is None:
lst = []
...
--
Terr
On 7/2/2011 12:52 PM, Dan Stromberg wrote:
Is there a decent way of running "from import *"? Perhaps
using __import__?
Does it mean using the copy module or adding an element to globals()
somehow?
Yes, I think I do have a good use for this: importing either pure python
or cython versions of
No other objects have code objects. No other objects in
Python have this special optimization.
A .pyc file is a serialized code object for a module.
As for the rest, I am not sure what you are asking.
Terry Reedy
--
http://mail.python.org/mailman/listinfo/python-list
On 7/9/2011 6:34 PM, Steven D'Aprano wrote:
Suppose instead an implementation of Python did not pre-compile the
function. Each time you called spam(n), the implementatio n would have to
locate the source code and interpret it on the spot. Would that be
allowed?"
If that's your question, then I
those with individual names. Just use def statements.
Terry J. Reedy
--
http://mail.python.org/mailman/listinfo/python-list
s, it does not have paid people sitting around writing things to
pad numbers to justify a $2k price tag. On the other hand, lots of
people have added and made available lots of good add-ons. Mathematica
should probably be most fairly compared with Python+numpy+scipy and
maybe a few other things.
f up are quite sensible and not dumb
idiots for preferring 'f(x)' to the '(f x)' of Lisp. In a function call,
the function has a different role than the arguments, so it is
appropriate that it have a different role in the expression.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
e StopIteration
def tail(filename):
with open(filename, 'rb') as f:
while True:
yield f.readline()
When the caller gets '', it should go and do something else for awhile.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
On 7/12/2011 2:23 PM, gene heskett wrote:
Now, I hate to mention it Terry, but your clock seems to be about 126
months behind the rest of the world.
Please do not hate to be helpful. It was a bad malfunction perhaps due
to a run-down battery on a machine turned off for two weeks. I will keep
On 7/13/2011 4:29 AM, Teemu Likonen wrote:
* 2001-01-01T14:11:11-05:00 * Terry Reedy wrote:
As a side note, the same principle of expressions matching operations
in symmetry suggest that majority of up are quite sensible and not
dumb idiots for preferring 'f(x)' to the '(f x)
ider
def myfunc(a,
b,
c):
return a+b+c
All indentation was done automatically by IDLE's editor.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
t e.g.
Is there any good example to illustrate the concept?
What is the most important features you think I should cover?
Functions are first-class objects, like everything else.
Use of closures to create functions to be returned.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
On 7/13/2011 10:19 AM, Anthony Kong wrote:
One of the main difference is that pypy supports only R-Python, which
stands for 'Restricted Python".
Not true. PyPy is *written* in rpython. It runs standard Python.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
are CPython users.
http://sourceforge.net/mail/?group_id=12867
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
uble the backslash in that one particular spot, the
string will parse, even if it is not correct.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
with readline, so it is possible.
If above does not work, try (untested):
def getlines(f):
lines = []
while True:
l = f.readline()
if l: lines.append(l)
else: return lines
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
uilt-in types' section (which could now be called the
built-isssn classes section.
A more exact title would be 'built-in callables', but that would be even
less helpful to newcomers. Callables are functions in the generic sense.
In any case, the new index makes it easy to s
on a per column basis.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
r the file. If I call .readline() myself, I forfeit that performance
gain.
Are you sure? Have you measured the difference?
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
re is no more data for now.
a None or other sentinel value would do this as well (as ChrisA already
said).
A sentinel does provide a work around, but it also passes the problem
onto the caller rather than the callee:
No more so than a new exception that the caller has to recognize.
--
Terr
functool.partial is essential a generic version of makeadder in that it
also abstract the function/operator. It is useful when one has a
function but perhaps not the source. It's limitation is that args are
frozen left to right while the above example freezes the right operand.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
rtial Function Application -- just a few
minutes ago.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
root = Tk()
root.title ("Color Option")
app = App(root)
root.mainloop()
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
few links that are missing from C.2 to C.5.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
S\system32\USER32.dll
POWRPROF.dll - C:\WINDOWS\system32\POWRPROF.dll
SHELL32.dll - C:\WINDOWS\system32\SHELL32.dll
ole32.dll - C:\WINDOWS\system32\ole32.dll
SHLWAPI.DLL - C:\WINDOWS\system32\SHLWAPI.DLL
COMDLG32.DLL - C:\WINDOWS\system32\COMDLG32.DLL
ADVAPI32.DLL - C:\WINDOWS\system32\ADVAPI32.DLL
msvcrt.dll - C:\WINDOWS\system32\msvcrt.dll
WS2_32.dll - C:\WINDOWS\system32\WS2_32.dll
WINSPOOL.DRV - C:\WINDOWS\system32\WINSPOOL.DRV
GDI32.dll - C:\WINDOWS\system32\GDI32.dll
DNSAPI.DLL - C:\WINDOWS\system32\DNSAPI.DLL
VERSION.dll - C:\WINDOWS\system32\VERSION.dll
KERNEL32.dll - C:\WINDOWS\system32\KERNEL32.dll
IMM32.DLL - C:\WINDOWS\system32\IMM32.DLL
COMCTL32.DLL - C:\WINDOWS\system32\COMCTL32.DLL
MSIMG32.DLL - C:\WINDOWS\system32\MSIMG32.DLL
MPR.dll - C:\WINDOWS\system32\MPR.dll
gdiplus.dll - C:\WINDOWS\system32\gdiplus.dll
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
On 7/19/2011 6:07 AM, Dave Angel wrote:
On 01/-10/-28163 02:59 PM, Thomas 'PointedEars' Lahn wrote:
Dave Angel wrote:
On 01/-10/-28163 02:59 PM, Terry Reedy wrote:
def makeadder(y)
def _add(x): return x+y
add2 = makeadder(2)
A couple of typos in that code:
def makeaddr(y):
nd have getToken use peekToken and then reset.
But that depends on the exact logic which depends on the specs. I would
more likely have just one function with a reset parameter defaulted to
the more common value.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
Inputs may cause a switch to another state and an
output. Another everyday example: a house door can be open, closed,
locked, dead-bolted, or both, and maybe barred. There are input actions
but no outputs, unless the door is hooked to an alarm system, which is
another finite-state system.
--
which means they should
declare
# encoding: utf-8
That is the default in Py3. Not sure of OP specified what he used.
or something else fitting, and use
os.path.isdir(u"C:/Users/조창준/Desktop/logs/2011-07-03")
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
you should be
able to resume pause time. Again, without a design spec, it is hard to
know what you intended.
Start, Pause, Reset (no obvious effect), Start has same effect.
The variables at __init__
self._pausestart = 0.0
self._elapsedpause = 0.0
and the method _updatepause are a attemp
of fences
('(', False), # or exact error output wanted
(')', False), # and so on
The above could be generated programatically from the set of pairs that
should be the input to the program, so that the pairs are not hardcoded
into the logic.
'([)]', ???),
...
)
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
self.tok = next(self.gen)
then this code (and OP's version) should run as is on both Py2.6/7 and Py3.
except StopIteration:
self.tok = NULL
return self.tok
def pop(self):
token = self.peek()
self.tok = None
return token
--
Terry Jan Reedy
--
and re-compute loop.
I have not specifically looked at your code.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
on. I think the pyjamas project is aimed in this
direction, but the author says he will never port to Py3. (He explained
his reasons on this list when I suggested that.)
---
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
On 7/20/2011 2:21 AM, Stefan Behnel wrote:
Terry Reedy, 19.07.2011 18:31:
Chapter 5 is mostly about the behavior of built-in class instances. For
some classes, like range, instances only come from class calls and the
behavior of instances is intimately tied to the constructor arguments.
Having
If the domain is int literals followed by '.' and some number of zeroes,
then split works. So does int(float(s)). Split also works for non-digits
following '.' whereas int(float(s)) does not.
If the domain is all float literals, then ??.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
mal' class for everything else. This could be
replaced in Python with a dict 'special' that only maps special
characters to their token class and used as "special.get(char, NORMAL)"
so that the thousands of normal characters are mapped by default to
NORMAL without a humongous ar
y are intended, the rationale is that lining up does
not work with proportional fonts. However, I have IDLE using fixed-space
font and I line things up how I want. PEP 8 only applies to new stdlib
code. For anything else, it is advisory on a point by point basis.
--
Terry Jan Reedy
--
py" (could
even be a package!) which exports both the zip and tar file classes.
However, unlike the current situation this archive module will be
consistent with it's API.
from archive import ZipFile, TarFile
zf = ZipFile(path, *args)
tf = TarFile(path, *args)
Not a bad idea. P
On 7/22/2011 2:40 AM, rantingrick wrote:
On Jul 22, 12:45 am, Terry Reedy wrote:
Let me give some overall comments rather than respond point by point.
Python-dev is a volunteer *human* community, not a faceless corporation,
with an ever-changing composition (a very mutable set;-).
It is
different
people at different times and hence the different apis. I do not know
the details of either well enough to know how consistent they could be.
You are right that discussing can be a distraction from coding;-).
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
er than 18 digits' after 'int
literals' to your spec.
I was just asking if there were any alternatives.
>>> int(s.split('.')[0])
123456789012345678901
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
On 7/22/2011 5:17 PM, Ned Deily wrote:
In article,
Terry Reedy wrote:
This introduced the problem that upgrading to Python 3 is no longer a
single thing. We really need 2to3.1 (the current 2to3), 2to3.2, 2to3.3,
etc, but someone would have to make the new versions, but no one,
currently, has
h the inevitable frustration of
doing (some) things a much harder way.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
in os.listdir(dir)
before joining them to the rootdir and re-encoding.
This sort of thing sometimes works better with Python 3.
Does someone knows how to fix this?
Thank you!
João Victor Sousa Jácome
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
On 7/24/2011 3:43 AM, Laszlo Nagy wrote:
Can it be a problem on my side? I have tried from several different
computers. I cannot even ping it.
python.org, bugs.python.org, docs.python.org, pypi.python.org
all work for me now.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo
te
people, especially if they have threads collapsed.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
s this one area where windows really wins?
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
ther than the entire field after
the fact, is it possible to set an onkey handler, that will pass on
valid keys?
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
it zeallous.
The stdlib test code has become zealous on this and other issues as it
is intended to be usable by all conforming implementations. We need more
zealous people like you to help with tests (and other code) ;-).
So I would stick with your style.
--
Terry Jan Reedy
--
http://mail.pyth
one open, which
succeeds.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
he id of mutables may be critical. Lists of lists is a
particular area where id() is really useful.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
layouts are different.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
e-reading. What you need
are investigative skills, and not just bits of data.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
On 7/28/2011 5:03 PM, Ethan Furman wrote:
I'm glad you asked! I'm using dictionaries to describe fields and
what their return values should be. There happen to be two special
cases: empty and Null. So a portion of the dictionary looks like:
fielddef = { 'empty':some_func, 'null':some_func }
De
On 7/29/2011 1:22 PM, rantingrick wrote:
* Introduce a new method named "partition" which (along with string
splitting methods) will replace the six methods "basename", "dirname",
"split", "splitdrive", "splitunc", "splittext". The method will return
a tuple of the path split into four parts:
ption is raised by default.
.__new__ methods returning the singleton have been added.
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
But having said that, I'm currently writing a library where nearly all the
functions violate the No Constant Argument rule. (The API isn't yet stable,
so I may still change my mind.) Make of that what you will.
See * above ;-).
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
re several packages for adding a graphical user interface to a
program. WxPython is one of those. It is the Python wrapper for the
wxwidgets library. It is not a 'python' in itself.
Terry
--
http://mail.python.org/mailman/listinfo/python-list
On 7/30/2011 12:39 PM, bruno.desthuilli...@gmail.com wrote:
On 28 juil, 17:39, Ethan Furman wrote:
--> bool(0) is bool(0)
True
This test is not reliable
It is in the sense that it will always work -- because False/True are
doubletone constants and so documented.
But expr is expr == Tr
code to native language (or C).
The idea of 'early binding' comes up periodically but I do not remember
many concrete proposals.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
ke so
cmdline = process.stdout.readline
and then, without repeating the attribute lookups, repeatedly call
cmdline()
.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
There has been some discussion about what to do with 'linux3'.
See http://bugs.python.org/issue12326 for example.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
within the code.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
oked up on
its class (and superclasses). Since all classes are subclasses of object
and that has a docstring, I guess everything will.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
th getting that to
work right on Windows (see issue 12540), but it works well when it does.
Depending on your use case, this might work for you too. Communication
is through (wrapped) OS pipes, not normal Python file objects.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
#x27;attribute'
Which is to say, the descriptor protocol allows custom get, set, and
delete methods, but not an attribute-specific getattribute method ;-).
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
On 8/8/2011 12:26 PM, Chris Angelico wrote:
As a side point: Does anyone else feel that it's potentially confusing
to have a function whose parameter has the same name as the function
itself? This is straight from the example.
Yes. I might change it someday when I can.
--
Terry Jan
ython version used
and copy *entire* traceback
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
bug. If this happens with current Python, 2.7.2 or 3.2.1, posting to the
bug tracker a minimal example needed to get the above might result in a fix.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
o idea how stable and local pickles are, but I know they were
not designed for diff-ing. Json or yaml representations might do better
if applicable.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
(or __dict__.items())
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
numpy/scipy questions are best asked on the numpy/scipy user lists.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
On 8/9/2011 8:29 PM, Tim Chase wrote:
On 08/09/2011 07:11 PM, Terry Reedy wrote:
On 8/9/2011 5:43 PM, Gelonida N wrote:
Now I wondered whether there is any way to implement a class such, that
I can write
for val in MyClass:
print val
And what are the items in a class that you expect that to
7;stack of dicts' has nothing to do
with how function and nested funcs operate.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
vel.
for...
for ...
if ...
for ...
if ...
[50 more lines of code]
#end outer if
[more code]
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
dered contributing a HOW-TO?
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
will open a console window).
In particular, IDLE runs in a pythonw process and it executes user code
in a separate pythonw process and usually uses a socket for the connection.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
their concern, of course, but
depriving their customers is.
supported versions could be deprecated -- and eventually removed by the
ISPs, except for the few customers who choose to install it themselves.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
On 8/15/2011 12:28 AM, Seebs wrote:
To repeat again: you are free to put in explicit dedent markers that
will let you re-indent code should all indents be removed.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
ect to csv.
codecs.open(filename, mode[, encoding[, errors[, buffering]]])
<http://docs.python.org/library/codecs.html#codec-objects>
In Python 3, just open with open(... encoding = 'xxx')
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
def body(self, r):
''; self.heading; ''
''
for itm in self.items:
''; itm; ''
''
The idea is simply to use python ASTs to transform this code so that it
accumulates the values of the bare expressions.
Interesting idea, though I have no experience for comparison.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
just want to look for a user and if it doesn't exist,
an action is taken (create user).
Replace if/then with try/except control flow
try:
pwd.getpwnam(user)
return True
except KeyWordError:
return False
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
lass/instance
attributes can also reuse builtin names. But 'open = ' would
be bad.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
en if suppressed.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
On 8/16/2011 7:49 PM, Seebs wrote:
On 2011-08-16, Terry Reedy wrote:
On 8/16/2011 2:56 PM, Seebs wrote:
I wonder whether there's a way to mitigate the cost of these things by
messing with -W settings, such that runtime that wants to be fast can
omit the checks, but the default could sti
On 8/16/2011 8:18 PM, Philip Semanchuk wrote:
Hi Terry,
To generalize from your example, are you saying that there's a mild admonition
> against shadowing builtins with unrelated variable names in standard
lib code?
I would expect that there might be. I would have to check PEP8.
H
this rare case.
--but changing either behavior would be a
very bad idea. This proposed syntax would be the Right Way to get
separate objects.)
It would be very Wrong as it already has a very different meaning.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
leads to the joke about people searching for the 'any' key
;-). The equivalent contrast for GUIs is "Click OK to continue" versus
"Click anywhere to continue" If having to click a specific area is okay
for GUIs, having to hit a specific key for TUIs should be also.
res a response to an email. Uptime is pretty good.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
7;computer', 'program' or 'language' in the response. 'snake'
fails the test.
Or 'Enter a Python keyword (search the tutorial if you do not know any)
'
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
hon distribution and available on SourceForge.
There is a windows module includes in the stdlib, but I do not know if
it has enough.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
, is bogus.
Or changed to getting their movies via NetFlix, for instance, as Comcast
*is* complaining about. I believe their real complaint is that they are
only paid to move bits, and not for originating them, even though they
already get several times as much per month as NetFlix.
--
Terry
witch-case
construct to execute it's opcodes and INPLACE_ADD cames after
BINARY_ADD, hence the difference in speed.
To be clear, this is nothing you should consider when writing fast code.
Complexity wise they both are the same.
With 64 bit 3.2.2 on my Win 7 Pentium, the difference was 4%
went down. Also it's in an
embedded box on a customer site. It's not in Antarctica or anything
like that, but it's a few towns over, and someone would have to drive
there (probably through heavy traffic) if something went wrong that
power cycling the box couldn't fix.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
/* fall through to PRINT_NEWLINE */
add jump to address of the code for PRINT_NEWLINE
1804
1805case PRINT_NEWLINE:
must be supported.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list
801 - 900 of 8120 matches
Mail list logo