a = 5
print(a.__class__.__name__)
int
b = 5.0
print(b.__class__.__name__)
float
Thank you very much! :)
^Bart
--
https://mail.python.org/mailman/listinfo/python-list
then within that for the name like this:
>>> a = 5
>>> print(a.__class__.__name__)
int
>>> b = 5.0
>>> print(b.__class__.__name__)
float
-Original Message-
From: Python-list On
Behalf Of Avi Gross
Sent: Sunday, February 10, 2019 5:43 PM
To: python-lis
Without using regular expressions, if you just want to extract the word
"int" or "float" you can substring the results by converting what type says
to a string:
>>> a = 5
>>> str(type(a))[8:11]
'int'
>>> a=5.0
>>> str(type(a))[8:13]
'float'
Since the format and length vary, this may not meet you
On Mon, Feb 11, 2019 at 8:46 AM ^Bart wrote:
>
> I need to print something like "this variable is int" or "this variable
> is string"
>
> n1 = 10
> n2 = 23
>
> print ("Total of n1+n2 is: ",n1+n2," the type is", type(n1+n2))
>
> When I run it I have:
>
> Total of n1+n2 is: 33 the type is
> >>>
En Tue, 22 May 2007 12:00:48 -0300, Joel Andres Granados
<[EMAIL PROTECTED]> escribió:
> I have been working with the universal_newlines option that can be
> specified while using the subprocess module. I'm calling an app that
> uses sys.stdout.write('\r'+' '*80) to manage its stdout. The sit
BJörn Lindqvist wrote:
Because it contains more non-significant symbols (, ), { and } that
"steal" the programmers attention. But consider
def f(x, y, z)
print x, y, z
to
def f(x, y, z):
print x, y, z
IMHO, the colon-less variant is more readable than the one with the colon.
Except that i
In <[EMAIL PROTECTED]>, bruno modulix wrote:
>
> In fact, from a purely technical POV, the ':' could have been omitted
> from the Python syntax, since indentation does the whole job of defining
> blocks. It's only here for readability AFAIK.
>
The ':' serves as a very good hint to "python awa
On Mon, 29 Nov 2004 01:12:16 -0500, Jeremy Bowers wrote:
> The only punctuation you *need* is whitespace. See Forth (I don't know
> if this is perfect but I'd bet the transform is simple),
: Announce ." Forth has a fair bit of punctuation" ;
--
http://mail.python.org/mailman/listinfo/python-list
A two-fer.
On Mon, 29 Nov 2004 10:28:42 +0800, Isaac To wrote:
>> "Greg" == Greg Ewing <[EMAIL PROTECTED]> writes:
>
> >> The only punctuation you *need* is whitespace. See Forth
>
> Greg> You don't even need that... see FORTRAN. :-)
Well, I for one don't like reading large program
> "Greg" == Greg Ewing <[EMAIL PROTECTED]> writes:
>> The only punctuation you *need* is whitespace. See Forth
Greg> You don't even need that... see FORTRAN. :-)
And you don't need everything else either... see this.
http://compsoc.dur.ac.uk/whitespace/
:-)
Regard
Jeremy Bowers wrote:
The only punctuation you *need* is whitespace. See Forth
You don't even need that... see FORTRAN. :-)
DOI=1TO10-ly,
--
Greg Ewing, Computer Science Dept,
University of Canterbury,
Christchurch, New Zealand
http://www.cosc.canterbury.ac.nz/~greg
--
http://mail.python.org/
On Sun, 28 Nov 2004, [ISO-8859-1] BJörn Lindqvist wrote:
> In the faq,
> http://www.python.org/doc/faq/general.html#why-are-colons-required-for-the-if-while-def-class-statements,
> it is stated that the colon is there "primarily to enhance readability
> (one of the results of the experimental ABC
12 matches
Mail list logo