Re: just started

2017-01-11 Thread metal . suomi
along the above discussion, resuming my python after the Xmas break (hope you had a nice one!) I want to install a number of scientific libraries, but I'm confused which packages it contains what. 1) I see on scipy.org that scipy contains scipy library (fine, it makes sense), along with other

Re: just started

2016-12-19 Thread metal . suomi
> In theory, "pip3" will install into the default "python3", whichever > that is. However, in practice, it's entirely possible that it installs > into a very different Python from the one you're expecting. The most > reliable form is the latter; whatever command you use to start Python, > add "-m p

read a table and make a basic plot

2016-12-18 Thread metal . suomi
Hi, I'm learning python and full of extensive tutorials around. Getting a bit lost and overflowed in my head with tuples, dictionaries, lists, etc ... etc... Everything great, but I'd like to perform some basic task while learning the rest. For example, I'm having a hard time to find some practi

just started

2016-12-15 Thread metal . suomi
Hi everybody, I have just installed python 3.5.2 (downloaded from https://www.python.org/) on my mac (El Capitan). 1) I see from command line that older version of python are already available on my machine (python, python2.6, python2.7, python3, python3.5). I guess some might have been instal

How to implement Varient/Tagged Unions/Pattern Matching in Python?

2009-12-02 Thread metal
I want to get pattern matching like OCaml in python(ref:http:// en.wikipedia.org/wiki/Tagged_union) I consider the syntax: def decl(): def Plus(expr, expr): pass def Minus(expr, expr): pass def Times(expr, expr): pass def Divide(expr, expr): pass def Value(

Re: join , split question

2009-11-05 Thread metal
On 11月6日, 上午8时34分, metal wrote: > On 11月4日, 下午5时39分, elca wrote: > > > Hello, > > i have some text file list such like following format. > > i want to change text format to other format. > >  i was upload it pastebin sitehttp://elca.pastebin.com/d71261168 > &g

Re: join , split question

2009-11-05 Thread metal
On 11月4日, 下午5时39分, elca wrote: > Hello, > i have some text file list such like following format. > i want to change text format to other format. >  i was upload it pastebin sitehttp://elca.pastebin.com/d71261168 > > if anyone help ,much appreciate thanks in advance > -- > View this message in > c

Re: parse a string (Cadence Allegro Netlist) to dictionary

2009-11-05 Thread metal
On 11月6日, 上午4时02分, Leland wrote: > Hi, > > I always use readline(), strip(), split() and so on to parse a string. > Is there some elegant way to parse the following string into a > dictionary {'50MHZ_CLK_SRC' : 'U122.2, R1395.1'}? > > NET_NAME > '50MHZ_CLK_SRC' > '@TEST_LIB.TEST(SCH_1):50MHZ_CLK_

Re: About one class/function per module

2009-11-01 Thread metal
On 11月2日, 上午9时27分, Peng Yu wrote: > On Sun, Nov 1, 2009 at 7:02 PM, alex23 wrote: > > On Nov 2, 8:11 am, Peng Yu wrote: > >> I prefer organized my code one class/function per file (i.e per module > >> in python). I know the majority of programmers don't use this > >> approach. Therefore, I'm won

Re: If a class Child inherits from Parent, how to implement Child.some_method if Parent.some_method() returns Parent instance ?

2009-10-30 Thread metal
On 10月30日, 下午4时44分, Bruno Desthuilliers wrote: > metal a écrit : > > > The actual situation is I'm coding with a immuable set-like datatype > > XSet which supports XSet(['al']) & XSet(['ah'] = XSet(['ax'] > > I assume it was &

Re: If a class Child inherits from Parent, how to implement Child.some_method if Parent.some_method() returns Parent instance ?

2009-10-30 Thread metal
On 10月30日, 上午8时03分, metal wrote: > The actual situation is I'm coding with a immuable set-like datatype > XSet which supports XSet(['al']) & XSet(['ah'] = XSet(['ax'] if I > declare ax is consists of al and ah > A typo, XSet(['al']) |

Re: Modify dict/set during iteration?

2009-10-29 Thread metal
On 10月30日, 上午11时59分, Steven D'Aprano wrote: > On Thu, 29 Oct 2009 19:02:01 -0700, metal wrote: > > I used this quickndirty way, any good idea to solve this problem? > > It's not a problem that wants solving, it's a feature that wants paying > attention to. >

Modify dict/set during iteration?

2009-10-29 Thread metal
I used this quickndirty way, any good idea to solve this problem? def miter(iterable): cache = set() while True: try: for x in iterable: if x not in cache: cache.add(x) yield x break except Runt

Re: '11' + '1' is '111'?

2009-10-29 Thread metal
On 10月30日, 上午9时03分, Benjamin Peterson wrote: > metal gmail.com> writes: > > > > > '11' + '1' == '111' is well known. > > > but it suprises me '11'+'1' IS '111'. > > > Why? Obviously they are two d

Re: '11' + '1' is '111'?

2009-10-29 Thread metal
On 10月30日, 上午8时49分, Chris Rebert wrote: > On Thu, Oct 29, 2009 at 5:43 PM, metal wrote: > > '11' + '1' == '111' is well known. > > > but it suprises me '11'+'1' IS '111'. > > > Why? Obviously they

'11' + '1' is '111'?

2009-10-29 Thread metal
'11' + '1' == '111' is well known. but it suprises me '11'+'1' IS '111'. Why? Obviously they are two differnt object. Is this special feature of imutable object? -- http://mail.python.org/mailman/listinfo/python-list

Re: If a class Child inherits from Parent, how to implement Child.some_method if Parent.some_method() returns Parent instance ?

2009-10-29 Thread metal
The actual situation is I'm coding with a immuable set-like datatype XSet which supports XSet(['al']) & XSet(['ah'] = XSet(['ax'] if I declare ax is consists of al and ah "That" means I can't explian it very well 'cause my english... Now I try to make some mess like this...I know it's not good to

If a class Child inherits from Parent, how to implement Child.some_method if Parent.some_method() returns Parent instance ?

2009-10-29 Thread metal
Consider the following: class Parent: def some_method(self): return Parent(...) class Child: def some_method(self): ... return Parent.some_method(self)

strange behaviour when inheriting from tuple

2009-10-12 Thread metal
Environment: PythonWin 2.5.4 (r254:67916, Apr 27 2009, 15:41:14) [MSC v.1310 32 bit (Intel)] on win32. Portions Copyright 1994-2008 Mark Hammond - see 'Help/About PythonWin' for further copyright information. Evil Code: class Foo: def __init__(self, *args): print args Fo

Re: strange behaviour when inheriting from tuple

2009-10-11 Thread metal
On 10月11日, 下午5时30分, ryles wrote: > On Oct 11, 3:04 am, metal wrote: > > > > > Environment: > > > PythonWin 2.5.4 (r254:67916, Apr 27 2009, 15:41:14) [MSC v.1310 32 bit > > (Intel)] on win32. > > Portions Copyright 1994-2008 Mark Hammond - see 'Hel

Why ELIF?

2009-10-10 Thread metal
I wonder the reason for ELIF. it's not aligned with IF, make code ugly IMHO OR maybe better? if foo == bar: ... or foo == baz: ... or foo == bra: ... else: ... -- http://mail.python.org/mailman/listinfo/python-list

Can not dump class object created on runtime

2009-06-10 Thread Metal Zong
Hello, Can not dump class object created on runtime. Is there anybody can help me? Thank. Following is testing code: import pickle from new import classobj class A: def __str__(self): return self.__class__.name if __name__ == "__main__": c = classobj('B', (A, ), {}) # crea

RE: regex help

2008-06-30 Thread Metal Zong
>>> import re >>> >>> if __name__ == "__main__": ... lst = [281, 713, 832, 1281, 1713, 1832, 2281, 2713, 2832] ... for item in lst: ... if re.match("^1?(?=281)|^1?(?=713)|^1?(?=832)", str(item)): ... print "%d invalid" % item ... else: ... print "%d v

is operator

2008-03-10 Thread Metal Zong
The operator is and is not test for object identity: x is y is true if and only if x and y are the same objects. >>> x = 1 >>> y = 1 >>> x is y True Is this right? Why? Thanks. -- http://mail.python.org/mailman/listinfo/python-list

RE: [help] Is it true to call obj.__str__() while executing "printobj"?

2006-11-30 Thread Metal Zong
Thanks. Please refer to following snipt: 1 >>> class Printable(type): 2 ... def __str__(cls): 3 ... return "This is class %s" % cls.__name__ 4 ... 5 >>> class C(object): 6 ... __metaclass__ = Printable 7 ... 8 >>> 9 >>> C.__str__ 10 11 >>> 12 >>> print C 13 This is class C I see,