Question
Python This should be done using python function not by hand You are working on a large-scale software project involving thousands of different Python files.
Python
This should be done using python function not by hand
You are working on a large-scale software project involving thousands of different Python files. The files have been written by different programmers and the naming of functions is somewhat inconsistent. You receive a new directive stating that the function names all have to be in camel case. In camel case, function names consisting of multiple words have a capital letter in each word and most underscores are removed. For instance, def MyArithmeticCalculator is in camel case but def my_arithmetic_calculator is not in camel case.
To implement this, write a function camel_case(code) that takes as input a string code that represents the Python code. It is typically a multi-line Python string. Your function needs to return the tuple (d, newcode)
(code: is a multiline input string )
How to convert a given function to camel case in python? for example
def sum_two_digits(a, b): return a + b print(sum_two_digits(10, 20))
THE potential function should process the above function and return it in camel case like below:
def SumTwoDigit(a, b): return a + b print(SumTwoDigit(10, 20))
the nested dictionary is
The nested dictionary is given by d = {'sum_two_digits': {'hash':-9214996652071026704, 'camelcase':'SumTwoDigits', 'allcaps':'SUM_TWO_DIGITS'} }
If the function name starts with _ like
_sum_digits(a,b)
it should be converted to _SumDigits(a,b)
if the function name is already in camel case leave it as its.
function needs to return the tuple (d, newcode): d is a nested dictionary where each key corresponds to the original function name. The value is a nested dictionary that has the following items: o hash: hash code of the original function name (tip: use Python's hash function) o camelcase: camel case version of original function name o allcaps: all caps version of original function name newcode is a string containing the code wherein all function names have been renamed by their camel case versions. Note that you need to change the function name and also all other locations where the function name is used (e.g. function calls). You should not change anything else in the code (e.g. the contents of any strings).
WITH EXPLAINTATION PLEASE
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started