Re: Compiling main script into .pyc

2014-01-16 Thread MRAB
On 2014-01-17 02:56, bob gailer wrote: On 1/16/2014 8:01 PM, Sam wrote: One thing I observe about python byte-code compiling is that the main script does not gets compiled into .pyc. Only imported modules are compiled into .pyc. May I know how can I compile the main script into .pyc? Duh?

Re: Bind event is giving me a bug.

2014-01-15 Thread MRAB
On 2014-01-15 20:16, eneskri...@gmail.com wrote: While working with tkinter in python 3.3, I had the following problem. def get_text(event): self.number_of_competitors = entered_text.get() try: self.number_of_competitors =

python-list@python.org

2014-01-14 Thread MRAB
On 2014-01-14 16:37, Florian Lindner wrote: Hello! I'm using python 3.2.3 on debian wheezy. My script is called from my mail delivery agent (MDA) maildrop (like procmail) through it's xfilter directive. Script works fine when used interactively, e.g. ./script.py testmail but when called

Re: Printer list value problem

2014-01-14 Thread MRAB
On 2014-01-14 19:24, Mike wrote: Hello, I confudsed,need printer the value of list (this is reaer from csv) . The reader is ok, but my problem is in the print moment because printer only the last value. For example my csv is: [] us...@example.com;user1;lastName;Name

Re: dictionary with tuples

2014-01-14 Thread MRAB
On 2014-01-14 21:10, Igor Korot wrote: Hi, ALL, C:\Documents and Settings\Igor.FORDANWORK\Desktop\winpdbpython Python 2.7.5 (default, May 15 2013, 22:43:36) [MSC v.1500 32 bit (Intel)] on win32 Type help, copyright, credits or license for more information. dict = {} dict[(1,2)] = ('a','b')

Re: Python 3.x adoption

2014-01-14 Thread MRAB
On 2014-01-15 02:55, Steven D'Aprano wrote: On Tue, 14 Jan 2014 20:33:50 +0100, Staszek wrote: Hi What's the problem with Python 3.x? Nothing. It was first released in 2008, That was only five years ago. I know that to young kids today who change their iPhone every six months, five

Re: python-list@python.org

2014-01-14 Thread MRAB
On 2014-01-15 01:25, Florian Lindner wrote: Am Dienstag, 14. Januar 2014, 17:00:48 schrieb MRAB: On 2014-01-14 16:37, Florian Lindner wrote: Hello! I'm using python 3.2.3 on debian wheezy. My script is called from my mail delivery agent (MDA) maildrop (like procmail) through it's xfilter

Re: 'Straße' ('Strasse') and Python 2

2014-01-12 Thread MRAB
On 2014-01-12 08:31, Peter Otten wrote: wxjmfa...@gmail.com wrote: sys.version 2.7.6 (default, Nov 10 2013, 19:24:18) [MSC v.1500 32 bit (Intel)] s = 'Straße' assert len(s) == 6 assert s[5] == 'e' jmf Signifying nothing. (Macbeth) Python 2.7.2+ (default, Jul 20 2012, 22:15:08) [GCC

Re: python first project

2014-01-12 Thread MRAB
On 2014-01-12 06:04, Chris Angelico wrote: On Sun, Jan 12, 2014 at 4:14 PM, ngangsia akumbo ngang...@gmail.com wrote: What options do you think i can give the Ceo. Because from what you have outline, i think i will like to follow your advice. If it is just some recording data stuff then some

Re: Time zones and why they change so damned often

2014-01-10 Thread MRAB
On 2014-01-10 18:22, Peter Pearson wrote: On Thu, 9 Jan 2014 15:14:55 +1100, Chris Angelico wrote: [snip] What I find, most of the time, is that it's Americans who can't handle DST. I run an international Dungeons and Dragons campaign (we play online, and new players are most welcome, as are

Re: Python 2.x and 3.x usage survey

2014-01-10 Thread MRAB
On 2014-01-10 19:43, John Ladasky wrote: On Friday, January 10, 2014 9:48:43 AM UTC-8, Ned Batchelder wrote: On Python-Dev, Dan Stromberg posted this link with the results: http://stromberg.dnsalias.org/~strombrg/python-2.x-vs-3.x-survey/ That link gave me a 404. :^( It's available here:

Re: Send array back in result from urllib2.urlopen(request, postData)

2014-01-10 Thread MRAB
On 2014-01-10 20:57, vanommen.rob...@gmail.com wrote: Hello, I have a Raspberry Pi with 10 temperature sensors. I send the data from the sensors and some other values with json encoding and: result = urllib2.urlopen(request, postData) to a online PHP script wich places the data in a mysql

Re: Re : Python GTK GUI struck when process is going on.

2014-01-09 Thread MRAB
On 2014-01-09 11:53, Prapulla Kumar wrote: Hi all, I'm using python gtk to upload file to S3 service by boto API , GUI struck when uploading file and releases the GUI after completed download I'm using thread to show progress of upload in GUI but it struck. Can you some suggestion how to show

Re: [Python-ideas] RFC: bytestring as a str representation [was: a new bytestring type?]

2014-01-07 Thread MRAB
On 2014-01-07 17:46, Andrew Barnert wrote: I think Stephen's name 7-bit is confusing people. If you try to interpret the name sensibly, you get Steven's broken interpretation. But if you read it as a nonsense word and work through the logic, it all makes sense. On Jan 7, 2014, at 7:44,

Re: Trying to wrap my head around futures and coroutines

2014-01-06 Thread MRAB
On 2014-01-07 00:56, Skip Montanaro wrote: I've been programming for a long while in an eventcallback-driven world. While I am comfortable enough with the mechanisms available (almost 100% of what I do is in a PyGTK world with its signal mechanism), it's never been all that satisfying, breaking

Re: Trying to wrap my head around futures and coroutines

2014-01-06 Thread MRAB
On 2014-01-07 02:29, Cameron Simpson wrote: On 06Jan2014 18:56, Skip Montanaro skip.montan...@gmail.com wrote: [...] Let's say I have a dead simple GUI with two buttons labeled, Do A and Do B. Each corresponds to executing a particular activity, A or B, which take some non-zero amount of time

Re: Blog about python 3

2014-01-04 Thread MRAB
On 2014-01-05 02:32, Chris Angelico wrote: On Sun, Jan 5, 2014 at 1:27 PM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: But regardless of how fast your path-finder algorithm might become, you're unlikely to be satisfied with a solution that travels around in a circle from A to B

Re: BLANK PAGE when i try Filtering Adsense with abpy

2013-12-22 Thread MRAB
On 22/12/2013 18:08, Michael Torrie wrote: On 12/22/2013 10:20 AM, em rexhepi wrote: When I use my code it just displays nothing My code: #!/usr/local/bin/python3.1 import cgitb;cgitb.enable() import urllib.request response = urllib.request.build_opener() response.addheaders =

Re: PDFMiner install question

2013-12-19 Thread MRAB
On 19/12/2013 19:36, Jason Mellone wrote: MRAB: Thank you your exact solution worked perfectly. Now I am trying to run some code from (http://www.unixuser.org/~euske/python/pdfminer/programming.html) under basic usage. If I try to run code from pdfminer.pdfparser import PDFParser from

Re: PDFMiner install question

2013-12-17 Thread MRAB
On 17/12/2013 20:06, Jason Mellone wrote: Hello, I have python up and running using the exact setup as recommended by http://learnpythonthehardway.org/ I am now trying to use pdfminer. I have python here: C:\USERS\Python27 using import os, i am able to cwd to C:\users\python where i have

Re: PDFMiner install question

2013-12-17 Thread MRAB
On 17/12/2013 20:59, Jason Mellone wrote: On Tuesday, December 17, 2013 3:53:24 PM UTC-5, Jason Mellone wrote: On Tuesday, December 17, 2013 3:32:56 PM UTC-5, MRAB wrote: On 17/12/2013 20:06, Jason Mellone wrote: Hello, I have python up and running using the exact setup as recommended

Re: Small script to check serial port sucking down system resources.

2013-12-16 Thread MRAB
On 16/12/2013 14:31, sem...@gmail.com wrote: i am new to python and programming all together. i wrote a program to watch a serial port and look for a command. then send a tcp packet. all works great but it takes my processor load to about %25. not sure if there is a way to make this more

Re: Eliminate extra variable

2013-12-15 Thread MRAB
On 15/12/2013 22:46, Igor Korot wrote: Tim, On Sun, Dec 15, 2013 at 4:29 AM, Tim Chase python.l...@tim.thechases.com wrote: On 2013-12-15 06:17, Tim Chase wrote: conn = sqlite3.connect('x.sqlite', ... detect_types=sqlite3.PARSE_DECLTYPES|sqlite3.PARSE_COLNAMES) Your example code omitted

Re: min max from tuples in list

2013-12-12 Thread MRAB
On 12/12/2013 11:44, Steven D'Aprano wrote: On Wed, 11 Dec 2013 23:25:53 -0800, Robert Voigtländer wrote: Hi, I have a list like this: a = [(52, 193), (52, 193), (52, 192), ... I need to find a -performant- way to transform this into a list with tuples (a[0],[a[0][1]min],[a[0][1]max]).

Re: Optimizing list processing

2013-12-12 Thread MRAB
On 12/12/2013 12:25, Chris Angelico wrote: On Thu, Dec 12, 2013 at 11:08 PM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: P.S. The algorithm I'm working on is a way of generating index and rank tables. Not that it really matters -- what matters is determining whether or not to

Re: Python Script

2013-12-12 Thread MRAB
On 12/12/2013 18:05, Amimo Benja wrote: I have an issue with a Python script that I will show as follows: http://codepad.org/G8Z2ConI Assume that you have three (well defined) classes: AirBase and VmNet, . VmNet has got a method that is called recursively each time an HTTP response is received.

Re: Tree library - multiple children

2013-12-12 Thread MRAB
On 12/12/2013 19:30, Joel Goldstick wrote: On Thu, Dec 12, 2013 at 2:26 PM, Neil Cerutti ne...@norwich.edu mailto:ne...@norwich.edu wrote: On 2013-12-12, Ricardo Aráoz ricar...@gmail.com mailto:ricar...@gmail.com wrote: I need to use a tree structure. Is there a good and known

Re: Downloading file

2013-12-12 Thread MRAB
On 12/12/2013 20:45, Matt Graves wrote: I have direct links to a number of csv files to download. Copying and pasting it to my browser would take too long, how would i go to this site for example and get the file? Right when you go to the site the download should start

Re: Optimizing list processing

2013-12-11 Thread MRAB
On 11/12/2013 23:54, Steven D'Aprano wrote: I have some code which produces a list from an iterable using at least one temporary list, using a Decorate-Sort-Undecorate idiom. The algorithm looks something like this (simplified): table = sorted([(x, i) for i,x in enumerate(iterable)]) table = [i

Re: Optimizing list processing

2013-12-11 Thread MRAB
On 12/12/2013 01:43, Steven D'Aprano wrote: On Thu, 12 Dec 2013 00:59:42 +, MRAB wrote: table = [(x, i) for i,x in enumerate(iterable)] table.sort() This looks wrong to me: for x, i in table: table[i] = x Yes, you're right, I over-simplified the example, and in doing so

Re: grab dict keys/values without iterating ?!

2013-12-10 Thread MRAB
On 11/12/2013 00:02, Tamer Higazi wrote: Hi people! Is there a way to get dict by search terms without iterating the entire dictionary ?! Let us assume I have: {'Amanda':'Power','Amaly':'Higgens','Joseph':'White','Arlington','Black','Arnold','Schwarzenegger'} I want to grab the dict's key

Re: ProgrammingError: (1064, You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'S SIZE 11.5 NEW IN BOX', '$49.99')'

2013-12-09 Thread MRAB
On 09/12/2013 09:32, Daniel Watkins wrote: On Mon, Dec 09, 2013 at 12:41:57AM -0800, Jai wrote: sql = insert into `category` (url, catagory,price) VAlUES ('%s', '%s', '%s')%(link1,x,y) sql = unicodedata.normalize('NFKD', sql).encode('ascii','ignore') cursor.execute(sql)

Re: Possible PEP Submission

2013-12-09 Thread MRAB
On 09/12/2013 20:36, Logan Collins wrote: Just checking whether 1) a PEP is the proper place for this and 2) what y'all think about it. I would like to propose a change to the the 're' standard library to support iterables. So, something like the following would work: import re text = hello

Re: Is It Bug?

2013-12-07 Thread MRAB
On 08/12/2013 00:59, Mahan Marwat wrote: Why this is not working. 'Hello, World'.replace('\\', '\\') To me, Python will interpret '' to '\\'. And the replace method will replace '\\' with '\'. So, the result will be 'Hello, \World'. But it's give me 'Hello, World'. The result I

Re: using ffmpeg command line with python's subprocess module

2013-12-06 Thread MRAB
On 06/12/2013 15:34, Steven D'Aprano wrote: On Fri, 06 Dec 2013 06:52:48 -0800, iMath wrote: yes ,I am a native Chinese speaker.I always post question by Google Group not through email ,is there something wrong with it ? your english is a little strange to me . Mark is writing in fake

Re: ASCII and Unicode [was Re: Managing Google Groups headaches]

2013-12-06 Thread MRAB
On 07/12/2013 02:41, Chris Angelico wrote: On Sat, Dec 7, 2013 at 1:33 PM, rusi rustompm...@gmail.com wrote: That seems to suggest that something is not right with the python mailing list config. No?? If in doubt, blame someone else, eh? I'd first check what your browser's actually sending.

Re: Python Unicode handling wins again -- mostly

2013-12-02 Thread MRAB
On 02/12/2013 21:14, Ned Batchelder wrote: On 12/2/13 3:38 PM, Ethan Furman wrote: On 11/29/2013 04:44 PM, Steven D'Aprano wrote: Out of the nine tests, Python 3.3 passes six, with three tests being failures or dubious. If you believe that the native string type should operate on code-points,

Re: Python and PEP8 - Recommendations on breaking up long lines?

2013-11-28 Thread MRAB
On 28/11/2013 03:06, Ben Finney wrote: Ned Batchelder n...@nedbatchelder.com writes: The important thing in a with statement is that the assigned name will be closed (or otherwise exited) automatically. The open call is just the expression used to assign the name. The expression there isn't

Re: Downloading/Saving to a Directory

2013-11-28 Thread MRAB
On 28/11/2013 15:19, TheRandomPast . wrote: Hi, I've created a script that allows me to see how many images are on a webpage and their URL however now I want to download all .jpg images from this website and save them onto my computer. I've never done this before and I've become a little

Re: For-each behavior while modifying a collection

2013-11-28 Thread MRAB
On 28/11/2013 17:20, Ned Batchelder wrote: On 11/28/13 10:49 AM, Valentin Zahnd wrote: Hello For-each does not iterate ober all entries of collection, if one removes elements during the iteration. Example code: def keepByValue(self, key=None, value=[]): for row in self.flows:

Re: how to implement a queue-like container with sort function

2013-11-28 Thread MRAB
On 29/11/2013 01:54, iMath wrote: I want to a fixed length list-like container, it should have a sorted()-like function that I can use to sort it,I think there should also a function I can use it to detect whether the numbers of items in it reaches the length of the container , because if the

Re: Cracking hashes with Python

2013-11-27 Thread MRAB
On 27/11/2013 12:40, TheRandomPast . wrote: Hi, So apparently when I've been staring at code all day and tired my brain doesn't tell my hands to type half of what I want it to. I apologise for my last post. This is my code; import md5 import sys

Re: cx_Oracle throws: ImportError: DLL load failed: This application has failed to start ...

2013-11-24 Thread MRAB
On 24/11/2013 17:12, Ruben van den Berg wrote: I'm on Windows XP SP3, Python 2.7.1. On running import cx_Oracle I got the error ImportError: DLL load failed: This application has failed to start because the application configuration is incorrect. Reinstalling the application may fix this

Re: stuck at this from so much time,need help....please ..

2013-11-23 Thread MRAB
On 23/11/2013 22:29, Bhanu Karthik wrote: On Saturday, 23 November 2013 14:23:08 UTC-8, Chris Angelico wrote: On Sun, Nov 24, 2013 at 9:15 AM, Bhanu Karthik bhanukarthik2...@gmail.com wrote: data = sock.recv(RECV_BUFFER) username = str(sock.getpeername())

Re: Recursive generator for combinations of a multiset?

2013-11-22 Thread MRAB
On 23/11/2013 00:58, John O'Hagan wrote: On Thu, 21 Nov 2013 12:59:26 -0800 Dan Stromberg drsali...@gmail.com wrote: On Wed, Nov 20, 2013 at 10:46 PM, John O'Hagan resea...@johnohagan.comwrote: Short story: the subject says it all, so if you have an answer already, fire away. Below is the

Re: using getattr/setattr for local variables in a member function

2013-11-21 Thread MRAB
On 21/11/2013 23:12, Catherine M Moroney wrote: Hello, If I have a class that has some member functions, and all the functions define a local variable of the same name (but different type), is there some way to use getattr/setattr to access the local variables specific to a given function?

Re: [Python-Dev] PEP 0404 and VS 2010

2013-11-20 Thread MRAB
On 20/11/2013 23:36, Christian Tismer wrote: Hey Barry, On 20.11.13 23:30, Barry Warsaw wrote: On Nov 20, 2013, at 09:52 PM, Christian Tismer wrote: Many customers are forced to stick with Python 2.X because of other products, but they require a Python 2.X version which can be compiled using

Re: Off-topic: Pop culture references [was Re: Newbie - Trying to Help a Friend]

2013-11-20 Thread MRAB
On 21/11/2013 00:27, Steven D'Aprano wrote: On Wed, 20 Nov 2013 18:09:42 +, Mark Lawrence defended his reference to Nazism: It's an excellent analogy that I've used before, hence the smiley. Clearly you don't do any research before bothering to say anything. I for one *have* done

Re: Automation

2013-11-19 Thread MRAB
On 19/11/2013 12:59, Alister wrote: On Tue, 19 Nov 2013 23:52:09 +1100, Chris Angelico wrote: On Tue, Nov 19, 2013 at 11:36 PM, Alister alister.w...@ntlworld.com wrote: the language nationality is Scottish, the people are Scots Scotch is a type of whisky. Hmm, I don't know that it's that

Re: Asyncmongo and Python3: ImportError: No module named 'errors'

2013-11-16 Thread MRAB
On 16/11/2013 18:58, Laszlo Nagy wrote: I'm about to convert a complete library into python3. I need asnycmongo for this. Trying to install it on Ubuntu. After executing sudo pip3 install asyncmongo I have the following traceback: Traceback (most recent call last): ... import

Re: grammar (was Re: Automation)

2013-11-16 Thread MRAB
On 17/11/2013 03:44, Andrew Berg wrote: On 2013.11.16 11:02, Paul Smith wrote: The one that really irks me is people using loose when they mean lose. These words are not related, and they don't sound the same. Plus this mistake is very common; I typically see it at least once a day. Don't be

Re: Bug asking for input number

2013-11-15 Thread MRAB
On 16/11/2013 02:15, Arturo B wrote: Hi! I hope you can help me. I'm writting a simple piece of code. I need to keep asking for a number until it has all this specifications: - It is a number - It's lenght is 3 - The hundred's digit differs from the one's digit by at least two My problem is

Re: Odd msg received from list

2013-11-14 Thread MRAB
On 14/11/2013 13:53, Verde Denim wrote: I got an odd message this morning from the list telling me that my account was de-activated due to excessive bounces. I've only sent a handful of messages to this board, but do read an awful lot of the posts in order to learn more about the language. The

Re: datetime question

2013-11-12 Thread MRAB
On 12/11/2013 16:12, Tim Chase wrote: On 2013-11-12 17:57, Ferrous Cranus wrote: Best practices say to move the value from local time to UTC as soon as possible, then store/use the UTC time internally for all operations. Only when it's about to be presented to the user should you convert

Re: Some python newb help please?

2013-11-12 Thread MRAB
On 12/11/2013 22:27, lrwarre...@gmail.com wrote: On Tuesday, November 12, 2013 4:21:58 PM UTC-6, Mark Lawrence wrote: On 12/11/2013 22:14, lr@gmail.com wrote: So I'm trying to write a program for a problem in class, and something strange is happening that I can't figure out why is

Re: datetime question

2013-11-12 Thread MRAB
On 13/11/2013 00:37, Dennis Lee Bieber wrote: On Wed, 13 Nov 2013 09:42:38 +1100, Chris Angelico ros...@gmail.com declaimed the following: Plus, they switch clocks at 2am all the time, not at 2am forward and 3am backward. 2AM is the time at which US switches occur also, in either

Re: Install Tkinter for Windows 7 64-bit

2013-11-11 Thread MRAB
On 11/11/2013 16:43, jonas.thornv...@gmail.com wrote: Here is the example file i have tried. #!/usr/bin/python # -*- coding: utf-8 -*- ZetCode Tkinter tutorial This program draws three rectangles filled with different colors. author: Jan Bodar last modified: January 2011 website:

Re: New user's initial thoughts / criticisms of Python

2013-11-09 Thread MRAB
On 09/11/2013 22:44, Jonathan wrote: On Saturday, November 9, 2013 8:27:02 AM UTC-5, Joshua Landau wrote: `select` is quite an odd statement, in that in most cases it's just a weaker variant of `if`. By the time you're at the point where a `select` is actually more readable you're also at the

Re: pywin32 programming error on Win7 with shell.SHGetDesktopFolder, desktop.BindToObject, desktop.GetDisplayNameOf

2013-11-08 Thread MRAB
On 08/11/2013 03:30, iMath wrote: When running the following code on WinXP , all is fine , -- from win32com.shell import shell def launch_file_explorer(path, files): folder_pidl = shell.SHILCreateFromPath(path,0)[0] desktop

Re: splitting file/content into lines based on regex termination

2013-11-07 Thread MRAB
On 07/11/2013 17:45, bruce wrote: update... dat=re.compile(br#(\d+) / (\d+)#(\d+)#).split(s) almost works.. except i get m = 10116#000#C S#S#100##001##DAY#Fund of Computing#Barrett, William#3#MWFbr#08:00ambr#08:50ambr#3718 HBLL m = 45 m = 58 m = 0 m = 10116#000#C S#S#100##002##DAY#Fund of

Re: To whoever hacked into my Database

2013-11-07 Thread MRAB
On 07/11/2013 18:11, Mark Lawrence wrote: On 07/11/2013 17:42, Νίκος Αλεξόπουλος wrote: Στις 7/11/2013 6:34 μμ, ο/η Mark Lawrence έγραψε: On 07/11/2013 13:47, Νίκος Αλεξόπουλος wrote: Στις 7/11/2013 11:31 πμ, ο/η Ferrous Cranus έγραψε: Τη Πέμπτη, 7 Νοεμβρίου 2013 11:15:02 π.μ. UTC+2, ο

Re: Python 3.3.2 Shell Message‏

2013-11-07 Thread MRAB
On 07/11/2013 20:02, Bart Montgomery wrote: My thanks to Ned Deily for his timely response. IDLE is now stable, and I’m at the next step which is to run the file I created called hello.py. I get this message from the shell: Python 3.3.2 (v3.3.2:d047928ae3f6, May 13 2013, 13:52:24) [GCC 4.2.1

Re: Show off your Python chops and compete with others

2013-11-06 Thread MRAB
On 07/11/2013 00:59, Chris Angelico wrote: On Thu, Nov 7, 2013 at 11:00 AM, Nathaniel Sokoll-Ward nathanielsokollw...@gmail.com wrote: Thought this group would appreciate this: www.metabright.com/challenges/python MetaBright makes skill assessments to measure how talented people are at

Re: Help me with this code

2013-11-05 Thread MRAB
On 06/11/2013 01:51, chovd...@gmail.com wrote: Hi friends help me with the following code. Im able to execute the code but getting wrong output def sequence_b(N): N = 10 result = 0 for k in xrange (1,N): result += ((-1) ** (k+1))/2*k-1 print result print

Re: Automation

2013-11-03 Thread MRAB
On 03/11/2013 21:53, Mark Lawrence wrote: On 03/11/2013 21:22, bob gailer wrote: On 11/3/2013 11:19 AM, Renato Barbosa Pim Pereira wrote: I have one .xls file with the values of PV MV and SP, I wanna to calculate Kp Ki Kd with python from this file, can anyone give me any suggestion about how

Re: New to using re. Search for a number before a string.

2013-11-01 Thread MRAB
On 01/11/2013 21:33, Captain Dunsel wrote: I have a text file that has lines with numbers occasionally appearing right before a person's name. For example: COLLEGE:ENROLLMENT:COMPLETED EVALUATIONS:624309FUDD, ELMER where I want to search for the name ELMER FUDD and extract the number right

Re: multiprocessing: child process race to answer

2013-11-01 Thread MRAB
On 02/11/2013 02:35, smhall05 wrote: I am using a basic multiprocessing snippet I found: #- from multiprocessing import Pool def f(x): return x*x if __name__ == '__main__': pool = Pool(processes=4) # start 4 worker

Re: how to extract page-URL using BeautifulSoup

2013-10-31 Thread MRAB
On 31/10/2013 15:59, bhaktanish...@gmail.com wrote: I want to extract the page-url. for example: if i have this code import urllib2 from bs4 import BeautifulSoup link = http://www.google.com; page = urllib2.urlopen(link).read() soup = BeautifulSoup(page) then i can extract title of page by:

Re: Python wart

2013-10-31 Thread MRAB
On 01/11/2013 01:45, Mark Lawrence wrote: Quite often I type this print('Total of accounts %.2f', total) when I meant to type this print('Total of accounts %.2f' % total) Do I have to raise a PEP to get this stupid language changed so that it dynamically recognises what I want it to do and

Re: First day beginner to python, add to counter after nested loop

2013-10-30 Thread MRAB
On 30/10/2013 16:31, jonas.thornv...@gmail.com wrote: Den onsdagen den 30:e oktober 2013 kl. 17:22:23 UTC+1 skrev Mark Lawrence: No that is not my problem, apparently so it is that the newsreader constructors do not like the competition of Google groups otherwise they would had written the

Re: stacked decorators and consolidating

2013-10-29 Thread MRAB
On 29/10/2013 16:54, Tim Chase wrote: I've got some decorators that work fine as such: @dec1(args1) @dec2(args2) @dec3(args3) def myfun(...): pass However, I used that sequence quite a bit, so I figured I could do something like dec_all =

Re: Check if this basic Python script is coded right

2013-10-26 Thread MRAB
On 26/10/2013 18:36, HC wrote: I'm doing my first year in university and I need help with this basic assignment. Assignment: Write Python script that prints sum of cubes of numbers between 0-200 that are multiples of 3. 3^3+6^3+9^3+12^3+198^3=? My script: count = 0 answer = 0 while

Re: trying to strip out non ascii.. or rather convert non ascii

2013-10-26 Thread MRAB
On 26/10/2013 21:11, bruce wrote: hi.. getting some files via curl, and want to convert them from what i'm guessing to be unicode. I'd like to convert a string like this:: div class=profNamea href=ShowRatings.jsp?tid=1312168Alcántar, Iliana/a/div to:: div class=profNamea

Re: Unlimited canvas painting program

2013-10-24 Thread MRAB
On 24/10/2013 20:32, markot...@gmail.com wrote: So, i`ll take the canvas, somekind of mouse tracker, for each mouse location il draw a dot or 2X2 square or something. Main thing i have never understood, is how can i get the backround to move. Lets say ia hve 200X200 window. In the middle of it

Re: functools and objective usage

2013-10-23 Thread MRAB
On 23/10/2013 17:48, Mohsen Pahlevanzadeh wrote: Dear all, I have the following code in each steps of loop: obj = partial(self.myinstance.myfunc) obj.func = self.myinstance.myfunc obj.arg =

Re: Python Front-end to GCC

2013-10-22 Thread MRAB
On 22/10/2013 18:23, Steven D'Aprano wrote: On Tue, 22 Oct 2013 16:53:07 +, Frank Miles wrote: [snip C code] What you're missing is that arr[] is an automatic variable. Put a static in front of it, or move it outside the function (to become global) and you'll see the difference. Ah,

Re: Python Front-end to GCC

2013-10-22 Thread MRAB
On 22/10/2013 18:50, Mark Janssen wrote: So which of you is confused? I ask that in the inclusive (not exclusive OR) sense ;^) -- face says both. Could you please be less snarky? We're trying to communicate here, and it is not at all clear yet who is confused and who is not. If you are

Re: Python Front-end to GCC

2013-10-22 Thread MRAB
On 22/10/2013 19:22, Mark Janssen wrote: Okay. The purpose of BNF (at least as I envision it) is to produce/specify a *context-free* grammar. A lexer parses the tokens specified in the BNF into an Abstract Syntax Tree. If one can produce such a tree for any given source, the language, in

Re: Tkinter tutorial?

2013-10-22 Thread MRAB
On 22/10/2013 21:57, Walter Hurry wrote: I have some experience with Python, having used it for a couple of years. Until now, my builder of choice for cross-platform GUI applications has been wxPython (with wxGlade), and I have been well satisfied with these tools. However, for a different

Re: functools and objective usage

2013-10-22 Thread MRAB
On 22/10/2013 23:13, Ben Finney wrote: Mohsen Pahlevanzadeh moh...@pahlevanzadeh.org writes: Suppose i have function name, 3 arguments for it, and object of its caller such as self.blahbalah This doesn't make much sense to me. I think you mean: You have an object, ‘self.blahblah’, which has

Re: Using with context handler, and catching specific exception?

2013-10-21 Thread MRAB
On 22/10/2013 02:43, Victor Hooi wrote: Hi, I suspect I'm holding How should I use the with context handler as well as handling specific exceptions? For example, for a file: with open('somefile.log', 'wb') as f: f.write(hello there) How could I specifically catch IOError in

Re: how to add object from dict

2013-10-17 Thread MRAB
On 17/10/2013 01:46, Chris Angelico wrote: On Thu, Oct 17, 2013 at 11:43 AM, MRAB pyt...@mrabarnett.plus.com wrote: I'm guessing, but perhaps you need: instance = getattr(self, %s % key) How's that different from getattr(self,str(key))? I'm trying to make the bug clearer for the OP

Re: Sexism in the Ruby community: how does the Python community manage it?

2013-10-17 Thread MRAB
On 17/10/2013 17:43, Paul Pittlerson wrote: What we need to do is A) Prove that we are not sexist and racist by excluding and intolerating people who do not agree with. B) Head on over to the Ruby mailing list and make a thread called Hey guys we are the python people, and can you learn to

Re: Python was designed (was Re: Multi-threading in Python vs Java)

2013-10-17 Thread MRAB
On 17/10/2013 18:32, rusi wrote: On Wednesday, October 16, 2013 1:56:27 AM UTC+5:30, zipher wrote: Yes, well clearly we are not having the same thoughts, yet the purpose of the academic establishment is to pin down such terminology and not have these sloppy understandings everywhere. You dig?

Re: pointer and python

2013-10-17 Thread MRAB
On 18/10/2013 00:17, Mohsen Pahlevanzadeh wrote: Dear all, Suppose I have the following code: ##3 mydic = dict() mydict.update({'string':QtGui.QCheckBox()}) ## suppose this dic has many value with some string and QCheckBox Object If you do this, you're

Re: converting letters to numbers

2013-10-16 Thread MRAB
On 16/10/2013 23:39, Rotwang wrote: On 14/10/2013 06:02, Steven D'Aprano wrote: On Sun, 13 Oct 2013 20:13:32 -0700, Tim Roberts wrote: def add(c1, c2): % Decode c1 = ord(c1) - 65 c2 = ord(c2) - 65 % Process i1 = (c1 + c2) % 26 % Encode return

Re: how to add object from dict

2013-10-16 Thread MRAB
On 16/10/2013 23:14, Mohsen Pahlevanzadeh wrote: Dear all, I have the following code in projects.py: ##33 for row in xrange(len(uniqueFields)): instance = QtGui.QCheckBox(uniqueFields[row])

Re: Error connecting to MySQL from Python

2013-10-12 Thread MRAB
On 12/10/2013 17:09, carlos.ortiz@gmail.com wrote: Hello guys I am currently working in a python project at my school. First I want to make clear that I'm not a python programmer (I was just called to put out the flames in this project because no one else would and I was brave enough to

Re: I am never going to complain about Python again

2013-10-10 Thread MRAB
On 10/10/2013 09:23, Frank Millman wrote: Steven D'Aprano st...@pearwood.info wrote in message news:52562ee3$0$2931$c3e8da3$76491...@news.astraweb.com... Just came across this little Javascript gem: ,,, == Array((null,'cool',false,NaN,4)); = evaluates as true

Re: I am never going to complain about Python again

2013-10-10 Thread MRAB
On 10/10/2013 16:57, Rotwang wrote: On 10/10/2013 16:51, Neil Cerutti wrote: [...] Mixed arithmetic always promotes to the wider type (except in the case of complex numbers (Ha!)). r == c is equivalent to r == abs(c), which returns the magintude of the complex number. What? -1 == -1 +

Re: Encoding of surrogate code points to UTF-8

2013-10-08 Thread MRAB
On 08/10/2013 16:23, Pete Forman wrote: Steven D'Aprano steve+comp.lang.pyt...@pearwood.info writes: I think this is a bug in Python's UTF-8 handling, but I'm not sure. [snip] py s = '\ud800\udc01' py s.encode('utf-8') Traceback (most recent call last): File stdin, line 1, in module

Re: Tail recursion to while iteration in 2 easy steps

2013-10-07 Thread MRAB
On 07/10/2013 18:57, Antoon Pardon wrote: Op 07-10-13 19:15, Alain Ketterlin schreef: I want to consider here what it would mean to concretely implement the abstract notion 'disallow rebinding of function names' and show what would be behind calling the idea 'not feasible'. Again, I'm more

Re: HEX to ASCII

2013-10-06 Thread MRAB
On 06/10/2013 20:07, markot...@gmail.com wrote: problem is : Traceback (most recent call last): File C:\Users\Marko\Desktop\hacker.org\XOR cypher.py, line 35, in module print(Key- + str(võti) + : + str(.join(tulemus2))) TypeError: sequence item 0: expected str instance, bytes found

Re: Strange extra f added to bytes object

2013-10-06 Thread MRAB
On 06/10/2013 23:47, Robert Jackson wrote: I am very new to python so I'll apologize up front if this is some boneheaded thing. I am using python and pyserial to talk to an embedded pic processor in a piece of scientific equipment. I sometimes find the when I construct the bytes object to

Re: Select fails when cookie tried to get a numeric value

2013-10-05 Thread MRAB
On 05/10/2013 15:44, Zero Piraeus wrote: On Sat, Oct 05, 2013 at 05:30:53PM +0300, Νίκος Αλεξόπουλος wrote: Every mysql statemtns that involved cookieID fails. in this example this: # find the visitor record for the (saved) cID and current host cur.execute('''SELECT * FROM visitors WHERE

Re: compare two list of dictionaries

2013-10-04 Thread MRAB
On 04/10/2013 03:29, Mohan L wrote: [snip] output1=[ {'count': 3 , 'ip': 'xxx.xx.xxx.1'}, {'count': 4, 'ip': 'xxx.xx.xxx.2'}, {'count': 8, 'ip': 'xxx.xx.xxx.3'}, {'count': 10, 'ip': 'xxx.xx.xxx.4'}, {'count': 212, 'ip': 'hostname1'}, {'count': 27, 'ip': 'hostname2'}, {'count': 513, 'ip':

Re: Why didn't my threads exit correctly ?

2013-10-03 Thread MRAB
On 03/10/2013 18:37, 李洛 wrote: Hi list, I write an example script using threading as follow. It look like hang when the list l_ip is empty. And any suggestion with debug over the threading in Python ? 1 #!/usr/bin/env python 2 # -*- coding: utf-8 -*- 3 import re 4 import os 5

Re: compare two list of dictionaries

2013-10-03 Thread MRAB
On 03/10/2013 17:11, Mohan L wrote: Dear All, I have two list of dictionaries like below: In the below dictionaries the value of ip can be either hostname or ip address. output1=[ {'count': 3 , 'ip': 'xxx.xx.xxx.1'}, {'count': 4, 'ip': 'xxx.xx.xxx.2'}, {'count': 8, 'ip': 'xxx.xx.xxx.3'},

Re: PyDoc_STRVAR error in msvc compile

2013-10-02 Thread MRAB
On 02/10/2013 12:28, Robin Becker wrote: On 02/10/2013 11:49, Dave Angel wrote: conditional string or then MSVC 9 seems to be ok with it. MSVC and other compilers do not not see eye to eye on the preprocessor semantics. I no longer use MSVC so I can't experiment. I can only try to recall

Re: Tail recursion to while iteration in 2 easy steps

2013-10-02 Thread MRAB
On 03/10/2013 02:39, Dave Angel wrote: On 2/10/2013 21:24, Steven D'Aprano wrote: On Wed, 02 Oct 2013 18:17:06 -0400, Terry Reedy wrote: CPython core developers have be very conservative about what tranformations they put into the compiler. (1,2,3) can always be compiled as a constant, and

<    13   14   15   16   17   18   19   20   21   22   >