Re: Opinion on best practice...

2013-02-06 Thread Chris Angelico
On Thu, Feb 7, 2013 at 5:50 PM, Steven D'Aprano wrote: > On Thu, 07 Feb 2013 16:28:17 +1100, Chris Angelico wrote: > >> You misunderstand. It's actually a very simple rule. Python follows C's >> principle of accepting that any return value from an expression should >> be ignored if you don't do an

select.epoll question

2013-02-06 Thread Paul Rubin
I'm trying to listen to a bunch of sockets using epoll under Linux, e.g. import select, socket socket1 = socket.socket() ... p = select.epoll() p.register(socket1); p.register(socket2); ... result = p.poll() This returns `result' as a list of 2-tuples (fd, status) where fd is a Li

Re: Opinion on best practice...

2013-02-06 Thread Steven D'Aprano
On Thu, 07 Feb 2013 16:28:17 +1100, Chris Angelico wrote: > On Thu, Feb 7, 2013 at 10:46 AM, Steven D'Aprano > wrote: >> Dennis Lee Bieber wrote: >>> Though that is the nice feature of REXX*... Anything that wasn't >>> parsable as a REXX statement was automatically sent to the current >>> command

Re: Monitoring updating directory for image for GUI

2013-02-06 Thread Chris Angelico
On Thu, Feb 7, 2013 at 9:02 AM, wrote: > Basically I am creating a program that will stream musical notes into a > program called Lilypond one-by-one and it will create the sheet music for > that stream of music via OS command. Your understanding of Lilypond is not > needed, but you need to kn

Re: Decimal 0**0

2013-02-06 Thread Tim Roberts
Steven D'Aprano wrote: > >Does anyone have an explanation why Decimal 0**0 behaves so differently from >float 0**0? >... >I am familiar with the arguments for treating 0**0 as 0, or undefined, but >thought that except for specialist use-cases, it was standard practice for >programming languages to

Re: Opinion on best practice...

2013-02-06 Thread Chris Angelico
On Thu, Feb 7, 2013 at 10:46 AM, Steven D'Aprano wrote: > Dennis Lee Bieber wrote: >> Though that is the nice feature of REXX*... Anything that wasn't >> parsable as a REXX statement was automatically sent to the current >> command processor. > > Nice? Are you being sarcastic? What you're describi

2013-14 H1B Sponsor / Visa Transfer / GC Processing for Eligible Candidates (I can Help You)

2013-02-06 Thread sush@AjelTechnologies
2013-14 H1b Visa Sponsor / Visa Transfer / GC Processing to eligible candidates- Ajel Technologies can help you. Mail me ur resumes with contact info to a...@ajel.com Looking for Good Projects with Green Card Process? I can help you. If you are interested to file H1B or H1 Extension or Visa Trans

Re: urllib2 FTP Weirdness

2013-02-06 Thread Steven D'Aprano
On Thu, 07 Feb 2013 10:06:32 +1100, Cameron Simpson wrote: > | I cannot see how the firewall could possible distinguish between using > | a temporary variable or not in these two snippets: > | > | # no temporary variable hangs, or fails > | urllib2.urlopen("ftp://ftp2.census.gov/";).read() > | >

Re: Plotting syntax

2013-02-06 Thread Steven D'Aprano
On Wed, 06 Feb 2013 10:37:07 -0500, Vladimir Ivkovic wrote: > Hi Python experts, > > I am working with an array of data and am trying to plot several columns > of data which are not continuous; i.e. I would like to plot columns 1:4 > and 6:8, without plotting column 5. The syntax I am currently u

Re: best way to share an instance of a class among modules?

2013-02-06 Thread Ethan Furman
On 02/06/2013 04:57 PM, Ethan Furman wrote: On 02/06/2013 04:43 PM, c wrote: But the function in the module is also within a *class* so I don't think the function does have access to the module's global namespace. Here's the hierarchy: -- Module namespace class namespace (Database

Re: best way to share an instance of a class among modules?

2013-02-06 Thread Ethan Furman
On 02/06/2013 04:43 PM, c wrote: But the function in the module is also within a *class* so I don't think the function does have access to the module's global namespace. Here's the hierarchy: -- Module namespace class namespace (DatabaseAccess is the name of the class) --

Re: best way to share an instance of a class among modules?

2013-02-06 Thread Michael Torrie
On 02/06/2013 05:45 PM, CM wrote: > But the function in the module is also within a *class* so I don't > think the function does have access to the module's global namespace. > Here's the hierarchy: > > -- Module namespace > class namespace (DatabaseAccess is the name of the class) >

Re: best way to share an instance of a class among modules?

2013-02-06 Thread CM
I was using self correctly, I think; but I should have said that the code in the importing module would be within a class, so self there refers to that class. But that's a side point. I agree that utilities.shared_cursor is visible within the importing module. But the problem below remains for m

Re: best way to share an instance of a class among modules?

2013-02-06 Thread c
On Feb 6, 7:03 pm, Michael Torrie wrote: > On 02/06/2013 03:41 PM, CM wrote: > > > Thank you.  But, I'm sorry, I'm not following this enough to get it to > > work.  Shouldn't it be a little more like this: > > No, not exactly. > > > > > # in utilities module > > shared_cursor =  DatabaseAccess_ins

Re: best way to share an instance of a class among modules?

2013-02-06 Thread Michael Torrie
On 02/06/2013 05:03 PM, Michael Torrie wrote: > Every function in a module has access to the module's global namespace. > And your shared_cursor is there, inside of the utilities reference, > since utilities was imported into your module, "importer." Just to be clear: mod1.py: a=5 -

Re: best way to share an instance of a class among modules?

2013-02-06 Thread Michael Torrie
On 02/06/2013 03:41 PM, CM wrote: > Thank you. But, I'm sorry, I'm not following this enough to get it to > work. Shouldn't it be a little more like this: No, not exactly. > > # in utilities module > shared_cursor = DatabaseAccess_instance #but how? see my question > below... How what? > #

Re: Help about finding a python script on geographic masking

2013-02-06 Thread Michael Torrie
Let's keep this on the mailing list. Replying to back to the list. On 02/06/2013 10:47 AM, tkhan10 wrote: > Yes I have some shapefiles where some locations are geocoded. You can > think it as a layer containing some points. I need to hide the actual > point locations and create a new locations in

Re: Opinion on best practice...

2013-02-06 Thread Steven D'Aprano
Dennis Lee Bieber wrote: > On Wed, 6 Feb 2013 17:16:04 +1100, Chris Angelico > declaimed the following in gmane.comp.python.general: > >> >> It feels silly enough translating this OS/2 batch script: >> >> @logon SOME_USER /pSOME_PASS /vl >> @e:\rexx\load >> @db2 start database manager >> @exit

Re: toy list processing problem: collect similar terms

2013-02-06 Thread Nick Mellor
Oops! Not that sort stability is used in this algorithm. Was thinking of something else :-) N On Thursday, 7 February 2013 10:25:36 UTC+11, Nick Mellor wrote: > Python 3 version: > > > > from collections import defaultdict > > > > data = > ((0,'a','b'),(1,'c','d'),(2,'e','f'),(3,'g','h')

Re: Improve reduce functions of SQLite3 request

2013-02-06 Thread Steffen Mutter
Hi Dennis, Dennis Lee Bieber wrote: > If this is meant to be a web-based system, you probably should be > looking into using some sort of framework: Django, Zope/Plone, etc. I tried both frameworks but I always see, that these frameworks improve the progress to get things done but also lim

Re: toy list processing problem: collect similar terms

2013-02-06 Thread Nick Mellor
Python 3 version: from collections import defaultdict data = ((0,'a','b'),(1,'c','d'),(2,'e','f'),(3,'g','h'),(1,'i','j'),(2,'k','l'),(4,'m','n'),(2,'o','p'),(4,'q','r'),(5,'s','t')) register = defaultdict(list) for number, *letters in data: register[number].extend(letters) final = [] for i

Re: Curious to see alternate approach on a search/replace via regex

2013-02-06 Thread MRAB
On 2013-02-06 21:41, rh wrote: I am curious to know if others would have done this differently. And if so how so? This converts a url to a more easily managed filename, stripping the http protocol off. This: http://alongnameofasite1234567.com/q?sports=run&a=1&b=1 becomes this: alongnameofasi

Re: urllib2 FTP Weirdness

2013-02-06 Thread Cameron Simpson
On 24Jan2013 04:12, Steven D'Aprano wrote: | On Thu, 24 Jan 2013 01:45:31 +0100, Hans Mulder wrote: | > On 24/01/13 00:58:04, Chris Angelico wrote: | >> Possibly it's some kind of race condition?? | > | > If urllib2 is using active mode FTP, then a firewall on your box could | > explain what you

Re: best way to share an instance of a class among modules?

2013-02-06 Thread CM
On Feb 6, 12:04 am, Terry Reedy wrote: > On 2/5/2013 11:40 PM, CM wrote: > > > > > > > > > > > I have recently moved all my SQLite3 database-related functions into a > > class, DatabaseAccess, that lives in a "utilities" module.  When the > > application loads, the namespace of the instance of the

Re: Curious to see alternate approach on a search/replace via regex

2013-02-06 Thread Demian Brecht
python -m cProfile [script_name].py http://docs.python.org/2/library/profile.html#module-cProfile Demian Brecht http://demianbrecht.github.com On 2013-02-06 2:30 PM, "richard_hubbe11" wrote: >I see that urlparse uses split and not re at all and, in my tests, >urlparse >completes in less ti

Re: each process only has one main thread ,right ?

2013-02-06 Thread Cameron Simpson
On 06Feb2013 09:59, Dave Angel wrote: | The only place I now of where we care whether a particular thread in a | process is "the main thread" is with a gui, which usually can only sit | in a single, "main" thread. Any gui-related processing done in other | threads must be done very carefully.

Monitoring updating directory for image for GUI

2013-02-06 Thread ciscorucinski
Hello, I have been using Python for a few months now, so I am still learning a few things here and there. Basically I am creating a program that will stream musical notes into a program called Lilypond one-by-one and it will create the sheet music for that stream of music via OS command. Your

Re: Detecting a click on the turtle screen when the turtle isn't doing anything?

2013-02-06 Thread Adam Funk
On 2013-02-05, Dennis Lee Bieber wrote: > I'll echo the "Ugh" about the use of global AND ADD a dislike of the > busy loop that only exits if some other return sets a value. If the busy > loop were performing some action that changed the test state within the > loop itself, okay... TBH, I w

Re: Detecting a click on the turtle screen when the turtle isn't doing anything?

2013-02-06 Thread Adam Funk
On 2013-02-05, Dave Angel wrote: > I'm no fan of Java. But it's not about a "main" method, it's about > sharing data between functions. Most of the time non-constant globals > are a mistake. If the data can't be passed as an argument, then it > should probably be part of the instance data of

Re: Curious to see alternate approach on a search/replace via regex

2013-02-06 Thread Demian Brecht
Well, an alternative /could/ be: from urlparse import urlparse parts = urlparse('http://alongnameofasite1234567.com/q?sports=run&a=1&b=1') print '%s%s_%s' % (parts.netloc.replace('.', '_'), parts.path.replace('/', '_'), parts.query.replace('&', '_').replace('=', '_') ) Although wit

Re: Curious to see alternate approach on a search/replace via regex

2013-02-06 Thread Roy Smith
In article , rh wrote: > I am curious to know if others would have done this differently. And if so > how so? > > This converts a url to a more easily managed filename, stripping the > http protocol off. I would have used the urlparse module. http://docs.python.org/2/library/urlparse.html --

Re: Thoughts on SQL vs ORM

2013-02-06 Thread Walter Hurry
On Wed, 06 Feb 2013 10:03:08 -0800, rusi wrote: > On Feb 6, 5:58 pm, Andriy Kornatskyy wrote: >> The question of persistence implementation arise often. I found >> repository pattern very valuable due to separation of concerns, mediate >> between domain model and data source (mock, file, database

Re: Thoughts on SQL vs ORM

2013-02-06 Thread Alec Taylor
I agree that ORMs can be rather complicated; especially when you need to do some refactoring. Another reason not to use ORMs is difficult of measuring query complexity. However, some of the most major advantages of ORMs are: - Generation of forms - Same code can be used with multiple backends - T

Re: Thoughts on SQL vs ORM

2013-02-06 Thread rusi
On Feb 6, 5:58 pm, Andriy Kornatskyy wrote: > The question of persistence implementation arise often. I found repository > pattern very valuable due to separation of concerns, mediate between domain > model and data source (mock, file, database, web service, etc). > > The database data source is

Re: Help about finding a python script on geographic masking

2013-02-06 Thread Michael Torrie
On 02/06/2013 09:37 AM, tkhan10 wrote: > Hello Everyone > > I am new to python and trying to understand this programming > language. But right now I need to find a script on geographic masking > methods. This is an emergency. These masking methods are to hide a > specific location so that the iden

Re: Random and fork

2013-02-06 Thread Alain Ketterlin
Julien Le Goff writes: > Today I came accross a behaviour I did not expect in python (I am > using 2.7). In my program, random.random() always seemed to return the > same number; it turned out to be related to the fact that I was using > os.fork. The random number generator is initialized once,

Re: Random and fork

2013-02-06 Thread Peter Otten
Julien Le Goff wrote: > Hi everyone, > > Today I came accross a behaviour I did not expect in python (I am using > 2.7). In my program, random.random() always seemed to return the same > number; it turned out to be related to the fact that I was using os.fork. > > See below a small program that

Help about finding a python script on geographic masking

2013-02-06 Thread tkhan10
Hello Everyone I am new to python and trying to understand this programming language. But right now I need to find a script on geographic masking methods. This is an emergency. These masking methods are to hide a specific location so that the identification of that location is not revealed. I a

Random and fork

2013-02-06 Thread Julien Le Goff
Hi everyone, Today I came accross a behaviour I did not expect in python (I am using 2.7). In my program, random.random() always seemed to return the same number; it turned out to be related to the fact that I was using os.fork. See below a small program that illustrates this. It is easily fixe

Re: How to improve writing code in python?

2013-02-06 Thread rusi
On Feb 6, 4:52 am, Banh wrote: > Hi, > I have a problem with learning Python. My code is really bad and I can't > solve many problems. I > really want to improve it. Do you know any website which helps me to learn > python effectively (for > beginners)? This is my first programming language and

Re: mySQLdb

2013-02-06 Thread sinaiy
On Saturday, February 2, 2013 12:01:40 PM UTC+2, Armin Karner wrote: > Dear Sir or Madam, > > > > > > > > I am curious if there is an update of MySQLdb for python versions 3.3 or > higher. Because I really need this for a diploma thesis.  > I've tried several of them, including various 2.x

Plotting syntax

2013-02-06 Thread Vladimir Ivkovic
Hi Python experts, I am working with an array of data and am trying to plot several columns of data which are not continuous; i.e. I would like to plot columns 1:4 and 6:8, without plotting column 5. The syntax I am currently using is: oplot (t,d[:,0:4]) The question is: How do I specif

Re: Opinion on best practice...

2013-02-06 Thread Grant Edwards
On 2013-02-06, Steven D'Aprano wrote: > Chris Angelico wrote: > >> Python is not an "excellent option". It's a bad fit for shell >> scripting, it just happens to be way better than a weak shell. Having >> grown up on command.com, I found OS/2's cmd.exe to be a massive >> improvement, and Windows's

Can you reference VCS location in distutils.core.setup()?

2013-02-06 Thread Skip Montanaro
The distutils.core.setup() function accepts a bunch of attributes, among them a download_url parameter. I don't see a way to specify a VCS repository. Is that possible? Thx, Skip -- http://mail.python.org/mailman/listinfo/python-list

Re: Opinion on best practice...

2013-02-06 Thread Grant Edwards
On 2013-02-06, Neil Cerutti wrote: > On 2013-02-05, Grant Edwards wrote: >> On 2013-02-05, Neil Cerutti wrote: >>> On 2013-02-05, Walter Hurry wrote: > Sorry, I'm a Linux guy. I have no clue what that means. Hooray for common sense! Python is great, but it's silly to use Pyt

Re: Compiling native extensions with Visual Studio 2012?

2013-02-06 Thread wcdolphin
On Saturday, January 12, 2013 2:45:38 AM UTC-5, Alec Taylor wrote: > There have been various threads for MSVC 2010[1][2], but the most > > recent thing I found for MSVC 2012 was [3]… from 6 months ago. > > > > Basically I want to be able to compile bcrypt—and yes I should be > > using Keccak—x

Re: Opinion on best practice...

2013-02-06 Thread Grant Edwards
On 2013-02-06, Ian Kelly wrote: > On Tue, Feb 5, 2013 at 3:59 PM, Grant Edwards wrote: >> On 2013-02-05, Neil Cerutti wrote: >>> On 2013-02-05, Walter Hurry wrote: > Sorry, I'm a Linux guy. I have no clue what that means. Hooray for common sense! Python is great, but it's silly t

Re: each process only has one main thread ,right ?

2013-02-06 Thread Dave Angel
On 02/06/2013 06:52 AM, Steven D'Aprano wrote: iMath wrote: When a program starts up, one thread begins running immediately. This is usually called the main thread of the program ,so each process only has one main thread ,right ? I'm not sure if we should say "each process HAS one main thread

Re: How to improve writing code in python?

2013-02-06 Thread Jean-Michel Pichavant
- Original Message - > Hi, > I have a problem with learning Python. My code is really bad and I > can't solve many problems. I really want to improve it. Do you know > any website which helps me to learn python effectively (for > beginners)? This is my first programming language and I am s

Re: puzzled by name binding in local function

2013-02-06 Thread Dave Angel
On 02/06/2013 05:19 AM, Ulrich Eckhardt wrote: Dave and Terry, Thanks you both for your explanations! I really appreciate the time you took. Am 05.02.2013 19:07, schrieb Dave Angel: The main place where I see this type of problem is in a gui, where you're defining a callback to be used by

Re: Recording live video stream from IP camera issue

2013-02-06 Thread Xavier Ho
On 7 February 2013 00:12, Sam Berry wrote: > Hi, > > This is for a university project. > > My issue is that i have built an App using pythons Kivy module, and i need > to be able to stream and record from an IP camera upon request. > > I have just used the VLC.exe to stream the video feed. But it

Re: How to improve writing code in python?

2013-02-06 Thread Piet van Oostrum
Banh writes: > Hi, > I have a problem with learning Python. My code is really bad and I can't > solve many problems. I really want to improve it. Do you know any website > which helps me to learn python effectively (for beginners)? This is my first > programming language and I am studying abou

Re: Opinion on best practice...

2013-02-06 Thread Neil Cerutti
On 2013-02-05, Grant Edwards wrote: > On 2013-02-05, Neil Cerutti wrote: >> On 2013-02-05, Walter Hurry wrote: Sorry, I'm a Linux guy. I have no clue what that means. >>> >>> Hooray for common sense! Python is great, but it's silly to use >>> Python (unless there is good reason) when a sim

Re: Opinion on best practice...

2013-02-06 Thread Anssi Saari
Dennis Lee Bieber writes: > PowerShell is meant to be used for administrative level scripting, > replacing such things as WSH. Yeah and WSH has been included since Windows 98... So Windows has been at least OK with shell scripting VBScript and JScript for the last 15 years or so. And I can

Re: Recording live video stream from IP camera issue

2013-02-06 Thread Sam Berry
Hi, This is for a university project. My issue is that i have built an App using pythons Kivy module, and i need to be able to stream and record from an IP camera upon request. I have just used the VLC.exe to stream the video feed. But it is the recording i am having problems with. I'l look

Thoughts on SQL vs ORM

2013-02-06 Thread Andriy Kornatskyy
The question of persistence implementation arise often. I found repository pattern very valuable due to separation of concerns, mediate between domain model and data source (mock, file, database, web service, etc). The database data source is somewhat specific since you can proceed with SQL fu

Re: Recording live video stream from IP camera issue

2013-02-06 Thread Sam Berry
Thank you for the quick reply! I found this code just from multiple google searches, but yer it mentioned online video streaming, however my IP camera would be streaming in Mjpeg format (I thought been able to convert between the two formats seemed way to easy!) So i'm guessing its just 20mb of

Fwd: Recording live video stream from IP camera issue

2013-02-06 Thread Xavier Ho
On 6 February 2013 23:12, Sam Berry wrote: > I have no vast knowledge of python, but i came across this code to capture > video from my IP camera > > This code works, however when i try to playback the .avi file in VLC > player... I've been working with several IP cameras with Python and OpenCV

Re: Recording live video stream from IP camera issue

2013-02-06 Thread Steven D'Aprano
Sam Berry wrote: > Hey, > > I have no vast knowledge of python, but i came across this code to capture > video from my IP camera > > import urllib2 > import time > import logging > > print "Recording video..." > response = urllib2.urlopen("IP Address") > filename = time.strftime("%Y%m%d%H%M%S",

Recording live video stream from IP camera issue

2013-02-06 Thread Sam Berry
Hey, I have no vast knowledge of python, but i came across this code to capture video from my IP camera import urllib2 import time import logging print "Recording video..." response = urllib2.urlopen("IP Address") filename = time.strftime("%Y%m%d%H%M%S",time.localtime())+".avi" f = open(filenam

Re: each process only has one main thread ,right ?

2013-02-06 Thread Steven D'Aprano
iMath wrote: > When a program starts up, one thread begins running immediately. This is > usually called the main thread of the program ,so each process only has > one main thread ,right ? I'm not sure if we should say "each process HAS one main thread" or "each process IS one main thread", or wh

each process only has one main thread ,right ?

2013-02-06 Thread iMath
When a program starts up, one thread begins running immediately. This is usually called the main thread of the program ,so each process only has one main thread ,right ? -- http://mail.python.org/mailman/listinfo/python-list

Re: puzzled by name binding in local function

2013-02-06 Thread Ulrich Eckhardt
Dave and Terry, Thanks you both for your explanations! I really appreciate the time you took. Am 05.02.2013 19:07, schrieb Dave Angel: If you need to have separate function objects that already know a value for i, you need to somehow bind the value into the function object. One way to do it,

Re: toy list processing problem: collect similar terms

2013-02-06 Thread Nick Mellor
You can just flatten the list using itertools and collate the results using defaultdict: import itertools from collections import defaultdict sequence = ((0,'a','b'),(1,'c','d'),(2,'e','f'),(3,'g','h'),(1,'i','j'),(2,'k','l'),(4,'m','n'),(2,'o','p'),(4,'q','r'),(5,'s','t')) # flatten the list

Re: Best Practice Question

2013-02-06 Thread Jean-Michel Pichavant
- Original Message - > > [...] > > By the way, did someone ever notice that r'\' fails ? I'm sure > > there's a > > reason for that... (python 2.5) Anyone knows ? > > > > r'\' > > SyntaxError: EOL while scanning single-quoted string > > > > > "Even in a raw string, string quotes can be e

Re: Improve reduce functions of SQLite3 request

2013-02-06 Thread Steffen Mutter
Dennis Lee Bieber wrote: > Which does, to me, imply an unnormalized database. The > "team/category" should be a separate field. > club(*ID*, name) > > team(*ID*, /club/, category) > > {where *..* is primary key, /../ is a foreign key} You are right, but as I mentioned above I had to use so