Re: how to convert from Decimal('1.23456789') to Decimal('1.234')

2009-03-23 Thread alex23
On Mar 23, 4:40 pm, valpa wrote: > I only need the 3 digits after '.' > > Is there any way other than converting from/to string? I'm not sure if this is the canonical way but it works: >>> d = Decimal('1.23456789') >>> three_places = Decimal('0.001') # or anything that has the exponent depth >>

Re: Unicode problem in ucs4

2009-03-23 Thread abhi
On Mar 20, 5:47 pm, "M.-A. Lemburg" wrote: > On 2009-03-20 12:13, abhi wrote: > > > > > > > On Mar 20, 11:03 am, "Martin v. Löwis" wrote: > >>> Any idea on why this is happening? > >> Can you provide a complete example? Your code looks correct, and should > >> just work. > > >> How do you know th

Re: How can I do bit operation on python float value

2009-03-23 Thread John Machin
On Mar 23, 5:44 pm, valpa wrote: > I have a python float 1.2345678. I know that it is stored as a double > in C type. And I know it actually is 1010101010101 -like format. Then > I want to do some bit operation on it. How? > > Sure, I want a float output when I finish the operation. import struct

Re: how to convert from Decimal('1.23456789') to Decimal('1.234')

2009-03-23 Thread Hyunchul Kim
In that case, I usually use # when rounding is proper, s = '1.23456789' print round(float(s)) or # when cut out is proper, from math import floor print floor(float(s)*1000)/1000 Hyunchul valpa wrote: I only need the 3 digits after '.' Is there any way other than converting from/to string? -

Re: how to convert from Decimal('1.23456789') to Decimal('1.234')

2009-03-23 Thread Steven D'Aprano
On Sun, 22 Mar 2009 23:40:38 -0700, valpa wrote: > I only need the 3 digits after '.' > > Is there any way other than converting from/to string? You should Read the Fine Manual: http://docs.python.org/library/decimal.html [quote] The quantize() method rounds a number to a fixed exponent. This

Re: splitting a large dictionary into smaller ones

2009-03-23 Thread Steven D'Aprano
On Sun, 22 Mar 2009 23:10:21 -0400, Terry Reedy wrote: > Searching for a key in, say, 10 dicts will be slower than searching for > it in just one. The only reason I would do this would be if the dict > had to be split, say over several machines. But then, you could query > them in parallel. Tha

Re: lipo: can't figure out the architecture type of

2009-03-23 Thread VJ
On Mar 19, 4:48 pm, Vijayendra Bapte wrote: > Hi, > > I am getting an gcc compilation error while installing FSEvents > (http://pypi.python.org/packages/source/p/pyobjc-framework-FSEvents/ > pyobjc-framework-FSEvents-2.2b1.tar.gz) package on my Mac (OS X > 10.4.11, Intel Core Duo 32 bit processor,

Re: Unicode problem in ucs4

2009-03-23 Thread John Machin
On Mar 23, 6:18 pm, abhi wrote: [snip] > Hi Mark, >      Thanks for the help. I tried PyUnicode_AsWideChar() but I am > getting the same result i.e. only the first letter. > > sample code: > > #include > > static PyObject *unicode_helper(PyObject *self,PyObject *args){ >         PyObject *sampleO

Re: Async serial communication/threads sharing data

2009-03-23 Thread Hendrik van Rooyen
"Nick Craig-Wood" wrote: > > I wrote a serial port to TCP proxy (with logging) with twisted. The > problem I had was that twisted serial ports didn't seem to have any > back pressure. By that I mean I could pump data into a 9600 baud > serial port at 10 Mbit/s. Twisted would then buffer the d

Re: Unicode problem in ucs4

2009-03-23 Thread John Machin
On Mar 23, 6:41 pm, John Machin had a severe attack of backslashitis: > [presuming littleendian] The ucs4 string will look like "\t\0\0\0e > \0\0\0s\0\0\0t\0\0\0" in memory. I suspect that your wprintf is > grokking only 16-bit doodads -- "\t\0" is printed and then "\0\0" is > end-of-string. Try

Re: splitting a large dictionary into smaller ones

2009-03-23 Thread John Machin
On Mar 23, 1:32 pm, per wrote: > hi all, > > i have a very large dictionary object that is built from a text file > that is about 800 MB -- it contains several million keys.  ideally i > would like to pickle this object so that i wouldnt have to parse this > large file to compute the dictionary ev

Re: how to convert from Decimal('1.23456789') to Decimal('1.234')

2009-03-23 Thread Mark Dickinson
On Mar 23, 7:01 am, alex23 wrote: > On Mar 23, 4:40 pm, valpa wrote: > > > I only need the 3 digits after '.' > > > Is there any way other than converting from/to string? > > I'm not sure if this is the canonical way but it works: > > >>> d = Decimal('1.23456789') > >>> three_places = Decimal('0.

Re: Obtaining the attributes and properties of a folder recursively.

2009-03-23 Thread Tim Golden
venutaurus...@gmail.com wrote: On Mar 21, 3:05 pm, Tim Golden wrote: venutaurus...@gmail.com wrote: Thank you Sir for your reply. It is working for me. But is failing if I have Unicode characters in my path. I tried giving a 'u' in front of the path but still it fails at f.createdat. Does it s

Re: How can I do bit operation on python float value

2009-03-23 Thread valpa
On 3月23日, 上午3时18分, John Machin wrote: > On Mar 23, 5:44 pm, valpa wrote: > > > I have a python float 1.2345678. I know that it is stored as a double > > in C type. And I know it actually is 1010101010101 -like format. Then > > I want to do some bit operation on it. How? > > > Sure, I want a float

Re: python 3, subclassing TextIOWrapper.

2009-03-23 Thread lambertdw
For D. Murray's suggestion---I think that we programmers have to learn the idiom. We don't always control open, such as subprocess.Popen(). Thank you. I hope these thoughts help with issue 5513 and the related questions to follow about complete removal of file in python3. Opening the file in bin

Re: how to convert from Decimal('1.23456789') to Decimal('1.234')

2009-03-23 Thread Mark Dickinson
On Mar 23, 6:40 am, valpa wrote: > I only need the 3 digits after '.' > > Is there any way other than converting from/to string? And in Python 3.0, just use the built-in round function: >>> from decimal import Decimal >>> round(Decimal('1.23456789'), 3) Decimal('1.235') This uses the rounding s

Re: How can I do bit operation on python float value

2009-03-23 Thread Mark Dickinson
On Mar 23, 8:44 am, valpa wrote: > Yes, I want to do a & operation. Right, but what & operation, and why? Are you trying to do something that's mathematically meaningful? If so, there may be a better (more portable/faster/clearer) way than bit-twiddling. Mark -- http://mail.python.org/mailman/l

Re: Unicode problem in ucs4

2009-03-23 Thread M.-A. Lemburg
On 2009-03-23 08:18, abhi wrote: > On Mar 20, 5:47 pm, "M.-A. Lemburg" wrote: >>> unicodeTest.c >>> #include >>> static PyObject *unicode_helper(PyObject *self,PyObject *args){ >>>PyObject *sampleObj = NULL; >>>Py_UNICODE *sample = NULL; >>> if (!PyArg_ParseTuple(args, "O", &

Re: how to convert from Decimal('1.23456789') to Decimal('1.234')

2009-03-23 Thread Mensanator
On Mar 23, 2:24�am, Steven D'Aprano wrote: > On Sun, 22 Mar 2009 23:40:38 -0700, valpa wrote: > > I only need the 3 digits after '.' > > > Is there any way other than converting from/to string? > > You should Read the Fine Manual: > > http://docs.python.org/library/decimal.html > > [quote] > The q

Re: Async serial communication/threads sharing data

2009-03-23 Thread Nick Craig-Wood
Jean-Paul Calderone wrote: > On Sun, 22 Mar 2009 12:30:04 -0500, Nick Craig-Wood > wrote: > >I wrote a serial port to TCP proxy (with logging) with twisted. The > >problem I had was that twisted serial ports didn't seem to have any > >back pressure. By that I mean I could pump data into a 960

Re: How can I do bit operation on python float value

2009-03-23 Thread John Machin
On Mar 23, 7:44 pm, valpa wrote: > On 3月23日, 上午3时18分, John Machin wrote: > > > > > On Mar 23, 5:44 pm, valpa wrote: > > > > I have a python float 1.2345678. I know that it is stored as a double > > > in C type. And I know it actually is 1010101010101 -like format. Then > > > I want to do some bi

Re: How can I do bit operation on python float value

2009-03-23 Thread Miles
On Mon, Mar 23, 2009 at 2:44 AM, valpa wrote: > I have a python float 1.2345678. I know that it is stored as a double > in C type. And I know it actually is 1010101010101 -like format. Then > I want to do some bit operation on it. How? > > Sure, I want a float output when I finish the operation. J

Re: how to convert from Decimal('1.23456789') to Decimal('1.234')

2009-03-23 Thread Steven D'Aprano
On Mon, 23 Mar 2009 01:45:53 -0700, Mensanator wrote: >> but you can create a helper >> function very easily: >> >> def round(dec, places, rounding=decimal.ROUND_HALF_UP): � � return >> dec.quantize(decimal.Decimal(str(10**-places)), rounding) > > Still ugly. I would do this: > a = Decimal(

Re: Unicode problem in ucs4

2009-03-23 Thread abhi
On Mar 23, 3:04 pm, "M.-A. Lemburg" wrote: > On 2009-03-23 08:18, abhi wrote: > > > > > On Mar 20, 5:47 pm, "M.-A. Lemburg" wrote: > >>> unicodeTest.c > >>> #include > >>> static PyObject *unicode_helper(PyObject *self,PyObject *args){ > >>>    PyObject *sampleObj = NULL; > >>>            Py_UNIC

Re: Safe to call Py_Initialize() frequently?

2009-03-23 Thread Mark Hammond
On 23/03/2009 12:14 PM, Graham Dumpleton wrote: On Mar 21, 10:27 am, Mark Hammond wrote: Calling Py_Initialize and Py_Finalize multiple times does leak (Python 3 has mechanisms so this need to always be true in the future, but it is true now for non-trivial apps. Mark, can you please clarify

Re: splitting a large dictionary into smaller ones

2009-03-23 Thread Dave Angel
As others have said, a database is probably the right answer. There, the data is kept on disk, and only a few records at a time are read for each access, with modification transactions usually being synchronous. However, there are use cases where your approach makes more sense. And it should

Re: Safe to call Py_Initialize() frequently?

2009-03-23 Thread Graham Dumpleton
On Mar 23, 10:00 pm, Mark Hammond wrote: > On 23/03/2009 12:14 PM, Graham Dumpleton wrote: > > > On Mar 21, 10:27 am, Mark Hammond  wrote: > >> Calling > >> Py_Initialize and Py_Finalize multiple times does leak (Python 3 has > >> mechanisms so this need to always be true in the future, but it is

Re: splitting a large dictionary into smaller ones

2009-03-23 Thread Dave Angel
As others have said, a database is probably the right answer. There, the data is kept on disk, and only a few records at a time are read for each access, with modification transactions usually being synchronous. However, there are use cases where your approach makes more sense. And it should

Re: Using python 3 for scripting?

2009-03-23 Thread Timo Myyrä
Not too keen on working with Solaris either. Did some small configuration last time I worked there and it was all a mess. I'm trying to convince them to switch to OpenBSD :) Timo -- http://mail.python.org/mailman/listinfo/python-list

Re: Unicode problem in ucs4

2009-03-23 Thread M.-A. Lemburg
On 2009-03-23 11:50, abhi wrote: > On Mar 23, 3:04 pm, "M.-A. Lemburg" wrote: > Thanks Marc, John, > With your help, I am at least somewhere. I re-wrote the code > to compare Py_Unicode and wchar_t outputs and they both look exactly > the same. > > #include > > static PyObject *unicode_

Re: Style formating of multiline query, advise

2009-03-23 Thread someon
On Mar 19, 10:26 am, Marco Mariani wrote: > someone wrote: > >> Also, for SQL, (A) why are you using nested joins?, and > > > inner select produce smaller set which is then joined with other > > table, kind a optimization > > Did you time it? I've did explain on both kinds of query (with nested s

Re: Unicode problem in ucs4

2009-03-23 Thread abhi
On Mar 23, 4:37 pm, "M.-A. Lemburg" wrote: > On 2009-03-23 11:50, abhi wrote: > > > > > On Mar 23, 3:04 pm, "M.-A. Lemburg" wrote: > > Thanks Marc, John, > >          With your help, I am at least somewhere. I re-wrote the code > > to compare Py_Unicode and wchar_t outputs and they both look exac

Escaping optional parameter in WHERE clause

2009-03-23 Thread someone
Hi, as you can see below I have some optional parameter for my query (mf, age). They are in WHERE clause only if not empty. In this function they are not escaped as, for example, 'search' parameter, cause I can't pass them to execute function, which does escaping automatically. I could write anot

Re: Async serial communication/threads sharing data

2009-03-23 Thread Jean-Paul Calderone
On Mon, 23 Mar 2009 05:30:04 -0500, Nick Craig-Wood wrote: Jean-Paul Calderone wrote: [snip] In the case of a TCP to serial forwarder, you don't actually have to implement either a producer or a consumer, since both the TCP connection and the serial connection are already both producers an

Looking for a Python Django Freelancer

2009-03-23 Thread dajor85...@googlemail.com
For a Python Google Apps Project with Django we are looking for a technical developer offsite. IF you are interesting please send your CV and rate to daniel.jor...@fellow-consulting.de -- http://mail.python.org/mailman/listinfo/python-list

Re: Escaping optional parameter in WHERE clause

2009-03-23 Thread MRAB
someone wrote: Hi, as you can see below I have some optional parameter for my query (mf, age). They are in WHERE clause only if not empty. In this function they are not escaped as, for example, 'search' parameter, cause I can't pass them to execute function, which does escaping automatically. I

Re: Escaping optional parameter in WHERE clause

2009-03-23 Thread andrew cooke
note that your version is open to sql injection attacks, while mrab's reply isn't. andrew someone wrote: > if mf: > mf = " AND mf = %s " % mf > if age: > age = " AND age = %s " % age -- http://mail.python.org/mailman/listinfo/python-list

Re: splitting a large dictionary into smaller ones

2009-03-23 Thread Tim Chase
i have a very large dictionary object that is built from a text file that is about 800 MB -- it contains several million keys. ideally i would like to pickle this object so that i wouldnt have to parse this large file to compute the dictionary every time i run my program. however currently the pi

Re: Escaping optional parameter in WHERE clause

2009-03-23 Thread andrew cooke
ah, sorry, from title i guess you were aware of this. andrew andrew cooke wrote: > note that your version is open to sql injection attacks, while mrab's > reply isn't. andrew > > someone wrote: >> if mf: >> mf = " AND mf = %s " % mf >> if age: >> age = "

Re: Escaping optional parameter in WHERE clause

2009-03-23 Thread someon
On Mar 23, 1:48 pm, MRAB wrote: > someone wrote: > > Hi, > > > as you can see below I have some optional parameter for my query (mf, > > age). They are in WHERE clause only if not empty. > > In this function they are not escaped as, for example, 'search' > > parameter, cause I can't pass them to e

Portable Python 1.1 released

2009-03-23 Thread Perica Zivkovic
Dear people, Portable Python 1.1 is released in three flavors: Python 2.5.4, 2.6.1 and 3.0.1. More information: Included in this release: - This release contains three different packages for three different Python versions – Python 2.5.4, Python 2.6.1 and Python 3.0.1. Pac

Re: Unicode problem in ucs4

2009-03-23 Thread abhi
On Mar 23, 4:57 pm, abhi wrote: > On Mar 23, 4:37 pm, "M.-A. Lemburg" wrote: > > > > > On 2009-03-23 11:50, abhi wrote: > > > > On Mar 23, 3:04 pm, "M.-A. Lemburg" wrote: > > > Thanks Marc, John, > > >          With your help, I am at least somewhere. I re-wrote the code > > > to compare Py_Unic

Re: file.read() doesn't read the whole file

2009-03-23 Thread R. David Murray
Sreejith K wrote: > > Try and write an example that shows the problem in fifteen lines or > > less. Much easier for us to focus on the issue that way. > > import os > def read(length, offset): > os.chdir('/mnt/gfs_local/') > snap = open('mango.txt_snaps/snap1/0','r') > snap.seek

Re: file.read() doesn't read the whole file

2009-03-23 Thread Steve Holden
Sreejith K wrote: >> Try and write an example that shows the problem in fifteen lines or >> less. Much easier for us to focus on the issue that way. > > import os > def read(length, offset): > os.chdir('/mnt/gfs_local/') > snap = open('mango.txt_snaps/snap1/0','r') > snap.seek(of

Re: what features would you like to see in 2to3?

2009-03-23 Thread Steve Holden
Kay Schluehr wrote: > On 22 Mrz., 20:39, Benjamin Peterson wrote: >> It's GSoC time again, and I've had lots of interested students asking about >> doing on project on improving 2to3. What kinds of improvements and features >> would you like to see in it which student programmers could accomplish?

Re: script files with python (instead of tcsh/bash)?

2009-03-23 Thread Esmail
MRAB wrote: Two quick questions: As a replacement for grep I would use the re module and its methods? What about awk which I regularly use to extract fields based on position but not column number, what should I be using in Python to do the same? Just use string slicing. Would that be equ

Re: splitting a large dictionary into smaller ones

2009-03-23 Thread Steve Holden
per wrote: > hi all, > > i have a very large dictionary object that is built from a text file > that is about 800 MB -- it contains several million keys. ideally i > would like to pickle this object so that i wouldnt have to parse this > large file to compute the dictionary every time i run my pr

Re: script files with python (instead of tcsh/bash)?

2009-03-23 Thread Esmail
Hi Gabriel, Gabriel Genellina wrote: En Sun, 22 Mar 2009 11:05:22 -0300, MRAB escribió: Esmail wrote: Nick Craig-Wood wrote: Esmail wrote: <..> As a replacement for grep I would use the re module and its methods? Perhaps; but strings have methods too (`"abc" in line` is easier to read

Re: Escaping optional parameter in WHERE clause

2009-03-23 Thread Steve Holden
MRAB wrote: > someone wrote: >> Hi, >> >> as you can see below I have some optional parameter for my query (mf, >> age). They are in WHERE clause only if not empty. >> In this function they are not escaped as, for example, 'search' >> parameter, cause I can't pass them to execute function, which do

Re: script files with python (instead of tcsh/bash)?

2009-03-23 Thread Esmail
Hello again Nick, thanks for the additional script example. I was able to put something together where I read the whole file into a list as a series of lines (via readlines()) and then loop through the lines seeing if the target string was "in" the line .. seems to have worked reasonably well. I

Re: Lambda forms and scoping

2009-03-23 Thread R. David Murray
"Gabriel Genellina" wrote: > > However, I think that a Python closure is not quite the same thing as a > > 'computer science' closure, for the same reason that people coming from a > > language with variables-and-values as opposed to namespaces get confused > > when dealing with Python function ca

Re: loading program's global variables in ipython

2009-03-23 Thread Esmail
Peter Otten wrote: Use %run -i myfile.py or execfile("myfile.py") # not ipython-specific thanks for these suggestions Peter, I have had exactly the same problem and was looking for a way around it -- this will be very helpful. Esmail ps: for some reason I am unable to post to the gma

Re: Generator

2009-03-23 Thread R. David Murray
John Posner wrote: > > [snip] > > > If you want next(g) to yield 3, you'd have to do something like: > > > > > > g = (x for x in s[:]) > > > > > > where s[:] makes a copy of s that is then iterated over. > > > BTW, this simpler statement works, too: > >g = iter(s[:]) Yes, but one p

Relative Imports, why the hell is it so hard?

2009-03-23 Thread CinnamonDonkey
Hi All, I'm fairly new to Python so I still have a lot to learn. But I'd like to know how to correectly use relative imports. Please, please... please! don't go off on rants about why you think relative imports should not be used. I've got 15+ years in C++ and relative inclusion of other sections

Re: Relative Imports, why the hell is it so hard?

2009-03-23 Thread Maxim Khitrov
On Mon, Mar 23, 2009 at 10:16 AM, CinnamonDonkey wrote: > Hi All, > > I'm fairly new to Python so I still have a lot to learn. But I'd like > to know how to correectly use relative imports. > > Please, please... please! don't go off on rants about why you think > relative imports should not be use

Re: Relative Imports, why the hell is it so hard?

2009-03-23 Thread skip
>> Please, please... please! don't go off on rants about why you think >> relative imports should not be used. I've got 15+ years in C++ and >> relative inclusion of other sections of code has never been a >> problem. As far as I am concerned what I am trying to do is >> perfe

Re: Relative Imports, why the hell is it so hard?

2009-03-23 Thread CinnamonDonkey
Hi Guys, Thanx for the quick responses, it is very much appreciated! Skip, that's a good point about "C++ != Python" and I assure you I am very much aware of that ;-). Looking at http://www.python.org/dev/peps/pep-0328/#guido-s-decision would suggest, unless I am completely miss-understanding th

Re: [python-list] Re: Strange crash issue on Windows w/ PyGTK, Cairo...

2009-03-23 Thread CJ Kucera
CJ Kucera wrote: > Okay, I've got a reproducible testcase of this available up here: > http://apocalyptech.com/pygtk-zlib/ > > I'm no longer *totally* convinced that it's a zlib issue... zlib's call > actually returns a valid string, and the error happens later in the app. Hello, again, list. O

Re: Relative Imports, why the hell is it so hard?

2009-03-23 Thread Maxim Khitrov
On Mon, Mar 23, 2009 at 11:22 AM, CinnamonDonkey wrote: > Looking at http://www.python.org/dev/peps/pep-0328/#guido-s-decision > would suggest, unless I am completely miss-understanding the example, > that '.' refers to the current level and '..' pops up a level. That is correct, but you cannot j

Re: Relative Imports, why the hell is it so hard?

2009-03-23 Thread Gabriel Genellina
En Mon, 23 Mar 2009 12:22:21 -0300, CinnamonDonkey escribió:     >> \ App     >> |   main.py     >> +--\subpack1     >> |   |   __init__.py     >> |   |   module1.py     >> |     >> +--\subpack2     >> |   |   __init__.py     >> |   |   module2.py     >> Module1 needs to access functionality

Re: pickle.load() extremely slow performance

2009-03-23 Thread Jim Garrison
Benjamin Peterson wrote: Terry Reedy udel.edu> writes: 3.1a1 is out and I believe it has the io improvements. Massive ones, too. It'd be interesting to see your results on the alpha. On 3.1a1 the unpickle step takes 2.4 seconds, an 1875% improvement. Thanks. -- http://mail.python.org/mailm

Re: Relative Imports, why the hell is it so hard?

2009-03-23 Thread CinnamonDonkey
My applogies if this is a silly question... but what makes something a package? and does that mean that what I am trying to do is not possible ? :( On 23 Mar, 15:53, "Gabriel Genellina" wrote: > En Mon, 23 Mar 2009 12:22:21 -0300, CinnamonDonkey   > escribió: > > > > >>     >> \ App > >>    

Re: Relative Imports, why the hell is it so hard?

2009-03-23 Thread Maxim Khitrov
On Mon, Mar 23, 2009 at 12:19 PM, CinnamonDonkey wrote: > My applogies if this is a silly question... but what makes something a > package? and does that mean that what I am trying to do is not > possible ? A package is a directory that has an __init__.py file. That file can be empty, or contain

pylint 0.17.0 and astng 0.18.0 release

2009-03-23 Thread Emile Anclin
Hello, we are glad to announce the release of pylint 0.17.0 http://www.logilab.org/project/pylint/0.17.0 which is based on a major refactoring of astng (0.18.0) http://www.logilab.org/project/logilab-astng/0.18.0 . For python 2.5, pylint will now use python's _ast module which is much faster than

Re: Using python 3 for scripting?

2009-03-23 Thread Alan G Isaac
On 3/22/2009 12:41 PM Chris Rebert apparently wrote: 2.6.1, the latest non-3.x release is probably best. Most libraries haven't been ported to 3.x yet, so Python 3 has yet to become widespread. This seems slightly optimistic to me. Until a week ago, there was not a NumPy release for 2.6. There

Re: Relative Imports, why the hell is it so hard?

2009-03-23 Thread Gabriel Genellina
En Mon, 23 Mar 2009 13:19:51 -0300, CinnamonDonkey escribió: My applogies if this is a silly question... but what makes something a package? A package is a directory with an __init__.py file [that Python is aware of]. and does that mean that what I am trying to do is not possible ? Y

Re: pickle.load() extremely slow performance

2009-03-23 Thread Jean-Paul Calderone
On Mon, 23 Mar 2009 10:57:54 -0500, Jim Garrison wrote: Benjamin Peterson wrote: Terry Reedy udel.edu> writes: 3.1a1 is out and I believe it has the io improvements. Massive ones, too. It'd be interesting to see your results on the alpha. On 3.1a1 the unpickle step takes 2.4 seconds, an 1

Re: script files with python (instead of tcsh/bash)?

2009-03-23 Thread Alan G Isaac
On 3/21/2009 9:26 AM Esmail apparently wrote: I also write out some gnuplot scripts that later get executed to generate .jpg images. See Gnuplot.py Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list

Re: Relative Imports, why the hell is it so hard?

2009-03-23 Thread rocky
On Mar 23, 11:22 am, CinnamonDonkey wrote: > Hi Guys, > > Thanx for the quick responses, it is very much appreciated! > > Skip, that's a good point about "C++ != Python" and I assure you I am > very much aware of that ;-). > > Looking athttp://www.python.org/dev/peps/pep-0328/#guido-s-decision > w

Re: how to convert from Decimal('1.23456789') to Decimal('1.234')

2009-03-23 Thread Mensanator
On Mar 23, 5:48 am, Steven D'Aprano wrote: > On Mon, 23 Mar 2009 01:45:53 -0700, Mensanator wrote: > >> but you can create a helper > >> function very easily: > > >> def round(dec, places, rounding=decimal.ROUND_HALF_UP): return > >> dec.quantize(decimal.Decimal(str(10**-places)), rounding) > > >

Re: pickle.load() extremely slow performance

2009-03-23 Thread Steve Holden
Jean-Paul Calderone wrote: > On Mon, 23 Mar 2009 10:57:54 -0500, Jim Garrison wrote: >> Benjamin Peterson wrote: >>> Terry Reedy udel.edu> writes: 3.1a1 is out and I believe it has the io improvements. >>> >>> Massive ones, too. It'd be interesting to see your results on the alpha. >> >> On

Re: Async serial communication/threads sharing data

2009-03-23 Thread Nick Craig-Wood
Jean-Paul Calderone wrote: > On Mon, 23 Mar 2009 05:30:04 -0500, Nick Craig-Wood > wrote: > >Jean-Paul Calderone wrote: > > [snip] > >> > >> In the case of a TCP to serial forwarder, you don't actually have to > >> implement either a producer or a consumer, since both the TCP connection > >>

mocking xmlrpclib

2009-03-23 Thread J Kenneth King
At the risk of sounding like I don't know what I'm doing, I must say that I am finding it rather difficult/tedious to mock the xmlrpclib interface using minimock. I refuse to believe that I'm the only developer to have tried this before, but google isn't being my friend and I can't seem to get it

Syntax error when importing a file which starts with a number

2009-03-23 Thread simon . woolf
Hello, all. I don't suppose anyone has any idea why it seems to be impossible to import any file which starts with a number? You get a syntax error, whether the file exists or not. Try it yourself: >>> import foo ImportError: No module named foo >>> import 1foo File "", line 1 import 1fo

Re: Syntax error when importing a file which starts with a number

2009-03-23 Thread simon . woolf
Forgot to mention: I'm on Python 2.5.2, on Ubuntu 8.10. Simon -- http://mail.python.org/mailman/listinfo/python-list

Re: Disable automatic interning

2009-03-23 Thread Hrvoje Niksic
George Sakkis writes: > I'm working on some graph generation problem where the node identity > is significant (e.g. "if node1 is node2: # do something) but ideally I > wouldn't want to impose any constraint on what a node is I'm not sure if it helps in your case, but you can easily turn off the

Re: Syntax error when importing a file which starts with a number

2009-03-23 Thread Miles
On Mon, Mar 23, 2009 at 1:56 PM, wrote: > Hello, all. > > I don't suppose anyone has any idea why it seems to be impossible to > import any file which starts with a number?  You get a syntax error, > whether the file exists or not. Identifiers can't start with a number. http://docs.python.org/r

Re: Syntax error when importing a file which starts with a number

2009-03-23 Thread Gabriel Genellina
En Mon, 23 Mar 2009 14:56:21 -0300, escribió: I don't suppose anyone has any idea why it seems to be impossible to import any file which starts with a number? You get a syntax error, whether the file exists or not. You don't import a file, you import a module. And a module name is an ident

Mail client in Python?

2009-03-23 Thread Ken D'Ambrosio
Idle curiosity: is there a (decent) IMAP mail client (web or local) written in Python? I've got a project that needs doing, and it just occurred to me that a mail client might be the ideal interface; I'd have to change some back-end stuff (to do database queries instead of IMAP or POP queries), bu

Re: Syntax error when importing a file which starts with a number

2009-03-23 Thread andrew cooke
The grammar indicates that the module name is an identifier, and identifiers can't start with digits (you can't have a variable name that starts with a '1' either). This is probably quite fundamental (I guess the lexer will implement it) so suspect it is impossible to change. That means it is a

Re: Syntax error when importing a file which starts with a number

2009-03-23 Thread MRAB
simon.wo...@gmail.com wrote: Hello, all. I don't suppose anyone has any idea why it seems to be impossible to import any file which starts with a number? You get a syntax error, whether the file exists or not. Try it yourself: import foo ImportError: No module named foo import 1foo Fil

Re: Syntax error when importing a file which starts with a number

2009-03-23 Thread andrew cooke
andrew cooke wrote: ffs. feature, not bug. sorry. > This is probably quite fundamental (I guess the lexer will implement it) > so suspect it is impossible to change. That means it is a bug, not a > feature (and it's quite a reasonable restriction, since it reduces > ambiguity). -- http://mai

Re: Mail client in Python?

2009-03-23 Thread Petite Abeille
On Mar 23, 2009, at 7:14 PM, Ken D'Ambrosio wrote: Idle curiosity: is there a (decent) IMAP mail client (web or local) written in Python? I've got a project that needs doing, and it just occurred to me that a mail client might be the ideal interface; I'd have to change some back-end stuff (t

Re: Using python 3 for scripting?

2009-03-23 Thread Nick Craig-Wood
Alan G Isaac wrote: > On 3/22/2009 12:41 PM Chris Rebert apparently wrote: > > 2.6.1, the latest non-3.x release is probably best. Most libraries > > haven't been ported to 3.x yet, so Python 3 has yet to become > > widespread. > > This seems slightly optimistic to me. Until a week ago, there

Re: Relative Imports, why the hell is it so hard?

2009-03-23 Thread bearophileHUGS
CinnamonDonkey: >what makes something a package? If you don't know what a package is, then maybe you don't need packages. In your project is it possible to avoid using packages and just use modules in the same directory? Bye, bearophile -- http://mail.python.org/mailman/listinfo/python-list

Re: Portable Python 1.1 released

2009-03-23 Thread Dutch Masters
This is a great piece of work. Thanks. -- http://mail.python.org/mailman/listinfo/python-list

udp package header

2009-03-23 Thread mete
Hi all, I got a problem. İ want to send udp package and get this package (server and clinet ). it's easy to python but i want to look the udp header how can i do ? -- http://mail.python.org/mailman/listinfo/python-list

Wing IDE 3.1.8 released

2009-03-23 Thread Wingware
Hi, Wingware has released version 3.1.8 of Wing IDE, a bug-fix release for all three product levels of Wing IDE. *Release Highlights* This release includes the following: * Fixed problems seen with Subversion 1.4+ * Properly ignore settrace exception on x64 systems * Fixed "perforce submit" fo

Re: Syntax error when importing a file which starts with a number

2009-03-23 Thread John Machin
On Mar 24, 4:56 am, simon.wo...@gmail.com wrote: > It's a bit annoying, as I have an enforced naming scheme. Do you mean that some authority other than yourself is seriously insisting that the names of source files *must* start with one or more digits? What is the rationale for such a scheme? --

Re: pickle.load() extremely slow performance

2009-03-23 Thread Jim Garrison
Steve Holden wrote: Jean-Paul Calderone wrote: On Mon, 23 Mar 2009 10:57:54 -0500, Jim Garrison wrote: Benjamin Peterson wrote: Terry Reedy udel.edu> writes: 3.1a1 is out and I believe it has the io improvements. Massive ones, too. It'd be interesting to see your results on the alpha. On

Re: Unicode problem in ucs4

2009-03-23 Thread M.-A. Lemburg
On 2009-03-23 14:05, abhi wrote: > Hi Marc, >Is there any way to ensure that wchar_t size would always be 2 > instead of 4 in ucs4 configured python? Googling gave me the > impression that there is some logic written in PyUnicode_AsWideChar() > which can take care of ucs4 to ucs2 conversion

Re: Unicode problem in ucs4

2009-03-23 Thread M.-A. Lemburg
On 2009-03-23 12:57, abhi wrote: >>> Is there any way >>> by which I can force wchar_t to be 2 bytes, or can I convert this UCS4 >>> data to UCS2 explicitly? >> Sure: just use the appropriate UTF-16 codec for this. >> >> /* Generic codec based encoding API. >> >>object is passed through the enc

Re: what features would you like to see in 2to3?

2009-03-23 Thread Benjamin Peterson
Kay Schluehr gmx.net> writes: > > On 22 Mrz., 20:39, Benjamin Peterson wrote: > > It's GSoC time again, and I've had lots of interested students asking about > > doing on project on improving 2to3. What kinds of improvements and features > > would you like to see in it which student programmers

Re: Syntax error when importing a file which starts with a number

2009-03-23 Thread simon . woolf
Many thanks to all for explanations. I'm going to take everyone's advice and ignore the naming scheme (especially as, on rereading, the naming scheme is apparently only mandatory if you're using C or Maple, for some reason). Thanks again. Simon (For those interested: > Do you mean that some au

Re: script files with python (instead of tcsh/bash)?

2009-03-23 Thread Esmail
Alan G Isaac wrote: On 3/21/2009 9:26 AM Esmail apparently wrote: I also write out some gnuplot scripts that later get executed to generate .jpg images. See Gnuplot.py Thanks Alan, I will! Esmail -- http://mail.python.org/mailman/listinfo/python-list

Re: decorators tutorials

2009-03-23 Thread Scott David Daniels
Josiah Carlson wrote: ... I try to limit my use of decorators whenever possible, both because I still have to support Python 2.3 (which doesn't support the syntax), and because I find that they obfuscate what the code is doing more often than not. I will admit that they are useful as a metapro

Re: Syntax error when importing a file which starts with a number

2009-03-23 Thread John Machin
On Mar 24, 9:12 am, simon.wo...@gmail.com wrote: > Many thanks to all for explanations.  I'm going to take everyone's > advice and ignore the naming scheme (especially as, on rereading, the > naming scheme is apparently only mandatory if you're using C or Maple, > for some reason). > > Thanks again

Re: Syntax error when importing a file which starts with a number

2009-03-23 Thread simon . woolf
> So in a sorted list of files, some of the project 1.2 files will > appear under 1-2 and others miles away under 1_2 ? And even if > the submitter is not so dopey, the submittee has two different > possibilities when looking for project 1.2's files? Brilliant! And > this is an educational

Re: What's the difference between generating a value and returning a value?

2009-03-23 Thread Alan G Isaac
On 3/23/2009 6:12 PM grocery_stocker apparently wrote: http://openbookproject.net/thinkCSpy/ch05.xhtml#index15 "The built-in functions we have used, such as abs, pow, and max, have produced results. Calling each of these functions generates a value, which we usually assign to a variable or use

Re: how to convert from Decimal('1.23456789') to Decimal('1.234')

2009-03-23 Thread Steven D'Aprano
On Mon, 23 Mar 2009 10:06:23 -0700, Mensanator wrote: > On Mar 23, 5:48 am, Steven D'Aprano cybersource.com.au> wrote: >> On Mon, 23 Mar 2009 01:45:53 -0700, Mensanator wrote: >> >> but you can create a helper >> >> function very easily: >> >> >> def round(dec, places, rounding=decimal.ROUND_HALF

  1   2   >