Re: Python Book for a C Programmer?

2012-05-24 Thread Ulrich Eckhardt
Am 24.05.2012 01:45, schrieb hsa...@gmail.com: > I am trying to join an online class that uses python. I need to brush > up on the language quickly. Is there a good book or resource that > covers it well but does not have to explain what an if..then..else > statement is? First thing to check first

Re: Wish: Allow all log Handlers to accept the level argument

2012-05-24 Thread Peter Otten
Fayaz Yusuf Khan wrote: > ***TRIVIAL ISSUE***, but this has been irking me for a while now. > The main logging.Handler class' __init__ accepts a level argument while > none of its children do. The poor minions seem to be stuck with the > setLevel method which considerably lengthens the code. > >

Working with dates : complex problem

2012-05-24 Thread Thibaut DIRLIK
Hi, I've a list of python objects with dates attributes. This list is ordered by one of these date. Elements mandatory follow each other : Element #1 Element #2 Element #3 |-|--|--| Now, I want to "insert" an

Namespace hack

2012-05-24 Thread Steven D'Aprano
>From the Zen of Python ("import this"): Namespaces are one honking great idea -- let's do more of those! Inspired by this, I have a decorator that abuses function closures to create a namespace type with the following properties: - all methods are static methods that do not take a "self" para

Re: Working with dates : complex problem

2012-05-24 Thread Peter Otten
Thibaut DIRLIK wrote: > Hi, > > I've a list of python objects with dates attributes. This list is ordered > by one of these date. Elements mandatory follow each other : > > Element #1 Element #2 Element #3 > |-|--|--

Re: Korean fonts on Python 2.6 (MacOsX)

2012-05-24 Thread Ulrich Eckhardt
Am 23.05.2012 11:30, schrieb 20_feet_tall: > I have a problem with the visualization of korean fonts on Python. > When I try to type in the characters only squares come out. > I have tried to install the CJK codec, the hangul 1.0 codec but still > no result. What exactly do you mean with "visualiz

Re: Wish: Allow all log Handlers to accept the level argument

2012-05-24 Thread Jean-Michel Pichavant
Fayaz Yusuf Khan wrote: Jean-Michel Pichavant wrote: Meanwhile you can shorten the code this way: root.addHandler(FileHandler('debug.log')) root.handlers[-1].setLevel(DEBUG) Eh? Readability was the aim. I fail to see how it's not readable, code is short and no magic is involved pr

Re: Wish: Allow all log Handlers to accept the level argument

2012-05-24 Thread Peter Otten
Jean-Michel Pichavant wrote: > Fayaz Yusuf Khan wrote: >> Jean-Michel Pichavant wrote: >> >>> Meanwhile you can shorten the code this way: >>> >>> root.addHandler(FileHandler('debug.log')) >>> root.handlers[-1].setLevel(DEBUG) >>> >>> >> Eh? Readability was the aim. >> > I fail to see h

Re: Wish: Allow all log Handlers to accept the level argument

2012-05-24 Thread Jean-Michel Pichavant
Peter Otten wrote: Jean-Michel Pichavant wrote: Fayaz Yusuf Khan wrote: Jean-Michel Pichavant wrote: Meanwhile you can shorten the code this way: root.addHandler(FileHandler('debug.log')) root.handlers[-1].setLevel(DEBUG) Eh? Readability was the aim.

Re: Wish: Allow all log Handlers to accept the level argument

2012-05-24 Thread Peter Otten
Jean-Michel Pichavant wrote: > Peter Otten wrote: >> Jean-Michel Pichavant wrote: >> >> >>> Fayaz Yusuf Khan wrote: >>> Jean-Michel Pichavant wrote: > Meanwhile you can shorten the code this way: > > root.addHandler(FileHandler('debug.log')) > root.

other languages API to python

2012-05-24 Thread Rita
Hello, A vendor provided a C, C++ and Java API for a application. They dont support python so I would like to create a library for it. My question is, how hard/easy would it be to create something like this? Is there a simple HOWTO or examples I can follow? Can someone shed home light on this? TI

Re: problem loading matlab data with ompc and python

2012-05-24 Thread Tim Williams
On May 23, 5:10 pm, no1 wrote: > Hi, we're investigating transitioning our company from matlab to python. We > found OMPC as a MATLAB m-file-to Python translator, but we're encountering a > problem using the translated code to import MATLAB data structures into > Python. For example, when we sa

Re: other languages API to python

2012-05-24 Thread Chris Angelico
On Thu, May 24, 2012 at 9:58 PM, Rita wrote: > Hello, > > A vendor provided a C, C++ and Java API for a application. They dont support > python so I would like to create a library for it. My question is, how > hard/easy would it be to create something like this? Is there a simple HOWTO > or exampl

Email Id Verification

2012-05-24 Thread niks
Hello everyone.. I am new to asp.net... I want to use Regular Expression validator in Email id verification.. Can anyone tell me how to use this and what is the meaning of this \w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)* -- http://mail.python.org/mailman/listinfo/python-list

Re: Email Id Verification

2012-05-24 Thread Chris Angelico
On Thu, May 24, 2012 at 10:32 PM, niks wrote: > Hello everyone.. > I am new to asp.net... > I want to use Regular Expression validator in Email id verification.. > Can anyone tell me how to use this and what is the meaning of > this > \w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)* This is a mailing

Re: Python Book for a C Programmer?

2012-05-24 Thread William R. Wing (Bill Wing)
On May 23, 2012, at 7:45 PM, hsa...@gmail.com wrote: > I am trying to join an online class that uses python. I need to brush up on > the language quickly. Is there a good book or resource that covers it well > but does not have to explain what an if..then..else statement is? > > Thanks. > -- >

Re: Email Id Verification

2012-05-24 Thread alister
On Thu, 24 May 2012 05:32:16 -0700, niks wrote: > Hello everyone.. > I am new to asp.net... > I want to use Regular Expression validator in Email id verification.. > Can anyone tell me how to use this and what is the meaning of this > \w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)* this is not reall

Re: Python Book for a C Programmer?

2012-05-24 Thread alister
On Wed, 23 May 2012 16:45:05 -0700, hsaziz wrote: > I am trying to join an online class that uses python. I need to brush up > on the language quickly. Is there a good book or resource that covers it > well but does not have to explain what an if..then..else statement is? > > Thanks. Dive into p

Re: Namespace hack

2012-05-24 Thread Daniel Fetchinson
> >From the Zen of Python ("import this"): > > Namespaces are one honking great idea -- let's do more of those! > > > Inspired by this, I have a decorator that abuses function closures to > create a namespace type with the following properties: > > - all methods are static methods that do not take

Re: Python Book for a C Programmer?

2012-05-24 Thread Javier Novoa C.
On 2012-05-24, alister wrote: > On Wed, 23 May 2012 16:45:05 -0700, hsaziz wrote: > >> I am trying to join an online class that uses python. I need to brush up >> on the language quickly. Is there a good book or resource that covers it >> well but does not have to explain what an if..then..else st

Re: Python Book for a C Programmer?

2012-05-24 Thread boB Stepp
On Thu, May 24, 2012 at 8:28 AM, Javier Novoa C. wrote: > On 2012-05-24, alister wrote: >> On Wed, 23 May 2012 16:45:05 -0700, hsaziz wrote: >> >>> I am trying to join an online class that uses python. I need to brush up >>> on the language quickly. Is there a good book or resource that covers it

Dynamic comparison operators

2012-05-24 Thread mlangenhoven
I would like to pass something like this into a function test(val1,val2,'>=') and it should come back with True or False. Is there a way to dynamically compare 2 values like this or will I have to code each operator individually? -- http://mail.python.org/mailman/listinfo/python-list

Re: Dynamic comparison operators

2012-05-24 Thread Phil Le Bienheureux
Hello, You can pass an operator as an argument to your function. See : http://docs.python.org/library/operator.html Regards, -- Forwarded message -- From: Date: 2012/5/24 Subject: Dynamic comparison operators To: python-list@python.org I would like to pass something like thi

Re: Dynamic comparison operators

2012-05-24 Thread Alain Ketterlin
mlangenho...@gmail.com writes: > I would like to pass something like this into a function > test(val1,val2,'>=') > > and it should come back with True or False. def test(x,y,c): return c(x,y) Call with: test(v1,v2, lambda x,y:x<=y ). A bit noisy imho. If you have a finite number of comparis

Re: Dynamic comparison operators

2012-05-24 Thread Tim Chase
On 05/24/12 09:32, Phil Le Bienheureux wrote: >> I would like to pass something like this into a function >> test(val1,val2,'>=') > > You can pass an operator as an argument to your function. > > See : > http://docs.python.org/library/operator.html And if you want to use strings, you can map them

Re: Dynamic comparison operators

2012-05-24 Thread Jussi Piitulainen
Alain Ketterlin writes: > mlangenho...@gmail.com writes: > > > I would like to pass something like this into a function > > test(val1,val2,'>=') > > > > and it should come back with True or False. > > def test(x,y,c): > return c(x,y) > > Call with: test(v1,v2, lambda x,y:x<=y ). A bit noisy

Re: Email Id Verification

2012-05-24 Thread Chris Angelico
On Thu, May 24, 2012 at 11:45 PM, Dennis Lee Bieber wrote: >        And maybe follow-up with a review of this monster: > http://www.ex-parrot.com/pdw/Mail-RFC822-Address.html That is awesome. Epic. Eyeball-bleeding. ChrisA -- http://mail.python.org/mailman/listinfo/python-list

Re: Dynamic comparison operators

2012-05-24 Thread Colin J. Williams
On 24/05/2012 10:14 AM, mlangenho...@gmail.com wrote: I would like to pass something like this into a function test(val1,val2,'>=') and it should come back with True or False. Is there a way to dynamically compare 2 values like this or will I have to code each operator individually? Would so

Czy dysponujesz dwoma wolnymi godzinami w tygodniu? Oto jak zarobc 185 EUR w tym czasie.

2012-05-24 Thread python-list
Dzien dobry! Dziekujemy bardzo za zainteresowanie pozycja regionalnego przedstawiciela dostepna obecnie w Polsce i krajach Europy Srodkowej. Chcialem by przedstawic, bardzo krotko - nasza wybitna firme. W.U.G. Inc zostala zalozona w 1992 roku i obecnie stala sie jedna z najbardziej uznawanych

Re: Python Book for a C Programmer?

2012-05-24 Thread Javier Novoa C.
On Thu, May 24, 2012 at 08:34:24AM -0500, boB Stepp wrote: > On Thu, May 24, 2012 at 8:28 AM, Javier Novoa C. > wrote: > > On 2012-05-24, alister wrote: > >> On Wed, 23 May 2012 16:45:05 -0700, hsaziz wrote: > >> > >>> I am trying to join an online class that uses python. I need to brush up > >>>

Embedding Python27 in C++ on Windows: CRT compatibility issues with VS2010?

2012-05-24 Thread Stephen Lin
Hello, I'm a relative python newbie but I've been tasked to figure out how to embed calls to a python library in an Excel XLL add-in. The Python/C API for doing this seems pretty straightforward, but I seem to have read somewhere online that it's important that the C++ program or DLL linking to a

Re: Email Id Verification

2012-05-24 Thread John Nagle
On 5/24/2012 5:32 AM, niks wrote: Hello everyone.. I am new to asp.net... I want to use Regular Expression validator in Email id verification.. Can anyone tell me how to use this and what is the meaning of this \w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)* Not a Python question. It matche

Re: Python Book for a C Programmer?

2012-05-24 Thread Jim Wilson
On 05/23/2012 07:45 PM, hsa...@gmail.com wrote: > I am trying to join an online class that uses python. I need to brush up on > the language quickly. Is there a good book or resource that covers it well > but does not have to explain what an if..then..else statement is? > > Thanks. My opinion:

Help doing it the "python way"

2012-05-24 Thread Scott Siegler
Hello, I am an experienced programmer but a beginner to python. As such, I can figure out a way to code most algorithms using more "C" style syntax. I am doing something now that I am sure is a more python way but i can't quite get it right. I was hoping someone might help. So I have a list

Re: Help doing it the "python way"

2012-05-24 Thread Duncan Booth
Scott Siegler wrote: > Hello, > > I am an experienced programmer but a beginner to python. As such, I > can figure out a way to code most algorithms using more "C" style > syntax. > > I am doing something now that I am sure is a more python way but i > can't quite get it right. I was hoping

Re: Help doing it the "python way"

2012-05-24 Thread Paul Rubin
Scott Siegler writes: > is there a way to do something like: >[(x,y-1), (x,y+1) for zzz in coord_list] > or something along those lines? You should read the docs of the itertools module on general principles, since they are very enlightening in many ways. Your particular problem can be hand

Re: Help doing it the "python way"

2012-05-24 Thread Dave Angel
On 05/24/2012 04:22 PM, Scott Siegler wrote: > Hello, > > I am an experienced programmer but a beginner to python. As such, I can > figure out a way to code most algorithms using more "C" style syntax. > > I am doing something now that I am sure is a more python way but i can't > quite get it ri

Re: Help doing it the "python way"

2012-05-24 Thread Paul Rubin
Paul Rubin writes: > new_list = chain( ((x,y-1), (x,y+1)) for x,y in coord_list ) Sorry: new_list = list(chain( ((x,y-1), (x,y+1)) for x,y in coord_list)) -- http://mail.python.org/mailman/listinfo/python-list

Re: problem loading matlab data with ompc and python

2012-05-24 Thread no1
On Thursday, May 24, 2012 5:06:41 AM UTC-7, Tim Williams wrote: > On May 23, 5:10 pm, no1 wrote: > > Hi, we're investigating transitioning our company from matlab to python. We > > found OMPC as a MATLAB m-file-to Python translator, but we're encountering > > a problem using the translated code

Re: Email Id Verification

2012-05-24 Thread Ben Finney
John Nagle writes: >It matches anything that looks like a mail user name followed by > an @ followed by anything that looks more or less like a domain name. > The domain name must contain at least one ".", and cannot end with > a ".", which is not strictly correct but usually works. It will

Re: Wish: Allow all log Handlers to accept the level argument

2012-05-24 Thread Cameron Simpson
On 24May2012 12:48, Jean-Michel Pichavant wrote: | Peter Otten wrote: | > Jean-Michel Pichavant wrote: | >> Fayaz Yusuf Khan wrote: | >>> Jean-Michel Pichavant wrote: | Meanwhile you can shorten the code this way: | root.addHandler(FileHandler('debug.log')) | root.handlers[-1].setLe

Re: Email Id Verification

2012-05-24 Thread Cameron Simpson
On 25May2012 01:20, Chris Angelico wrote: | On Thu, May 24, 2012 at 11:45 PM, Dennis Lee Bieber | wrote: | >        And maybe follow-up with a review of this monster: | > http://www.ex-parrot.com/pdw/Mail-RFC822-Address.html | | That is awesome. Epic. Eyeball-bleeding. +1 !! I hope someone

Re: Email Id Verification

2012-05-24 Thread Cameron Simpson
On 24May2012 05:32, niks wrote: | Hello everyone.. | I am new to asp.net... Time to run away fast before you're commited then:-) You're aware this is a _python_ list/group, yes? | I want to use Regular Expression validator in Email id verification.. You can't. Valid addresses including nesting

Re: Help doing it the "python way"

2012-05-24 Thread Emile van Sebille
On 5/24/2012 2:30 PM Paul Rubin said... Paul Rubin writes: new_list = chain( ((x,y-1), (x,y+1)) for x,y in coord_list ) Sorry: new_list = list(chain( ((x,y-1), (x,y+1)) for x,y in coord_list)) >>> from itertools import chain >>> coord_list = zip(range(20,30),range(30,40)) >>> a =

Re: Email Id Verification

2012-05-24 Thread Chris Angelico
On Fri, May 25, 2012 at 9:03 AM, Cameron Simpson wrote: > On 24May2012 05:32, niks wrote: > | Hello everyone.. > | I am new to asp.net... > > Time to run away fast before you're commited then:-) > You're aware this is a _python_ list/group, yes? Committed to an asylum or to source control? Pyth

Re: Email Id Verification

2012-05-24 Thread Steven D'Aprano
On Thu, 24 May 2012 05:32:16 -0700, niks wrote: > Hello everyone.. > I am new to asp.net... > I want to use Regular Expression validator in Email id verification.. Why do you want to write buggy code that makes your users hate your program? Don't do it! Write good code, useful code! Validating e

Re: Email Id Verification

2012-05-24 Thread MRAB
On 25/05/2012 00:03, Cameron Simpson wrote: On 24May2012 05:32, niks wrote: | Hello everyone.. | I am new to asp.net... Time to run away fast before you're commited then:-) You're aware this is a _python_ list/group, yes? | I want to use Regular Expression validator in Email id verification..

Re: Dynamic comparison operators

2012-05-24 Thread Steven D'Aprano
On Thu, 24 May 2012 11:22:37 -0400, Colin J. Williams wrote: > On 24/05/2012 10:14 AM, mlangenho...@gmail.com wrote: >> I would like to pass something like this into a function >> test(val1,val2,'>=') >> >> and it should come back with True or False. >> >> Is there a way to dynamically compare 2 v

Scoping Issues

2012-05-24 Thread SherjilOzair
def adder(): s = 0 def a(x): s += x return sum return a pos, neg = adder(), adder() for i in range(10): print pos(i), neg(-2*i) This should work, right? Why does it not? Checkout slide no. 37 of a Tour of Go to know inspiration. Just wanted

Re: Email Id Verification

2012-05-24 Thread Paul Rubin
Steven D'Aprano writes: > Why do you want to write buggy code that makes your users hate your > program? ... > The only way to validate an email address is to ACTUALLY SEND AN EMAIL TO > IT. Of course spamming people will make them hate you even more. Insisting that people give you a valid em

Re: Dynamic comparison operators

2012-05-24 Thread Paul Rubin
mlangenho...@gmail.com writes: > I would like to pass something like this into a function > test(val1,val2,'>=') > > and it should come back with True or False. import operator test(val1, val2, operator.ge) -- http://mail.python.org/mailman/listinfo/python-list

Re: Scoping Issues

2012-05-24 Thread MRAB
On 25/05/2012 02:23, SherjilOzair wrote: def adder(): s = 0 def a(x): s += x return sum return a pos, neg = adder(), adder() for i in range(10): print pos(i), neg(-2*i) This should work, right? Why does it not? Checkout slide no. 37 of a

Re: Email Id Verification

2012-05-24 Thread Steven D'Aprano
On Thu, 24 May 2012 18:35:21 -0700, Paul Rubin wrote: > Steven D'Aprano writes: >> Why do you want to write buggy code that makes your users hate your >> program? ... >> The only way to validate an email address is to ACTUALLY SEND AN EMAIL >> TO IT. > > Of course spamming people will make them

Re: Scoping Issues

2012-05-24 Thread Steven D'Aprano
On Thu, 24 May 2012 18:23:18 -0700, SherjilOzair wrote: > def adder(): > s = 0 > def a(x): > s += x > return sum > return a I think you mean "return s", not sum. > This should work, right? Why does it not? No, it shouldn't. When you have an assignment, suc

Re: Scoping Issues

2012-05-24 Thread Chris Rebert
On Thu, May 24, 2012 at 6:23 PM, SherjilOzair wrote: > def adder(): >        s = 0 >        def a(x): Add a "nonlocal s" declaration right here. See http://www.python.org/dev/peps/pep-3104/ >            s += x >            return sum >        return a > > pos, neg = adder(), adder() > for i in r

Re: Embedding Python27 in C++ on Windows: CRT compatibility issues with VS2010?

2012-05-24 Thread Mark Hammond
On 25/05/2012 2:10 AM, Stephen Lin wrote: Hello, I'm a relative python newbie but I've been tasked to figure out how to embed calls to a python library in an Excel XLL add-in. The Python/C API for doing this seems pretty straightforward, but I seem to have read somewhere online that it's import

Re: Scoping Issues

2012-05-24 Thread Dave Angel
On 05/24/2012 09:23 PM, SherjilOzair wrote: > def adder(): > s = 0 > def a(x): > s += x > return sum > return a > > pos, neg = adder(), adder() > for i in range(10): > print pos(i), neg(-2*i) > > This should work, right? Why does it not? > Guess that dep

Re: Email Id Verification

2012-05-24 Thread Chris Angelico
On Fri, May 25, 2012 at 11:35 AM, Paul Rubin wrote: > Steven D'Aprano writes: >> Why do you want to write buggy code that makes your users hate your >> program? ... >> The only way to validate an email address is to ACTUALLY SEND AN EMAIL TO >> IT. > > Of course spamming people will make them hat

Re: Scoping Issues

2012-05-24 Thread Andrew Berg
On 5/24/2012 8:59 PM, Dave Angel wrote: > so I fixed that, and got > inconsistent use of tabs and spaces in indentation > > because you mistakenly used tabs for indentation. Not to start another tabs-vs.-spaces discussion, but tabs are perfectly legal indentation in Python. That exception is

Re: Namespace hack

2012-05-24 Thread Steven D'Aprano
Pardon me for breaking threading, but Daniel's response is not available on my ISP's news server, and I only discovered it by accident. On Thu May 24 15:04:34 CEST 2012, Daniel Fetchinson wrote: > > On Thu, 24 May 2012 08:50:59 +, Steven D'Aprano wrote: > > From the Zen of Python ("import t

Is there a custom fields plugin or component of django

2012-05-24 Thread kevon wang
I want to find a plugin of django what it can custom fields in the form. The functions include custom fields in web page and create the fields in database. plugin's flow like these: 1.we can define fields in web page --> 2.create the table in database(table includes all custom fields) --> 3.

Re: Help doing it the "python way"

2012-05-24 Thread Terry Reedy
On 5/24/2012 4:53 PM, Duncan Booth wrote: Scott Siegler wrote: Hello, I am an experienced programmer but a beginner to python. As such, I can figure out a way to code most algorithms using more "C" style syntax. Hi, welcome to Python. I came here from C also. I am doing something now tha

Re: Scoping Issues

2012-05-24 Thread Dave Angel
On 05/24/2012 10:27 PM, Andrew Berg wrote: > On 5/24/2012 8:59 PM, Dave Angel wrote: >> so I fixed that, and got >> inconsistent use of tabs and spaces in indentation >> >> because you mistakenly used tabs for indentation. > Not to start another tabs-vs.-spaces discussion, but tabs are perfect

Re: Email Id Verification

2012-05-24 Thread Ben Finney
Paul Rubin writes: > Steven D'Aprano writes: > > Why do you want to write buggy code that makes your users hate your > > program? ... > > The only way to validate an email address is to ACTUALLY SEND AN EMAIL TO > > IT. > > Of course spamming people will make them hate you even more. Use the

Re: Namespace hack

2012-05-24 Thread Temia Eszteri
[Default] On 25 May 2012 02:47:11 GMT, Steven D'Aprano wrote: >Do you object to the ability to write standard Python modules? > ># module.py >def spam(obj, n): >return len(obj) + n > >def ham(obj): >return spam(obj, 23) > > >By your apparent misunderstanding of the Zen, you think that thi

Re: Email Id Verification

2012-05-24 Thread Paul Rubin
Ben Finney writes: > The point is that, having collected the email address, it's useless > unless one actually uses it *as an email address*, by sending a message > to it. Before then, “validating” it tells you nothing. Right, the only legitimate use of an email address is sending legitimate emai

Re: Namespace hack

2012-05-24 Thread Chris Angelico
On Fri, May 25, 2012 at 1:02 PM, Temia Eszteri wrote: > But then we've got "Simple is better than complex", and "Complex is > better than complicated". Of course if we decided to start iterating > through the zen of Python's verses and continually modifying the > example code to fit, it would get