[SciPy-User] ERROR : while finding size

Hector hector1618@gmail....
Thu Mar 3 03:17:53 CST 2011


On Thu, Mar 3, 2011 at 2:16 PM, ESKalaiyarasan <eskalaiyarasan@gmail.com>wrote:

> hi,
>    I am Kalaiyarasan.I am doing my graduate degree in anna university
> chennai.I am using python pylab for my project.
>
> in matlab we can get input from user using x=input() command similarly in
> python we use x=raw_input() command
>

Hello Kalaiyarasan,
This is an information about raw_input function( I strongly recommend you to
switch to IPython if you are not using it yet). The point I would like to
highlight is that, raw input returns the *string* and hence may not be very
useful if you are looking for an matrix input.

In [17]: raw_input?
Type:        builtin_function_or_method
Base Class:    <type 'builtin_function_or_method'>
String Form:    <built-in function raw_input>
Namespace:    Python builtin
Docstring:
    raw_input([prompt]) -> string

    Read a string from standard input.  The trailing newline is stripped.
    If the user hits EOF (Unix: Ctl-D, Windows: Ctl-Z+Return), raise
EOFError.
    On Unix, GNU readline is used if enabled.  The prompt string, if given,
    is printed without a trailing newline before reading.




>
>
> but i want to how to know size of data, in matlab we use size(x) command
> return size (example 3 X 2). what is command for python?
>
>
And with the sting you can always use len(a) function to know the length of
string.

In [18]: a = raw_input()
343

In [19]: type(a)
Out[19]: <type 'str'>

In [20]: len(a)
Out[20]: 3

The additional tool I know in this regard is

In [21]: a = int(raw_input())
232

In [22]: type(a)
Out[22]: <type 'int'>

Hope this will help you a bit.
But I am not an expert here so there is a good chance that someone else can
give you better answer.


>
> please help me.
>
>
>
> -Kalaiyarasan
>
>
For the  rest of group, kindly save me from misguiding  him if I am not
right.

> _______________________________________________
> SciPy-User mailing list
> SciPy-User@scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
>
>


-- 
-Regards
Hector

Whenever you think you can or you can't, in either way you are right.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/scipy-user/attachments/20110303/9a77890e/attachment.html 


More information about the SciPy-User mailing list