Timeit

2009-02-18 Thread cokofreedom
I've having an annoying problem at the moment. I'm writing code for the travelling salesmen problem and comparing different techniques. But I've having a problem using timeit. I have a file called testplatform.py that contains 4 class: Test() - which is called first to create the cities/routes to

Re: def X(l=[]): weirdness. Python bug ?

2008-08-22 Thread cokofreedom
On Aug 22, 11:13 am, Bart van Deenen [EMAIL PROTECTED] wrote: Hi all. I've stumbled onto a python behavior that I don't understand at all. Python 2.5.2 (r252:60911, Jul 31 2008, 17:28:52) # function def X(l=[]):    l.append(1)    print l # first call of X X() [1] #second call of X

Re: Weird expression result

2008-08-18 Thread cokofreedom
On Aug 18, 5:57 pm, George Sakkis [EMAIL PROTECTED] wrote: I'm probably missing something obvious but I can't put my finger on it: (3 in [3]) == True True 3 in ([3] == True) Traceback (most recent call last): File stdin, line 1, in module TypeError: argument of type 'bool' is not

Re: benchmark

2008-08-11 Thread cokofreedom
On Aug 11, 10:55 am, [EMAIL PROTECTED] wrote: On Aug 10, 10:10 pm, Kris Kennaway [EMAIL PROTECTED] wrote: jlist wrote: I think what makes more sense is to compare the code one most typically writes. In my case, I always use range() and never use psyco. But I guess for most of my work

Re: benchmark

2008-08-08 Thread cokofreedom
On Aug 8, 9:08 am, alex23 [EMAIL PROTECTED] wrote: On Aug 8, 2:49 pm, Dhananjay [EMAIL PROTECTED] wrote: Is it that a question of time and effort, or is there something that doesn't make it appropriate to python ? I don't think I've ever seen anyone who has raised concerns about the speed

Re: benchmark

2008-08-07 Thread cokofreedom
Honestly, performance benchmarks seem to be the dick size comparison of programming languages. But in the honour of dick size: http://shootout.alioth.debian.org/gp4/benchmark.php?test=alllang=all http://shootout.alioth.debian.org/debian/benchmark.php?test=alllang=all --

Re: Attack a sacred Python Cow

2008-07-25 Thread cokofreedom
By that logic, C++ is not OO. By that logic, Ruby is not OO. By that logic, I know of only one OO language: Java :) The fact that a language doesn't force you to do object-oriented programming doesn't mean that it's not object-oriented. In other words, your words are nonsense. No, what it

Re: Attack a sacred Python Cow

2008-07-24 Thread cokofreedom
Please understand that I'm not arguing about this particular design choice (and FWIW, I'd mostly agree on the point that having a != b different from not (a == b) is actually a wart). I'm just correcting your statement about the behaviour of __eq__ / __ne__ not being documented, which is

Re: New to Python, familiar with Perl - Seeking info sources

2008-07-24 Thread cokofreedom
On Jul 24, 3:53 pm, Brett Ritter [EMAIL PROTECTED] wrote: After many years happily coding Perl, I'm looking to expand my horizons. [no flames please, I'm pretty aware of Perl's strengths and weaknesses and I'm just here to learn more, not to enter religious debates]. I've gone through some

Re: Attack a sacred Python Cow

2008-07-24 Thread cokofreedom
My words aren't as clear as they should be. I mean that Python lets *you* do something without documenting, or rather stating to use a better term, that your intention is the non-obvious one. I'm not saying that Python itself lacks documentation for its own behaviour; I'm saying it should

Re: Python Written in C?

2008-07-22 Thread cokofreedom
On Jul 22, 5:59 am, Larry Bates [EMAIL PROTECTED] wrote: Grant Edwards wrote: On 2008-07-22, Larry Bates [EMAIL PROTECTED] wrote: You talk about writing it in assembly language for each MPU chip. Actually it is even better than that. We now have these modern inventions, called

Re: What is the role of python2.6 and C++?

2008-07-21 Thread cokofreedom
On Jul 21, 10:17 am, 甜瓜 [EMAIL PROTECTED] wrote: Howdy, I'm confused about the motivation of releasing python2.6 and python3.0 at the *same* time. IMO, 2.6 should be compatible with 2.5 while 3.0 is new style python. Currenly, most python projects works fine in 2.5. When 3.0 becomes final

Re: Beginner Question : Iterators and zip

2008-07-14 Thread cokofreedom
zip(*vec_list) will zip together all entries in vec_list Do be aware that zip stops on the shortest iterable. So if vec[1] is shorter than vec[0] and matches otherwise, your output line will be truncated. Or if vec[1] is longer and vec[0] matches as far as it goes, there will be no signal

Re: You, spare time and SyntaxError

2008-07-10 Thread cokofreedom
just... great !-) Thanks :) -- http://mail.python.org/mailman/listinfo/python-list

Re: Impossible to change methods with special names of instances of new-style classes?

2008-07-09 Thread cokofreedom
My question is: did something about the way the special method names are implemented change for new-style classes? class old: pass class new(object): pass testone = old() testone.__call__ = lambda : 33 testone() 33 testtwo = new() testtwo.__call__ = lambda : 33

Re: a simple 'for' question

2008-07-09 Thread cokofreedom
On Jul 9, 2:08 am, Ben Keshet [EMAIL PROTECTED] wrote: Hi fans, I want to use a 'for' iteration to manipulate files in a set of folders, something like: folders= ['1A28','1A6W','56Y7'] for x in folders: print x # print the current folder f = open('my/path/way/x/my_file.txt',

You, spare time and SyntaxError

2008-07-09 Thread cokofreedom
def ine(you): yourself = what? go = list(something), list(anything) be = something please = be, yourself yourself = great for good in yourself: if you is good: good in you please.add(more, good) else: def inition(lacks, clarity):

Re: yo...

2008-07-07 Thread cokofreedom
On Jul 7, 11:55 am, A.T.Hofkamp [EMAIL PROTECTED] wrote: On 2008-07-07, abhishek [EMAIL PROTECTED] wrote: hey guys...me nu 2 python yo...help me...by da way...jus joined inthanks Ask a specific question and you may get an answer. If you want an answer from me, it helps *a lot* if you

Re: yo...

2008-07-07 Thread cokofreedom
On Jul 7, 3:47 pm, Bruno Desthuilliers bruno. [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] a écrit : (snip) However welcome to Python and this Google Group. OT This is *not* a google group. This is the usenet newsgroup comp.lang.python, made accessible TTW by google. /OT Touche ;) --

Installing paramiko and pycrypto

2008-07-01 Thread cokofreedom
I am really stuck presently, trying to install these on my Windows XP. I have downloaded easy_install and it is now in Python25\Scripts but none of the commands I have read in either program folder have worked to install them. I was hoping someone could give me a step by step guide to installing

Re: Why is recursion so slow?

2008-06-30 Thread cokofreedom
In case anyone is interested... # Retrieved from: http://en.literateprograms.org/Fibonacci_numbers_(Python)?oldid=10746 # Recursion with memoization memo = {0:0, 1:1} def fib(n): if not n in memo: memo[n] = fib(n-1) + fib(n-2) return memo[n] # Quick exact computation of large

Re: what is meaning of @ in pyhon program.

2008-06-30 Thread cokofreedom
On Jun 28, 8:41 pm, Thierry [EMAIL PROTECTED] wrote: ie: @if os.exists(foo): etc etc and @for blah: etc etc This sounds more like PHP code, where a @ prefixing a function means that even if there are errors or warnings, you don't want to see them. Could also by

Making code more efficient and effective

2008-06-26 Thread cokofreedom
I've written up a little piece of code that isn't that foolproof to scan through a file (java presently) to find functions and then look for them throughout the document and output the name of the function, followed by how many times it appears and the lines it appears on. What I was looking for

Re: Making code more efficient and effective

2008-06-26 Thread cokofreedom
On Jun 26, 5:42 pm, [EMAIL PROTECTED] wrote: Cédric Lucantis: PAT = re.compile('^[ ]*(public|protected|private)[ ]+([a-zA-Z0-9_]+) [ ]+([a-zA-Z0-9_]+)[ ]+\((.*)\).*$') ... It might be hard to read but will avoid a lot of obscure parsing code. You can use the VERBOSE mode, to add

Re: python -regular expression - list element

2008-06-25 Thread cokofreedom
On Jun 25, 11:55 am, antar2 [EMAIL PROTECTED] wrote: Hello, I am a beginner in Python and am not able to use a list element for regular expression, substitutions. list1 = [ 'a', 'o' ] list2 = ['star', 'day', 'work', 'hello'] Suppose that I want to substitute the vowels from list2 that

Re: IDE on the level of Eclipse or DEVc++?

2008-06-25 Thread cokofreedom
On Jun 25, 12:38 pm, Jorge Godoy [EMAIL PROTECTED] wrote: Ben Finney wrote: Bruno Desthuilliers [EMAIL PROTECTED] writes: If you're into clickodroms, you may want to have a look at Eric too. As far as i'm concerned, I still wait for something that would be worth dropping emacs +

Re: Python 3000 vs Perl 6

2008-06-24 Thread cokofreedom
On Jun 24, 8:20 am, Corey G. [EMAIL PROTECTED] wrote: If Perl 6 ever does get on its feet and get released, how does it compare to Python 3000? Is Perl 6 more like Java now with Parrot? I just want to make sure that Python is staying competitive. If this is the wrong mailing list, just let

Re: String question

2008-06-24 Thread cokofreedom
On Jun 24, 5:38 am, Mark Tolonen [EMAIL PROTECTED] wrote: Andreu [EMAIL PROTECTED] wrote in messagenews:[EMAIL PROTECTED] Yes, ... don't ask me why, but in fact v1,v2,v3 = str1.split() does not seem to work. My original problem was I forgot about the parenthesis as Tim point out. So I

Re: Python 3000 vs Perl 6

2008-06-24 Thread cokofreedom
On Jun 24, 10:36 am, Corey G. [EMAIL PROTECTED] wrote: What I meant, in terms of dealing with accurate or non-accurate rumors is with speed, yes. There are plenty of comparisons where Perl is 4-15x faster then Python for 'some' operations regarding regular expressions, etc. For me

Re: binary representation of an integer

2008-06-24 Thread cokofreedom
On Jun 24, 10:38 am, Mark Dickinson [EMAIL PROTECTED] wrote: On Jun 24, 9:03 am, eliben [EMAIL PROTECTED] wrote: What would be the quickest way to do this ? I think that for dec2bin conversion, using hex() and then looping with a hex-bin lookup table would be probably much faster than the

Re: binary representation of an integer

2008-06-24 Thread cokofreedom
And: # return as a string def itob_string(integer, count = 8): return .join(str((integer i) 1) for i in range(count - 1, -1, -1)) # return as an iterator (i.e [0, 0, 0, 0, 1, 0, 1, 0]) def itob_list(integer, count = 8): return [(integer i) 1 for i in range(count - 1, -1, -1)] #

Re: String question

2008-06-23 Thread cokofreedom
On Jun 23, 4:45 pm, Andreu [EMAIL PROTECTED] wrote: I want to split a sentence and assign each word to a variable. In Ruby I can do it as: v1,v2,v3,v4,v5 = str1.split Which will be the Python equivalent ? Thanks. Andrew. Well a straight copy would be... example = Hello, how are you v1,

Re: Simple Python class questions

2008-06-20 Thread cokofreedom
Yes I was wondering about that, but I wasn't clear about when 'body' code (ie not contained within a def block) in the module might run under Python. So it seemed to be safer to place the import statement inside the 'constructor' to get the earliest warning of non-visibility of pyserial. But

Re: dict order

2008-06-18 Thread cokofreedom
On Jun 18, 11:22 am, Robert Bossy [EMAIL PROTECTED] wrote: Hi, I wish to know how two dict objects are compared. By browsing the archives I gathered that the number of items are first compared, but if the two dict objects have the same number of items, then the comparison algorithm was not

Re: dict order

2008-06-18 Thread cokofreedom
On Jun 18, 12:32 pm, [EMAIL PROTECTED] wrote: On Jun 18, 11:22 am, Robert Bossy [EMAIL PROTECTED] wrote: Hi, I wish to know how two dict objects are compared. By browsing the archives I gathered that the number of items are first compared, but if the two dict objects have the same

Re: dict order

2008-06-18 Thread cokofreedom
On Jun 18, 4:45 pm, Kirk Strauser [EMAIL PROTECTED] wrote: At 2008-06-18T10:32:48Z, [EMAIL PROTECTED] writes: # untested 2.5 for keys in dict_one.items(): if keys in dict_two: if dict_one[keys] != dict_two[keys]: # values are different else: # key is not present

Re: boolian logic

2008-06-13 Thread cokofreedom
if var not in (A, B, C): do_something() And this is why I love python. -- http://mail.python.org/mailman/listinfo/python-list

Re: Why does python not have a mechanism for data hiding?

2008-06-11 Thread cokofreedom
On Jun 11, 8:11 am, Russ P. [EMAIL PROTECTED] wrote: On Jun 10, 11:58 am, Jonathan Gardner Who cares what the type of an object is? Only the machine. Being able to tell, in advance, what the type of a variable is is a premature optimization. Tools like psyco prove that computers (really,

Re: Newb question: underscore

2008-06-06 Thread cokofreedom
My question is: Why would anyone decide to obfuscate something as easy to read as Python??? They didn't decide to obfuscate; they decided to follow a strongly-expected convention for the name of that function by existing users of the 'gettext' functionality, in contexts that predate the

Re: Why does python not have a mechanism for data hiding?

2008-06-06 Thread cokofreedom
Someone asked about Java; class FieldTest { public String publicString = Foobar; private String privateString = Hello, World!; } import java.lang.reflect.Field; public class Test4 { public static void main(String args[]) { final Field fields[] =

Re: defaultdict.fromkeys returns a surprising defaultdict

2008-06-04 Thread cokofreedom
No need. The patch would be rejected. It would break existing code that uses default.fromkeys() as designed and documented. Perhaps that could be useful, so that future questions or posts on the matter could instantly be directed to the rejected patch? --

Re: Why does python not have a mechanism for data hiding?

2008-06-04 Thread cokofreedom
But the leading underscore doesn't tell you whether it is your own private date, which you can use a you see fit, or those of someone else, which you have to be very carefull with. -- Antoon Pardon Well how is that different from public accessor and mutators of private variables? --

Re: Tuple of coordinates

2008-05-29 Thread cokofreedom
a = 1, 2 b = 3, 4, 5 c = 6, 7, 8, 9 coord = list() for i, j, k in zip(a, b, c): coord.append((i, j, k)) print coord -- http://mail.python.org/mailman/listinfo/python-list

Re: php vs python

2008-05-28 Thread cokofreedom
On May 28, 1:42 pm, Michael Fesser [EMAIL PROTECTED] wrote: .oO(Ivan Illarionov) No. Language does matter. And the weather. If you know how to program, you can write good code in any language if you're familiar enough with it. Many people write good code in PHP, and many write total crap

Re: Misuse of list comprehensions?

2008-05-21 Thread cokofreedom
''.join(seen.add(c) or c for c in s if c not in seen) From what I can understand... .join will be a String of unique 'c' values. 'seen.add(c) or c' will always point to the second statement 'c' because seen.add(c) returns None. 'if c not in seen' will ensure 'c' being added to both the .join

Re: C-like assignment expression?

2008-05-21 Thread cokofreedom
On May 21, 3:12 pm, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: On May 21, 1:47 pm, Hrvoje Niksic [EMAIL PROTECTED] wrote: Although that solution is pretty, it is not the canonical solution because it doesn't cover the important case of if bodies needing to access common variables in the

Re: C-like assignment expression?

2008-05-21 Thread cokofreedom
And wastes time. regular expressions can become expensive to match - doing it twice might be hurtful. Diez match = (my_re1.match(line) or my_re2.match(line)) or my_re3.match(line) ? -- http://mail.python.org/mailman/listinfo/python-list

Re: C-like assignment expression?

2008-05-21 Thread cokofreedom
On May 21, 4:09 pm, Diez B. Roggisch [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] wrote: And wastes time. regular expressions can become expensive to match - doing it twice might be hurtful. Diez match = (my_re1.match(line) or my_re2.match(line)) or my_re3.match(line) How do you know

Re: C-like assignment expression?

2008-05-21 Thread cokofreedom
On May 21, 4:57 pm, inhahe [EMAIL PROTECTED] wrote: one of the few things i miss from C is being able to use assignment in expressions. that's the only thing, really. also there's no switch/case, you have to use a dictionary of functions instead, although i rarely need that, usually i just

Re: Is using range() in for loops really Pythonic?

2008-05-14 Thread cokofreedom
On May 14, 8:37 am, Marc 'BlackJack' Rintsch [EMAIL PROTECTED] wrote: On Tue, 13 May 2008 10:20:41 -0700, John Nagle wrote: Matt Nordhoff wrote: Well, you should use xrange(10) instead of range(10). CPython really is naive. That sort of thing should be a compile-time optimization.

Re: anagram finder / dict mapping question

2008-05-09 Thread cokofreedom
key = ''.join(sorted(word)) I tend to strip and lower the word as well, otherwise Hello and hello do not compare...depends on what you want though! Plus you might get a lot of word\n as keys... My technique is the this way def anagram_finder(words): anagrams = {} for word in words:

Re: Newbie to python --- why should i learn !

2008-05-08 Thread cokofreedom
C# using System; namespace HelloWorld { Class HelloWorld { static void Main(String[] args) { Console.WriteLine(Hello World); } } } -- http://mail.python.org/mailman/listinfo/python-list

Re: comparing dictionaries

2008-05-07 Thread cokofreedom
On May 7, 4:08 pm, brad [EMAIL PROTECTED] wrote: I want to compare two dicts that should have identical info just in a different data structure. The first dict's contents look like this. It is authoritative... I know for sure it has the correct key value pairs: {'001' : '01'} The second

Re: What is the purpose of ptyhon in Windows

2008-05-07 Thread cokofreedom
On May 7, 4:08 pm, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: hi All, I have no idea why I need to learn a new scripting language, nothing much to the sytnax, I need to understand what could be the prupose of another scripting language Cna you please help me with this, Is there a

Re: Newbie question - probably FAQ (but not exactly answered by regular FAQ)

2008-05-06 Thread cokofreedom
2.5 seems the defacto standard now for a new user, NB: probably not the standard for the common business productions. However are you on Windows or *nix? *nix may ship a certain version, so for ease of use it would be best to use that. Personally I use 2.5 because it is a complete version, and

Re: computing with characters

2008-05-06 Thread cokofreedom
On May 6, 12:22 pm, Boris Borcic [EMAIL PROTECTED] wrote: Duncan Booth wrote: Torsten Bronger [EMAIL PROTECTED] wrote: The biggest ugliness though is ,.join(). No idea why this should be better than join(list, separator= ). Besides, ,.join(ux) yields an unicode object. This is

Re: Am I missing something with Python not having interfaces?

2008-05-06 Thread cokofreedom
I would imagine this is why I haven't found any schools teaching Python in their basic programming classes too. On the dynamic typing, isn't that the same sort of thing that lots of scripting languages do? VBScript doesn't require you to define your variables, but I don't really want to use

Re: Reversing a dict?

2008-05-06 Thread cokofreedom
On May 6, 5:20 pm, [EMAIL PROTECTED] wrote: Hi - further to my earlier query regarding partial matches (which with all your replies enabled me to advance my understanding, thanks), I now need to reverse a dict. I know how to reverse a list (with the reverse method - very handy), but it

Re: Code/test ratio wrt static vs dynamic typing [was: Re: Python Success stories]

2008-04-30 Thread cokofreedom
A rather off-topic and perhaps naive question, but isn't a 1:4 production/test ratio a bit too much ? Is there a guesstimate of what percentage of this test code tests for things that you would get for free in a statically typed language ? I'm just curious whether this argument against

Re: Issue with regular expressions

2008-04-29 Thread cokofreedom
| # Double Quote Text |# match a double quote |(# - Two Possiblities: |\\. # match two backslashes followed by anything (include newline) ||# OR |[^]

Re: Python Success stories

2008-04-23 Thread cokofreedom
Civilisation 4 uses Python everywhere and is the main tool used by Modders of the game. -- http://mail.python.org/mailman/listinfo/python-list

Re: Rounding a number to nearest even

2008-04-11 Thread cokofreedom
couldn't you just do. #untested new_round(n): answer = round(n) # is answer now odd if answer % 2: return answer - 1 else: return answer -- http://mail.python.org/mailman/listinfo/python-list

Re: Rounding a number to nearest even

2008-04-11 Thread cokofreedom
On Apr 11, 1:19 pm, [EMAIL PROTECTED] wrote: couldn't you just do. #untested new_round(n): answer = round(n) # is answer now odd if answer % 2: return answer - 1 else: return answer Whoops, this also affects odd numbers... Will try and find a GOOD solution later...

Re: PROBLEMS WITH PYTHON IN SOME VARIABLE,FUNCTIONS,ETC.

2008-04-10 Thread cokofreedom
Umm, Mesopotamia is an area geographically located between the Tigris and Euphrates rivers, Bangalore isn't anywhere near that. And most of that is presently under American control. If you don't want to give out your code then try explaining it better. What is the input, what is the output, how

Re: questions about Exceptions?

2008-04-10 Thread cokofreedom
In general you should only catch the exceptions you want to catch, therefore avoiding the issue of catching unexpected ones, for instances the programming unexpectandly closing. Well, exception handling is expensive (when it catches one) so it really is up to you. If you are using eval and know

Re: questions about Exceptions?

2008-04-10 Thread cokofreedom
def Calc(): global nbr try: print eval(nbr) #a = Label(mygui, text=eval(nbr)) #a.place(relx=0.4, rely=0.1, anchor=CENTER) except: print Not computable nbr = def Erase(): global nbr nbr = Seems to me you could be better off

Re: questions about Exceptions?

2008-04-10 Thread cokofreedom
the erase() id alwys need if u wanna abort whilst u wrote something. But if it is meant to only evaluate once you've pressed the enter key (I take it?) you shouldn't need that. And if you are to abort while evaluating it will not do that. -- http://mail.python.org/mailman/listinfo/python-list

Re: How to find documentation about methods etc. for iterators

2008-04-10 Thread cokofreedom
This for me is Python's chief selling point: dir()dir() and help(). Python's two selling points are dir(), help(), and very readable code. Python's *three* selling points are dir(), help(), very readable code, and an almost fanatical devotion to the BFDL. Amongst Python's selling

Re: PROBLEMS WITH PYTHON IN SOME VARIABLE,FUNCTIONS,ETC.

2008-04-08 Thread cokofreedom
'I have designed a program with more than 500 if elif else' This was your first mistake... (ii) x3=x1.find(x2) returns an integer corresponding to the start position in x1 where it found x2, otherwise it will return -1. (i) ... what kind of vague numbers? It should just give you an integer

Re: PROBLEMS WITH PYTHON IN SOME VARIABLE,FUNCTIONS,ETC.

2008-04-08 Thread cokofreedom
I have a car. I have turned the ignition key but it fails to start. Please tell me what is wrong with it. The engine is missing! Am I close? -- http://mail.python.org/mailman/listinfo/python-list

Re: First Python project - comments welcome!

2008-04-07 Thread cokofreedom
Just a random check. Is __gsignals__ a builtin type? Else it would probably be better not to include the postfix underscores. Though I might be wrong here. Otherwise seems pretty good and well organised. I hate it when people go comment mad, but you've kept them to the places where an explanation

Looking for Advanced Python Tutorials

2008-04-04 Thread cokofreedom
I was wondering if anyone knew of some online (free if possible) advanced tutorials, especially ones that provides tasks and ideas for small projects. The issue for myself is I want to improve my python programming level, and my ability to program in general, but come up blank thinking of a

Re: Nested try...except

2008-04-02 Thread cokofreedom
On Apr 2, 3:06 pm, [EMAIL PROTECTED] wrote: Hi, I found the following code on the net - http://mail-archives.apache.org/mod_mbox/httpd-python-cvs/200509.mbox/[EMAIL PROTECTED] def count(self): -db = sqlite.connect(self.filename, isolation_level=ISOLATION_LEVEL) -

who said python can't be obsfucated!?

2008-04-02 Thread cokofreedom
def s(c):return[]if c==[]else s([_ for _ in c[1:]if _c[0]])+[c[0]] +s([_ for _ in c[1:]if _=c[0]]) Anyone else got some wonders...? -- http://mail.python.org/mailman/listinfo/python-list

globals() using For Loop against Generator

2008-03-18 Thread cokofreedom
if __name__ == '__main__': print Globals (For Loop): try: for i in globals(): print \t%s % i except RuntimeError: print Only some globals() printed\n else: print All globals() printed\n print Globals (Generator): try: print

Re: Immutable and Mutable Types

2008-03-17 Thread cokofreedom
a = 1 b = 1 a is b True id(a) 10901000 id(b) 10901000 Isn't this because integers up to a certain range are held in a single memory location, thus why they are the same? -- http://mail.python.org/mailman/listinfo/python-list

Re: List mutation method gotcha - How well known?

2008-03-13 Thread cokofreedom
On Mar 13, 8:36 am, Hendrik van Rooyen [EMAIL PROTECTED] wrote: Hi, I am surprised that it took me so long to bloody my nose on this one. It must be well known - and I would like to find out how well known. So here is a CLOSED BOOK multiple choice question - no RTFM, no playing at the

Re: List mutation method gotcha - How well known?

2008-03-13 Thread cokofreedom
Still, I suppose this is a gotcha for a lot of people, just follow the good advice Paul said; By Python convention, methods that mutate the object return None, and also stuff that returns None doesn't generate output at the interactive prompt. And you should survive most. --

Re: Creating a file with $SIZE

2008-03-12 Thread cokofreedom
On Mar 12, 2:44 pm, Robert Bossy [EMAIL PROTECTED] wrote: Matt Nordhoff wrote: Robert Bossy wrote: k.i.n.g. wrote: I think I am not clear with my question, I am sorry. Here goes the exact requirement. We use dd command in Linux to create a file with of required size. In similar

Re: Converting a string to the most probable type

2008-03-10 Thread cokofreedom
The trick in the case of when you do not want to guess, or the choices grow too much, is to ask the user to tell you in what format they want it and format according to their wishes. Neatly avoids too much guessing and isn't much extra to add. --

Re: How about adding rational fraction to Python?

2008-02-26 Thread cokofreedom
What is it with people and double++ posting... If you have a lot to say, say it together and take the time to slow down, re-read it and not just fly it out, line by line, by line, by line... To answer only the following: That's creepy for people that are new to programming and doesn't know

Re: Double underscores -- ugly?

2008-02-21 Thread cokofreedom
On Feb 21, 3:31 am, [EMAIL PROTECTED] wrote: On Feb 19, 8:20 pm, Steve Holden [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] wrote: On Feb 19, 10:26 am, Wildemar Wildenburger [EMAIL PROTECTED] wrote: Jason wrote: Hmm. I must be the only person who doesn't think the double

Re: newbie in python

2008-02-21 Thread cokofreedom
Can someone help me to get in the right track, and get a good move? http://wiki.python.org/moin/BeginnersGuide http://www.diveintopython.org/ -- http://mail.python.org/mailman/listinfo/python-list

Re: What's the standard for code docs?

2008-02-20 Thread cokofreedom
On Feb 20, 9:12 am, Diez B. Roggisch [EMAIL PROTECTED] wrote: Are people really writing pure HTML snippets in docstrings to document each module/class/method? For anything other than a toy project? One of the main reasons I'm considering moving to epydoc + reST is precisely because it's

Re: Double underscores -- ugly?

2008-02-20 Thread cokofreedom
So people's problem with __word__ is that it is not very readable? How so, it stands out on page, it clearly is different from other objects and doesn't abuse other symbols that generally have a meaning based on their use. I haven't seen a single alternative that really stands out as much as

Re: Current Fastest Python Implementation?

2008-02-18 Thread cokofreedom
On Feb 18, 9:37 am, Stefan Behnel [EMAIL PROTECTED] wrote: samuraisam wrote: Has anyone done any recent testing as to which current python implementation is the quickest? Search for a recent thread on CPython and IronPython. Perhaps for Django development - though the current one

Re: TRAC - Trac, Project Leads, Python, and Mr. Noah Kantrowitz (sanitizer)

2008-02-18 Thread cokofreedom
Dear Ilias, Post in a single reply. Coko -- http://mail.python.org/mailman/listinfo/python-list

Re: Assignment saves time?

2008-02-15 Thread cokofreedom
$ python -m timeit -s 'l=[]' 'len(l)==1000' 100 loops, best of 3: 0.256 usec per loop $ python -m timeit -s 'l=[]' 'len(l)==1000' 100 loops, best of 3: 0.27 usec per loop $ python -m timeit -s 'l=[]' 's=len(l); s==1000' 100 loops, best of 3: 0.287 usec per loop $ python -m

Re: Regular Expression for Prime Numbers (or How I came to fail at them, and love the bomb)

2008-02-14 Thread cokofreedom
hmm... interesting here is another way you can find prime numbershttp://love-python.blogspot.com/2008/02/find-prime-number-upto-100-nu... Sadly that is pretty slow though... If you don't mind readability you can make the example I gave into five lines. def p(_): if _3:return[2]if _==2

Re: OT: Speed of light [was Re: Why not a Python compiler?]

2008-02-13 Thread cokofreedom
And the rest of us just use SI. (And if you bring up the _kilogram-force_, I'll just cry.) SI = Super Incredible? Awesome name for Force/Mass / NewItemOfClothing2050! -- http://mail.python.org/mailman/listinfo/python-list

Re: ways to declare empty set variable

2008-02-13 Thread cokofreedom
The irony that, x = (,) produces an error. Personally I would of thought it would be a better example of an empty tuple than anything else, but it still isn't that readable. The use of dict/list/tuple/set seems to stand out a lot better, makes it readable! Else in a few years you'll have §x§ =

Regular Expression for Prime Numbers (or How I came to fail at them, and love the bomb)

2008-02-13 Thread cokofreedom
I was reading up on this site [http://www.noulakaz.net/weblog/ 2007/03/18/a-regular-expression-to-check-for-prime-numbers/] of an interesting way to work out prime numbers using Regular Expression. However my attempts to use this in Python keep returning none (obviously no match), however I don't

Re: OT: Speed of light [was Re: Why not a Python compiler?]

2008-02-11 Thread cokofreedom
On Feb 12, 7:16 am, Jeff Schwab [EMAIL PROTECTED] wrote: Erik Max Francis wrote: Jeff Schwab wrote: Erik Max Francis wrote: Grant Edwards wrote: On 2008-02-12, Jeff Schwab [EMAIL PROTECTED] wrote: Fair enough! Dear me, what's Usenet coming to these days... I know, really.

Re: Why does list have no 'get' method?

2008-02-08 Thread cokofreedom
On Feb 8, 8:23 am, Carl Banks [EMAIL PROTECTED] wrote: On Feb 7, 8:44 am, Steve Holden [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] wrote: I'd like to know what others think about it, about this anti-feature. What I can say is that other computer languages too think that boolean

Re: How to autorun a python script when a specific user logs on?

2008-02-08 Thread cokofreedom
On Feb 8, 1:30 am, jack trades [EMAIL PROTECTED] wrote: Mike Hjorleifsson [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] on windows you can put this in HKEY_Local_Machine\Software\Microsoft \Windows\Current Version\Run and it will run at logon (or fast user switch) for each

Re: Why not a Python compiler?

2008-02-05 Thread cokofreedom
On Feb 5, 9:19 am, Santiago Romero [EMAIL PROTECTED] wrote: ( Surely if this question has been asked for a zillion of times... ) ( and sorry for my english! ) I'm impressed with python. I'm very happy with the language and I find Python+Pygame a very powerful and productive way of writing

Re: Removal of element from list while traversing causes the next element to be skipped

2008-01-30 Thread cokofreedom
On Jan 30, 9:50 am, Santiago Romero [EMAIL PROTECTED] wrote: On 30 ene, 08:09, Paul Rubin http://[EMAIL PROTECTED] wrote: Santiago Romero [EMAIL PROTECTED] writes: li = [1,2,3,4,5] filter(lambda x: x != 3, li) [1, 2, 4, 5] I haven't measured it, but this should be the

Re: Removal of element from list while traversing causes the next element to be skipped

2008-01-30 Thread cokofreedom
Anyone else noticed that the OP has not actually replied to any of the suggestions... -- http://mail.python.org/mailman/listinfo/python-list

Re: optional static typing for Python

2008-01-28 Thread cokofreedom
On Jan 28, 11:42 am, Russ P. [EMAIL PROTECTED] wrote: On Jan 28, 1:51 am, Bruno Desthuilliers bruno. [EMAIL PROTECTED] wrote: Russ P. a écrit : A while back I came across a tentative proposal from way back in 2000 for optional static typing in Python: (snip) In any case,

Re: Stripping whitespace

2008-01-24 Thread cokofreedom
On Jan 24, 8:21 am, ryan k [EMAIL PROTECTED] wrote: On Jan 23, 6:30 pm, John Machin [EMAIL PROTECTED] wrote: On Jan 24, 9:50 am, ryan k [EMAIL PROTECTED] wrote: Steven D'Aprano, you are a prick. And your reasons for coming to that stridently expressed conclusion after reading a

  1   2   >