Typing Casting in Python Question [closed]

南笙酒味 提交于 2019-12-07 01:42:31

Types are determined at runtime in Python. Thus, there is typically less "code hinting" (I assume you mean completion, navigation, and so forth) in IDEs. There is still some.

Related: a commonly used IDE for Python development with some hinting is Eclipse (or Aptana) with pydev. Some installation instructions.

There is no type casting in Python, as types are dynamic, so casting is completely pointless. Your IDE will give hints if it can figure out what type it is, which it often can't.

Your best bet is to use logging. Python has a default logging module (with five strict levels: debug, info, error, etc), but I prefer my own tagalog (which supports n arbitrary tags on log messages).

With python logging module:

import logging

for foo in foo_list:
    logging.log(type(foo))

With tagalog:

import tagalog

for foo in foo_list:
    tagalog.log(type(foo))

Either of these approaches will write entries to a log. The output location for tagalog is always a file, which is specified in the 'log_file_path' variable here. The output location for Python's logging module (docs here) depends on your configuration.

To watch a file in realtime, do this in the linux/unix/mac terminal:

tail -f /path/to/file

Figured this out, Python deal with classes a little more intelligently

In Actionscript

for ( var f in itemArray ) {
   // call function in f
   FooObject(f).doSomething()
}

In Python

for FooObject in itemArray: 
    # call function
    FooObject.foo()
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!