#πŸ”’ Leetcode?!

34 messages Β· Page 1 of 1 (latest)

pliant perch
#

I somehow don't understand why 0P is not a palindrome because p == p, right? What did I forget to consider? πŸ€”

carmine hatchBOT
#

@pliant perch

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

unique heart
mighty gulch
#

you should only be removing whitespace and punctuation.

#

!d str.isalnum

carmine hatchBOT
#

str.isalnum()```
Return `True` if all characters in the string are alphanumeric and there is at least one character, `False` otherwise. A character `c` is alphanumeric if one of the following returns `True`: `c.isalpha()`, `c.isdecimal()`, `c.isdigit()`, or `c.isnumeric()`.
pliant perch
pliant perch
mighty gulch
#

technically not builtin, just a method on a builtin type

#

you can call it stdlib

pliant perch
#

What is the difference between built-in and stdlib?

mighty gulch
#

builtins don't need to be imported and can be accessed without a .x form

#

!d builtins

carmine hatchBOT
#

This module provides direct access to all β€˜built-in’ identifiers of Python; for example, builtins.open is the full name for the built-in function open().

This module is not normally accessed explicitly by most applications, but can be useful in modules that provide objects with the same name as a built-in value, but in which the built-in of that name is also needed. For example, in a module that wants to implement an open() function that wraps the built-in open(), this module can be used directly:

mighty gulch
#

basically, every file has an implicit from builtins import * at the top.

pliant perch
mighty gulch
#

Yes.

#

Fun fact: If you add a new attribute to the builtins module, any newly imported modules will also have that new attribute.

#

If for whatever reason you never need to shadow a builtin with a variable, you can always access it via the builtins module.

pliant perch
#

Does it mean that from builtins import * is the mother of all files?

mighty gulch
#

I don't think so.

pliant perch
#

And what about stdlib functions? Is there also a from ... import ...?

mighty gulch
#

stdlib just means it comes standard with python

#

you can import it without installing any extra packages

#

stdlib: standard library

pliant perch
#

So there is also a background mechanism I can't see, but use?

mighty gulch
#

in what way?

#

you mean the import?

pliant perch
mighty gulch
#

basically.

#

It gets complicated, but that's the gist of it.

#

sorry for going on a tangent btw

carmine hatchBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.