[Python-ideas] Re: The Pattern Matching Wildcard Is A Bad Idea

2021-06-02 Thread Shreyan Avigyan
Reply to Alexis Masson: There's no way we can end up in an undefined state. Python just detects if _ is there, it doesn't use it's value. If it is there it's a wildcard pattern. ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe

[Python-ideas] Re: Add "try: stmt except: stmt" syntax to Python

2021-06-02 Thread Shreyan Avigyan
Reply to Chris: My Browser showed "No results" and a windows error sound could be heard. I couldn't find the PEP. If I did I would have studied a lot. I didn't have any idea this idea was proposed before and also had a PEP (unfortunately rejected) ___

[Python-ideas] Re: Add "try: stmt except: stmt" syntax to Python

2021-06-02 Thread Shreyan Avigyan
Hmmm. Didn't show up as a search result. Yet I feel like it's really to good to have that feature. (Again, it's the PEP dictator's decision.) :-( ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to

[Python-ideas] Re: Add "try: stmt except: stmt" syntax to Python

2021-06-02 Thread Shreyan Avigyan
l execute and then exceptexpr will execute if expr raised Exception (This may not be the best syntax I could come up with. This is just an example. The syntax can be discussed later and will probably end up being different from this.). Thanking you, With Regards, Shreya

[Python-ideas] Re: Add "try: stmt except: stmt" syntax to Python

2021-06-02 Thread Shreyan Avigyan
Reply to Chris: Yes you're right, I meant if-else expression. ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message

[Python-ideas] Add "try: stmt except: stmt" syntax to Python

2021-06-01 Thread Shreyan Avigyan
Python has support for conditional statement, list comprehensions, dict comprehensions, etc. So we can write these in mere one or two lines. But for try-except it's not possible to write it one or two lines. Many a times, we have one stmt that we want to check and if it raises error then do

[Python-ideas] Re: Introduce constants in Python (constant name binding)

2021-05-29 Thread Shreyan Avigyan
Now it seems Python doesn’t need constant. There are many ways we can achieve constants. Though constants may increase performance. Yet again it can also be the opposite. From: Paul Sokolovsky Sent: Saturday, May 29, 2021 12:44:09 AM To: Shreyan Avigyan Cc

[Python-ideas] Re: Add static variable storage in functions

2021-05-28 Thread Shreyan Avigyan
I was thinking about introducing new opcodes for implementing static variables. Not sure though. All of the ideas actually do the same thing. The difference is approach. On Fri, May 28, 2021 at 6:57 PM Chris Angelico wrote: > On Fri, May 28, 2021 at 10:11 PM Steven D'Aprano > wrote: > > > > On

[Python-ideas] Re: Add static variable storage in functions

2021-05-27 Thread Shreyan Avigyan
Reply to Chris: Also it's rarely the case where it can become thread unsafe suddenly. 1 / 10*something chances. Because I've repeatedly run a thread-unsafe code and have not encountered thread unsafe state yet. GIL executes the code to a very good extent. And is it hypothetically even possible

[Python-ideas] Re: Add static variable storage in functions

2021-05-27 Thread Shreyan Avigyan
Chris wrote: > This is thread-safe: > > from threading import Lock > > lock = Lock() > counter = 0 > def get_next(): >with lock: >global counter >counter += 1 >my_counter = counter This is a great workaround. I can try to improve this. But first of all should we

[Python-ideas] Re: Add static variable storage in functions

2021-05-27 Thread Shreyan Avigyan
Reply to Chris: The only problem is that with that approach that we can't understand if that's the last yield statement. To achieve that we need to keep going until we encounter a StopIteration. And the value of x would 3. Because we're not iterating over a particular generator. We're creating

[Python-ideas] Re: Add static variable storage in functions

2021-05-27 Thread Shreyan Avigyan
> A context switch can happen between any two of those instructions. > That means one thread could load the global, then another thread could > load the same value, resulting in both of them writing back the same > incremented value. Or, between opcodes 6 and 8 (between the lines of > Python

[Python-ideas] Re: Add static variable storage in functions

2021-05-27 Thread Shreyan Avigyan
My proposal is somewhat the sum of all of your ideas. Well I propose there should a STORE_STATIC_FAST opcode that stores a static variable. Static variable will be declared only once and will be initialized to None (statement syntax will be similar to that of global). It will be initialized in

[Python-ideas] Re: Add static variable storage in functions

2021-05-27 Thread Shreyan Avigyan
I'll try to implement the idea roughly and I'll try to observe how much performance improvements (or the opposite) will occur. ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org

[Python-ideas] Re: Add static variable storage in functions

2021-05-27 Thread Shreyan Avigyan
For the implementation I had the same idea as Steven. And I don't think static variables should stored in __dict__ or __defaults__. Instead to increase efficiency (more importantly not to decrease current efficiency) it should be stored as a dict in __static__ or some other dunder member.

[Python-ideas] Re: Add static variable storage in functions

2021-05-27 Thread Shreyan Avigyan
Reply to Chris: I'm proposing a way to do this officially in Python. For example I know another hack, def count(cur={"cur":0}): cur["cur"] += 1 return cur >> Static should behave much like Python's for loop variables. > I have no idea what this means. That's a bad example. I was just

[Python-ideas] Re: Add static variable storage in functions

2021-05-27 Thread Shreyan Avigyan
Well sometimes we don't want to pollute the module namespace. Two functions can have two variables with the same name but with different values that we want to be static. And this functionality already exists in Python but as a *hack*. This idea proposes to add a new dunder member and a keyword

[Python-ideas] Add static variable storage in functions

2021-05-27 Thread Shreyan Avigyan
Lot of programming languages have something known as static variable storage in *functions* not *classes*. Static variable storage means a variable limited to a function yet the data it points to persists until the end of the program. Well Python also kind of has that functionality. Python's

[Python-ideas] Re: Introduce constants in Python (constant name binding)

2021-05-26 Thread Shreyan Avigyan
Well. How can I go beyond why constant was invented in the first place? As far as I can understand by my limited knowledge that *sometimes* constants can be useful, sometimes they are terrible. The main reason constant was invented was to provide an additional support to programmers so that

[Python-ideas] Re: Introduce constants in Python (constant name binding)

2021-05-26 Thread Shreyan Avigyan
Reply to Paul Moore: > But you just said it was runtime, so it definitely *isn't* similar to > the syntax error "Can't assign to literal here". You're making > inconsistent statements again :-( That's exactly why I wrote SomeErrorType instead of SyntaxError. They are never similar. I just said

[Python-ideas] Re: Introduce constants in Python (constant name binding)

2021-05-26 Thread Shreyan Avigyan
Reply to Chris: Yes I know that. sys.stdout exists there for that reason only. But if we can't print then it means we changed it somewhere. I just gave an example. I've seen code where constants can be really necessary. Python lets us use these things because it's a programming language. But

[Python-ideas] Re: Introduce constants in Python (constant name binding)

2021-05-26 Thread Shreyan Avigyan
I've already given one. Since Python is dynamically typed changing a critical variable can cause huge instability. Want a demonstration? Here we go, import sys sys.stdout = None Now what? Now how can we print anything? Isn't this a bug? There are lots of code out there where we need to protect

[Python-ideas] Re: Introduce constants in Python (constant name binding)

2021-05-26 Thread Shreyan Avigyan
Reply to Stestagg: That's annotation to make sure no one uses a name. This is a proposal to implement constant name binding in Python. There are many applications of constants. ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe

[Python-ideas] Re: Introduce constants in Python (constant name binding)

2021-05-26 Thread Shreyan Avigyan
Reply to Paul Moore: if some_condition: constant a = 1 else: a = 2 a = 3 Yes this is allowed. This is runtime. for i in range(10): constant a = [] Not sure. Though it's preferable to be runtime. Preferable is "not allowed". And lists are also literals. Any Python Object that is

[Python-ideas] Re: Introduce constants in Python (constant name binding)

2021-05-26 Thread Shreyan Avigyan
Reply to Paul Moore: In Python terms, a constant is a name that binds itself to a value in memory and that name cannot bind itself to a different value now (unlike variables). The value can be mutated (if mutable) but the name cannot bind to a different value once it has bind itself to a

[Python-ideas] Re: Introduce constants in Python (constant name binding)

2021-05-26 Thread Shreyan Avigyan
> What's a const *ptr and a const *ptr const? In C, a const pointer means a pointer that can only point to one value while const pointer const means a pointer that can only point to one constant value. ___ Python-ideas mailing list --

[Python-ideas] Re: Introduce constants in Python (constant name binding)

2021-05-26 Thread Shreyan Avigyan
Reply to Steven - Sorry for creating confusions. 1. Leave debugging. As I said that's not a good argument for the existence of constants. 2. "Constants doesn't mean we can't reassign the name to a different value." was differently intended. I was trying to say that we should *treat* it like

[Python-ideas] Re: Introduce constants in Python (constant name binding)

2021-05-26 Thread Shreyan Avigyan
Reply to Richard Damon: The values can be changed. It can be mutated (if mutable). This idea suggests we can't reassign anything to the name. Suppose, constant x = ["List"] x.append("something") # OK x = [] # Error Think of it as a const *ptr. Don't think of it as const *ptr const.

[Python-ideas] Re: Introduce constants in Python (constant name binding)

2021-05-26 Thread Shreyan Avigyan
Reply to Steven - Literals mean 10 or 20. Can you assign something to literal? No. But you can assign something to a variable to point to another value. That's why I said constants should behave like literals. Point is constants are names bind to a value. We can change the value but not the

[Python-ideas] Re: Introduce constants in Python (constant name binding)

2021-05-26 Thread Shreyan Avigyan
Chris wrote: > There are many arguments in favour of constants, but this one strikes > me as particularly weak. That's not exactly how I meant it. I was telling that while constant should be there it should not be used as "Use constants everywhere". I actually believe the main reason for

[Python-ideas] Re: Introduce constants in Python (constant name binding)

2021-05-26 Thread Shreyan Avigyan
Reply to Chris: There are two things I want to say about constants :- 1) Global-Local Constants - The ALL_CAPS convention variables should become constant. 2) Class member constants - Constants should be used only for avoiding from being overridden. It should not be used as "We have a class.

[Python-ideas] Re: Introduce constants in Python (constant name binding)

2021-05-26 Thread Shreyan Avigyan
Reply to Steven D'Aprano: > But you've said that you want constants to be capable of being rebound > to a new value. So your constants are identical to variables. No, not at all. Actually to be clear, constants are supposed to behave like literals but in implementation they are nothing more

[Python-ideas] Re: Introduce constants in Python (constant name binding)

2021-05-25 Thread Shreyan Avigyan
I actually suggest a different kind of Constant in Python not the classical const we see in Java or C/C++. Constants doesn't mean we can't reassign the name to a different value. Constants behave like literals. They are sort of literals actually. We reference a value by a name. Variable is

[Python-ideas] Re: Introduce constants in Python (constant name binding)

2021-05-25 Thread Shreyan Avigyan
Reply to Chris: Wait. Deployment? Before deploying we *run the code* at least once and then we get the errors. And I'm not sure but type checking is ok but sometimes enforcing is a better option. Why? Mypy or typecheckers have to be run manually and they are also not part of the stdlib.

[Python-ideas] Re: Introduce constants in Python (constant name binding)

2021-05-25 Thread Shreyan Avigyan
I'm aware that Python is a "Consenting Adults" language but I think Python should provide this functionality at least. This idea doesn't actually make it like Java. Because why should we mess around with that member anyway. Sometimes we want to provide members that users must use but mustn't

[Python-ideas] Re: Introduce constants in Python (constant name binding)

2021-05-25 Thread Shreyan Avigyan
First it would seem useless or not necessary but soon this becomes clear. 1) It would help programmers debug their code easily and help them find out that the bug's not in the constant, that's for sure. 2) This would allow another branch of OOP programming to enter Python. Read-only member

[Python-ideas] Re: Introduce constants in Python (constant name binding)

2021-05-25 Thread Shreyan Avigyan
Ethan: > Optional typing != core Python. Exactly ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at

[Python-ideas] Re: Introduce constants in Python (constant name binding)

2021-05-25 Thread Shreyan Avigyan
Yes I'm aware of that. That's for typing. I'm talking about implementing it in Python itself not Python typing. ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org

[Python-ideas] Introduce constants in Python (constant name binding)

2021-05-25 Thread Shreyan Avigyan
I posted my previous idea regarding this on the mailing list. This idea is a little different. This idea suggests introducing constant name bindings. This is similar to const pointer in C/C++. Once a name has been assigned to a data we can change the data (if mutable) but we cannot change the

[Python-ideas] Re: Introduce constant variables in Python

2021-05-25 Thread Shreyan Avigyan
Sorry for the name conflict. I tried to type Steven D'Aprano but instead it resulted in Steve D'Aprano ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org

[Python-ideas] Re: Introduce constant variables in Python

2021-05-24 Thread Shreyan Avigyan
Reply to Steve D'Aprano - I am talking about constant name binding. Once the name is bind it cannot be changed. The data will remain immutable or mutable. > That seems very odd. That would mean that you can't pass constants to > functions, or put them in lists or dicts, since that would create

[Python-ideas] Re: Introduce constant variables in Python

2021-05-24 Thread Shreyan Avigyan
Thomas Grainger: > This is already available with typing.Final and immutable types: > > from typing import Final > > ham: Final = 3 > ham = 4 # Error > > hams: Final[Sequence[str]] = ["ham", "spam"] > hams.append("meat") # Error I'm not sure whether it's a reply to me or someone else. But anyways

[Python-ideas] Introduce constant variables in Python

2021-05-24 Thread Shreyan Avigyan
Many times a programmer would want a variable that will be a constant. The programmer could have been careless and suddenly changed a very important variable. Proposed syntax, constant variable = 10 variable = 20 # Error Now constant means making a variable value immutable. It means now we can

[Python-ideas] Re: symbolic math in Python

2021-05-19 Thread Shreyan Avigyan
People always come up with hacks like Ir. Robert Vanden Eynde has come up with the vertical bar hack. This is why I feel there's no need to have additional performance decrease and new syntax only to solve a little problem that occurs in some third party like sympy.

[Python-ideas] Re: symbolic math in Python

2021-05-19 Thread Shreyan Avigyan
I'm +1 on the idea but -1 on the proposed syntax. Yes it would be kind of nice *but* it's not how Python arithmetic or grammar works. And why should Python have that functionality? AFAICT Python doesn't have a module in stdlib for symbolic math. This looks like a feature request to third party

[Python-ideas] Re: Fractions vs. floats - let's have the cake and eat it

2021-05-18 Thread Shreyan Avigyan
Why do we need this functionality? What are the benefits? What are you trying to solve? Is it worth adding it? ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org

[Python-ideas] Re: Fractions vs. floats - let's have the cake and eat it

2021-05-18 Thread Shreyan Avigyan
As I said in my post in your previous thread, I'm -1. Why? Because you're not solving anything. In fact you're making it more complicated. Developers can have difficulties studying your idea, beginners don't stand a chance (In fact I have no idea what you described here in your idea and trust

[Python-ideas] Re: division of integers should result in fractions not floats

2021-05-17 Thread Shreyan Avigyan
Christopher Baker: > Python assumes, and converts to, floats all over the place. So users need > to understand and accommodate the limitations of floats anyway. Having > exact fractions in seemingly arbitrary places will not result in more > accurate (or precise) results in most cases, but would

[Python-ideas] Re: Python 3.10: ranges in pattern matching

2021-05-17 Thread Shreyan Avigyan
Range here means low <= value <= high. I also don't understand what Valentine suggested and meant by range. I thought Valentine means low..=high as low <= value <= high and meant to say that functionality already exists. I'm really sorry for confusing everyone.

[Python-ideas] Re: Python 3.10: ranges in pattern matching

2021-05-17 Thread Shreyan Avigyan
Chris: > What do you mean by "an object in range"? Please be very specific >here. I gave two interpretations, both of which make plausible sense > within Python, and it's not clear which one you're addressing, or if > you're talking about something completely different. > > What exactly is "range

[Python-ideas] Re: division of integers should result in fractions not floats

2021-05-17 Thread Shreyan Avigyan
Chris: > But none of the rest of your statement is an argument against Fraction > literals. If we have fractions.Fraction then we must have decimal.Decimal. We always don't judge by accuracy. There are other factors in motion that are to be considered.

[Python-ideas] Re: Python 3.10: ranges in pattern matching

2021-05-17 Thread Shreyan Avigyan
Chris: > There are two obvious definitions of a range: a range object, and a > pair of inequalities. I'm not sure whether a range object is > supported, but it's possible to use a built-in type with a guard as a > range check: By range I mean an object in range. Is it possible to match object in

[Python-ideas] Re: division of integers should result in fractions not floats

2021-05-17 Thread Shreyan Avigyan
hange" or simply "beginners concerning change" since all previous versions of Python displayed floats and now it's displaying Fractions! Some code may be hoping to find type() == float and to it's surprise it's not that! Thanking you, With Rega

[Python-ideas] Re: Python 3.10: ranges in pattern matching

2021-05-13 Thread Shreyan Avigyan
-1. This would require definition of what is a range and which types it support. Defining ranges of user-defined classes doesn't make sense and it would also be hard to implement. ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe

[Python-ideas] Re: Improved multi-tasking performance through deterministic GIL hand-off

2021-05-11 Thread Shreyan Avigyan
I'm currently learning about the GIL and how can it be removed. So I'm confessing that I understood only half of your words and I can be wrong. As far I understood by reading your long passage, the problem is other threads don't get enough chance to run and the CPU-Bound Python process will

[Python-ideas] Re: Add a mechanism so that multiple exceptions can be caught using `except E1, E2, E3:`

2021-05-10 Thread Shreyan Avigyan
+1 and -1 at the same time. I feel like :- "This makes sense", try: # something except E1, E2, E3: # something "This doesn't make sense", try: # something except E1, E2, E3 as e: # something The second one according to this idea would be parsed as, try: # something except

[Python-ideas] Re: Add a mechanism so that multiple exceptions can be caught using `except E1, E2, E3:`

2021-05-09 Thread Shreyan Avigyan
+1 ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at

[Python-ideas] Adding classes to modules is a tedious job. Wait! What about introducing a slot in PyModuleDef to hold the objects?

2021-05-07 Thread Shreyan Avigyan
be best if a macro (like PY_AUTO_OBJECT maybe?) is defined then it'll add those classes automatically. If the slot is NULL or 0 then don't add anything. But yeah they may add more classes if they want but it doesn't matter much. Thanking you, With Regards, Shreyan Avigyan

[Python-ideas] Re: Add support for private variables, methods and functions in Python

2021-05-07 Thread Shreyan Avigyan
Ethan: > As you may have noticed, this is a mailing list -- no thread is closed. I've > seen posts to three-year-old threads. Since the discussion has come to a halt and it's decided that we'll continue to use the Pythonic way for private and it's also very hard to implement what I suggested,

[Python-ideas] Re: Add support for private variables, methods and functions in Python

2021-05-06 Thread Shreyan Avigyan
Steven D'Aprano: > My guess is that you have used a lot of Java, or at least read a lot of > Object Oriented Programming theory that is based on the Java model I've never used Java. I don't even know Java so well. But the Java and C++ model is similar and since I know C/C++ I'm guessing about

[Python-ideas] Re: Add support for private variables, methods and functions in Python

2021-05-06 Thread Shreyan Avigyan
. Thanks anyway for considering this. This thread is closed now. Thanking you, With Regards Shreyan Avigyan ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org

[Python-ideas] Re: Add support for private variables, methods and functions in Python

2021-05-06 Thread Shreyan Avigyan
Chris: > I'm not sure about other people, but I have never, not once, used > @property as a means of controlling access. So giving me another way > to do something that I am not, and don't want to, do... isn't much of > an argument. :) Ok. I'm giving you another example that doesn't cause

[Python-ideas] Re: Add support for private variables, methods and functions in Python

2021-05-06 Thread Shreyan Avigyan
Chris: > That would require some definition of what's "within" and what's > "outside" the class, and whatever definition you use, it won't work > with all forms of dynamic code. Yes, implementing that will be hard. But the question is I can't quite understand why this is not acceptable by the

[Python-ideas] Re: Add support for private variables, methods and functions in Python

2021-05-06 Thread Shreyan Avigyan
David Mertz: > I am a strong -1 on this Thanks for your feedback. But I'm not suggesting introducing a new behavior. The @property already creates read-only member variables. What I'm suggesting is that introducing a new keyword or decorator as required to create a variable that can be

[Python-ideas] Re: Add support for private variables, methods and functions in Python

2021-05-06 Thread Shreyan Avigyan
André Roberge: > My own email specifically referred to two instances where I found it necessary to **modify** methods that are indicated as being private as their names begin with double underscores. So, I am strongly opposed to your suggestion. Actually as I explained in this comment

[Python-ideas] Re: Add support for private variables, methods and functions in Python

2021-05-06 Thread Shreyan Avigyan
Again. See what I suggested. I changed my suggestion from "Private" to "Non-modifiable member variables". ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org

[Python-ideas] Re: Add support for private variables, methods and functions in Python

2021-05-06 Thread Shreyan Avigyan
Chris :- > Please actually quote some text so we know who you're responding to, what you're talking about, etc. I'm actually telling to read my comment here https://mail.python.org/archives/list/python-ideas@python.org/message/426EPANCVEGZV2AZL7MWNG67BTZMORNG. See the Conclusion section in

[Python-ideas] Re: Add support for private variables, methods and functions in Python

2021-05-06 Thread Shreyan Avigyan
Most of the time when someone fixes a bug using a private member of another class then it's completely considered private code. Sometimes applications can cause crashes if there's memory leak or modification. Like there's an example where you change the name attribute of a bank account class

[Python-ideas] Re: Add support for private variables, methods and functions in Python

2021-05-06 Thread Shreyan Avigyan
Please read my whole comment. ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at

[Python-ideas] Re: Add support for private variables, methods and functions in Python

2021-05-06 Thread Shreyan Avigyan
First of all, the reason that private members can be hacked in C++ because of pointers. I don't know Java, so I don't know how it's possible there. But Python doesn't have pointers and getattr, settatr can be adjusted to work with private members. The only way the hack is possible if someone

[Python-ideas] Re: Add support for private variables, methods and functions in Python

2021-05-05 Thread Shreyan Avigyan
See my comment here - https://mail.python.org/archives/list/python-ideas@python.org/message/L5LUQDNNV5ZTF4E33L2JSOYIKPJUJJK5/ ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org

[Python-ideas] Re: Add support for private variables, methods and functions in Python

2021-05-05 Thread Shreyan Avigyan
I don't know if it's worth adding private to python modules but what about classes? Private in class is an important feature in OOP that Python lacks (Most OOP languages have private like Java, C++, etc.). I don't know why it was introduced in the first place but it's kind of a convention to

[Python-ideas] Add support for private variables, methods and functions in Python

2021-05-05 Thread Shreyan Avigyan
at's been explained already (sometimes I miss out a feature in a PEP and think about suggesting that feature when it's already there and then I realize "Oh! It's already here in this PEP"). If that's the case then please correct me.) With Regar

[Python-ideas] Re: Add switch-case statements in Python

2021-05-04 Thread Shreyan Avigyan
Got it ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at

[Python-ideas] Re: Add switch-case statements in Python

2021-05-04 Thread Shreyan Avigyan
This thread is closed therefore. (It was mistakenly opened due to misunderstanding.) ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org

[Python-ideas] Re: Add switch-case statements in Python

2021-05-04 Thread Shreyan Avigyan
Ooops...Didn't notice it. Anyway this thread is considered closed. ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/

[Python-ideas] Re: Add switch-case statements in Python

2021-05-04 Thread Shreyan Avigyan
Ok. ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at

[Python-ideas] Re: Add switch-case statements in Python

2021-05-04 Thread Shreyan Avigyan
Ok. Now I'm able to understand. PEP 634 should have a reference to PEP 636 or else it's pretty hard to understand because the syntax section demonstrates PEG implementation of this. ___ Python-ideas mailing list -- python-ideas@python.org To

[Python-ideas] Re: Add switch-case statements in Python

2021-05-04 Thread Shreyan Avigyan
I'm confused. PEP 634 is about switch statements in Python or PEG? ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/

[Python-ideas] Re: Add switch-case statements in Python

2021-05-04 Thread Shreyan Avigyan
Sorry PEP 634 not PEP 643 ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at

[Python-ideas] Re: Add switch-case statements in Python

2021-05-04 Thread Shreyan Avigyan
Isn't PEP 643 for PEG grammar pattern matching? (I'm talking about switch statements in Python) ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org

[Python-ideas] Add switch-case statements in Python

2021-05-04 Thread Shreyan Avigyan
Most of programming languages out there have switch-case statements. Python doesn't have support for switch-case statements though. switch-case statements can sometimes be nice and tidy and sometimes it may be a horrible nightmare. But that also applies to if-elif-else statements. It would be

[Python-ideas] Re: Accepting a function argument of a particular type specified by the user

2021-04-25 Thread Shreyan Avigyan
Thanks for clarifying. And I agree with you. Not writing checking code will make the function more flexible. Thanking you, With Regards ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to

[Python-ideas] Re: Accepting a function argument of a particular type specified by the user

2021-04-25 Thread Shreyan Avigyan
First of all the use case is when for example we have UserDefined class and my function or another class can only handle instances of the UserDefined class. Second of all why not add a built-in type check decorator then? ___ Python-ideas mailing list

[Python-ideas] Re: Accepting a function argument of a particular type specified by the user

2021-04-25 Thread Shreyan Avigyan
I am aware of all those libraries that allows us to type check. But it would be nice to have this feature built-in. I'm not talking about modifying type annotation but introducing a new feature. Like, def add(int a, int b): return a + b If type is not provided then take in any parameter

[Python-ideas] Accepting a function argument of a particular type specified by the user

2021-04-25 Thread Shreyan Avigyan
Think it like this. We have this code in Python :- def add(a, b): return a + b Here we are taking two arguments a, b and then returning a + b. But we can pass in instance of any class like str, int, float, dict, user-defined class, etc. But we only want to add int here. Here we can modify

[Python-ideas] Re: Why not deprecate Py_XDECREF in a future python version? Maybe a DeprecationWarning for now?

2021-04-15 Thread Shreyan Avigyan
Thanks for clarifying. And I wasn't telling to write if (obj != NULL) { Py_DECREF(obj); } I was actually proposing to change the code in the static inline function _Py_DECREF by putting all of the code in the function inside the if block. But Chris has a point. If we know for sure that

[Python-ideas] Why not deprecate Py_XDECREF in a future python version? Maybe a DeprecationWarning for now?

2021-04-15 Thread Shreyan Avigyan
After going through the https://github.com/python/cpython/blob/master/Include/object.h it seems that Py_XDECREF is just calling Py_DECREF if the PyObject pointer is not NULL. This if statement could be directly implemented in Py_DECREF right? Therefore is it really required to have Py_XDECREF?

[Python-ideas] Re: Change the exception type and message raised when _curses is not found

2021-04-05 Thread Shreyan Avigyan
Got it. Thanks. On Mon, Apr 5, 2021 at 2:24 PM Eric V. Smith wrote: > > > On Apr 5, 2021, at 4:43 AM, Shreyan Avigyan > wrote: > > > > Yes you are right. But isn't informing people about a change the work > of PEP? I mean this is kind of a major change becau

[Python-ideas] Re: Change the exception type and message raised when _curses is not found

2021-04-05 Thread Shreyan Avigyan
OkSo the text will be changed. I've already used the issue tracker to describe this change. I'm yet to receive confirmation from there. I'll submit the PR as soon as I receive confirmation. Thanks a lot everyone. With Regards ___ Python-ideas

[Python-ideas] Re: Change the exception type and message raised when _curses is not found

2021-04-05 Thread Shreyan Avigyan
Yes you are right. But isn't informing people about a change the work of PEP? I mean this is kind of a major change because we're trying to change the error message and/or the type. If the type is not changed then no PEP is required but if the type is changed then there comes a maybe. What

[Python-ideas] Re: Change the exception type and message raised when _curses is not found

2021-04-05 Thread Shreyan Avigyan
OkA CursesNotFoundError derived from ModuleNotFoundError is okNow should a draft PEP be submitted or should a PR be directly submitted to https://github.com/python/cpython? ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe

[Python-ideas] Change the exception type and message raised when _curses is not found

2021-04-04 Thread Shreyan Avigyan
When importing the curses module, be it on Windows or Darwin or UNIX-based OS or any other platform, if the _curses module is not found then just a ModuleNotFoundError is raised. But this error is not very informational in case of _curses module. Since the curses module is packaged with the