Re: Confused about np.polyfit()

2020-07-19 Thread duncan smith
On 19/07/2020 16:11, Dino wrote: > On 7/19/2020 4:54 PM, duncan smith wrote: >> >> It depends on what you expect the result to be. There's nothing >> inherently wrong with transforming variables before using least squares >> fitting. Whether it gives you the "best" estimates for the coefficients

Re: Confused about np.polyfit()

2020-07-19 Thread Richard Damon
On 7/19/20 10:54 AM, duncan smith wrote: > On 19/07/2020 11:19, Dino wrote: >> Hi, I am looking at someone else's code trying to understand their use >> of numpy.polyfit. >> >> My understanding was that you can use it to fit polynomials, but >> apparently, the original author has used it for

Re: Confused about np.polyfit()

2020-07-19 Thread duncan smith
On 19/07/2020 11:19, Dino wrote: > > Hi, I am looking at someone else's code trying to understand their use > of numpy.polyfit. > > My understanding was that you can use it to fit polynomials, but > apparently, the original author has used it for logarithmic and > exponential curves as well this

Re: Confused on git commit tree about Lib/datetime.py

2018-08-01 Thread Thomas Jollans
On 01/08/18 12:49, Chris Angelico wrote: On Wed, Aug 1, 2018 at 8:40 PM, Thomas Jollans wrote: On 01/08/18 05:16, Jeffrey Zhang wrote: I found a interesting issue when checking the Lib/datetime.py implementation in python3 This patch is introduced by cf86e368ebd17e10f68306ebad314eea31daaa1e

Re: Confused on git commit tree about Lib/datetime.py

2018-08-01 Thread Chris Angelico
On Wed, Aug 1, 2018 at 8:40 PM, Thomas Jollans wrote: > On 01/08/18 05:16, Jeffrey Zhang wrote: >> >> I found a interesting issue when checking the Lib/datetime.py >> implementation in python3 >> >> This patch is introduced by cf86e368ebd17e10f68306ebad314eea31daaa1e [0]. >> But if you >> check

Re: Confused on git commit tree about Lib/datetime.py

2018-08-01 Thread Thomas Jollans
On 01/08/18 05:16, Jeffrey Zhang wrote: I found a interesting issue when checking the Lib/datetime.py implementation in python3 This patch is introduced by cf86e368ebd17e10f68306ebad314eea31daaa1e [0]. But if you check the github page[0], or using git tag --contains, you will find v2.7.x

Re: Confused with installing per-user in Windows

2016-11-09 Thread ddbug
@eryk sun: Thank you for useful reply. But note that I don't propose to touch the python interpeters (python*.exe), neither to change anything in how distutils work (about entry points). My proposal is only for the Windows-specific Py launcher. For those who runs python*.exe thru associations

Re: Confused with installing per-user in Windows

2016-11-07 Thread eryk sun
On Mon, Nov 7, 2016 at 1:11 AM, ddbug wrote: > > In Windows, the user-local directory for scripts is %APPDATA%\Python\Scripts. > It is not in > PATH by default and finding it is hard (because Microsoft made it hidden in > their infinite > wisdom). POSIX "~/.local" is

Re: Confused with installing per-user in Windows

2016-11-06 Thread Ivan Pozdeev via Python-list
On 07.11.2016 4:11, ddbug wrote: Dear experts, I need to install some scripts for current user (to skip sudo, UAC popups and whatever). So I make a sdist and use python -m pip install --user This should work for either Python 2 or 3. On Linux, pip installs the scripts into ~/.local/bin

Re: Confused with installing per-user in Windows

2016-11-06 Thread ddbug
So basically I want to modify py.exe to not only detect the Python version from a script file, but also help locating the script file. -- d -- https://mail.python.org/mailman/listinfo/python-list

Re: Confused by wxpython documentation

2016-02-08 Thread Ian Kelly
On Mon, Feb 8, 2016 at 8:36 AM, wrote: > I'm playing around with some existing code that uses wxpython. I've > been trying to understand a basic bit about the import statement and > so went to the beginning of the wxPython on line documents. > > Going from the top to the "Hello

Re: Confused by wxpython documentation

2016-02-08 Thread cl
Ian Kelly wrote: > On Mon, Feb 8, 2016 at 8:36 AM, wrote: > > I'm playing around with some existing code that uses wxpython. I've > > been trying to understand a basic bit about the import statement and > > so went to the beginning of the wxPython on line

Re: Confused with Functions and decorators

2014-07-21 Thread CHIN Dihedral
On Saturday, July 19, 2014 8:44:25 PM UTC+8, Wojciech Giel wrote: On 19/07/14 12:40, Jerry lu wrote: oh yeah i forgot about the decorators. Um say that you wanted to decorate a function with the outer() func you would just put @outer on top of it? And this is the same as passing another

Re: Confused with Functions and decorators

2014-07-21 Thread Steven D'Aprano
On Mon, 21 Jul 2014 00:30:00 -0700, CHIN Dihedral wrote: Uhn, a local object inside a function can be passed back in Python. Of course, a local function is treated as an object in Python,and the GC is built-in. Sigh, the Dihedral bot is not what it used to be... -- Steven --

Re: Confused with Functions and decorators

2014-07-20 Thread Steven D'Aprano
On Sat, 19 Jul 2014 03:52:18 -0700, Jerry lu wrote: Ok so i am trying to learn this and i do not understand some of it. I also tried to searched the web but i couldnt find any answers. 1. I dont understand when i will need to use a function that returns another function. eg

Re: Confused with Functions and decorators

2014-07-19 Thread Chris Angelico
On Sat, Jul 19, 2014 at 8:52 PM, Jerry lu nicholascann...@gmail.com wrote: Ok so i am trying to learn this and i do not understand some of it. I also tried to searched the web but i couldnt find any answers. 1. I dont understand when i will need to use a function that returns another

Re: Confused with Functions and decorators

2014-07-19 Thread Jerry lu
oh yeah i forgot about the decorators. Um say that you wanted to decorate a function with the outer() func you would just put @outer on top of it? And this is the same as passing another func into the outer func? and also with the first example you say x is in the scope when is was created

Re: Confused with Functions and decorators

2014-07-19 Thread Chris Angelico
On Sat, Jul 19, 2014 at 9:40 PM, Jerry lu nicholascann...@gmail.com wrote: oh yeah i forgot about the decorators. Um say that you wanted to decorate a function with the outer() func you would just put @outer on top of it? And this is the same as passing another func into the outer func? and

Re: Confused with Functions and decorators

2014-07-19 Thread Jerry lu
Ok thanks man I have never used forums and stuff before but it is great help thank you so much. -- https://mail.python.org/mailman/listinfo/python-list

Re: Confused with Functions and decorators

2014-07-19 Thread Wojciech Giel
On 19/07/14 11:52, Jerry lu wrote: Ok so i am trying to learn this and i do not understand some of it. I also tried to searched the web but i couldnt find any answers. 1. I dont understand when i will need to use a function that returns another function. eg def outer():

Re: Confused with Functions and decorators

2014-07-19 Thread Wojciech Giel
On 19/07/14 11:52, Jerry lu wrote: Ok so i am trying to learn this and i do not understand some of it. I also tried to searched the web but i couldnt find any answers. 1. I dont understand when i will need to use a function that returns another function. eg def outer():

Re: Confused with Functions and decorators

2014-07-19 Thread Wojciech Giel
On 19/07/14 12:40, Jerry lu wrote: oh yeah i forgot about the decorators. Um say that you wanted to decorate a function with the outer() func you would just put @outer on top of it? And this is the same as passing another func into the outer func? yes. syntax was added because with very long

Re: Confused with Functions and decorators

2014-07-19 Thread Jerry lu
ok I seem to very confused about this. Is there like a page or web page that like completely sums this up so i can study. I am going to look up 'functions in python'. I am not sure if this is what we a talking about as a whole here but I'am sure that I'll find something. I am all good with

Re: Confused with Functions and decorators

2014-07-19 Thread Chris Angelico
On Sun, Jul 20, 2014 at 12:24 PM, Jerry lu nicholascann...@gmail.com wrote: ok I seem to very confused about this. Is there like a page or web page that like completely sums this up so i can study. I am going to look up 'functions in python'. Yep, look up stuff like that. I gave you some

Re: Confused with Functions and decorators

2014-07-19 Thread Jerry lu
Ok thanks so much i really want to get good. I also found this MIT open course lectures for python. Is this good to use as a source of learning? I think it would because it is MIT. -- https://mail.python.org/mailman/listinfo/python-list

Re: confused about the different built-in functions in Python

2014-05-26 Thread Deb Wyatt
snip On 5/25/14 7:55 PM, Deb Wyatt wrote: I am confused about how various built-in functions are called. Some are called with dot notation snip How do you know/remember which way to call them? TIA, Deb in WA, USA It can be confusing. Generally, built-in functions (like sum, len,

Re: confused about the different built-in functions in Python

2014-05-26 Thread Terry Reedy
On 5/26/2014 11:15 AM, Deb Wyatt wrote: snip On 5/25/14 7:55 PM, Deb Wyatt wrote: I am confused about how various built-in functions are called. Some are called with dot notation snip How do you know/remember which way to call them? It can be confusing. Generally, built-in functions

Re: confused about the different built-in functions in Python

2014-05-26 Thread Marko Rauhamaa
Terry Reedy tjre...@udel.edu: Part of the answer is Python's history. Up to about 2.1, most built-in types did not have methods, though I know lists did. Ints and strings did not, or chr and ord might have been int.chr() and str.ord(). (The current string methods were originally functions in

Re: confused about the different built-in functions in Python

2014-05-26 Thread Christian Heimes
On 26.05.2014 21:00, Marko Rauhamaa wrote: Terry Reedy tjre...@udel.edu: Part of the answer is Python's history. Up to about 2.1, most built-in types did not have methods, though I know lists did. Ints and strings did not, or chr and ord might have been int.chr() and str.ord(). (The current

Re: confused about the different built-in functions in Python

2014-05-26 Thread Marko Rauhamaa
Christian Heimes christ...@python.org: Python creates a new bound method object every time. A bound method object is a callable object that keeps a strong reference to the function, class and object. The bound method object adds the object as first argument to the function (aka 'self'). I

Re: confused about the different built-in functions in Python

2014-05-26 Thread Marko Rauhamaa
Marko Rauhamaa ma...@pacujo.net: Christian Heimes christ...@python.org: Python creates a new bound method object every time. A bound method object is a callable object that keeps a strong reference to the function, class and object. The bound method object adds the object as first argument

Re: confused about the different built-in functions in Python

2014-05-26 Thread Gregory Ewing
Marko Rauhamaa wrote: IOW, you can override a method with setattr() but you cannot delete a method with delattr(). Actually, you can -- but you need to delete it from the class, not the instance: delattr(X, 'f') x.f() Traceback (most recent call last): File stdin, line 1, in module

Re: confused about the different built-in functions in Python

2014-05-26 Thread Steven D'Aprano
On Mon, 26 May 2014 23:58:37 +0300, Marko Rauhamaa wrote: Marko Rauhamaa ma...@pacujo.net: Christian Heimes christ...@python.org: Python creates a new bound method object every time. A bound method object is a callable object that keeps a strong reference to the function, class and

Re: confused about the different built-in functions in Python

2014-05-26 Thread Terry Reedy
On 5/26/2014 4:32 PM, Marko Rauhamaa wrote: I stand corrected. I had thought the trampoline (bound method object) was created once and for all. Assuming that bound methods are immutable, this is an implementation detail, either way. However, it is common for a specific method to be called

Re: confused about the different built-in functions in Python

2014-05-25 Thread Ned Batchelder
On 5/25/14 7:55 PM, Deb Wyatt wrote: I am confused about how various built-in functions are called. Some are called with dot notation each_item.isalpha() and some are called like 'normal' sum(numlist) How do you know/remember which way to call them? TIA, Deb in WA, USA It can be

Re: confused about the different built-in functions in Python

2014-05-25 Thread Cameron Simpson
On 25May2014 15:55, Deb Wyatt codemon...@inbox.com wrote: I am confused about how various built-in functions are called. Some are called with dot notation each_item.isalpha() and some are called like 'normal' sum(numlist) How do you know/remember which way to call them? Documentation.

Re: Confused about timezones

2013-10-23 Thread Skip Montanaro
LOCAL_TZ.localize(dt1).utcoffset() datetime.timedelta(-1, 68400) LOCAL_TZ.localize(dt2).utcoffset() datetime.timedelta(-1, 64800) Why is the UTC offset the same for both datetime objects despite the presence/absence of Daylight Savings? Brain freeze! A quick glance told me they were the

Re: Confused about timezones

2013-10-23 Thread Ethan Furman
On 10/23/2013 12:00 PM, Skip Montanaro wrote: -- LOCAL_TZ.localize(dt1).utcoffset() datetime.timedelta(-1, 68400) -- LOCAL_TZ.localize(dt2).utcoffset() datetime.timedelta(-1, 64800) Why is the UTC offset the same for both datetime objects despite the presence/absence of Daylight Savings?

Re: Confused about logger config from within Python (3)

2012-12-29 Thread Roy Smith
In article 50de7a0a$0$29967$c3e8da3$54964...@news.astraweb.com, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: In Python 3.2 and 3.3, the message about no handlers is not printed, which is an interesting difference. (Somebody who knows more about the logging package than I do

Re: Confused about logger config from within Python (3)

2012-12-29 Thread Terry Reedy
On 12/29/2012 8:48 AM, Roy Smith wrote: In article 50de7a0a$0$29967$c3e8da3$54964...@news.astraweb.com, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: In Python 3.2 and 3.3, the message about no handlers is not printed, which is an interesting difference. (Somebody who knows

Re: Confused about logger config from within Python (3)

2012-12-29 Thread Roy Smith
In article mailman.1455.1356826759.29569.python-l...@python.org, Terry Reedy tjre...@udel.edu wrote: On 12/29/2012 8:48 AM, Roy Smith wrote: In article 50de7a0a$0$29967$c3e8da3$54964...@news.astraweb.com, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: In Python 3.2 and

Re: Confused about logger config from within Python (3)

2012-12-28 Thread andrew cooke
similarly, if i run the following, i see only done: from logging import DEBUG, root, getLogger if __name__ == '__main__': root.setLevel(DEBUG) getLogger(__name__).debug(hello world) print('done') -- http://mail.python.org/mailman/listinfo/python-list

Re: Confused about logger config from within Python (3)

2012-12-28 Thread Peter Otten
andrew cooke wrote: similarly, if i run the following, i see only done: from logging import DEBUG, root, getLogger if __name__ == '__main__': root.setLevel(DEBUG) getLogger(__name__).debug(hello world) print('done') You need a handler. The easiest way to get one

Re: Confused about logger config from within Python (3)

2012-12-28 Thread andrew cooke
On Friday, 28 December 2012 21:56:46 UTC-3, Peter Otten wrote: Other revolutionary ideas: read the docs http://docs.python.org/dev/howto/logging.html#logging-basic-tutorial ;) how do you think i knew about the root handler without reading the damn docs you condescending asshole? anyway,

Re: Confused about logger config from within Python (3)

2012-12-28 Thread Dave Angel
On 12/28/2012 09:29 PM, andrew cooke wrote: On Friday, 28 December 2012 21:56:46 UTC-3, Peter Otten wrote: snip reading the damn docs you condescending *? You've made four posts this year to this forum, in two threads, to ask for help. In that same year, Peter Otten has voluntarily

Re: Confused about logger config from within Python (3)

2012-12-28 Thread Steven D'Aprano
On Fri, 28 Dec 2012 11:57:29 -0800, andrew cooke wrote: When I use a config file things seem to work (in other projects), but for my current code I hoped to configure logging from Python. I distilled my problem down to the following test, which does not print anything. Please can someone

Re: Confused about logger config from within Python (3)

2012-12-28 Thread Steven D'Aprano
On Fri, 28 Dec 2012 16:41:20 -0800, andrew cooke wrote: similarly, if i run the following, i see only done: from logging import DEBUG, root, getLogger if __name__ == '__main__': root.setLevel(DEBUG) getLogger(__name__).debug(hello world) print('done') In Python

Re: Confused compare function :)

2012-12-08 Thread MRAB
On 2012-12-08 07:17, Chris Angelico wrote: On Sat, Dec 8, 2012 at 6:01 PM, Terry Reedy tjre...@udel.edu wrote: Unfortunately, catching exceptions may be and often is as slow as the redundant check and even multiple redundant checks. It depends on how often you're going to catch and how often

Re: Confused compare function :)

2012-12-08 Thread Ramchandra Apte
On Thursday, 6 December 2012 17:44:17 UTC+5:30, Chris Angelico wrote: On Thu, Dec 6, 2012 at 10:47 PM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: Not so. Which one is faster will depend on how often you expect to fail. If the keys are nearly always present, then:

Re: Confused compare function :)

2012-12-08 Thread Chris Angelico
On Sun, Dec 9, 2012 at 2:07 PM, Ramchandra Apte maniandra...@gmail.com wrote: Not really. I remember a bug saying that only 256 hashes were required of known texts and then the randomization becomes useless. That requires that someone be able to get you to hash some text and give back the

Re: Confused compare function :)

2012-12-08 Thread Steven D'Aprano
On Sun, 09 Dec 2012 14:22:21 +1100, Chris Angelico wrote: On Sun, Dec 9, 2012 at 2:07 PM, Ramchandra Apte maniandra...@gmail.com wrote: Not really. I remember a bug saying that only 256 hashes were required of known texts and then the randomization becomes useless. That requires that

Re: Confused compare function :)

2012-12-07 Thread Anatoli Hristov
Calling it 'found' is misleading, because it's True only if it updated. If it found a match but didn't update, 'found' will still be False. Using a loop within a loop like this could be the cause of your problem. It's certainly not the most efficient way of doing it. I will keep you posted

Re: Confused compare function :)

2012-12-07 Thread Neil Cerutti
On 2012-12-07, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: On Thu, 06 Dec 2012 13:51:29 +, Neil Cerutti wrote: On 2012-12-06, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: total = 0 for s in list_of_strings: try: total += int(s) except

Re: Confused compare function :)

2012-12-07 Thread Steven D'Aprano
On Thu, 06 Dec 2012 23:14:17 +1100, Chris Angelico wrote: Setting up the try/except is a constant time cost, It's not just constant time, it's constant time and *cheap*. Doing nothing inside a try block takes about twice as long as doing nothing: [steve@ando ~]$ python2.7 -m timeit try: pass

Re: Confused compare function :)

2012-12-07 Thread Terry Reedy
On 12/7/2012 5:16 PM, Steven D'Aprano wrote: On Thu, 06 Dec 2012 23:14:17 +1100, Chris Angelico wrote: Setting up the try/except is a constant time cost, It's not just constant time, it's constant time and *cheap*. Doing nothing inside a try block takes about twice as long as doing nothing:

Re: Confused compare function :)

2012-12-07 Thread Chris Angelico
On Sat, Dec 8, 2012 at 6:01 PM, Terry Reedy tjre...@udel.edu wrote: Unfortunately, catching exceptions may be and often is as slow as the redundant check and even multiple redundant checks. It depends on how often you're going to catch and how often just flow through. In Python, as in most

Re: Confused compare function :)

2012-12-06 Thread Bruno Dupuis
On Thu, Dec 06, 2012 at 04:32:34AM +, Steven D'Aprano wrote: On Thu, 06 Dec 2012 03:22:53 +, Rotwang wrote: On 06/12/2012 00:19, Bruno Dupuis wrote: [...] Another advice: never ever except XXXError: pass at least log, or count, or warn, or anything, but don't

Re: Confused compare function :)

2012-12-06 Thread Chris Angelico
On Thu, Dec 6, 2012 at 7:49 PM, Bruno Dupuis python.ml.bruno.dup...@lisael.org wrote: The point is Exceptions are made for error handling, not for normal workflow. I hate when i read that for example: try: do_stuff(mydict[k]) except KeyError: pass (loads of them

Re: Confused compare function :)

2012-12-06 Thread Anatoli Hristov
On Thu, Dec 6, 2012 at 1:31 AM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: On Wed, 05 Dec 2012 23:50:49 +0100, Anatoli Hristov wrote: def Change_price(): Misleading function name. What price does it change? total = 0 tnf = 0 tnf? Does that mean something?

Re: Confused compare function :)

2012-12-06 Thread Steven D'Aprano
On Thu, 06 Dec 2012 09:49:26 +0100, Bruno Dupuis wrote: The point is Exceptions are made for error handling, not for normal workflow. That's certainly not the case in Python. Using exceptions for flow control is a standard part of the language. IndexError and StopIteration are used to

Re: Confused compare function :)

2012-12-06 Thread peter
On 12/06/2012 08:47 AM, Steven D'Aprano wrote: On Thu, 06 Dec 2012 09:49:26 +0100, Bruno Dupuis wrote: The point is Exceptions are made for error handling, not for normal workflow. That's certainly not the case in Python. Using exceptions for flow control is a standard part of the language.

Re: Confused compare function :)

2012-12-06 Thread Chris Angelico
On Thu, Dec 6, 2012 at 10:47 PM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: Not so. Which one is faster will depend on how often you expect to fail. If the keys are nearly always present, then: try: do_stuff(mydict[k]) except KeyError: pass will be faster. Setting

Re: Confused compare function :)

2012-12-06 Thread Hans Mulder
On 6/12/12 12:55:16, peter wrote: Is perfectly right to use try catch for a flow control. Just think in something more complex like this. try: self._conn = MySQLdb.connect(host=host, user=user, passwd=passwd, db=db)

Re: Confused compare function :)

2012-12-06 Thread Thomas Rachel
Am 06.12.2012 09:49 schrieb Bruno Dupuis: The point is Exceptions are made for error handling, not for normal workflow. I hate when i read that for example: try: do_stuff(mydict[k]) except KeyError: pass I as well, but for other reasons (see below). But basically

Re: Confused compare function :)

2012-12-06 Thread Chris Angelico
On Fri, Dec 7, 2012 at 12:32 AM, Hans Mulder han...@xs4all.nl wrote: On 6/12/12 12:55:16, peter wrote: Is perfectly right to use try catch for a flow control. Just think in something more complex like this. try: self._conn = MySQLdb.connect(host=host,

Re: Confused compare function :)

2012-12-06 Thread Neil Cerutti
On 2012-12-06, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: total = 0 for s in list_of_strings: try: total += int(s) except ValueError: pass # Not a number, ignore it. If it's internal data, perhaps. Of course, that would mean I had the option of

Re: Confused compare function :)

2012-12-06 Thread Chris Angelico
On Fri, Dec 7, 2012 at 12:33 AM, Thomas Rachel nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa...@spamschutz.glglgl.de wrote: Am 06.12.2012 09:49 schrieb Bruno Dupuis: The point is Exceptions are made for error handling, not for normal workflow. I hate when i read that for example: try:

Re: Confused compare function :)

2012-12-06 Thread Anatoli Hristov
Guys I'm still confusing my script is working better, but not enough. I did a logfile to see which products are not found anymore in the CSV and I found some that are present but python says they are not ?? Here is the product in the CSV: MONIIE2407HDS-B1;MON;II;E2407HDS-B1;E2407HDS-B1;IIYAMA LCD

Re: Confused compare function :)

2012-12-06 Thread Hans Mulder
On 6/12/12 14:58:01, Chris Angelico wrote: On Fri, Dec 7, 2012 at 12:33 AM, Thomas Rachel nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa...@spamschutz.glglgl.de wrote: Am 06.12.2012 09:49 schrieb Bruno Dupuis: The point is Exceptions are made for error handling, not for normal workflow. I

Re: Confused compare function :)

2012-12-06 Thread Chris Angelico
On Fri, Dec 7, 2012 at 1:21 AM, Hans Mulder han...@xs4all.nl wrote: Errhm, no. Look again. The do_stuff(value) call is in the else: clause, so it will only be done of there was no Exception of any kind, and in that case the assignment to value must have succeeded. DOH! My bad. Sorry! I

Re: Confused compare function :)

2012-12-06 Thread Dave Angel
On 12/06/2012 08:58 AM, Chris Angelico wrote: On Fri, Dec 7, 2012 at 12:33 AM, Thomas Rachel nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa...@spamschutz.glglgl.de wrote: Am 06.12.2012 09:49 schrieb Bruno Dupuis: The point is Exceptions are made for error handling, not for normal workflow. I

Re: Confused compare function :)

2012-12-06 Thread peter
On 12/06/2012 10:58 AM, Chris Angelico wrote: On Fri, Dec 7, 2012 at 12:33 AM, Thomas Rachel nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa...@spamschutz.glglgl.de wrote: Am 06.12.2012 09:49 schrieb Bruno Dupuis: The point is Exceptions are made for error handling, not for normal workflow. I hate

Re: Confused compare function :)

2012-12-06 Thread Anatoli Hristov
On Thu, Dec 6, 2012 at 3:22 PM, Anatoli Hristov toli...@gmail.com wrote: Guys I'm still confusing my script is working better, but not enough. I did a logfile to see which products are not found anymore in the CSV and I found some that are present but python says they are not ?? Here is the

Re: Confused compare function :)

2012-12-06 Thread Mark Lawrence
On 06/12/2012 16:16, Anatoli Hristov wrote: No one have an idea ? Thanks Basically because your code is crap. Others have already suggested refactoring your code to make it easier to follow. Try (diabolical pun very deliberate) following that advice. Failing that find out how much

Re: Confused compare function :)

2012-12-06 Thread Anatoli Hristov
No one have an idea ? Thanks Basically because your code is crap. Others have already suggested refactoring your code to make it easier to follow. Thank you Mark for your notes. I changed the name of the variables as was suggested before. I know my code should be crappy, but at least I

Re: Confused compare function :)

2012-12-06 Thread MRAB
On 2012-12-06 14:22, Anatoli Hristov wrote: Guys I'm still confusing my script is working better, but not enough. I did a logfile to see which products are not found anymore in the CSV and I found some that are present but python says they are not ?? Here is the product in the CSV:

Re: Confused compare function :)

2012-12-06 Thread Anatoli Hristov
Here is the product in the CSV: MONIIE2407HDS-B1;MON;II;E2407HDS-B1;E2407HDS-B1;IIYAMA LCD 24 Wide 1920x1080TN Speakers 2ms Black DVI HDMI;133;20;RECTD0.41;0,41; This one is still not found and it is in the CSV file - I just don't get it why ! if len(db_sku) != 0

Re: Confused compare function :)

2012-12-06 Thread MRAB
On 2012-12-06 17:31, Anatoli Hristov wrote: Here is the product in the CSV: MONIIE2407HDS-B1;MON;II;E2407HDS-B1;E2407HDS-B1;IIYAMA LCD 24 Wide 1920x1080TN Speakers 2ms Black DVI HDMI;133;20;RECTD0.41;0,41; This one is still not found and it is in the CSV file - I just don't get it why

Re: Confused compare function :)

2012-12-06 Thread Anatoli Hristov
Here is the product in the CSV: MONIIE2407HDS-B1;MON;II;E2407HDS-B1;E2407HDS-B1;IIYAMA LCD 24 Wide 1920x1080TN Speakers 2ms Black DVI HDMI;133;20;RECTD0.41;0,41; [snip] It's not saying that it's not found, it's saying that it wasn't updated because: You are right, the price at the

Re: Confused compare function :)

2012-12-06 Thread Anatoli Hristov
gmane.comp.python.general: But basically, the code seems to run a pair of nested for-loops: for SKU in database: for SKU in csv file: if the two SKUs match: compare their prices and update the database OUCH... I'm presuming the CSV is restarted

Re: Confused compare function :)

2012-12-06 Thread Rotwang
On 06/12/2012 08:49, Bruno Dupuis wrote: On Thu, Dec 06, 2012 at 04:32:34AM +, Steven D'Aprano wrote: On Thu, 06 Dec 2012 03:22:53 +, Rotwang wrote: On 06/12/2012 00:19, Bruno Dupuis wrote: [...] Another advice: never ever except XXXError: pass at least log, or count, or

Re: Confused compare function :)

2012-12-06 Thread Rotwang
On 06/12/2012 04:32, Steven D'Aprano wrote: On Thu, 06 Dec 2012 03:22:53 +, Rotwang wrote: [...] Is there a problem with either of the above? If so, what should I do instead? They're fine. Never, ever say that people should never, ever do something. *cough* Thanks. -- I have made

Re: Confused compare function :)

2012-12-06 Thread Steven D'Aprano
On Thu, 06 Dec 2012 13:51:29 +, Neil Cerutti wrote: On 2012-12-06, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: total = 0 for s in list_of_strings: try: total += int(s) except ValueError: pass # Not a number, ignore it. If it's internal data,

Re: Confused compare function :)

2012-12-05 Thread Bruno Dupuis
On Wed, Dec 05, 2012 at 11:50:49PM +0100, Anatoli Hristov wrote: I'm confused again with a compare update function. The problem is that my function does not work at all and I don't get it where it comes from. in my DB I have total of 754 products. when I run the function is says: Total

Re: Confused compare function :)

2012-12-05 Thread Steven D'Aprano
On Wed, 05 Dec 2012 23:50:49 +0100, Anatoli Hristov wrote: def Change_price(): Misleading function name. What price does it change? total = 0 tnf = 0 tnf? Does that mean something? for row in DB: # DB is mySQL DB, logically I get out # 1 SKU and I

Re: Confused compare function :)

2012-12-05 Thread Steven D'Aprano
On Thu, 06 Dec 2012 01:19:58 +0100, Bruno Dupuis wrote: I tried, I swear I did try, I didn't understand the whole algorithm of the function. However, in a first sight, I find it way to deeply nested. Yes! But basically, the code seems to run a pair of nested for-loops: for SKU in database:

Re: Confused compare function :)

2012-12-05 Thread Rotwang
On 06/12/2012 00:19, Bruno Dupuis wrote: [...] Another advice: never ever except XXXError: pass at least log, or count, or warn, or anything, but don't pass. Really? I've used that kind of thing several times in my code. For example, there's a point where I have a list of strings and

Re: Confused compare function :)

2012-12-05 Thread Steven D'Aprano
On Thu, 06 Dec 2012 03:22:53 +, Rotwang wrote: On 06/12/2012 00:19, Bruno Dupuis wrote: [...] Another advice: never ever except XXXError: pass at least log, or count, or warn, or anything, but don't pass. Really? I've used that kind of thing several times in my code. For

Re: confused in decorate and closure

2012-09-13 Thread Peter Otten
月忧茗 wrote: HI, I have some test code: def num(num): def deco(func): def wrap(*args, **kwargs): inputed_num = num return func(*args, **kwargs) return wrap return deco @num(5) def test(a): return a + inputed_num print

Re: confused about __new__

2011-12-27 Thread K Richard Pixley
On 12/26/11 21:48 , Fredrik Tolf wrote: On Mon, 26 Dec 2011, K. Richard Pixley wrote: I don't understand. Can anyone explain? I'm also a bit confused about __new__. I'd very much appreciate it if someone could explain the following aspects of it: * The manual

Re: confused about __new__

2011-12-27 Thread Fredrik Tolf
On Tue, 27 Dec 2011, Ian Kelly wrote: On Mon, Dec 26, 2011 at 10:48 PM, Fredrik Tolf fred...@dolda2000.com wrote: I'm also a bit confused about __new__. I'd very much appreciate it if someone could explain the following aspects of it:  * The manual

Re: confused about __new__

2011-12-27 Thread Ian Kelly
On Tue, Dec 27, 2011 at 10:41 AM, K Richard Pixley r...@noir.com wrote: The conceptual leap for me was in recognizing that a class is just an object.  The best way, (imo, so far), to create a singleton in python is to use the class itself as the singleton rather than ever instantiating it.  

Re: confused about __new__

2011-12-27 Thread Ian Kelly
On Tue, Dec 27, 2011 at 1:31 PM, K Richard Pixley r...@noir.com wrote: On 12/27/11 10:28 , Ian Kelly wrote: On Tue, Dec 27, 2011 at 10:41 AM, K Richard Pixleyr...@noir.com  wrote: The conceptual leap for me was in recognizing that a class is just an object.  The best way, (imo, so far), to

Re: confused about __new__

2011-12-27 Thread K Richard Pixley
On 12/27/11 10:28 , Ian Kelly wrote: On Tue, Dec 27, 2011 at 10:41 AM, K Richard Pixleyr...@noir.com wrote: The conceptual leap for me was in recognizing that a class is just an object. The best way, (imo, so far), to create a singleton in python is to use the class itself as the singleton

Re: confused about __new__

2011-12-27 Thread K Richard Pixley
On 12/27/11 12:34 , Ian Kelly wrote: On Tue, Dec 27, 2011 at 1:31 PM, K Richard Pixleyr...@noir.com wrote: On 12/27/11 10:28 , Ian Kelly wrote: On Tue, Dec 27, 2011 at 10:41 AM, K Richard Pixleyr...@noir.comwrote: The conceptual leap for me was in recognizing that a class is just an

Re: confused about __new__

2011-12-27 Thread Ian Kelly
On Tue, Dec 27, 2011 at 3:19 PM, K Richard Pixley r...@noir.com wrote: Are you trying to demonstrate that I haven't prevented you from instantiating Foo?  If so, then I will cede that point.  I certainly don't know enough about python internals just now to even claim to be capable of

Re: confused about __new__

2011-12-26 Thread Steven D'Aprano
On Mon, 26 Dec 2011 20:28:26 -0800, K. Richard Pixley wrote: I'm confused about the following. The idea here is that the set of instances of some class are small and finite, so I'd like to create them at class creation time, then hijack __new__ to simply return one of the preexisting classes

Re: confused about __new__

2011-12-26 Thread K Richard Pixley
On 12/26/11 20:53 , Steven D'Aprano wrote: On Mon, 26 Dec 2011 20:28:26 -0800, K. Richard Pixley wrote: I'm confused about the following. The idea here is that the set of instances of some class are small and finite, so I'd like to create them at class creation time, then hijack __new__ to

Re: confused about __new__

2011-12-26 Thread Fredrik Tolf
On Mon, 26 Dec 2011, K. Richard Pixley wrote: I don't understand. Can anyone explain? I'm also a bit confused about __new__. I'd very much appreciate it if someone could explain the following aspects of it: * The manual (http://docs.python.org/reference/datamodel.html) says that

Re: confused about __new__

2011-12-26 Thread Ian Kelly
On Mon, Dec 26, 2011 at 10:48 PM, Fredrik Tolf fred...@dolda2000.com wrote: I'm also a bit confused about __new__. I'd very much appreciate it if someone could explain the following aspects of it:  * The manual (http://docs.python.org/reference/datamodel.html) says   that __new__ is a static

  1   2   3   4   >