Linked Questions
30 questions linked to/from Can you add new statements to Python's syntax?
0 votes
1 answer
603 views
Is it possible to overload keywords in Python? [duplicate]
Is it possible to overload the meaning of different keywords in Python? I'd like to implement my own version of if and for etc.
-1 votes
4 answers
641 views
How to write a small tokenizer in Python? [duplicate]
Normally, Python calls functions by func(arg0, arg1) But I would like to change to func arg0 arg1 For example, #Something... cmd = input() interpret(cmd) #Something... If I input 'func arg0 arg1', ...
2 votes
0 answers
618 views
Is it possible to create a statement in python? [duplicate]
Can I create a statement in python 2.7? Something similar to the print statement, that it's like a function, but gets the parameters without parenthesis.
0 votes
1 answer
319 views
python function name limitations [duplicate]
I'm wondering if there is anyway around the typical limitations on python function names (alphanumerics etc). Typical function application proceeds like this myFunction(arg1,arg2). But we know there ...
0 votes
1 answer
186 views
How to create something like exponent 'e' or imaginary 'j' [duplicate]
I have been searching already but I have no idea how those e and j are called and therefore not found useful information. I am searching for numbers with chars for specification or as operators. Like ...
0 votes
1 answer
121 views
how to make new flow controls in python? [duplicate]
Not sure how to explain, I mean statemtents like: for i in l: if a==b: def x(): lambda x: class spam: while True: basically those control statements that end with : can I create novel ones? (like in ...
1 vote
1 answer
44 views
Express a method like a keyword [duplicate]
How can I express a method (e.g. dir(os)) like a keyword (e.g. dir_ os)? Is it even possible? The opposite is quite easy to achieve: # `assert` expressed like a method def assert_(x): assert x ...
0 votes
0 answers
45 views
Is it possible to create a 'class constructor with a unicode caracter' in python? [duplicate]
By 'class constructor with a unicode caracter' I mean an analogous to the list constructor '[' or the tuple constructor '('. For exemple, can I define a class Circular_List, a '|' constructor such ...
1 vote
0 answers
31 views
Create a keyword in python instead of inheriting from a class [duplicate]
Is it possible to create a keyword in python that's equivalent to inheriting a class? So given class: class Hello: pass I could write keyword Custom: pass which would be equivalent to class ...
116 votes
10 answers
164k views
Python 3 print without parentheses
The print used to be a statement in Python 2, but now it became a function that requires parenthesis in Python 3. Is there anyway to suppress these parenthesis in Python 3? Maybe by re-defining the ...
5 votes
8 answers
2k views
How to create recalculating variables in Python
Suppose I have the code: a = 2 b = a + 2 a = 3 The question is: how to keep b updated on each change in a? E.g., after the above code I would like to get: print(b) to be 5, not 4. Of course, b can ...
20 votes
4 answers
7k views
Raise an exception from a higher level, a la warnings
In the module warnings (https://docs.python.org/3.5/library/warnings.html) there is the ability to raise a warning that appears to come from somewhere earlier in the stack: warnings.warn('This is a ...
7 votes
4 answers
8k views
Possible to call single-parameter Python function without using parentheses? [duplicate]
The Python documentation specifies that is is legal to omit the parentheses if a function only takes a single parameter, but myfunction "Hello!" generates a syntax error. So, what's the ...
1 vote
1 answer
2k views
using an alternative string quotation syntax in python
Just wondering... I find using escape characters too distracting. I'd rather do something like this (console code): >>> print ^'Let's begin and end with sets of unlikely 2 chars and bingo!'^ Let's ...
6 votes
1 answer
5k views
How to use reserved keyword as the name of variable in python? [duplicate]
I want to use reserved keyword "from" as the name of variable. I have it in my arguments parser: parser.add_argument("--from") args = parser.parse_args() print(args.from) but this isn't working ...