Strongly typed list

  • Thread starter هاني الموصلي
  • Start date
Ù

هاني الموصلي

Hello, I am using eclips for python and i am facing a problem. I have
many classes with many properties and want a list of objects from one
of my declared classes. The problem is:When i am accessing any item
from the list, the IDE does not know it's type because in python we do
not declare the variable with it's type, so there is no auto complete
and i have to go to the class to copy the attribute name. To make idea
more clear:

class AutomataBranch(object):
def __init__(selfparams):
self.Name="";
self.nodes=[];

class LanguageAutomata(object):
def __init__(selfparams):
self.cfgAutomata=[];#This has AutomaBranch Type
Now in any method in LanguageAutomata class if i wrote: cfgAutomata.
Then it wont give me the Name attribute Is there any solution for
that?
Perhaps of there is some thing like C# List<AutomataBranch>
cfgAutomata such that the list wont accept items unless they are
AutomataBranch will be good.
 
F

Fabio Zadrozny

Hello, I am using eclips for python and i am facing a problem. I have
many classes with many properties and want a list of objects from one
of my declared classes. The problem is:When i am accessing any item
from the list, the IDE does not know it's type because in python we do
not declare the variable with it's type, so there is no auto complete
and i have to go to the class to copy the attribute name. To make idea
more clear:

class AutomataBranch(object):
   def __init__(selfparams):
       self.Name="";
       self.nodes=[];

class LanguageAutomata(object):
   def __init__(selfparams):
       self.cfgAutomata=[];#This has AutomaBranch Type
Now in any method in LanguageAutomata class if i wrote: cfgAutomata.
Then it wont give me the Name attribute Is there any solution for
that?
Perhaps of there is some thing like C# List<AutomataBranch>
cfgAutomata such that the list wont accept items unless they are
AutomataBranch will be good.


Hello,

Unfortunately, right now there is no way to gather that specific code
completion in pydev -- because of the dynamic nature of python, that
info is very hard to get.

Best Regards,

Fabio
 
Ù

هاني الموصلي

Please could you lead me to a way or a good IDE that makes developing
huge projects in python more easier than what i found.Now i am using
eclips. Actually it is very hard to remember all my classes methods
and attributes or copy and paste them each time.
Thanks very much for your interest
Hani Almousli.....
 
J

Jonathan Gardner

Please could you lead me to a way or a good IDE that makes developing
huge projects in python more easier than what i found.Now i am using
eclips. Actually it is very hard to remember all my classes methods
and attributes or copy and paste them each time.
Thanks very much for your interest
Hani Almousli.....

You're relying on your IDE too much. You should rely on the code and
on your own notes. Your project should never get big because there is
no reason to throw in a bunch of useless code.

Think of the simplest way to get your job done. Then write that in
pseudo-code. Finally, run it in Python to see if it actually works.
You may be surprised with how far that will get you.

If you are having problems remembering the attributes and methods of
your instances, you are probably using too many attributes and
methods, their names are too long, or you have too many arguments to
each method. Keep the interfaces between parts as simple as possible.

If you still have a big project, then break it up into several
smaller, re-usable, and independent modules. Keep the interfaces as
simple as possible, and never write code that does anything but Duck-
Typing.
 
D

Diez B. Roggisch

هاني الموصلي said:
Please could you lead me to a way or a good IDE that makes developing
huge projects in python more easier than what i found.Now i am using
eclips. Actually it is very hard to remember all my classes methods
and attributes or copy and paste them each time.
Thanks very much for your interest
Hani Almousli.....

There are many really big projects written in Python - none of them with
the aid of intelli-sense.

What python lacks in that respect due to it's dynamic typing, it more
than compensates by being faster to develop and having to write much
less code.

Diez
 
A

Albert Hopkins

There are many really big projects written in Python - none of them with
the aid of intelli-sense.

What python lacks in that respect due to it's dynamic typing, it more
than compensates by being faster to develop and having to write much
less code.

But this class can do *anything*! It .slice()s.. It .dice()s...


.... sorry, couldn't resist ;-)

-a
 
Ù

هاني الموصلي

I think i found a good managable solution. Actually it is trivial but
may help (I used it now).
When i wnat to access the list then i assign the object which i want
to access to a variable ex:
1)x=AutomataBranch()
2)x=self.cfgAutomata

The first line is used only to make the IDE knows that x is from
AutomatBranch type.After that when i press x. then all methods and
properties are visualized.

I think it is some how good.
 
D

Diez B. Roggisch

هاني الموصلي said:
I think i found a good managable solution. Actually it is trivial but
may help (I used it now).
When i wnat to access the list then i assign the object which i want
to access to a variable ex:
1)x=AutomataBranch()
2)x=self.cfgAutomata

The first line is used only to make the IDE knows that x is from
AutomatBranch type.After that when i press x. then all methods and
properties are visualized.

I think it is some how good.


Unless x=AutomataBranch() is something that is expensive. And to be honest:
changing code (possibly introducing bugs!!!) to work around short-comings
in either your IDE or your way you insist to work strikes me as odd.

I understand the desire to have autocompletion. But it's not *that*
important. Maybe fabrio (who's maintaining the PyDev-eclipse-plugin) could
be asked to add something like this:

#@x:AutomataBranch

to the plugin - so that when pydev reads that comment, it has a hint on what
to use for autocompletion.

Diez
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top