Python Forum
what does x reprsent in this code ?
Thread Rating:
  • 1 Vote(s) - 1 Average
  • 1
  • 2
  • 3
  • 4
  • 5
what does x reprsent in this code ?
#21
does anyone knows ?
help is much appreciated...
Reply
#22
That depends on the specifics of your system, not on python itself.

But in general, you don't want to uninstall packages that you didn't install yourself. There might be hidden dependencies that just assume that some ancient version of python is there and runnable.

Better to just put the version on that you want, and make sure it's in your PATH so you run it. You can ignore the other packages on the system. Other than a bit of disk space, I see no benefit to removing the system-installed packages.
Reply
#23
okay,
if i write - pip3 --version
it shows me the following:

Output:
pip 8.1.1 from /usr/lib/python3/dist-packages (python 3.5)
so it shows that the pip3 version for python3.5 is 8.1.1
while if i check - pip --version
it shows:

Output:
pip 20.0.2 from /home/tal/.local/lib/python2.7/site-packages/pip (python 2.7)
so what i wanna have is the latest pip version, on python3.5

any advice ?
Reply
#24
another quiz,
in the following code:

class MyNumbers:
  def __iter__(self):
    self.a = 1
    return self

  def __next__(self):
    if self.a <= 20:
      x = self.a
      self.a += 1
      return x
    else:
      raise StopIteration

myclass = MyNumbers()
myiter = iter(myclass)

for x in myiter:
  print(x)
i see that in line 14 - myclass = Mynumbers() - as i understand it - myclass is a new variable ? which is assigned the value of the class MyNumbers ?
but then how is it that the class is being wrote with () - (that's a function feature, isn't it ?)
Reply
#25
myclass is a variable which is assigned the value of an object of type MyNumbers(). mclass is a bad variable name. You are correct that () causes MyNumbers() to do something. This time it causes python to create a new object of type MyNumbers. If MyNumbers had an __init__ method/function that would get executed at this time.

This is a new question. You should have started a new thread.
Reply
#26
thank you !

should i start a new thread for every question ? this seems to be a very similar question, i think, like - a nuance
Reply
#27
If it is really similar to a previous question, then no. However you started out with "what does x do in this code?"
thisset = {"apple", "banana", "cherry"}
 
for x in thisset:
  print(x)
When you find yourself typing "another quiz" that is an indication it is time for another thread.
Reply
#28
hehe...okay !
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020