Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Assigning datatype to variable in python
QtWS25 Last Chance

Assigning datatype to variable in python

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 562 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Ravi_exact
    wrote on last edited by
    #1

    Hi,

    I've created new signal , where i specify list and object datatype.

    dataChanged = QtCore.Signal(list, object)

    But list and object datatype don't convey properly that what will be in list and in the object.
    So it would be good if we could declare something like this,

    dataChanged = QtCore.Signal(lst_employees, obj_sender)

    so that, if anyone sees the code, would understand easily. But i don't know it's possible in Python or not.

    But i have done something like this, i don't know this is correct or not

    lst_employees = list
    obj_sender = object

    dataChanged = QtCore.Signal(lst_employees, obj_sender)

    Is this right and pythanic way to use ? Please guide me.

    Thanks
    Ravi

    1 Reply Last reply
    0
    • jazzycamelJ Offline
      jazzycamelJ Offline
      jazzycamel
      wrote on last edited by
      #2

      Python is a dynamically typed language and its containers and collections are not constrained to contain only one type of data therefore aliasing the list type with your own name doesn't really achieve anything and is certainly not Pythonic. You should provide a comment in your code above the signal definition to describe what you expect the signal arguments to contain if you feel it necessary:

      @

      dataChanged(list employees, object sender) [signal]

      dataChanged=QtCore.Signal(list, object)
      @

      Hope this helps ;o)

      For the avoidance of doubt:

      1. All my code samples (C++ or Python) are tested before posting
      2. As of 23/03/20, my Python code is formatted to PEP-8 standards using black from the PSF (https://github.com/psf/black)
      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved