Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #52986

Re: Checking homogeneity of Array using List in Python

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'string.': 0.05; 'subject:Python': 0.06; 'list?': 0.07; 'referring': 0.07; 'string': 0.09; '[1,': 0.09; 'interpreted': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:using': 0.09; 'used.': 0.09; 'array.': 0.16; 'assumptions': 0.16; 'decimal.': 0.16; 'element.': 0.16; 'fit,': 0.16; 'function?': 0.16; 'illustrates': 0.16; 'multiplies': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'do,': 0.16; 'wrote:': 0.18; 'code.': 0.18; 'trying': 0.19; 'advance.': 0.19; 'else,': 0.19; 'help.': 0.21; 'seems': 0.21; 'input': 0.22; 'example': 0.22; 'header:User-Agent:1': 0.23; 'error': 0.23; 'skip': 0.24; 'header:X-Complaints-To:1': 0.27; 'function': 0.29; 'array': 0.29; 'characters': 0.30; 'code': 0.31; 'getting': 0.31; "skip:' 10": 0.31; 'produces': 0.31; 'values.': 0.31; 'lists': 0.32; 'another': 0.32; 'entirely': 0.33; 'could': 0.34; 'but': 0.35; 'there': 0.35; 'false': 0.36; 'subject:List': 0.36; 'doing': 0.36; 'charset:us-ascii': 0.36; 'wrong': 0.37; 'being': 0.38; 'minimum': 0.38; 'thank': 0.38; 'form,': 0.38; 'somebody': 0.38; 'to:addr:python-list': 0.38; 'list,': 0.38; 'to:addr:python.org': 0.39; 'enough': 0.39; 'unable': 0.39; 'received:org': 0.40; 'how': 0.40; "you're": 0.61; "you'll": 0.62; 'making': 0.63; 'email addr:gmail.com': 0.63; 'show': 0.63; 'note:': 0.66; 'default': 0.69; 'as:': 0.81; 'characters,': 0.84; 'ideas.': 0.84; 'presumably': 0.84; 'either:': 0.91
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Dave Angel <davea@davea.name>
Subject Re: Checking homogeneity of Array using List in Python
Date Sun, 25 Aug 2013 20:49:57 +0000 (UTC)
References <39cf54bd-3772-448a-a56e-74e0b3cc8017@googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset=US-ASCII
Content-Transfer-Encoding 7bit
X-Gmane-NNTP-Posting-Host 174.32.174.33
User-Agent XPN/1.2.6 (Street Spirit ; Linux)
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.226.1377463819.19984.python-list@python.org> (permalink)
Lines 54
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1377463819 news.xs4all.nl 15989 [2001:888:2000:d::a6]:52534
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:52986

Show key headers only | View raw


sahil301290@gmail.com wrote:

> I am unable to check homogeneity of Array.
> I have take Array type Int to be default for my code.
>
> Instead of getting Error on NON-INT Values.

But none of them below are int values.

> I want to take input as string.
> Then check if all input is in (0-9) form, I typecast it into int and Accept.
> Else, I would like to skip that input.
>
> eg. my input is ['1', ' ', 'asdasd231231', '1213asasd', '43242']
> I want it to be interpreted as:
> [1, [None], [None], [None], 43242]
>
> NOTE: NO INBUILT FUNCTION BE USED. Thank you in advance.

I don't see any Arrays.  You show a list, however.  Lists don't have any
type for the whole list, only for each element.

Seems to me like the minimum functions you'll need are int(), type(),
isinstance().  They're built-in, not inbuilt, so perhaps that's okay. 
Or perhaps you're going to write your own equivalents.  But your example
contradicts your description enough that I could be wrong about any of
the three.

> > I want to take input as string.

So why do you show it as a list?

Do you know how to write a function?  Try writing one that takes  a
string and returns True if all the characters are digits, and False if
either:
   1) there are no characters
   2) there are some non-digit characters

Try writing another one that takes a string made up entirely of digit
characters, and produces an int from them.  Note you'll be doing some
multiplies by 10, since presumably you're working in decimal.  You could
call this function my_int()

Write some code that actually illustrates what you're trying to do, show
some data being fed into it, and indicate where you ran out of ideas.
Then somebody could perhaps help.  As it stands, you're referring to
types that don't fit, and making assumptions that make no sense.



-- 
DaveA

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Checking homogeneity of Array using List in Python sahil301290@gmail.com - 2013-08-24 22:50 -0700
  Re: Checking homogeneity of Array using List in Python Chris Angelico <rosuav@gmail.com> - 2013-08-25 16:03 +1000
  Re: Checking homogeneity of Array using List in Python Joel Goldstick <joel.goldstick@gmail.com> - 2013-08-25 11:54 -0400
  Re: Checking homogeneity of Array using List in Python Dave Angel <davea@davea.name> - 2013-08-25 20:49 +0000
  Re: Checking homogeneity of Array using List in Python Neil Cerutti <neilc@norwich.edu> - 2013-08-26 13:49 +0000
    Re: Checking homogeneity of Array using List in Python Joshua Landau <joshua@landau.ws> - 2013-08-26 23:39 +0100
      Re: Checking homogeneity of Array using List in Python Neil Cerutti <neilc@norwich.edu> - 2013-08-27 12:03 +0000

csiph-web