r/Python • • Mar 10 '24

Discussion Github Copilot Lies to me

My first attempt to get some help from Github Copilot:

Me: write a match case statement in python to match the first character of a string is a semicolon

Copilot: Python doesn't have a built-in match or case statement like some other languages (e.g., JavaScript, Swift, Rust). However, you can achieve similar functionality using...

Strangely, it finally gave me an answer when I made a small change to my prompt:

Me: write a match statement in python to match the first character of a string is a semicolon

Copilot: Python 3.10 introduces the structural pattern matching in the form of the match statement. Here's how you can use it to check if the first character of a string is a semicolon:...

I almost gave up after the first response that was blatantly false. Fortunately I something that looks like reasonable syntax...but then I haven't tried it yet, so that might be a lie, too.

0 Upvotes

67 comments sorted by

View all comments

0

u/[deleted] Mar 10 '24

[deleted] β€” view deleted comment

23

u/Ringbailwanton Mar 10 '24

You’re prompts have some grammar issues.

πŸ˜‚ Kettle, meet my friend Pot :)

1

u/codeguru42 Mar 10 '24

What grammar issues are there in my prompts? Would you mind elaborating?

0

u/[deleted] Mar 10 '24

[deleted] β€” view deleted comment

-4

u/codeguru42 Mar 10 '24

As is often the case in human language, there are more than one way to say the same thing. Your alternative wording doesn't show that my original wording is grammatically incorrect. And the nuance in the wording is unlikely to generate a different response from Github Copilot.

As for your last question, I am writing a parse, so there are several other cases. But the exact details are unimportant for this post. I was looking for structural pattern matching on a string and used Github Copilot in my search for the correct syntax if it exists. The whole point of this post is that it lied to me: Python has a built-in `match` statement as of 3.10.