Re: Query regarding Python sybase module

2009-03-23 Thread Kushal Kumaran
On Tue, 24 Mar 2009 09:53:02 +0530 (IST) srinivasan srinivas wrote: > > Hi, > Does Sybase Python driver module implement multiple result sets from > a single command? Could anyone guide e in finding answer for this? > > The site http://python-sybase.sourceforge.net/sybase/ has the documentati

Re: Does Python have certificate?

2009-03-23 Thread Kay Schluehr
On 24 Mrz., 05:30, Steve Holden wrote: > > No, there is no certification for Python. Maybe in the future... > > O'Reilly School of Technology have plans to offer a Python > certification. But I have to write the courses first :) If you're done with it I'd additionally suggest the honory title of

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

2009-03-23 Thread alex23
On Mar 24, 3:10 pm, John Yeung wrote: > In my opinion, it's especially poor form to use the term > "generate" in that context when the language you are using to explain > these concepts has very specific things called "generators". In its defense, I'm pretty sure 'How to Think Like a Computer Sci

User athentication in Python/wxpython

2009-03-23 Thread jai_python
Hi friends, I need to do one client side application which is for uploading files to remote server with ude ftp. only authenticated users are permitted to access it, how can i pass the ftp connection in different py files? Help would be thankful -- http://mail.python.org/mailman/listinfo/python-l

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

2009-03-23 Thread John Yeung
On Mar 23, 6:12 pm, grocery_stocker wrote: > So what's the difference between generating a value and returning a > value? I agree with Alan's first thought, which is that no distinction was intended. In my opinion, it's especially poor form to use the term "generate" in that context when the lan

Re: udp package header

2009-03-23 Thread Shantanu Joshi
mete writes: > 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 ? Check out Scapy (http://www.secdev.org/projects/scapy/). -- http://mail.python.org/mailman/listinfo/python-li

Re: PEP 3143: Standard daemon process library

2009-03-23 Thread Ben Finney
Jean-Paul Calderone writes: > Here is a demonstration of the problem: > > # python -c ' > from __future__ import with_statement > import sys, daemon, os > with daemon.DaemonContext(stdout=sys.stdout, stdin=sys.stdin, > stderr=sys.stderr, uid=1, gid=1) as c: > pa

Re: Does Python have certificate?

2009-03-23 Thread Steve Holden
Sebastian Bassi wrote: > On Mon, Mar 23, 2009 at 9:15 PM, Muddy Coder wrote: >> I wonder that does Python have certificate? You see, java, .NET, PHP, >> and so on, they have certificates for developers to get. Python is >> quite popular nowadays, I wonder is there such a thing? If so, I >> certain

Query regarding Python sybase module

2009-03-23 Thread srinivasan srinivas
Hi, Does Sybase Python driver module implement multiple result sets from a single command? Could anyone guide e in finding answer for this? Thanks, Srini Add more friends to your messenger and enjoy! Go to http://messenger.yahoo.com/invite/ -- http://mail.python.org/mailman/listinfo/pyt

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

2009-03-23 Thread Gabriel Genellina
En Mon, 23 Mar 2009 21:37:14 -0300, R. David Murray escribió: Steve Holden wrote: 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/

Re: Does Python have certificate?

2009-03-23 Thread Sebastian Bassi
On Mon, Mar 23, 2009 at 9:15 PM, Muddy Coder wrote: > I wonder that does Python have certificate? You see, java, .NET, PHP, > and so on, they have certificates for developers to get. Python is > quite popular nowadays, I wonder is there such a thing? If so, I > certainly want to get one. I searche

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

2009-03-23 Thread R. David Murray
Esmail wrote: > 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 hav

udp package header

2009-03-23 Thread R. David Murray
mete wrote: > 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 ? The English word is 'packet'. If you are on Linux you can use raw sockets for this. -- R. David Murray

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

2009-03-23 Thread R. David Murray
Steve Holden wrote: > 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/s

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

2009-03-23 Thread Mensanator
On Mar 23, 5:42 pm, Steven D'Aprano wrote: > 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: > >

Does Python have certificate?

2009-03-23 Thread Muddy Coder
Hi Folks, I wonder that does Python have certificate? You see, java, .NET, PHP, and so on, they have certificates for developers to get. Python is quite popular nowadays, I wonder is there such a thing? If so, I certainly want to get one. I searched, and Muddy Coder -- http://mail.python.org/ma

Regression test

2009-03-23 Thread Colin J. Williams
I am running a regression test, mainly because I wish to explore subprocess, and get a number of errors before crashing. Is this to be expected? The run output is below. Colin W. C:\Documents and Settings\cjw\Desktop>C:\python26\python.exe Python 2.6 (r26:66721, Oct 2 2008, 11:35:03) [M

Re: Unicode problem in ucs4

2009-03-23 Thread Martin v. Löwis
> So, both Py_UNICODE and wchar_t are 4 bytes and since it contains 3 > \0s after a char, printf or wprintf is only printing one letter. No. printf indeed will see a terminating character. However, wprintf should correctly know that a wchar_t has four bytes per character, and print it correctly. M

Re: Translating unicode data

2009-03-23 Thread Scott David Daniels
CaptainMcCrank wrote: Hi list, I'm struggling with a problem analyzing large amounts of unicode data in an http wireshark capture. I've solved the problem with the interpreter, but I'm not sure how to do this in an automated fashion. I'd like to grab a line from a text file & translate the unic

Re: Translating unicode data

2009-03-23 Thread Peter Otten
CaptainMcCrank wrote: > I'm struggling with a problem analyzing large amounts of unicode data > in an http wireshark capture. > I've solved the problem with the interpreter, but I'm not sure how to > do this in an automated fashion. > > I'd like to grab a line from a text file & translate the uni

Translating unicode data

2009-03-23 Thread CaptainMcCrank
Hi list, I'm struggling with a problem analyzing large amounts of unicode data in an http wireshark capture. I've solved the problem with the interpreter, but I'm not sure how to do this in an automated fashion. I'd like to grab a line from a text file & translate the unicode sections of it to as

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

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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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? --

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

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

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

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: 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: 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: 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: 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
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

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 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

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: 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 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

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

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

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 > >>

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: 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: 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: 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: 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: 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: 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

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: 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

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: 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 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: 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: [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 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: 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 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

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: 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

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: 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: 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: 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
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: 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
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: 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: 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: 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: 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

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: 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

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: 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
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: 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

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: 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

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: 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

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 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: 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: 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: 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: 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: 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: 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

  1   2   >