#๐ I need help with camelcase
82 messages ยท Page 1 of 1 (latest)
@final trench
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.
Have you already installed the module?
!pip camelcase
If you're facing difficulty installing it using your terminal, you can install it manually from here.
write your own version ๐
last release 2015. no chance, probably
!e
def camel_case(s: str) -> str:
first, *rest = s.split("_")
if not first: # s beings with '_'
first, *rest = rest
return first.lower() + "".join(word.title() for word in rest)
print(camel_case("_what_are_you_doing123"))
missing *
@young finch :white_check_mark: Your 3.12 eval job has completed with return code 0.
whatAreYouDoing123
Thanks. I did see it was just writing :)
this just removes the underscore but maybe I should add it ๐ค
yes I think I installed it in the terminal typing , pip install camelcase
!e
def camel_case(s: str) -> str:
prefix = ""
first, *rest = s.split("_")
if not first: # s beings with '_'
prefix = "_"
first, *rest = rest
return prefix + first.lower() + "".join(word.title() for word in rest)
print(camel_case("_what_are_you_doing123"))
@young finch :white_check_mark: Your 3.12 eval job has completed with return code 0.
_whatAreYouDoing123
tada
import camelcase
ModuleNotFoundError: No module named 'camelcase'
do py -0 in your terminal
G1:~$ pip install camelcase
Requirement already satisfied: camelcase in ./anaconda3/lib/python3.11/site-packages (0.2)
oh it's unix
you don't need to install anything just for converting a string to camelcase
do you have multiple versions installed?
but yeah like... why do you need to install this library
I've shown that a function can be easily constructed, as I have done in 5 mins or so
Its a exercise from school
'_what_are_you_doing123'.title().replace('_', '')
1:~$ py -0
Kommandot "py" hittades inte, men kan installeras med:
sudo apt install pythonpy
should I install that ?
sorry its in swedish ..
!e print("_what_are_you_doing123".title().replace("_", ""))
@young finch :white_check_mark: Your 3.12 eval job has completed with return code 0.
WhatAreYouDoing123
did not know that title would make stuff capitalized after underscores
very cool
but still that's not correct
pythonwhat is the desired output then
if you really need exactly that module...
create a file named camelcase.py and put in this code:
https://paste.pythondiscord.com/HLFA
That's the code from the pip module you're trying to install
because the first letter should be lowercase and the underscore at the beginning should stay
oh
hmm also an underscore at the end should be there ๐ค
what underscore at the end
this was the excercise
import camelcase
c = camelcase.CamelCase()
txt = "hello world"
print(c.hump(txt))
"next_" should stay as "next_"
my guess is that you have multiple versions installed on your computer
try pip3 for the install perhaps
1:~$ pip3 install camelcase
Requirement already satisfied: camelcase in ./anaconda3/lib/python3.11/site-packages (0.2)
so then it's an issue in how you are running your file
which means you definitely have more than on version of python present
how are you running the python file? what command are you using?
ok how do I remove or delete
it was someone that told me to install it
when I already had it
hmm didnt know it could be a problem with linux if you try do double isntall that it can become a error
why does it allow that it to be double installed ?
it's not an error, you are just installing and running different versions
again: what command are you using to run your script?
didnt know of it in windows or mac
Im your spyder
but I dont understand this, when trying install , can I only do it in terminal or can I do it in spyder aswerll ? Because Ive been trying on both
Im trying to understand this Im still new
spyder and pip seem to be using different installed pythons
pip installs in anaconda, and spyder probably uses something else
I sadly don't know anything about spyder
in spyder you can try to use at the top of your python file:
import sys
print(sys.executable)
that should show the exact path to the python you're using
/usr/bin/python3
okay, that's a global python.. not sure you can easily install with pip using that... hmmm
/usr/bin/python3 -m pip --user camelcase
you might have to potentially create a venv (which I recommend anyway) .. but no idea how to tell spyder to use a specific python
NameError: name 'usr' is not defined
That command goes to the command line / terminal. Not the python terminal
ok, output was tthere is no such file or catalog
rly cool, can i use this?
well it's not 100% correct in implemenation, and sure ig, I just wrote it quickly as reference here
thanks
you should fix it for trailing underscore
yea, i can def do that if i us it
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.