Newbie getting desperate with for

2011-02-17 Thread Werner
I have a trivially simple piece of code called timewaster.py: while True: i = 0 for i in range(10): break _ It runs fine with Eric but when I try to run it from shell... > ./ti

Re: Newbie getting desperate with for

2011-02-17 Thread Nitin Pawar
can you share the first line of your shell (shabang) ? I think you have forgotten to tell the shell which interpreter to use if you have not put #!/usr/bin/python then its plain shell script which is incorrect On Thu, Feb 17, 2011 at 1:57 PM, Werner wrote: > I have a trivially simple piece o

Re: Newbie getting desperate with for

2011-02-17 Thread Chris Rebert
On Thu, Feb 17, 2011 at 12:27 AM, Werner wrote: > I have a trivially simple piece of code called timewaster.py: > > > while True: >    i = 0 >    for i in range(10): >        break > _ > > It r

Re: Newbie getting desperate with for

2011-02-17 Thread Werner
On 17/02/11 16:39, Chris Rebert wrote: > On Thu, Feb 17, 2011 at 12:27 AM, Werner wrote: >> I have a trivially simple piece of code called timewaster.py: >> >> >> while True: >>i = 0 >>for i in range(10): >>break >> _

Re: IMAP4_SSL, libgmail, GMail and corporate firewall/proxy

2011-02-17 Thread Andrea Gavana
Hi Malcolm, On 17 February 2011 11:44, Malcolm Greene wrote: > Andrea, > > What type of result do you get trying port 993 ? Thank you for your answer. I have tried that, with imaplib and libgmail. This is what I get with imaplib: Traceback (most recent call last): File "D:\MyProjects\gmail

Re: How to use Python well?

2011-02-17 Thread flebber
On Feb 17, 11:43 am, Steven D'Aprano wrote: > On Thu, 17 Feb 2011 10:12:52 +1100, Ben Finney wrote: > > Terry Reedy writes: > > >> The most import thing is automated tests. > > > Steven D'Aprano writes: > > >> The most important thing is structured programming and modularization. > > > Steel-cag

Re: How to use Python well?

2011-02-17 Thread Chris Rebert
On Thu, Feb 17, 2011 at 1:53 AM, flebber wrote: > On Feb 17, 11:43 am, Steven D'Aprano +comp.lang.pyt...@pearwood.info> wrote: >> On Thu, 17 Feb 2011 10:12:52 +1100, Ben Finney wrote: >> > Terry Reedy writes: >> >> >> The most import thing is automated tests. >> >> > Steven D'Aprano writes: >>

2to3

2011-02-17 Thread andrea crotti
What would be an almost automated way to develop for both python 2.x and 3.x? 2to3 apparently can only output a diff or write directly on the file (with -w), but why doesn't it output the resulting file for 3.x instead? So for a single python file I tried a makefile like: Makefile: all: empathy.

Re: Method chaining on decorator got SyntaxError

2011-02-17 Thread Duncan Booth
alex23 wrote: > Makoto Kuwata wrote: >> I'm sad about this restriction because: >> >>     @recipe.product('*.html').ingreds('$(1).rst') >>     def file_html(c): >>         # do something >> >> is enough simple and more readable than: >> >>     @recipe.product('*.html') >>     @recipe.ingreds('$(

Re: 2to3

2011-02-17 Thread Chris Rebert
On Thu, Feb 17, 2011 at 2:11 AM, andrea crotti wrote: > What would be an almost automated way to develop for both python 2.x and > 3.x? > Then after that how do I test the various versions with the various python > versions in a portable way? > > I could just have a bash script that calls > > pyt

Connecting to remote Oracle db via Python

2011-02-17 Thread pstatham
Hi Guys, I've installed the cx_Oracle module for Python and I'm trying to connect to my remote Oracle db. Like so (username, password and ip below aren't real don't worry) >>> uid = "scott" >>> pwd = "tiger" >>> service = "10.5.1.12:1521:PR10" >>> db = cx_Oracle.connect(uid + "/" + pwd + "@" + se

Re: return an object of a different class

2011-02-17 Thread Jean-Michel Pichavant
s...@uce.gov wrote: How can I do something like this in python: #!/usr/bin/python3.1 class MyNumbers: def __init__(self, n): self.original_value = n if n <= 100: self = SmallNumers(self) else: self = BigNumbers(self) class SmallNumbers: def __init__(self, n): se

Re: 2to3

2011-02-17 Thread andrea crotti
2011/2/17 Chris Rebert > > Actually, so long as you specify a bit more specific versions, e.g.: > > python2.7 empathy.py > python3.1 empathy3.py > > it should be fine on most *nixes. Windows would of course require a > separate, but analogous, batch file or similar. As for porting the > tests the

Re: return an object of a different class

2011-02-17 Thread Jean-Michel Pichavant
Karim wrote: [snip] If you don't want to use a factory function I believe you can do this: class MyNumber(object): def __new__(cls, n): if n<= 100: cls = SmallNumbers else: cls = BigNumbers return object.__new__(cls, n) ... Chard.

Re: [newbie/2.5.1.1] Computing value of a word?

2011-02-17 Thread Gilles Ganault
On Wed, 16 Feb 2011 01:27:06 -0800, Chris Rebert wrote: >A = ord('a') - 1 >for line in your_file: >word = line.strip().lower() >score = sum(ord(letter)-A for letter in word) Thanks much Chris. -- http://mail.python.org/mailman/listinfo/python-list

Standard Delay Format (SDF) Parsing

2011-02-17 Thread moogyd
Hi, A Standard Delay Format (SDF) file is a text file used to store delay information, and is used in ASIC design. I need to parse some of these files and before I re-invent the wheel, is anyone aware of a module to allow parsing of these files? Thanks, Steven -- http://mail.python.org/mailman/

Re: How to use Python well?

2011-02-17 Thread Jean-Michel Pichavant
snorble wrote: I use Python a lot, but not well. I usually start by writing a small script, no classes or modules. Then I add more content to the loops, and repeat. It's a bit of a trial and error learning phase, making sure I'm using the third party modules correctly, and so on. I end up with a

Re: return an object of a different class

2011-02-17 Thread Steven D'Aprano
On Thu, 17 Feb 2011 12:02:28 +0100, Jean-Michel Pichavant wrote: > Karim wrote: >> [snip] >>> If you don't want to use a factory function I believe you can do this: >>> >>> class MyNumber(object): >>> def __new__(cls, n): >>> if n<= 100: >>> cls = SmallNumbers >>>

Re: 2to3

2011-02-17 Thread Dave Angel
On 01/-10/-28163 02:59 PM, andrea crotti wrote: 2011/2/17 Chris Rebert Actually, so long as you specify a bit more specific versions, e.g.: python2.7 empathy.py python3.1 empathy3.py it should be fine on most *nixes. Windows would of course require a separate, but analogous, batch file or si

FIX Message module

2011-02-17 Thread prakash jp
Hi all, Finacial Information Exchange (FIX) Protocol module is what I am looking for.Using it I would like to pump and listen to the FIX messages--(hard coded values). Please guide me through the relevant module (windows installer) and anything that you foresee as a potential bottleneck. So far I

Re: Best way to gain root privileges

2011-02-17 Thread Adam Skutt
On Thu, Feb 17, 2011 at 2:12 AM, Dan Stromberg wrote: > > On Wed, Feb 16, 2011 at 6:59 PM, Adam Skutt wrote: >> On Feb 16, 9:00 pm, Dan Stromberg wrote: >>> So yeah, whether you use perl or anything else invoked with #!, you're >>> pretty much better off with sudo, or a tiny C wrapper that's so

Re: Best way to gain root privileges

2011-02-17 Thread Adam Skutt
On Feb 16, 10:43 pm, GSO wrote: > OK, so I'm heading towards sudo then, aiming to make sure I don't > screw up the configuration.  This is a home CCTV application, so I > want things as secure as possible.  A setgid wrapper would require the > kind of skilled programming that I couldn't do myself

Re: return an object of a different class

2011-02-17 Thread Jean-Michel Pichavant
Steven D'Aprano wrote: On Thu, 17 Feb 2011 12:02:28 +0100, Jean-Michel Pichavant wrote: Karim wrote: [snip] If you don't want to use a factory function I believe you can do this: class MyNumber(object): def __new__(cls, n): if n<= 100: cls = SmallNum

Simple Question

2011-02-17 Thread uahmed
Why Tkinter on Linux dont support other format of logo picture except of .xbm format ? here logo Picture means an image which comes on top left of window . -- http://mail.python.org/mailman/listinfo/python-list

Re: IMAP4_SSL, libgmail, GMail and corporate firewall/proxy

2011-02-17 Thread python
Hi Andrea, Have you tried temporarily turning off your Windows firewall software and/or any locally installed internet security software like Norton, Avast, etc? You don't need to turn off your entire security package, just the component that controls internet access. If the problem can not be re

First time using an API...

2011-02-17 Thread Matty Sarro
This may be kind of a stupid question, so please be gentle. I've only ever used most programming in the past when shell scripting couldn't handle what I needed done. So, I rarely dabble with things like API's, or even python-isms. I just program to get things done. Well, that's about to change :)

Re: Connecting to remote Oracle db via Python

2011-02-17 Thread Anurag Chourasia
Could you try by using a connecting string in the standard format as below? Connection_String = 'scott/tiger@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=10.5.1.12(PORT=1521)))(CONNECT_DATA=(SID=PR10)))' db = cx_Oracle.connect(Connection_String) Regards, Anurag On Thu, Feb 17, 2011 a

Re: return an object of a different class

2011-02-17 Thread Westley Martínez
On Thu, 2011-02-17 at 11:43 +, Steven D'Aprano wrote: > On Thu, 17 Feb 2011 12:02:28 +0100, Jean-Michel Pichavant wrote: > > > Karim wrote: > >> [snip] > >>> If you don't want to use a factory function I believe you can do this: > >>> > >>> class MyNumber(object): > >>> def __new__(cls, n

Re: Connecting to remote Oracle db via Python

2011-02-17 Thread Anurag Chourasia
Try this please and it should work. Connection_String = 'scott/tiger@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=10.5.1.12)(PORT=1521)))(CONNECT_DATA=(SID=PR10)))' db = cx_Oracle.connect(Connection_String) I'm sorry i missed a bracket there. Regards, Anurag On Thu, Feb 17, 2011 at

Re: Connecting to remote Oracle db via Python

2011-02-17 Thread Anurag Chourasia
Apart from that, you could also use a shorter format which is a correction over what you were trying with earlier. Here.. uid = "scott" pwd = "tiger" service = "//10.5.1.12:1521/PR10" db = cx_Oracle.connect(uid + "/" + pwd + "@" + service) Please let us know how it goes. Regards, Anurag On

Re: interfacing python with emacs

2011-02-17 Thread andrea crotti
Not ready yet but the structure of the python and elisp files is more or less there: git://github.com/AndreaCrotti/empathy.git Feel welcome for any comments/hints. About the communication between the processes I think I'll use stdin/out too, since it comes quite natural using emacs sub-processes.

Re: First time using an API...

2011-02-17 Thread andrea crotti
2011/2/17 Matty Sarro > This may be kind of a stupid question, so please be gentle. > I've only ever used most programming in the past when shell scripting > couldn't handle what I needed done. So, I rarely dabble with things > like API's, or even python-isms. I just program to get things done. >

reimport module every n seconds

2011-02-17 Thread Santiago Caracol
Hello, a server program of mine uses data which are compiled to a Python module for efficiency reasons. In some module of the server program I import the data: from data import data As the data often changes, I would like to reimport it every n (e.g. 10) seconds. Unfortunately, it is rather dif

Re: Best way to gain root privileges

2011-02-17 Thread GSO
> I'm having a awfully hard time figuring out why a home CCTV > application might need privilege at all.  Are you sure you really need > privilege?  It sounds to me like there may be some larger design > issues mandating the need for privilege when it's not really > necessary. > A user login shoul

Re: reimport module every n seconds

2011-02-17 Thread Jean-Michel Pichavant
Santiago Caracol wrote: Hello, a server program of mine uses data which are compiled to a Python module for efficiency reasons. In some module of the server program I import the data: from data import data As the data often changes, I would like to reimport it every n (e.g. 10) seconds. Unfor

Re: Another related OO Python ?

2011-02-17 Thread RJB
On Feb 16, 6:21 am, Eric Brunel wrote: > In article > <6849fd3f-5116-4b35-b274-dc76ae39f...@a11g2000pro.googlegroups.com>, > > > > > >  RJB wrote: > > On Feb 16, 12:48 am, Eric Brunel > > wrote: > > > In article , > > >  Doug Epling wrote: > > > > > hey, does anyone find the UML useful during P

Re: return an object of a different class

2011-02-17 Thread MRAB
On 17/02/2011 14:39, Westley Martínez wrote: On Thu, 2011-02-17 at 11:43 +, Steven D'Aprano wrote: On Thu, 17 Feb 2011 12:02:28 +0100, Jean-Michel Pichavant wrote: Karim wrote: [snip] If you don't want to use a factory function I believe you can do this: class MyNumber(object): de

client server socket interaction (inetd)

2011-02-17 Thread Tim
Hi, I have an inetd service on freebsd that calls a program (daemon.py) with which I want the remote user to communicate. I can call daemon.py from the command line on the host machine and it works fine. What I don't understand is how to make my remote client script actually communicate. If I'm u

where to import

2011-02-17 Thread andrea crotti
Suppose I have a function which uses a few external libraries, and this function is only called once every 10 executions. Does it make sense to import these libraries for the whole module? import sys def fun(): import x, y, z Something like this is acceptable/good practice in the scenario I

Re: client server socket interaction (inetd)

2011-02-17 Thread Dan Stromberg
On Thu, Feb 17, 2011 at 8:14 AM, Tim wrote: > Hi, I have an inetd service on freebsd that calls a program > (daemon.py) with which I want the remote user to communicate. I can > call daemon.py from the command line on the host machine and it works > fine. > > What I don't understand is how to ma

Re: where to import

2011-02-17 Thread Chris Rebert
On Thu, Feb 17, 2011 at 8:44 AM, andrea crotti wrote: > Suppose I have a function which uses a few external libraries, > and this function is only called once every 10 executions. > > Does it make sense to import these libraries for the whole module? Yes. Having all the imports in one place keeps

another problem with modules

2011-02-17 Thread Tim Hanson
Okay, I solved my problem with Python finding modules: I put the following into a file in my home directory, on the good advice of Andrea Crotti: import sys sys.path.append('/home/foo/mypath' I named the file "~/pypath.py", so now, in idle: import pypath No errors. I'm still getting a little

wxPython in Eclipse?

2011-02-17 Thread Fred Marshall
How do I use wxPython or wxGlade in the context of Eclipse? A link to a howto would be great! Thanks, Fred -- http://mail.python.org/mailman/listinfo/python-list

Re: another problem with modules

2011-02-17 Thread Robert Kern
On 2/17/11 11:11 AM, Tim Hanson wrote: import pypath import intersect #the name of a file that contains the above short function. intersect('spam','spmmer') Traceback (most recent call last): File "", line 1, in intersect('spam','spmmer') TypeError: 'module' object is not callable H

Re: where to import

2011-02-17 Thread andrea crotti
2011/2/17 Chris Rebert > Yes, of course. Importing a module multiple times (as would happen if > fun() is called multiple times) is obviously slower than just > importing it once, although the 2nd and subsequent imports will be > faster as Python will just return another reference to the previous

Suggested editor for wxPython on Ubuntu

2011-02-17 Thread usenet.digi...@spamgourmet.com
Ok, I've decided that Boa Constructor is too buggy to be useful under Ubuntu, so what would the team recommend for developing Python projects with wxPython? Preferably with some GUI design capability? -- http://mail.python.org/mailman/listinfo/python-list

Re: another problem with modules

2011-02-17 Thread MRAB
On 17/02/2011 17:11, Tim Hanson wrote: Okay, I solved my problem with Python finding modules: I put the following into a file in my home directory, on the good advice of Andrea Crotti: import sys sys.path.append('/home/foo/mypath' I named the file "~/pypath.py", so now, in idle: import pypath

Re: Best way to gain root privileges

2011-02-17 Thread Terry Reedy
On 2/17/2011 10:32 AM, GSO wrote: I'm having a awfully hard time figuring out why a home CCTV application might need privilege at all. Are you sure you really need privilege? It sounds to me like there may be some larger design issues mandating the need for privilege when it's not really necess

Re: First time using an API...

2011-02-17 Thread Terry Reedy
On 2/17/2011 10:17 AM, andrea crotti wrote: 2011/2/17 Matty Sarro mailto:msa...@gmail.com>> This may be kind of a stupid question, so please be gentle. I've only ever used most programming in the past when shell scripting couldn't handle what I needed done. So, I rarely dabble with

Re: Editor/IDE with Python coverage support?

2011-02-17 Thread Detlev Offenbach
Matt Chaput wrote: > Are there any editors/IDEs with good support for line-coloring from > Python test coverage results? (I normally use Eclipse + PyDev but > PyDev's current coverage support isn't much better than nothing.) > > Thanks, > > Matt eric4 (Python2) and eric5 (Python3) do have this

Re: reimport module every n seconds

2011-02-17 Thread Aahz
In article <6cde71c6-5c56-40ea-9849-50fc44e5d...@o14g2000prb.googlegroups.com>, Santiago Caracol wrote: > >a server program of mine uses data which are compiled to a Python >module for efficiency reasons. In some module of the server program I >import the data: > >from data import data > >As the

Re: reimport module every n seconds

2011-02-17 Thread Roy Smith
In article , a...@pythoncraft.com (Aahz) wrote: > In article > <6cde71c6-5c56-40ea-9849-50fc44e5d...@o14g2000prb.googlegroups.com>, > Santiago Caracol wrote: > > > >a server program of mine uses data which are compiled to a Python > >module for efficiency reasons. In some module of the server

Re: First time using an API...

2011-02-17 Thread Cousin Stanley
Matty Sarro wrote: > > I am in charge of deploying a platform to allow people > across my company to access a variety of crunched metrics > using splunk. > For the convenience of others that may not be familar with splunk http://en.wikipedia.org/wiki/Splunk http://

Re: Suggested editor for wxPython on Ubuntu

2011-02-17 Thread Cousin Stanley
usenet.digi...@spamgourmet.com wrote: > Ok, I've decided that Boa Constructor is too buggy to be useful > under Ubuntu, so what would the team recommend for developing > Python projects with wxPython? Preferably with some GUI design capability? perhaps python-wxglade GUI designer w

Re: First time using an API...

2011-02-17 Thread Matty Sarro
Good point, pardon the assumption :) I'm reading more about RESTful and it looks like its a web based API. Oh well, I'll figure it out, I mean, my job depends on it, lol. On Thu, Feb 17, 2011 at 1:19 PM, Cousin Stanley wrote: > > Matty Sarro wrote: > >> >> I am in charge of deploying a platf

Re: Best way to gain root privileges

2011-02-17 Thread Adam Skutt
On Feb 17, 10:32 am, GSO wrote: > > I'm having a awfully hard time figuring out why a home CCTV > > application might need privilege at all.  Are you sure you really need > > privilege?  It sounds to me like there may be some larger design > > issues mandating the need for privilege when it's not

Re: Newbie getting desperate with for

2011-02-17 Thread Alister Ware
On Thu, 17 Feb 2011 16:42:05 +0800, Werner wrote: > On 17/02/11 16:39, Chris Rebert wrote: >> On Thu, Feb 17, 2011 at 12:27 AM, Werner wrote: >>> I have a trivially simple piece of code called timewaster.py: >>> >>> >>> while True: >>>i = 0

Re: Suggested editor for wxPython on Ubuntu

2011-02-17 Thread Verde Denim
On Thu, Feb 17, 2011 at 1:27 PM, Cousin Stanley wrote: > > usenet.digi...@spamgourmet.com wrote: > > > Ok, I've decided that Boa Constructor is too buggy to be useful > > under Ubuntu, so what would the team recommend for developing > > Python projects with wxPython? Preferably with some GUI desig

Re: Best way to gain root privileges

2011-02-17 Thread Katie T
On Wed, Feb 16, 2011 at 9:26 PM, GSO wrote: > I'm sure this question is as old as time, but what is the best way to > gain root privileges?  (Am using Python 2.6.5, pygtk2 v2.16, Gtk > v2.18.9, on RHEL6.) > Running any kind of script sudo'd is a bad idea, it's very very hard (in many cases imposs

Re: client server socket interaction (inetd)

2011-02-17 Thread Martin Gregorie
On Thu, 17 Feb 2011 08:14:36 -0800, Tim wrote: > Hi, I have an inetd service on freebsd that calls a program (daemon.py) > with which I want the remote user to communicate. I can call daemon.py > from the command line on the host machine and it works fine. > > What I don't understand is how to m

Re: client server socket interaction (inetd)

2011-02-17 Thread bobicanprogram
On Feb 17, 2:41 pm, Martin Gregorie wrote: > On Thu, 17 Feb 2011 08:14:36 -0800, Tim wrote: > > Hi, I have an inetd service on freebsd that calls a program (daemon.py) > > with which I want the remote user to communicate. I can call daemon.py > > from the command line on the host machine and it w

Re: interfacing python with emacs

2011-02-17 Thread Andrea Crotti
Il giorno 17/feb/2011, alle ore 16.14, andrea crotti ha scritto: > Not ready yet but the structure of the python and elisp files is more or less > there: > git://github.com/AndreaCrotti/empathy.git > > Feel welcome for any comments/hints. > > About the communication between the processes I thi

Re: client server socket interaction (inetd)

2011-02-17 Thread Tim
On Feb 17, 2:41 pm, Martin Gregorie wrote: > On Thu, 17 Feb 2011 08:14:36 -0800, Tim wrote: > > Hi, I have an inetd service on freebsd that calls a program (daemon.py) > > with which I want the remote user to communicate.  I can call daemon.py > > from the command line on the host machine and it w

Re: Best way to gain root privileges

2011-02-17 Thread Terry Reedy
On 2/17/2011 1:39 PM, Adam Skutt wrote: On Feb 17, 10:32 am, GSO wrote: I'm having a awfully hard time figuring out why a home CCTV application might need privilege at all. Are you sure you really need privilege? It sounds to me like there may be some larger design issues mandating the need f

Re: Newbie getting desperate with for

2011-02-17 Thread Cameron Simpson
On 17Feb2011 18:40, Alister Ware wrote: | On Thu, 17 Feb 2011 16:42:05 +0800, Werner wrote: | | > On 17/02/11 16:39, Chris Rebert wrote: | >> On Thu, Feb 17, 2011 at 12:27 AM, Werner wrote: | >>> I have a trivially simple piece of code called timewaster.py: | >>>

Re: How to use Python well?

2011-02-17 Thread Jorgen Grahn
On Wed, 2011-02-16, snorble wrote: > I use Python a lot, but not well. I usually start by writing a small > script, no classes or modules. Then I add more content to the loops, > and repeat. It's a bit of a trial and error learning phase, making > sure I'm using the third party modules correctly, a

Re: where to import

2011-02-17 Thread Terry Reedy
On 2/17/2011 12:27 PM, andrea crotti wrote: Well no I wasn't really worried about performances. I just thought that if an external module is really almost never used, it might make sense to import it only when it's really needed. If the module is only used in one function and the function may

Re: Converting getCSS Count Code from java to python

2011-02-17 Thread SMERSH009
On Feb 2, 7:03 am, Duncan Booth wrote: > Stefan Behnel wrote: > > You are using Selenium RC here. I have no idea if there is a Python > > API to it or what that API looks like. The rest is just trivial code > > that you can map 1:1 to Python: > > >      def count_css_matches(css_locator): > >    

Re: Best way to gain root privileges

2011-02-17 Thread Steven D'Aprano
On Thu, 17 Feb 2011 19:44:20 +, Katie T wrote: > Running any kind of script sudo'd is a bad idea, it's very very hard (in > many cases impossible) to do securely. Root permissions in general > should only be used for what they're needed for and nothing else (that > means getting the permission

Best way to gain root privileges

2011-02-17 Thread GSO
> > Could restarts and cleanups be done with a root daemon separate from user > scripts? > I like the idea of a user creating a login as you do typically with client/server progs, no need to have the root password all the time: http://www.python.org/dev/peps/pep-3143/ http://pypi.python.org/pypi/

Re: Archiving Modules

2011-02-17 Thread Jorgen Grahn
On Wed, 2011-02-16, peter wrote: > I am writing a small Tkinter utility to control archive files in > multiple formats (mainly for my own amusement and education). > Basically it presents the user with two adjacent listboxes, one with > the contents of the target directory and one with the contents

Re: Best way to gain root privileges

2011-02-17 Thread GSO
> Come to think of it, I would first consider creating a 'cctv' user that owns > the cameras and storage directories, and files and only do anything as root > if absolutely necessary. > You can run 'sudo -g [group] ...', so no need to go near root. > > Running any kind of script sudo'd is a bad i

Re: where to import

2011-02-17 Thread Santoso Wijaya
As a general rule, I group all my imports in the beginning of the module's source, even if it is only used a handful of times by a few functions. However, on such cases as the import is only needed by specific function(s) zero or once, then I do the import in the function itself. Importing argpars

Re: How to use Python well?

2011-02-17 Thread Roy Smith
In article , Jorgen Grahn wrote: > - Write user documentation and build/installation scripts. Since I'm > on Unix, that means man pages and a Makefile. Wow, I haven't built a man page in eons. These days, user documentation for me means good help text for argparse to use. If I need somethi

Re: client server socket interaction (inetd)

2011-02-17 Thread Martin Gregorie
On Thu, 17 Feb 2011 13:02:08 -0800, Tim wrote: > But. The server may encounter a problem > during the process and ask the user for more information like > 'abort/retry' or something like that. > Servers never ask the client for information: they are strictly request/ response handlers. To do what

Re: Newbie getting desperate with for

2011-02-17 Thread Werner
On 18/02/11 02:40, Alister Ware wrote: > On Thu, 17 Feb 2011 16:42:05 +0800, Werner wrote: > >> On 17/02/11 16:39, Chris Rebert wrote: >>> On Thu, Feb 17, 2011 at 12:27 AM, Werner wrote: I have a trivially simple piece of code called timewaster.py: __

Re: Newbie getting desperate with for

2011-02-17 Thread Cameron Simpson
On 18Feb2011 08:40, I wrote: | On 17Feb2011 18:40, Alister Ware wrote: | | On Thu, 17 Feb 2011 16:42:05 +0800, Werner wrote: | | > On 17/02/11 16:39, Chris Rebert wrote: | | >> On Thu, Feb 17, 2011 at 12:27 AM, Werner wrote: | | >>> I have a trivially simple piece of code called timewaster.py: |

Unit testing multiprocessing code on Windows

2011-02-17 Thread Matt Chaput
Does anyone know the "right" way to write a unit test for code that uses multiprocessing on Windows? The problem is that with both "python setup.py tests" and "nosetests", when they get to testing any code that starts Processes they spawn multiple copies of the testing suite (i.e. the new proc

Unit testing multiprocessing code on Windows

2011-02-17 Thread Matt Chaput
Does anyone know the "right" way to write a unit test for code that uses multiprocessing on Windows? The problem is that with both "python setup.py tests" and "nosetests", when they get to a multiprocessing test they spawn multiple copies of the testing suite. The test runner in PyDev works pr

Re: How to use Python well?

2011-02-17 Thread Michael Torrie
On 02/16/2011 04:00 PM, Steven D'Aprano wrote: > You should read about bottom-up and top-down programming. You'll probably > end up doing some of both, but mostly top-down. Most of my development is done by designing top-down and then coding bottom-up. Coding top down is fine, but I'd expect to

Re: return an object of a different class

2011-02-17 Thread Westley Martínez
On Thu, 2011-02-17 at 15:56 +, MRAB wrote: > On 17/02/2011 14:39, Westley Martínez wrote: > > On Thu, 2011-02-17 at 11:43 +, Steven D'Aprano wrote: > >> On Thu, 17 Feb 2011 12:02:28 +0100, Jean-Michel Pichavant wrote: > >> > >>> Karim wrote: > [snip] > > If you don't want to use a

interrupted system call w/ Queue.get

2011-02-17 Thread Philip Winston
We have a multiprocess Python program that uses Queue to communicate between processes. Recently we've seen some errors while blocked waiting on Queue.get: IOError: [Errno 4] Interrupted system call What causes the exception? Is it necessary to catch this exception and manually retry the Queue

Re: interrupted system call w/ Queue.get

2011-02-17 Thread James Mills
On Fri, Feb 18, 2011 at 11:46 AM, Philip Winston wrote: > We have a multiprocess Python program that uses Queue to communicate > between processes.  Recently we've seen some errors while blocked > waiting on Queue.get: > > IOError: [Errno 4] Interrupted system call > > What causes the exception?  

Re: return an object of a different class

2011-02-17 Thread alex23
Jean-Michel Pichavant wrote: > You simply don't return inconsistent types with a return statement. This > is a general rule in programming that has probably exceptions but > regarding what you're saying, you clearly don't want to do that. I don't think they were intended to be inconsistent types,

Re: Unit testing multiprocessing code on Windows

2011-02-17 Thread philip
Quoting Matt Chaput : Does anyone know the "right" way to write a unit test for code that uses multiprocessing on Windows? The problem is that with both "python setup.py tests" and "nosetests", when they get to testing any code that starts Processes they spawn multiple copies of the testi

Re: Problems of Symbol Congestion in Computer Languages

2011-02-17 Thread rantingrick
On Feb 16, 4:07 pm, Xah Lee wrote: > Vast majority of computer languages use ASCII as its character set. > This means, it jams multitude of operators into about 20 symbols. > Often, a symbol has multiple meanings depending on contex. I think in theory the idea of using Unicode chars is good, howe

Re: return an object of a different class

2011-02-17 Thread Steven D'Aprano
On Thu, 17 Feb 2011 15:53:14 -0800, Westley Martínez wrote: >> > Python 3 removed longs because they were ... cryptonic! >> > >> Strictly speaking, they weren't removed. ints were removed and long was >> renamed int. > My point stands. Your point is wrong. Ints and longs weren't unified because i

Re: Problems of Symbol Congestion in Computer Languages

2011-02-17 Thread Cthun
On 17/02/2011 9:11 PM, rantingrick wrote: . On Feb 16, 4:07 pm, Xah Lee wrote: .> Vast majority of computer languages use ASCII as its character set. .> This means, it jams multitude of operators into about 20 symbols. .> Often, a symbol has multiple meanings depending on contex. . . I think in t

Re: interrupted system call w/ Queue.get

2011-02-17 Thread Dan Stromberg
On Thu, Feb 17, 2011 at 5:46 PM, Philip Winston wrote: > We have a multiprocess Python program that uses Queue to communicate > between processes. Recently we've seen some errors while blocked > waiting on Queue.get: > > IOError: [Errno 4] Interrupted system call > > What causes the exception?

Re: Problems of Symbol Congestion in Computer Languages

2011-02-17 Thread Dan Stromberg
I prefer special symbol "congestion" to special symbol proliferation. A lot. A language with few special symbols looks less like line noise, is easier to read and write, and is easier to google for answers about. I guess nothing's perfect. On Wed, Feb 16, 2011 at 2:07 PM, Xah Lee wrote: > mig

Re: Problems of Symbol Congestion in Computer Languages

2011-02-17 Thread Cor Gest
Some entity, AKA Cthun , wrote this mindboggling stuff: (selectively-snipped-or-not-p) > And you omitted the #1 most serious objection to Xah's proposal, > rantingrick, which is that to implement it would require unrealistic > things such as replacing every 101-key keyboard with 10001-key > key

Re: Problems of Symbol Congestion in Computer Languages

2011-02-17 Thread rantingrick
On Feb 17, 8:40 pm, Cthun wrote: > What does your aversion to cultural diversity have to do with Lisp, > rantingrick? Gee, I do hope you're not a racist, rantingrick. Why must language be constantly "connected-at-the-hip" to cultural diversity? People have this irrational fear that if we create

Re: return an object of a different class

2011-02-17 Thread Westley Martínez
On Fri, 2011-02-18 at 02:25 +, Steven D'Aprano wrote: > On Thu, 17 Feb 2011 15:53:14 -0800, Westley Martínez wrote: > > >> > Python 3 removed longs because they were ... cryptonic! > >> > > >> Strictly speaking, they weren't removed. ints were removed and long was > >> renamed int. > > My poin

Help: python unicode

2011-02-17 Thread tom z
Hi all~ My script can't work.I've changed my defaultencoding from 'ascii' to 'utf-8',but Python also raises a 'UnicodeEncodeError' error. the error likes this: >>> s=u'La Pe\xf1a' >>>print s UnicodeEncodeError: 'ascii' codec can't encode character u'\xf1' in position 5: ... And in my script, the

Re: Problems of Symbol Congestion in Computer Languages

2011-02-17 Thread Littlefield, Tyler
>My intention was to educate him on the pitfalls of multiplicity. O. that's what you call that long-winded nonsense? Education? You must live in America. Can I hazard a guess that your universal language might be english? Has it not ever occured to you that people take pride in their language?

Re: Problems of Symbol Congestion in Computer Languages

2011-02-17 Thread Cthun
On 17/02/2011 10:29 PM, rantingrick wrote: On Feb 17, 8:40 pm, Cthun wrote: What does your aversion to cultural diversity have to do with Lisp, rantingrick? Gee, I do hope you're not a racist, rantingrick. Why must language be constantly "connected-at-the-hip" to cultural diversity? Langua

Lamp Engineers for 2 top game companies

2011-02-17 Thread Marta Daglow
Hey I'm working inhouse for two top games companies who are looking for top lamp engineers. If you are interested in knowing more about the details, please feel free to call or email me. Cheers, Marta Daglow President - Games (Social, Online & Console) Daglow Consulting Group PO Box 948 Ross,

Re: Problems of Symbol Congestion in Computer Languages

2011-02-17 Thread alex23
rantingrick wrote: > Cthun wrote: > > > What does your aversion to cultural diversity have to do with Lisp, > > rantingrick? Gee, I do hope you're not a racist, rantingrick. > > Why must language be constantly "connected-at-the-hip" to cultural > diversity? People have this irrational fear that i

How to conserve the integrity of the string from a database response using Python

2011-02-17 Thread Hidura
Hello, i am using py-postgresql as the driver the database, when make a select to a string with non-ASCII characters, the response replace the character with "�" what can i make to change this to the correct character? This is my code: class decodify: def __init__(self): db = pgDrive

Re: Newbie getting desperate with for

2011-02-17 Thread Larry Hudson
On 02/17/2011 12:27 AM, Werner wrote: I have a trivially simple piece of code called timewaster.py: while True: i = 0 for i in range(10): break _ It runs fine with Eric bu

  1   2   >