Commit Graph

254 Commits

Author SHA1 Message Date
Guido van Rossum 1c917072ca Very subtle syntax change: in a list comprehension, the testlist in
"for <var> in <testlist> may no longer be a single test followed by
a comma.  This solves SF bug #431886.  Note that if the testlist
contains more than one test, a trailing comma is still allowed, for
maximum backward compatibility; but this example is not:

    [(x, y) for x in range(10), for y in range(10)]
                              ^

The fix involved creating a new nonterminal 'testlist_safe' whose
definition doesn't allow the trailing comma if there's only one test:

    testlist_safe: test [(',' test)+ [',']]
2001-10-15 15:44:05 +00:00
Guido van Rossum 4668b000a1 Implement PEP 238 in its (almost) full glory.
This introduces:

- A new operator // that means floor division (the kind of division
  where 1/2 is 0).

- The "future division" statement ("from __future__ import division)
  which changes the meaning of the / operator to implement "true
  division" (where 1/2 is 0.5).

- New overloadable operators __truediv__ and __floordiv__.

- New slots in the PyNumberMethods struct for true and floor division,
  new abstract APIs for them, new opcodes, and so on.

I emphasize that without the future division statement, the semantics
of / will remain unchanged until Python 3.0.

Not yet implemented are warnings (default off) when / is used with int
or long arguments.

This has been on display since 7/31 as SF patch #443474.

Flames to /dev/null.
2001-08-08 05:00:18 +00:00
Tim Peters 5ca576ed0a Merging the gen-branch into the main line, at Guido's direction. Yay!
Bugfix candidate in inspect.py:  it was referencing "self" outside of
a method.
2001-06-18 22:08:13 +00:00
Jeremy Hylton bb40dc4892 remove commented-out vestiges of access statement 2001-02-27 18:36:14 +00:00
Neil Schemenauer 693291ba23 Superseded by $(srcdir)/Makefile.pre.in. 2001-02-03 17:18:21 +00:00
Fred Drake 0cdfc92a19 Fix typo: config.stat --> config.status 2000-09-28 20:53:39 +00:00
Thomas Wouters 434d0828d8 Support for three-token characters (**=, >>=, <<=) which was written by
Michael Hudson, and support in general for the augmented assignment syntax.
The graminit.c patch is large!
2000-08-24 20:11:32 +00:00
Fred Drake abca14d8e2 Added note stating that the parser module will need updating for most
changes to this file.
2000-08-23 15:45:28 +00:00
Skip Montanaro 46dfa5f4ed require list comprehensions to start with a for clause 2000-08-22 02:43:07 +00:00
Barry Warsaw 0360663e8e PEP 214, Extended print Statement, has been accepted by the BDFL.
This change modifies Python's grammar to include the extended print
form.
2000-08-21 15:34:33 +00:00
Thomas Wouters 9b18adcd16 Ignore Grammar/Makefile now that it's a made Makefile. 2000-08-21 12:25:17 +00:00
Thomas Wouters 5215225ea1 Apply SF patch #101135, adding 'import module as m' and 'from module import
name as n'. By doing some twists and turns, "as" is not a reserved word.

There is a slight change in semantics for 'from module import name' (it will
now honour the 'global' keyword) but only in cases that are explicitly
undocumented.
2000-08-17 22:55:00 +00:00
Sjoerd Mullender 59bb0800df Fix up problems when compiling in a directory other than the source
directory.
2000-08-17 11:38:18 +00:00
Trent Mick 9f6e6c63ef add dummy 'add2lib' target to Grammar/Makefile so non-GNU makes don't bail out
This closes patch:
http://sourceforge.net/patch/index.php?func=detailpatch&patch_id=101176&group_id=5470
2000-08-16 19:02:06 +00:00
Skip Montanaro 803d6e5451 list comprehensions. see
http://sourceforge.net/patch/?func=detailpatch&patch_id=100654&group_id=5470

for details.
2000-08-12 18:09:51 +00:00
Skip Montanaro c9bac09083 added .cvsignore so cvs doesn't complain about the generated graminit.h and
graminit.c files.
2000-07-27 20:31:12 +00:00
Jeremy Hylton 7690151c7e slightly modified version of Greg Ewing's extended call syntax patch
executive summary:
Instead of typing 'apply(f, args, kwargs)' you can type 'f(*arg, **kwargs)'.
Some file-by-file details follow.

Grammar/Grammar:
    simplify varargslist, replacing '*' '*' with '**'
    add * & ** options to arglist

Include/opcode.h & Lib/dis.py:
    define three new opcodes
        CALL_FUNCTION_VAR
        CALL_FUNCTION_KW
        CALL_FUNCTION_VAR_KW

Python/ceval.c:
    extend TypeError "keyword parameter redefined" message to include
        the name of the offending keyword
    reindent CALL_FUNCTION using four spaces
    add handling of sequences and dictionaries using extend calls
    fix function import_from to use PyErr_Format
2000-03-28 23:49:17 +00:00
Guido van Rossum d295f120ae Make first raise argument optional 1998-04-09 21:39:57 +00:00
Guido van Rossum 03a7466b8f OK, ready to make 'assert' a keyword (instead of '__assert__'). 1997-04-16 00:34:46 +00:00
Guido van Rossum 556440d278 Added __assert__ statement (later to be renamed) 1997-04-02 05:22:18 +00:00
Guido van Rossum 0dfcf753ad Disable support for access statement 1996-08-12 22:00:53 +00:00
Guido van Rossum 14f44516a4 Changes for stride in slices (x[a🅱️c]) and ellipses (x[a,...,z]) 1996-07-30 16:43:44 +00:00
Guido van Rossum 0bfd6c33fa Added power (**) operator 1996-01-12 01:00:58 +00:00
Guido van Rossum a996b910f2 new grammar for 3rd raise arg and keyword parameters 1995-07-07 22:26:23 +00:00
Guido van Rossum 4a1da26891 changed import to support NAME.NAME...NAME 1995-01-07 10:25:36 +00:00
Guido van Rossum e5f6f45a99 Got rid of history (was beginning to get silly).
Removed a few diagram breaks since Kees' program is now cleverer
1994-09-29 10:05:45 +00:00
Guido van Rossum a322862eff Added #diagram:... comments for Kees Blom's railroad diagram generator 1994-08-17 13:19:13 +00:00
Guido van Rossum da5d518d46 Bring alpha100 revision back to mainline 1994-08-01 11:00:20 +00:00
Guido van Rossum 6d5ebe24ee Added (dummy) depend target 1993-12-28 19:39:13 +00:00
Guido van Rossum 1dfec14f83 Py -> Include 1993-12-26 18:15:49 +00:00
Guido van Rossum 6fa6343f0e None 1993-12-24 10:36:57 +00:00
Guido van Rossum 248a50c168 * Grammar: corrected old typo (class instead of 'class')
* dosmodule.c: MSDOS specific stuff from posixmodule.c.
* posixmodule.c: removed all MSDOS specific stuff.
* tokenizer.h, parsetok.h: in prototypes, don't mix named and unnamed
  parameters (MSC doesn't like this).
1993-12-20 12:53:10 +00:00
Guido van Rossum 57531fea90 change syntactical position of lambdef (was an atom, now is a test) 1993-11-30 14:57:42 +00:00
Guido van Rossum 590baa4a7a * import.c (get_module): pass .py filename to parse_file, not .pyc filename!
* funcobject.c (func_repr): don't call getstringvalue(None) for anonymous
  functions.
* bltinmodule.c: removed lambda (which is now a built-in function);
  removed implied lambda for string arg to filter/map/reduce.
* Grammar, graminit.[ch], compile.[ch]: replaced lambda as built-in
  function by lambda as grammar entity: instead of "lambda('x: x+1')" you
  write "lambda x: x+1".
* Xtmodule.c (checkargdict): return 0, not NULL, for error.
1993-11-30 13:40:46 +00:00
Guido van Rossum 3b716046a0 Committing the correct graminit.c; also changed confusing comments in Grammar. 1993-10-27 13:25:30 +00:00
Guido van Rossum 12d12c5faf * compile.[ch]: support for lambda()
* PROTO.h, mymalloc.h: added #ifdefs for TURBOC and GNUC.
* allobjects.h: added #include "rangeobject.h"
* Grammar: added lambda_input; relaxed syntax for exec.
* bltinmodule.c: added bagof, map, reduce, lambda, xrange.
* tupleobject.[ch]: added resizetuple().
* rangeobject.[ch]: new object type to speed up range operations (not
  convinced this is needed!!!)
1993-10-26 17:58:25 +00:00
Guido van Rossum db3165e655 * bltinmodule.c: removed exec() built-in function.
* Grammar: add exec statement; allow testlist in expr statement.
* ceval.c, compile.c, opcode.h: support exec statement;
  avoid optimizing locals when it is used
* fileobject.{c,h}: add getfilename() internal function.
1993-10-18 17:06:59 +00:00
Guido van Rossum b3f7258f14 * Lots of small changes related to access.
* Added "access *: ...", made access work for class methods.
* Introduced subclass check: make sure that when calling
  ClassName.methodname(instance, ...), the instance is an instance of
  ClassName or of a subclass thereof (this might break some old code!)
1993-05-21 19:56:10 +00:00
Guido van Rossum 25831652fd Several changes in one:
(1) dictionaries/mappings now have attributes values() and items() as
well as keys(); at the C level, use the new function mappinggetnext()
to iterate over a dictionary.

(2) "class C(): ..." is now illegal; you must write "class C: ...".

(3) Class objects now know their own name (finally!); and minor
improvements to the way how classes, functions and methods are
represented as strings.

(4) Added an "access" statement and semantics.  (This is still
experimental -- as long as you don't use the keyword 'access' nothing
should be changed.)
1993-05-19 14:50:45 +00:00
Guido van Rossum cf49ac55ac Added missing change log entries 1992-04-06 14:39:51 +00:00
Guido van Rossum 02334d2be0 Use only '*' for varargs list 1992-04-06 12:36:19 +00:00
Guido van Rossum af82141bb6 Tighten syntax for try statements 1992-03-31 18:49:18 +00:00
Guido van Rossum e785fbcfa7 Allow NEWLINE* after eval input. 1992-03-04 16:41:24 +00:00
Guido van Rossum 610cdc52ca Add '*' for varargs list. 1992-01-26 18:17:23 +00:00
Guido van Rossum 526e909614 Added varargs syntax "def f(a, b, +c): ..." 1992-01-14 18:27:17 +00:00
Guido van Rossum 09cea47433 Don't allow '==' at top level yet, to catch conversion errors. 1992-01-01 14:51:57 +00:00
Guido van Rossum 6cf1273faa Allow trailing comma after fplist; '=' is no longer comparison;
expr/assignment statement now allows testlists.
1991-12-31 13:11:56 +00:00
Guido van Rossum 68fc349744 Added 'global' and new class syntax. 1991-12-10 13:51:08 +00:00
Guido van Rossum 9eb4f535aa Added shifting and masking operators. 1991-10-24 14:54:25 +00:00
Guido van Rossum a76fb5b653 Comparison operators '<=' '>' '<>' are now 1 token.
Also support '!=' and '==' as alternatives for '<>' and '='.
1991-10-20 20:10:09 +00:00
Guido van Rossum 7ac4a88721 Change treatment of multiple NEWLINES 1991-07-27 21:29:47 +00:00
Guido van Rossum 56f7837704 Added 'continue', semicolons and dictionary displays. 1991-07-17 18:39:15 +00:00
Guido van Rossum 4dae216784 Removed 'dir' statement.
Function call argument is a testlist instead of exprlist.
1991-01-21 15:07:21 +00:00
Guido van Rossum 85a5fbbdfe Initial revision 1990-10-14 12:07:46 +00:00