Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More suggestions #18

Open
SylvainDe opened this issue Nov 12, 2015 · 52 comments
Open

More suggestions #18

SylvainDe opened this issue Nov 12, 2015 · 52 comments

Comments

@SylvainDe
Copy link
Owner

Maybe things from https://twitter.com/DrapsTV/status/660657599210266624 can be reused (maybe not).

@SylvainDe
Copy link
Owner Author

A few ideas from http://migrateup.com/main-difference-python-3/ are interesting too.

@SylvainDe
Copy link
Owner Author

@SylvainDe
Copy link
Owner Author

https://github.com/mdipierro/autoinstaller : interesting idea. I'll try to understand the code and see if I can reuse ideas out of it.

Also, it could be nice to make things usable with the -m option ( http://python-packaging.readthedocs.org/en/latest/command-line-scripts.html / https://www.reddit.com/r/Python/comments/42u5dm/how_to_structure_a_module_that_is_intended_to_be/ ).

@SylvainDe
Copy link
Owner Author

@SylvainDe
Copy link
Owner Author

Principle of Least Astonishment and Python : http://lucumr.pocoo.org/2011/7/9/python-and-pola/ .

A few suggestions might make sense.

@SylvainDe
Copy link
Owner Author

@SylvainDe
Copy link
Owner Author

@SylvainDe
Copy link
Owner Author

I've just discovered the change about literal octals in Python 3. Might be interesting to have a suggestion.

@SylvainDe
Copy link
Owner Author

https://twitter.com/raymondh/status/772957699478663169
"#python tip: What Python says: "TypeError: 'method' object is not subscriptable" What it means: "Use parentheses instead of square brackets""

https://twitter.com/raymondh/status/773224135409360896
"What #Python says: TypeError: 'Tk' object cannot be interpreted as an integer What it means: class 'Tk' does not have an index method"

@SylvainDe
Copy link
Owner Author

@SylvainDe
Copy link
Owner Author

SyntaxError: if a = b: and if a == b

SylvainDe added a commit that referenced this issue Oct 4, 2016
Based on
https://twitter.com/brandon_rhodes/status/781234730091941888 .

This will probably break based on the
Python version and/or the interpreter...
@SylvainDe
Copy link
Owner Author

@SylvainDe
Copy link
Owner Author

>>> 3.5 ^ 2
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: unsupported operand type(s) for ^: 'float' and 'int'
>>> 3.5 ** 2
12.25

@SylvainDe
Copy link
Owner Author

>>> raise NotImplemented
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: exceptions must be old-style classes or derived from BaseException, not NotImplementedType

A fuzzy match on the actual subclasses of BaseException could be nice :)

@SylvainDe
Copy link
Owner Author

TypeError: unhashable instance

Maybe suggest how to make the instance hashable (on custom classes), maybe suggest hashable types (frozenset, tuple, etc).

@SylvainDe
Copy link
Owner Author

SylvainDe commented Dec 18, 2016

RuntimeError: dictionary changed size during iteration

Maybe suggest ideas from :
http://stackoverflow.com/questions/11941817/how-to-avoid-runtimeerror-dictionary-changed-size-during-iteration-error

@SylvainDe
Copy link
Owner Author

@SylvainDe
Copy link
Owner Author

This is an interesting issue and might deserve some suggestion :
http://stackoverflow.com/questions/4545661/unicodedecodeerror-when-redirecting-to-file

@SylvainDe
Copy link
Owner Author

SylvainDe commented Jan 5, 2017

TypeError: can only concatenate list (not "dict_keys") to list

@SylvainDe
Copy link
Owner Author

TypeError: argument to reversed() must be a sequence

@SylvainDe
Copy link
Owner Author

I got this issue : http://stackoverflow.com/questions/24463202/typeerror-get-takes-no-keyword-arguments . Maybe suggesting position arguments and explaining that C-level API is exception to the usual rule is a good idea.

@SylvainDe
Copy link
Owner Author

@SylvainDe
Copy link
Owner Author

@SylvainDe
Copy link
Owner Author

Idea: reuse _moved_attributes from https://github.com/benjaminp/six/blob/master/six.py (with proper attribution).

@SylvainDe
Copy link
Owner Author

Idea: use gc.get_objects() for various purposes (get_func_by_name, get_type_by_name, etc).

@SylvainDe
Copy link
Owner Author

"TypeError: 'generator' object is not subscriptable" -> itertools.islice(my_generator, 5)

@SylvainDe
Copy link
Owner Author

Set.remove keyerror set.discard

@SylvainDe
Copy link
Owner Author

Suggest using PYTHONIOENCODING n case of Encode/Decode error (when relevant - whatever it means, not always)

@SylvainDe
Copy link
Owner Author

TypeError: Cannot create a consistent method resolution... http://stackoverflow.com/questions/29214888/typeerror-cannot-create-a-consistent-method-resolution-order-mro

@SylvainDe
Copy link
Owner Author

Interesting thing already done : https://twitter.com/DRMacIver/status/912812300125577216?s=03 .

>>> sum(["a", "b", "c"], '')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: sum() can't sum strings [use ''.join(seq) instead]

@SylvainDe
Copy link
Owner Author

>>> set([42])[0]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'set' object does not support indexing

Maybe suggest pop ?

@SylvainDe
Copy link
Owner Author

>>> del s[42]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'set' object doesn't support item deletion
>>> s.remove(42)
>>> d = {43: 'x'}
>>> d.remove(43)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'dict' object has no attribute 'remove'
>>> del d[43]

(Also discard)

@SylvainDe
Copy link
Owner Author

@SylvainDe
Copy link
Owner Author

@SylvainDe
Copy link
Owner Author

SylvainDe commented Feb 5, 2019

@SylvainDe
Copy link
Owner Author

Add tests for walrus operator

@SylvainDe
Copy link
Owner Author

Add suggestion for keyerror. I thought this was tackled already but apparently no

https://realpython.com/python-keyerror/

@SylvainDe
Copy link
Owner Author

Positional only arguments

@SylvainDe
Copy link
Owner Author

@SylvainDe
Copy link
Owner Author

KeyError on del on a dict. Should call pop ?

@SylvainDe
Copy link
Owner Author

It looks like cfbolz really like to improve error messages: https://github.com/cfbolz/syntaxerrors . To be added to README eventually.

@SylvainDe
Copy link
Owner Author

https://twitter.com/AlSweigart/status/1186397310374203392?s=19 I can't remember if this would be handled properly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant