[R] Is there anyone who uses both R and Python here? How do you debug? Perhaps in RStudio?

C W tmr@g11 @end|ng |rom gm@||@com
Tue Jan 26 20:29:22 CET 2021


Hello all,

I'm a long time R user, but recently also using Python. I noticed that
RStudio rolled out Python through reticulate. It's great so far!

My question is, how do you debug in Python?

In R, I simply step through the code script in my console with cmd+enter.
But you can't do that with Python, some of them are objects.

Here's my example.
class person:
     def __init__(self, id, created_at, name, attend_date, distance):
          """Create a new `person`.
          """
          self._id = id
          self.created_at = created_at
          self.name = name
          self.attend_date = attend_date
          self.distance = distance

     @classmethod
          def get_person(self, employee):
          """Find and return a person by.
          """
          return person(employee['created_at'],
               employee['id'],
               employee['name'],
               employee['attend_date'],
               employee['distance']
               )

The error message says self._id was 'str', but expecting an 'int'. I can't
do:
> self._id = 5
I guess it's "hidden". Can't really assign and test like that.

It seems hardcore Python programmers just use a debugger, and do not
understand the greatness of interactive IDE and console. I'd still like to
stay in IDE, hopefully.

So, how are the R users coping with object classes? Do you just instantiate
every time? What if you got 10 of these class person objects to debug?

I know this may be a Python question. But, I really wanted to see from a R
user's working experience.

Thanks a lot,

Mike

	[[alternative HTML version deleted]]



More information about the R-help mailing list