Re: pymongo and attribute dictionaries

2015-02-04 Thread Steven D'Aprano
Vito De Tullio wrote: > Steven D'Aprano wrote: > >>> This just does not roll of the fingers well. Too many “reach for >>> modifier keys” in a row. >> >> *One* modifier key in a row is too many? >> >> s o m e SHIFT D o c [ ' SHIFT _ i d ' ] > > I'm not OP, but as side note... not everyone has "

Re: pymongo and attribute dictionaries

2015-02-04 Thread Vito De Tullio
Steven D'Aprano wrote: >> This just does not roll of the fingers well. Too many “reach for modifier >> keys” in a row. > > *One* modifier key in a row is too many? > > s o m e SHIFT D o c [ ' SHIFT _ i d ' ] I'm not OP, but as side note... not everyone has "[" as a direct character on the keyb

Re: Usage of some pastebin service proposed

2015-02-04 Thread Ben Finney
Abhiram R writes: > I've noticed a lot of people enquiring about syntactic errors and email > somewhat butchers the indentation every now and then and the actual error > gets buried in this mess. It is almost never email that butchers the indentation. It is the mis-use of HTML in email. The sim

Usage of some pastebin service proposed

2015-02-04 Thread Abhiram R
Hey guys, I've noticed a lot of people enquiring about syntactic errors and email somewhat butchers the indentation every now and then and the actual error gets buried in this mess. So is it possible to let everyone know that they need to paste their code on some site like pastebin.com and give us

Re: Indentation issues with python

2015-02-04 Thread Terry Reedy
class EventHubClient(object): ... def sendMessage(self,body,partition): ... > ^ IndentationError: expected an indented block *** and 'def' is not indented as it must be. This must be covered in the tutorial. -- Terry Ja

Re: Indentation issues with python

2015-02-04 Thread Ben Finney
syed khalid writes: > I downloaded this code and am attempting to run it. I keep getting > indentation error. Indentation is crucial information in Python code. If it is lost, don't waste time trying to guess it; instead, get the correct code. How did you download it? You should download the c

Indentation issues with python

2015-02-04 Thread syed khalid
I downloaded this code and am attempting to run it. I keep getting indentation error. there is a way to handle it with a editor which can recognize the tab or space issue. I have tried different options such as 2 or 3 spaces or tab to no avail. I have encased the error mesage with line 23 between

Re: pymongo and attribute dictionaries

2015-02-04 Thread Steven D'Aprano
Ian Kelly wrote: >> Extending this to wrap methods of classes is also left as an exercise. >> (Hint: don't subclass. Search the ActiveState Python recipes for >> "automatic delegation" by Alex Martelli.) > > Do you mean this one? > > http://code.activestate.com/recipes/52295-automatic-delegation

Re: pymongo and attribute dictionaries

2015-02-04 Thread Ian Kelly
On Wed, Feb 4, 2015 at 3:38 PM, Steven D'Aprano wrote: > Travis Griggs wrote: >> This just does not roll of the fingers well. Too many “reach for modifier >> keys” in a row. > > *One* modifier key in a row is too many? > > s o m e SHIFT D o c [ ' SHIFT _ i d ' ] I think the point was meant to be

Re: ANN: unpyc3 - a python bytecode decompiler for Python3

2015-02-04 Thread Michael Torrie
On 02/04/2015 05:19 PM, sohcahto...@gmail.com wrote: > They can take your computer and it doesn't matter if you've got your files on > Dropbox. > >> "My dog ate my USB stick." >> >> :-) > > I never used a USB stick for school work. > > At this point, I'm probably sounding like a shill for Dropb

Re: ANN: unpyc3 - a python bytecode decompiler for Python3

2015-02-04 Thread sohcahtoa82
On Wednesday, January 28, 2015 at 4:30:11 PM UTC-8, Steven D'Aprano wrote: > sohcahto...@gmail.com wrote: > > > I recently finished my CS degree, and I had more than one professor say > > that they won't take "My computer crashed and I lost everything!" as an > > excuse for not being able to turn

Re: ANN: unpyc3 - a python bytecode decompiler for Python3

2015-02-04 Thread Dave Angel
On 01/28/2015 07:34 PM, Steven D'Aprano wrote: Devin Jeanpierre wrote: On Wed, Jan 28, 2015 at 1:40 PM, Chris Angelico wrote: On Thu, Jan 29, 2015 at 5:47 AM, Chris Kaynor wrote: I use Google Drive for it for all the stuff I do at home, and use SVN for all my personal projects, with the SVN

Re: Cairo module

2015-02-04 Thread Cousin Stanley
> You might consider using python-imaging > to display the image after writing it > from cairo > > import image import statement should be import Image note uppercase I -- Stanley C. Kitching Human Being Phoenix, Arizona -- https://mail.python.org/mailman/listinfo/py

Re: Cairo module

2015-02-04 Thread Cousin Stanley
> > Could matplotlib be used to show the image? You might consider using python-imaging to display the image after writing it from cairo import image surface.write_to_png ( "x_surface.png" ) img = Image.open( "x_surface.png" ) img.show( command = 'display' )

Re: pymongo and attribute dictionaries

2015-02-04 Thread Steven D'Aprano
Travis Griggs wrote: > I really like pymongo. And I really like Python. But one thing my fingers > really get tired of typing is > > someDoc[‘_’id’] I've never used pymongo, so can't comment from experience, but surely any library which encourages, if not requires, that you access private data _

Re: pymongo and attribute dictionaries

2015-02-04 Thread Rob Gaddi
On Wed, 04 Feb 2015 13:54:22 -0700, Ian Kelly wrote: > I'd prefer map (or itertools.imap in Python 2) over the inline generator > in this case: > > for doc in map(Doc, client.db.radios.find({’_id': {’$regex’: > ‘^[ABC]'}})): > pprint(doc) > > Or if you like, a utility function wrapping the s

Re: Cairo module

2015-02-04 Thread Poul Riis
Could you be a little more specific (giving, for instance, a full working example)? I tried to interchange surface = cairo.ImageSurface (cairo.FORMAT_ARGB32, WIDTH, HEIGHT) with surface = cairo.Win32Surface (cairo.FORMAT_ARGB32, WIDTH, HEIGHT) but that didn't seem to work. Could matplotlib be

Re: meaning of: line, =

2015-02-04 Thread Chris Angelico
On Thu, Feb 5, 2015 at 4:36 AM, Peter Otten <__pete...@web.de> wrote: > Another alternative is to put a list literal on the lefthand side: > def f(): yield 42 > > ... [result] = f() result > 42 Huh, was not aware of that alternate syntax. > (If you're worried: neither the list nor

Re: pymongo and attribute dictionaries

2015-02-04 Thread Ian Kelly
On Wed, Feb 4, 2015 at 1:16 PM, Travis Griggs wrote: > Yes, that is clever. So if you wanted to minimize the amount of typing you > had to do at all of your pymongo API call sites, what strategy would you use > to keep that relatively terse? > > Is the following the right approach to take? > > c

Re: pymongo and attribute dictionaries

2015-02-04 Thread Ian Kelly
On Wed, Feb 4, 2015 at 1:16 PM, Travis Griggs wrote: > Yes, that is clever. So if you wanted to minimize the amount of typing you > had to do at all of your pymongo API call sites, what strategy would you use > to keep that relatively terse? > > Is the following the right approach to take? > > c

Re: pymongo and attribute dictionaries

2015-02-04 Thread Gregory Ewing
Travis Griggs wrote: for doc in client.db.radios.find({’_id': {’$regex’: ‘^[ABC]'}}): pprint(doc) changes to for doc in ((Doc(d) for d in client.db.radios.find({’_id': {’$regex’: ‘^[ABC]'}})): pprint(doc) Are there other approaches? Feel free to impress me with evil abuses in the interest of a

Re: pymongo and attribute dictionaries

2015-02-04 Thread Chris Kaynor
On Wed, Feb 4, 2015 at 12:16 PM, Travis Griggs wrote: > >> On Feb 4, 2015, at 9:22 AM, Ian Kelly wrote: >> >> On Wed, Feb 4, 2015 at 9:50 AM, Travis Griggs wrote: >>> I really like pymongo. And I really like Python. But one thing my fingers >>> really get tired of typing is >>> >>> someDoc[‘_’i

Re: pymongo and attribute dictionaries

2015-02-04 Thread Travis Griggs
> On Feb 4, 2015, at 9:22 AM, Ian Kelly wrote: > > On Wed, Feb 4, 2015 at 9:50 AM, Travis Griggs wrote: >> I really like pymongo. And I really like Python. But one thing my fingers >> really get tired of typing is >> >> someDoc[‘_’id’] >> >> This just does not roll of the fingers well. Too m

Re: meaning of: line, =

2015-02-04 Thread Peter Otten
Rustom Mody wrote: > Well its cryptic and confusing (to me at least) > And is helped by adding 2 characters: > > (result,) = f() > > instead of > > result, = f() Another alternative is to put a list literal on the lefthand side: >>> def f(): yield 42 ... >>> [result] = f() >>> result 42 (I

Re: pymongo and attribute dictionaries

2015-02-04 Thread Ian Kelly
On Wed, Feb 4, 2015 at 9:50 AM, Travis Griggs wrote: > I really like pymongo. And I really like Python. But one thing my fingers > really get tired of typing is > > someDoc[‘_’id’] > > This just does not roll of the fingers well. Too many “reach for modifier > keys” in a row. I would rather use

Re: basic generator question

2015-02-04 Thread Ian Kelly
On Wed, Feb 4, 2015 at 6:23 AM, Neal Becker wrote: > class rpt: > def __init__ (self, value, rpt): > self.value = value; self.rpt = rpt > def __call__ (self): > for i in range (self.rpt): > yield self.value Note that this class is just reimplementing itertools.repeat. >>> list(

Re: meaning of: line, =

2015-02-04 Thread Ethan Furman
On 02/04/2015 07:04 AM, Chris Angelico wrote: > On Thu, Feb 5, 2015 at 1:38 AM, Albert-Jan Roskam wrote: >> I have also never seen this before, but perhaps this: >> > f = lambda: [42] > result, = f() > result >> 42 >> >> ... is slightly cleaner than this: > result = f()[0] > re

pymongo and attribute dictionaries

2015-02-04 Thread Travis Griggs
I really like pymongo. And I really like Python. But one thing my fingers really get tired of typing is someDoc[‘_’id’] This just does not roll of the fingers well. Too many “reach for modifier keys” in a row. I would rather use someDoc._id Googling shows that I’m not the first to want to do

Re: basic generator question

2015-02-04 Thread Steven D'Aprano
Neal Becker wrote: > I have an object that expects to call a callable to get a value: > > class obj: > def __init__ (self, gen): > self.gen = gen > def __call__ (self): > return self.gen() As written, there is no need for this "obj" class, it just adds a pointless layer of indirectio

Re: basic generator question

2015-02-04 Thread Peter Otten
Neal Becker wrote: > I have an object that expects to call a callable to get a value: > > class obj: > def __init__ (self, gen): > self.gen = gen > def __call__ (self): > return self.gen() As written that looks a bit like if boolean_expression == True: ... as you could replace in

Re: basic generator question

2015-02-04 Thread Joel Goldstick
On Wed, Feb 4, 2015 at 10:19 AM, Joel Goldstick wrote: > > > On Wed, Feb 4, 2015 at 9:32 AM, Chris Angelico wrote: > >> On Thu, Feb 5, 2015 at 12:23 AM, Neal Becker wrote: >> > Now I want gen to be a callable that repeats N times. I'm thinking, >> this >> > sounds perfect for yield >> > >> > c

Re: basic generator question

2015-02-04 Thread Joel Goldstick
On Wed, Feb 4, 2015 at 9:32 AM, Chris Angelico wrote: > On Thu, Feb 5, 2015 at 12:23 AM, Neal Becker wrote: > > Now I want gen to be a callable that repeats N times. I'm thinking, this > > sounds perfect for yield > > > > class rpt: > > def __init__ (self, value, rpt): > > self.value = va

Re: meaning of: line, =

2015-02-04 Thread Rustom Mody
On Wednesday, February 4, 2015 at 8:14:29 PM UTC+5:30, Albert-Jan Roskam wrote: > - Original Message - > > > From: Chris Angelico > > Sent: Wednesday, February 4, 2015 3:24 PM > > Subject: Re: meaning of: line, = > > > > On Thu, Feb 5, 2015 at 1:08 AM, ast wrote: > >> I dont understand

Re: meaning of: line, =

2015-02-04 Thread Chris Angelico
On Thu, Feb 5, 2015 at 1:38 AM, Albert-Jan Roskam wrote: > I have also never seen this before, but perhaps this: > f = lambda: [42] result, = f() result > 42 > > ... is slightly cleaner than this: result = f()[0] result > 42 They're not technically identical. If the thing

Re: meaning of: line, =

2015-02-04 Thread Albert-Jan Roskam
- Original Message - > From: Chris Angelico > To: > Cc: "python-list@python.org" > Sent: Wednesday, February 4, 2015 3:24 PM > Subject: Re: meaning of: line, = > > On Thu, Feb 5, 2015 at 1:08 AM, ast wrote: >> I dont understand why there is a comma just after line in the following

Re: basic generator question

2015-02-04 Thread Chris Angelico
On Thu, Feb 5, 2015 at 12:23 AM, Neal Becker wrote: > Now I want gen to be a callable that repeats N times. I'm thinking, this > sounds perfect for yield > > class rpt: > def __init__ (self, value, rpt): > self.value = value; self.rpt = rpt > def __call__ (self): > for i in range (sel

Re: meaning of: line, =

2015-02-04 Thread Chris Angelico
On Thu, Feb 5, 2015 at 1:08 AM, ast wrote: > I dont understand why there is a comma just after line in the following > command: > > line, = plt.plot(x, np.sin(x), '--', linewidth=2) > > > I never saw that before > > Found here: > http://matplotlib.org/examples/lines_bars_and_markers/line_demo_dash

Re: meaning of: line, =

2015-02-04 Thread leo kirotawa
You'll find some explanation here: http://stackoverflow.com/questions/1708292/meaning-of-using-commas-and-underscores-with-python-assignment-operator On Wed, Feb 4, 2015 at 12:08 PM, ast wrote: > hello > > I dont understand why there is a comma just after line in the following > command: > > line

meaning of: line, =

2015-02-04 Thread ast
hello I dont understand why there is a comma just after line in the following command: line, = plt.plot(x, np.sin(x), '--', linewidth=2) I never saw that before Found here: http://matplotlib.org/examples/lines_bars_and_markers/line_demo_dash_control.html thanks -- https://mail.python.org/m

Re: re.findall help

2015-02-04 Thread Jugurtha Hadjar
On 02/04/2015 03:52 AM, w3t...@gmail.com wrote: I am trying to extract the following from a data stream using find all what would be the best way to capture the ip address only from the following text " ip=192.168.1.36 port=4992 " I also want to make sure the program can handle the ip that is as

basic generator question

2015-02-04 Thread Neal Becker
I have an object that expects to call a callable to get a value: class obj: def __init__ (self, gen): self.gen = gen def __call__ (self): return self.gen() Now I want gen to be a callable that repeats N times. I'm thinking, this sounds perfect for yield class rpt: def __init__ (se

PSF Python Brochure "sold out" - help us kick start the second print run !

2015-02-04 Thread M.-A. Lemburg
[Please help spread the word by forwarding to other relevant mailing lists, user groups, etc. world-wide; thanks :-)] *** PSF Python Brochure "sold out" *** Please help us kick start the second

Re: Cairo module

2015-02-04 Thread Michiel Overtoom
Hi Poul, I recently used cairo in a python project (https://github.com/luismqueral/jumpcityrecords). To see the cairo drawing directly on the screen I wrote a minimal Gtk application. It's in the 'src' directory and is called 'randomdraw.py'. Maybe it is of some help to you. Greetings, -- "