Re: *Advanced* Python book?

2009-01-16 Thread Michele Simionato
On Jan 16, 9:27 pm, mk wrote: > Hello everyone, > > I looked for it I swear, but just can't find it. > > Most Python books seem to focus on examples of how to call functions > from standard library. I don't need that, I have online Python > documentation for that. > > I mean really advanced mental

Re: *Advanced* Python book?

2009-01-16 Thread Scott David Daniels
Paul Rubin wrote: mk writes: Anybody found such holy grail? The favorite ones around here are "Python Cookbook" and "Python in a Nutshell", both by Alex Martelli, who used to be a newsgroup regular and still stops by from time to time. To the OP: Do yourself a favor and go to a bookst

Re: dynamic module import?

2009-01-16 Thread Steven D'Aprano
On Fri, 16 Jan 2009 20:36:50 -0800, alex23 wrote: > On Jan 17, 3:34 pm, Eduardo Lenz wrote: >> modu = "os" >> exec("from " + modu + " import *") > > And of course, there's the usual disclaimer that this should be only > used in circumstances where you can guarantee the contents of 'modu' > aren'

Re: Parallel package hierarchies/directories

2009-01-16 Thread atleta
OK, I'm answering my own question, it might be of some help for someone in the future: yes, it's possible to have parts of the same package in multiple directories, it's just not enabled by default. To make it work each such package should have the following code in their __init__.py: from pkgutil

Re: process/thread instances and attributes

2009-01-16 Thread James Mills
On Fri, Jan 16, 2009 at 10:33 PM, Jesse Noller wrote: (...) > Personally, rather then using a value to indicate whether to run or > not, I would tend to use an event to coordinate start/stop state. The reason I implemented workers.Thread and workers.Process this way is basically so taht long-run

Re: multiprocessing vs. distributed processing

2009-01-16 Thread James Mills
On Fri, Jan 16, 2009 at 10:15 PM, Jesse Noller wrote: > That being said, there is no reason why you could not use it in > conjunction with something like Kamaelia, pyro, $ipc mechanism/etc. And also circuits (1). circuits has full implementations of Thread and Process components. circuits also ha

Re: problem in implementing multiprocessing

2009-01-16 Thread James Mills
On Fri, Jan 16, 2009 at 7:16 PM, gopal mishra wrote: > I create two heavy objects sequentially without using multipleProcessing > then creation of the objects takes 2.5 sec.if i create these two objects in > separate process then total time is 6.4 sec. > > i am thinking it is happening due to the

Re: dynamic module import?

2009-01-16 Thread alex23
On Jan 17, 3:34 pm, Eduardo Lenz wrote: > modu = "os" > exec("from " + modu + " import *") And of course, there's the usual disclaimer that this should be only used in circumstances where you can guarantee the contents of 'modu' aren't ever going to be anything like: modu = "os import system; sy

Re: Totally confused by the str/bytes/unicode differences introduced in Pythyon 3.x

2009-01-16 Thread John Machin
On Jan 17, 3:08 pm, Steve Holden wrote: > Giampaolo Rodola' wrote: > > On 17 Gen, 04:43, Terry Reedy wrote: > >> Giampaolo Rodola' wrote: > >>> That would help to avoid replacing "" with b"" almost everywhere in my > >>> code. > >> Won't 2to3 do that for you? > > > I used 2to3 against my code but

Python Startup file

2009-01-16 Thread Gary Smith
Fellow Vipers, Although I've written lots of Python code, I'm still an embarrassed newbie. Here's my problem. I've never been able to get ActiveState Python's PythonWin to observe the file referenced in the Windows PYTHONSTARTUP environment variable. Many thanks for pointing out the obvious t

Re: what's the point of rpython?

2009-01-16 Thread alex23
On Jan 17, 10:37 am, "Brendan Miller" wrote: > What's the point of RPython? By this, I don't mean "What is RPython"? > I get that. I mean, why? This is more or less covered in the FAQ: "The restrictions are to ensure that type inference (and so, ultimately, translation to other languages) of RPy

Re: Totally confused by the str/bytes/unicode differences introduced in Pythyon 3.x

2009-01-16 Thread Steve Holden
Giampaolo Rodola' wrote: > On 17 Gen, 04:43, Terry Reedy wrote: >> Giampaolo Rodola' wrote: >>> That would help to avoid replacing "" with b"" almost everywhere in my >>> code. >> Won't 2to3 do that for you? > > I used 2to3 against my code but it didn't cover the "" -> b"" > conversion (and I dou

Re: Totally confused by the str/bytes/unicode differences introduced in Pythyon 3.x

2009-01-16 Thread Giampaolo Rodola'
On 17 Gen, 04:43, Terry Reedy wrote: > Giampaolo Rodola' wrote: > > That would help to avoid replacing "" with b"" almost everywhere in my > > code. > > Won't 2to3 do that for you? I used 2to3 against my code but it didn't cover the "" -> b"" conversion (and I doubt it is able to do so, anyway).

Re: ABCs, functions, and __call__ (Python3)

2009-01-16 Thread andrew cooke
On Jan 16, 10:13 pm, Christian Heimes wrote: > Any callable in Python 3.0 has a "__call__" attribute. Aha! Thanks! Andrew -- http://mail.python.org/mailman/listinfo/python-list

Re: Totally confused by the str/bytes/unicode differences introduced in Pythyon 3.x

2009-01-16 Thread Terry Reedy
Giampaolo Rodola' wrote: That would help to avoid replacing "" with b"" almost everywhere in my code. Won't 2to3 do that for you? -- http://mail.python.org/mailman/listinfo/python-list

Re: Skull Socks (was Re: Convention vs. fascism)

2009-01-16 Thread J. Clifford Dyer
On Fri, 2009-01-16 at 16:41 -0500, Steve Holden wrote: > Steven D'Aprano wrote: > > On Fri, 16 Jan 2009 11:01:18 -0500, J. Cliff Dyer wrote: > > > >> On Fri, 2009-01-16 at 08:57 +, Steven D'Aprano wrote: > >>> On Fri, 16 Jan 2009 10:03:28 +0200, Hendrik van Rooyen wrote: > >>> > Oh come o

Re: Totally confused by the str/bytes/unicode differences introduced in Pythyon 3.x

2009-01-16 Thread Giampaolo Rodola'
On 17 Gen, 03:40, Steve Holden wrote: > Giampaolo Rodola' wrote: > > On 17 Gen, 02:24, MRAB wrote: > > >> If you're truly working with strings of _characters_ then > >> 'str' is what you need, but if you're working with strings of _bytes_ > >> then 'bytes' is what you need. > > > I work with stri

Re: Totally confused by the str/bytes/unicode differences introduced in Pythyon 3.x

2009-01-16 Thread Steve Holden
Giampaolo Rodola' wrote: > On 17 Gen, 02:24, MRAB wrote: > >> If you're truly working with strings of _characters_ then >> 'str' is what you need, but if you're working with strings of _bytes_ >> then 'bytes' is what you need. > > I work with string of characters but to convert bytes into string

Re: Totally confused by the str/bytes/unicode differences introduced in Pythyon 3.x

2009-01-16 Thread Giampaolo Rodola'
On 17 Gen, 03:09, Steven D'Aprano wrote: > On Fri, 16 Jan 2009 17:32:17 -0800, Giampaolo Rodola' wrote: > > On 17 Gen, 02:24, MRAB wrote: > > >> If you're truly working with strings of _characters_ then 'str' is what > >> you need, but if you're working with strings of _bytes_ then 'bytes' is > >

Re: Totally confused by the str/bytes/unicode differences introduced in Pythyon 3.x

2009-01-16 Thread Steven D'Aprano
On Fri, 16 Jan 2009 17:32:17 -0800, Giampaolo Rodola' wrote: > On 17 Gen, 02:24, MRAB wrote: > >> If you're truly working with strings of _characters_ then 'str' is what >> you need, but if you're working with strings of _bytes_ then 'bytes' is >> what you need. > > I work with string of charac

Re: Incorrect title case?

2009-01-16 Thread John Machin
On Jan 17, 9:07 am, MRAB wrote: > Python 2.6.1 > > I've just found that the following 4 Unicode characters/codepoints don't > behave as I'd expect: Dž (U+01C5), Lj (U+01C8), Nj (U+01CB), Dz (U+01F2). > > For example, u"\u01C5".istitle() returns True and > unicodedata.category(u"\u01C5") returns "Lt",

Re: tuple methods: documentation missing

2009-01-16 Thread Alan G Isaac
Alan G Isaac wrote: http://docs.python.org/3.0/library/stdtypes.html#sequence-types-str-bytes-bytearray-list-tuple-range I see no mention of the tuple methods? Right after the paragraph "Most sequence types support the following operations." it seems appropriate to have one stating "Most seque

Re: Totally confused by the str/bytes/unicode differences introduced in Pythyon 3.x

2009-01-16 Thread Christian Heimes
Giampaolo Rodola' schrieb: > I work with string of characters but to convert bytes into string I > need to specify an encoding and that's what confuses me. > Before there was no need to deal with that. Why do you have to deal with unicode data? IIRC ftp uses ASCII only text so you can stick to byt

Re: Need help with os.system in linux

2009-01-16 Thread excord80
On Jan 16, 7:05 pm, akshay bhat wrote: > Hello > i am calling a program using os.system in python on Linux. > However in i found that program being executed and soon returned 256. > but when i ran it using terminal i got proper results. > Now in case of windows, python waits till the process is fi

Re: Totally confused by the str/bytes/unicode differences introduced in Pythyon 3.x

2009-01-16 Thread Giampaolo Rodola'
On 17 Gen, 02:24, MRAB wrote: > If you're truly working with strings of _characters_ then > 'str' is what you need, but if you're working with strings of _bytes_ > then 'bytes' is what you need. I work with string of characters but to convert bytes into string I need to specify an encoding and t

Re: Beginner: Data type conversion question

2009-01-16 Thread Terry Reedy
flagg wrote: If rdate.serial is already a string, as name would imply, the str() call is pointless. If not, can you get inc as int more directly? ... Actually when i run a type(serial) on that variable it returns a "long" Then inc = serial % 100 is 'more directly'. which i am not sure wh

Re: Finding the full path of an executable

2009-01-16 Thread Grant Edwards
On 2009-01-17, Michael Hoffman <9qobl2...@sneakemail.com> wrote: > Unknown wrote: >> On 2009-01-16, Michael Hoffman <9qobl2...@sneakemail.com> wrote: >>> Is there a portable way to find the full path of a filename that would >>> be called by os.execvp()? >> >> Yes. Use os.path.abspath() on the n

Re: Differences between class and function decorator

2009-01-16 Thread Terry Reedy
mk wrote: Hello everyone, I rewrote an example someone posted here recently from: >>> def print_method_name(method): def new_meth(*args, **kwargs): print method.func_name return method(*args, **kwargs) return new_meth >>> @print_method_name def f2(): pass >>> f2

Re: Totally confused by the str/bytes/unicode differences introduced in Pythyon 3.x

2009-01-16 Thread MRAB
Giampaolo Rodola' wrote: > Hi, I'm sure the message I'm going to write will seem quite dumb to > most people but I really don't understand the str/bytes/unicode > differences introduced in Python 3.0 so be patient. What I'm trying > to do is porting pyftpdlib to Python 3.x. I don't want to suppor

Re: optimizing large dictionaries

2009-01-16 Thread Luis M . González
On Jan 15, 6:39 pm, Per Freem wrote: > hello > > i have an optimization questions about python. i am iterating through > a file and counting the number of repeated elements. the file has on > the order > of tens of millions elements... > > i create a dictionary that maps elements of the file that

Re: ABCs, functions, and __call__ (Python3)

2009-01-16 Thread Christian Heimes
andrew cooke schrieb: > I think I'm missing something obvious here, so apologies in advance. > > I'd like to be able to test whether something is a function or > implements __call__. Now obviously I can do that as two separate > tests, but I though this was what ABCs were for. However, for the >

Re: *Advanced* Python book?

2009-01-16 Thread andrew cooke
not direct answers, but reading through the recipes can be interesting - http://code.activestate.com/recipes/langs/python/ also, reading any good computing book and then wondering how you can do that in python can help shed a new light on things. andrew -- http://mail.python.org/mailman/lis

Re: Class decorator with argument

2009-01-16 Thread Terry Reedy
mk wrote: Hello, I wrote this class decorator with argument: The following is a *function* decorator, with the twist of being an instance of a user class rather than of the built-in function class (one I had not thought of). A class decorator would be a callable the modifies or wraps a *cl

Re: Totally confused by the str/bytes/unicode differences introduced in Pythyon 3.x

2009-01-16 Thread Christian Heimes
Giampaolo Rodola' schrieb: > Now. The basic difference is that socket.recv() returns a bytes object > instead of a string object and that's the thing which confuses me > mainly. > My question is: is there a way to convert that bytes object into > exactly *the same thing* returned by socket.recv() i

ABCs, functions, and __call__ (Python3)

2009-01-16 Thread andrew cooke
I think I'm missing something obvious here, so apologies in advance. I'd like to be able to test whether something is a function or implements __call__. Now obviously I can do that as two separate tests, but I though this was what ABCs were for. However, for the life of me I cannot find what the

Re: Finding the full path of an executable

2009-01-16 Thread Michael Hoffman
Unknown wrote: On 2009-01-16, Michael Hoffman <9qobl2...@sneakemail.com> wrote: Is there a portable way to find the full path of a filename that would be called by os.execvp()? Yes. Use os.path.abspath() on the name before you call it with os.execvp() That doesn't work: Python 2.5.2 (r252:

Re: s = sha1(random()).hexdigest()

2009-01-16 Thread Paul Rubin
gert writes: > Is this the new way to create a list in Python3.0 ? > s=('test',) That is a 1-tuple in both 2.x and 3.0. For a list, you'd say s = ['test'] -- http://mail.python.org/mailman/listinfo/python-list

Re: Integrating awk in Python

2009-01-16 Thread Python Nutter
If you or anyone who reads the thread is interested in using Python in an advanced way you use generators and build processing chains that will take the performance of Python to the edge and even give old AWK a run for its money for certain types of processing. Python: wwwlog = open("access-lo

Re: what's the point of rpython?

2009-01-16 Thread Luis M . González
On Jan 16, 9:37 pm, "Brendan Miller" wrote: > So I kind of wanted to ask this question on the pypy mailing list.. > but there's only a pypy-dev list, and I don't want to put noise on the > dev list. > > What's the point of RPython? By this, I don't mean "What is RPython"? > I get that. I mean, why

Re: s = sha1(random()).hexdigest()

2009-01-16 Thread gert
On Jan 17, 1:14 am, gert wrote: > On Jan 16, 7:08 am, "Martin v. Löwis" wrote: > > > >  s = urandom(10).encode('hex') > > > >  AttributeError: 'bytes' object has no attribute 'encode' > > > py> binascii.hexlify(os.urandom(10)) > > b'92b91d5734a9fe562f23' > > sqlite3 > >  s = hexlify(urandom(10))

Totally confused by the str/bytes/unicode differences introduced in Pythyon 3.x

2009-01-16 Thread Giampaolo Rodola'
Hi, I'm sure the message I'm going to write will seem quite dumb to most people but I really don't understand the str/bytes/unicode differences introduced in Python 3.0 so be patient. What I'm trying to do is porting pyftpdlib to Python 3.x. I don't want to support Unicode. I don't want pyftpdlib

what's the point of rpython?

2009-01-16 Thread Brendan Miller
So I kind of wanted to ask this question on the pypy mailing list.. but there's only a pypy-dev list, and I don't want to put noise on the dev list. What's the point of RPython? By this, I don't mean "What is RPython"? I get that. I mean, why? The goals of the pypy project seems to be to create a

Re: dynamic module import?

2009-01-16 Thread Eduardo Lenz
On Friday 16 January 2009 16:13:49 Steven D'Aprano wrote: > On Fri, 16 Jan 2009 21:34:01 -0800, Eduardo Lenz wrote: > > modu = "os" > > exec("from " + modu + " import *") > > "from module import *" is generally frowned upon, although it does > occasionally have its uses. > > By the way, I think you

Re: s = sha1(random()).hexdigest()

2009-01-16 Thread gert
On Jan 16, 7:08 am, "Martin v. Löwis" wrote: > >  s = urandom(10).encode('hex') > > >  AttributeError: 'bytes' object has no attribute 'encode' > > py> binascii.hexlify(os.urandom(10)) > b'92b91d5734a9fe562f23' > sqlite3 s = hexlify(urandom(10)) db.execute('SELECT sid FROM sessions WHERE sid=?

Re: dynamic module import?

2009-01-16 Thread Steven D'Aprano
On Fri, 16 Jan 2009 21:34:01 -0800, Eduardo Lenz wrote: > modu = "os" > exec("from " + modu + " import *") "from module import *" is generally frowned upon, although it does occasionally have its uses. By the way, I think your computer's clock is set wrong. My newsclient is reporting that you

Re: optimizing large dictionaries

2009-01-16 Thread Matthias Julius
Per Freem writes: > the only 'twist' is that my elt is an instance of a class (MyClass) > with 3 fields, all numeric. the class is hashable, and so > my_dict[elt] works well. the __repr__ and __hash__ methods of my > class simply return str() representation of self, which just calls __str__().

Need help with os.system in linux

2009-01-16 Thread akshay bhat
Hello i am calling a program using os.system in python on Linux. However in i found that program being executed and soon returned 256. but when i ran it using terminal i got proper results. Now in case of windows, python waits till the process is finished, Can you please tell me how to implement th

Re: tuple methods: documentation missing

2009-01-16 Thread Terry Reedy
Alan G Isaac wrote: http://docs.python.org/3.0/library/stdtypes.html#sequence-types-str-bytes-bytearray-list-tuple-range I see no mention of the tuple methods? Right after the paragraph "Most sequence types support the following operations." it seems appropriate to have one stating "Most seque

multiprocessing question/error

2009-01-16 Thread Eduardo Lenz
Hi, I was using the former processing package with python 2.5 with no problems. After switching to python 2.6.1 I am having some problems with the same code. The problem seems to be related to the fact that I am using Pool.map with a bounded method, since it is inside a class. To clarify a little

Re: dynamic module import?

2009-01-16 Thread Eduardo Lenz
On Friday 16 January 2009 15:03:51 Lawson Hanson wrote: > Is it possible to import a module of Python code > where I do not know the name of the module > until run-time? > > The Python statement: > > from someModule import * > > requires that "someModule" be the name of the module, >

Re: dynamic module import?

2009-01-16 Thread Chris Rebert
On Fri, Jan 16, 2009 at 3:03 PM, Lawson Hanson wrote: > Is it possible to import a module of Python code >where I do not know the name of the module >until run-time? Yes. Use the __import__() built-in function. See http://docs.python.org/library/functions.html#__import__ for details. Che

dynamic module import?

2009-01-16 Thread Lawson Hanson
Is it possible to import a module of Python code where I do not know the name of the module until run-time? The Python statement: from someModule import * requires that "someModule" be the name of the module, but what I would like is to be able to define a value for "someMod

Re: List comprehension - NameError: name '_[1]' is not defined ?

2009-01-16 Thread ajaksu
On Jan 16, 3:45 pm, mario ruggier wrote: > > '(x for x in ()).throw("bork")' > > What is the potential security risk with this one? I don't see a concrete issue, just found it tempting... raising hand- crafted objects :) > All the above attempts will be blocked this way. Any other disallow- > su

[ANN] sqlkit 0.8.5

2009-01-16 Thread Sandro Dentella
I'm pleased to announce rel 0.8.5 of sqlkit, that adds many improvements. In this release localization has been added. I'd be very pleased if someone would like to contribute localization file for any language (but italian). Changes in this release: sqlkit 0.8.5 - 16.1.09 * lo

Re: *Advanced* Python book?

2009-01-16 Thread Paul Rubin
mk writes: > I mean really advanced mental gymnastics, like gory details of how > Python objects operate, how to exploit its dynamic capabilities, dos > and donts with particular Python objects, advanced tricks, everything > from chained decorators to metaprogramming. Dive Into Python comes > clos

Re: spam on the list - how are things now?

2009-01-16 Thread Cameron Simpson
On 16Jan2009 10:22, Hendrik van Rooyen wrote: | I read this solely via the mailing list - and Yes, whatever was done has helped | a lot. I use the mailing list. The spam is mch reduced. Thanks! -- Cameron Simpson DoD#743 -- http://mail.python.org/mailman/listinfo/python-list

Incorrect title case?

2009-01-16 Thread MRAB
Python 2.6.1 I've just found that the following 4 Unicode characters/codepoints don't behave as I'd expect: Dž (U+01C5), Lj (U+01C8), Nj (U+01CB), Dz (U+01F2). For example, u"\u01C5".istitle() returns True and unicodedata.category(u"\u01C5") returns "Lt", but u"\u01C5".title() returns u'\u01C4', whi

Re: Skull Socks (was Re: Convention vs. fascism)

2009-01-16 Thread Steve Holden
Steven D'Aprano wrote: > On Fri, 16 Jan 2009 11:01:18 -0500, J. Cliff Dyer wrote: > >> On Fri, 2009-01-16 at 08:57 +, Steven D'Aprano wrote: >>> On Fri, 16 Jan 2009 10:03:28 +0200, Hendrik van Rooyen wrote: >>> Oh come on you lot - you are carrying on as if Diez were wearing his skul

Re: *Advanced* Python book?

2009-01-16 Thread Jean-Claude Arbaut
mk wrote: Hello everyone, I looked for it I swear, but just can't find it. Most Python books seem to focus on examples of how to call functions from standard library. I don't need that, I have online Python documentation for that. IMHO, you don't need an advanced *python* book. If you kno

Re: Finding the full path of an executable

2009-01-16 Thread Grant Edwards
On 2009-01-16, Michael Hoffman <9qobl2...@sneakemail.com> wrote: > Is there a portable way to find the full path of a filename that would > be called by os.execvp()? Yes. Use os.path.abspath() on the name before you call it with os.execvp() -- Grant Edwards grante

Re: Class decorator with argument

2009-01-16 Thread Chris Rebert
On Fri, Jan 16, 2009 at 12:15 PM, mk wrote: > Hello, > > I wrote this class decorator with argument: > class ChangeDoc(object): >def __init__(self, docstring): >self.docstring = docstring >def __call__(self, func): >func.__doc__ = self.docstring

*Advanced* Python book?

2009-01-16 Thread mk
Hello everyone, I looked for it I swear, but just can't find it. Most Python books seem to focus on examples of how to call functions from standard library. I don't need that, I have online Python documentation for that. I mean really advanced mental gymnastics, like gory details of how Pyt

tuple methods: documentation missing

2009-01-16 Thread Alan G Isaac
http://docs.python.org/3.0/library/stdtypes.html#sequence-types-str-bytes-bytearray-list-tuple-range I see no mention of the tuple methods? Right after the paragraph "Most sequence types support the following operations." it seems appropriate to have one stating "Most sequence types support the

Finding the full path of an executable

2009-01-16 Thread Michael Hoffman
Is there a portable way to find the full path of a filename that would be called by os.execvp()? Thanks, Michael Hoffman -- http://mail.python.org/mailman/listinfo/python-list

Class decorator with argument

2009-01-16 Thread mk
Hello, I wrote this class decorator with argument: >>> class ChangeDoc(object): def __init__(self, docstring): self.docstring = docstring def __call__(self, func): func.__doc__ = self.docstring return func It seems to work: >>> @C

Re: Python 3: range objects cannot be sliced

2009-01-16 Thread Alan G Isaac
It is documented: http://docs.python.org/3.0/library/stdtypes.html#sequence-types-str-bytes-bytearray-list-tuple-range -- http://mail.python.org/mailman/listinfo/python-list

Re: English-like Python

2009-01-16 Thread Erik Max Francis
alex23 wrote: On Jan 16, 5:39 pm, Erik Max Francis wrote: Inform 7 has some interesting ideas, but I think the general problem with English-like programming language systems is that once you get into the nitty gritty details, you end up having to know exactly the right things to type, This ha

Re: English-like Python

2009-01-16 Thread has
On 16 Jan, 05:42, Chris Rebert wrote: > On Thu, Jan 15, 2009 at 5:02 PM, The Music Guy wrote: > > > > > Just out of curiousity, have there been any attempts to make a version > > of Python that looks like actual English text? > > [...] > Does the name "AppleScript" mean anything to you? ;-) [quo

Re: Lazy List Generator Problem

2009-01-16 Thread Gerald Britton
For those interested in the Sieve of Eratosthenes, have a look at: http://www.cs.hmc.edu/~oneill/papers/Sieve-JFP.pdf The examples in the paper are in Haskell, but I have been corresponding with the author who provided this Python version: def sieve(): innersieve = sieve() prevsquare = 1

Re: are there some special about '\x1a' symbol

2009-01-16 Thread Matthew Woodcraft
Steve Holden writes: > Unknown wrote: >> On 2009-01-12, John Machin wrote: >> >>> I didn't think your question was stupid. Stupid was (a) CP/M recording >>> file size as number of 128-byte sectors, forcing the use of an in-band >>> EOF marker for text files (b) MS continuing to regard Ctrl-Z as

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-16 Thread Russ P.
On Jan 16, 5:22 am, Steve Holden wrote: > Russ P. wrote: > > [...] > > > I spent *way* too much time on that post. I really need to quit > > spending my time refuting the baloney that passes for wisdom here. > > He who cannot ignore baloney is doomed to refute it. > > regards > Steve > -- > Steve

Re: Differences between class and function decorator

2009-01-16 Thread Duncan Booth
mk wrote: > Note that function decorator returned None, while class decorator > returned function. > > Why the difference in behavior? After all, print_method_name decorator > also returns a function (well it's a new function but still a function)? That would be because the function decorator

Differences between class and function decorator

2009-01-16 Thread mk
Hello everyone, I rewrote an example someone posted here recently from: >>> def print_method_name(method): def new_meth(*args, **kwargs): print method.func_name return method(*args, **kwargs) return new_meth >>> @print_method_name def f2():

FileCookieJar has not attribute "_self_load"

2009-01-16 Thread Dragos
I am trying to make a testing script to load/save cookies to a file with FileCookieJar, but it results in this error: FileCookieJar has not attribute "_self_load" This is my script: import urllib.request, urllib.parse,http.cookiejar url="http://localhost/test.php"; cs=http.cookiejar.FileCookieJar

Re: why o/p is different ???

2009-01-16 Thread Lie
On Jan 15, 1:34 pm, asit wrote: > I recently faced a peculiar o/p. > > My objective is to remove the command name(my script name) from > sys.argv[0]. > I coded like this > > import urllib > import sys > > print "\n\n\t\tlipun4u[at]gmail[dot]com" > print "\t\t" > > apppath =

Re: Python 3: range objects cannot be sliced

2009-01-16 Thread Christian Heimes
Alan G Isaac schrieb: > On 1/16/2009 1:15 PM Paul Rubin apparently wrote: >> range is an iterator now. Try itertools.islice. > > Well yes, it behaves like xrange did. > But (also like xrange) it supports indexing. (!) > So why not slicing? > I expected this (to keep it functionally > more similar

Re: Python 3: range objects cannot be sliced

2009-01-16 Thread Alan G Isaac
On 1/16/2009 1:15 PM Paul Rubin apparently wrote: range is an iterator now. Try itertools.islice. Well yes, it behaves like xrange did. But (also like xrange) it supports indexing. (!) So why not slicing? I expected this (to keep it functionally more similar to the old range). Alan Isaac -- h

minidom, drilling down to a low node in one line?

2009-01-16 Thread Matt Brown - nyc
Hello, I hope this isn't completely redundant... I'm working with an example found of parsing XML with xml.dom.minidom and am having some issues getting a node down three levels. Here is the tutorial: http://diveintopython.org/xml_processing/parsing_xml.html Given the XML: _ 0

Re: Integrating awk in Python

2009-01-16 Thread Grant Edwards
Am Freitag, 16. Januar 2009 13:02:59 schrieb Alfons Nonell-Canals: > Hello, > I'm developing a software package using python. I've programmed all > necessary tools but I have to use other stuff from other people. Most of > these external scripts are developed using awk. > > At the beggining I thoug

Re: List comprehension - NameError: name '_[1]' is not defined ?

2009-01-16 Thread Paul Rubin
mario ruggier writes: > All the above attempts will be blocked this way. Any other disallow- > sub-strings to add to the list above? I think what you are trying to do is fundamentally hopeless. You might look at web.py (http://webpy.org) for another approach, that puts a complete interpreter for

Re: Python 3: range objects cannot be sliced

2009-01-16 Thread Paul Rubin
Alan G Isaac writes: > >>> x = range(20) > >>> s = slice(None,None,2) > >>> x[s] > Traceback (most recent call last): >File "", line 1, in > TypeError: sequence index must be integer, not 'slice' range is an iterator now. Try itertools.islice. -- http://mail.python.org/mailman/listinfo/p

Re: Python 3: range objects cannot be sliced

2009-01-16 Thread Fuzzyman
On Jan 16, 5:45 pm, Alan G Isaac wrote: > Is the behavior below expected? Documented? > (The error msg is misleading.) > Thanks, > Alan Isaac > >  >>> x = range(20) >  >>> s = slice(None,None,2) >  >>> x[s] > Traceback (most recent call last): >    File "", line 1, in > TypeError: sequence index

Re: Start multiple listening servers in one file

2009-01-16 Thread MRAB
Thomas W wrote: I`m working on a django-project where I`m using the awsome pyftpdlib for ftpserver-functionality. I also have a simple worker deamon running in the background, but not listening to any port. How can I start all of these processes on one file? Tried using subprocess and popen bu

Re: List comprehension - NameError: name '_[1]' is not defined ?

2009-01-16 Thread mario ruggier
On Jan 16, 1:35 pm, ajaksu wrote: > On Jan 16, 5:09 am, mario ruggier wrote: > > > Laboriously doing all these > > checks on each expr eval will be very performance heavy, so I hope to > > be able to limit access to all these more efficiently. Suggestions? > > None regarding the general issue, a

Python 3: range objects cannot be sliced

2009-01-16 Thread Alan G Isaac
Is the behavior below expected? Documented? (The error msg is misleading.) Thanks, Alan Isaac >>> x = range(20) >>> s = slice(None,None,2) >>> x[s] Traceback (most recent call last): File "", line 1, in TypeError: sequence index must be integer, not 'slice' -- http://mail.python.org/mailman/li

Re: Beginner: Data type conversion question

2009-01-16 Thread flagg
On Jan 15, 11:43 pm, Marc 'BlackJack' Rintsch wrote: > On Thu, 15 Jan 2009 21:09:43 -0800, flagg wrote: > > def checkSerial(): > >     """ > >     Checks the current 'date' portion of the serial number and checks > >     the current 'counter'(the two digit number at the end of the serial > >     n

Re: Integrating awk in Python

2009-01-16 Thread mk
Alfons Nonell-Canals wrote: At the beggining I thought to "translate" them and program them in python but I prefer to avoid it because it means a lot of work and I should do it after each new version of this external stuff. I would like to integrate them into my python code. That's kind of

Re: lazy evaluation is sometimes too lazy... help please.

2009-01-16 Thread Scott David Daniels
Ken Pu wrote: Hi, below is the code I thought should create two generates, it[0] = 0,1,2,3,4,5, and it[1] = 0,10,20,30,..., but they turn out to be the same!!! from itertools import * itlist = [0,0] for i in range(2): itlist[i] = (x+(i*10) for x in count()) ... print list(islice(itlist[0], 5)

Re: Beginner: Data type conversion question

2009-01-16 Thread flagg
On Jan 15, 11:35 pm, Terry Reedy wrote: > flagg wrote: > > I am still fairly new to python and programming in general.  My > > question is regardingdataconversion, I am working on a script that > > will edit dns zone files, one of the functions i wrote handles > > updating the serial number. > > O

Re: optimizing large dictionaries

2009-01-16 Thread pruebauno
On Jan 15, 4:39 pm, Per Freem wrote: > hello > > i have an optimization questions about python. i am iterating through > a file and counting the number of repeated elements. the file has on > the order > of tens of millions elements... > > i create a dictionary that maps elements of the file that

Re: Possible bug in Tkinter - Python 2.6

2009-01-16 Thread Terry Reedy
Eric Brunel wrote: On Thu, 15 Jan 2009 23:49:22 +0100, Terry Reedy wrote: Eric Brunel wrote: [snip]>> And BTW, if this is actually a bug, where can I report it? bugs.python.org Thanks. I reported the problem. When you report that you reported to problem to the tracker (a good idea), pl

Python 2.6's multiprocessing lock not working on second use?

2009-01-16 Thread Frédéric Sagnes
Hi, I ran a few tests on the new Python 2.6 multiprocessing module before migrating a threading code, and found out the locking code is not working well. In this case, a pool of 5 processes is running, each trying to get the lock and releasing it after waiting 0.2 seconds (action is repeated twice

Re: mimetypes oddity

2009-01-16 Thread Terry Reedy
Sion Arrowsmith wrote: In article , wrote: [mimetype weirdness reported] Sion> Is this a bug? Might be. Can you file a bug report in the Python issue tracker with a small script that demonstrates the behavior? http://bugs.python.org/issue4963 (It's tagged as being 2.4 and 2.5 because

Re: English-like Python

2009-01-16 Thread Dotan Cohen
2009/1/16 The Music Guy : > Just out of curiousity, have there been any attempts to make a version > of Python that looks like actual English text? I mean, so much of Python > is already based on the English language that it seems like the next > natural step would be to make a programming language

Re: Integrating awk in Python

2009-01-16 Thread Terry Reedy
Willi Richert wrote: Hi, take a look at the 5th link at http://tinyurl.com/7s8kfq It's called pyawk. Stupid link wanting to set yet another useless cookie. Answer will not always be 5th. Just say 'Google pyawk' or better give link http://pyawk.sourceforge.net/ Am Freitag, 16. Januar 2009

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-16 Thread Paul Rubin
mk writes: > I was flabbergasted to read that optional static typing was dropped by > Guido due to "lack of interest in community" IIRC. I don't remember that happening. PEP 3107 still lists type checking as a use case for Python 3.0 function annotations. -- http://mail.python.org/mailman/listin

Re: Client Socket Connection to Java server

2009-01-16 Thread Venkatraman.S.
Hint: Java sends a '\n' character at the end. -- http://mail.python.org/mailman/listinfo/python-list

Re: Skull Socks (was Re: Convention vs. fascism)

2009-01-16 Thread Steven D'Aprano
On Fri, 16 Jan 2009 11:01:18 -0500, J. Cliff Dyer wrote: > On Fri, 2009-01-16 at 08:57 +, Steven D'Aprano wrote: >> On Fri, 16 Jan 2009 10:03:28 +0200, Hendrik van Rooyen wrote: >> >> > Oh come on you lot - you are carrying on as if Diez were wearing his >> > skull socks again - do me a favou

Skull Socks (was Re: Convention vs. fascism)

2009-01-16 Thread J. Cliff Dyer
On Fri, 2009-01-16 at 08:57 +, Steven D'Aprano wrote: > On Fri, 16 Jan 2009 10:03:28 +0200, Hendrik van Rooyen wrote: > > > Oh come on you lot - you are carrying on as if Diez were wearing his > > skull socks again - do me a favour and give him a break! > And... skull socks? Cool. Where can

Start two threads in same time

2009-01-16 Thread vedrandekovic
Hello, Does anybody know how can I start two threads in same time? Regards, John -- http://mail.python.org/mailman/listinfo/python-list

  1   2   >