Re: Python Newbie

2013-02-23 Thread Michael Torrie
On 02/23/2013 04:46 PM, piterrr.dolin...@gmail.com wrote: > Yes, it's true that I am trying to write C# code in Python. It is not > going to change any time soon, if at all - I have done too much > C#ing, C++ing before that and C-ing earlier still. Unfortunately as long as do, you'll find Python

Re: encoding error in python 27

2013-02-23 Thread Hala Gamal
thank you :)it worked well for small file but when i enter big file,, i obtain this error: "Traceback (most recent call last): File "D:\Python27\yarab (4).py", line 46, in writer.add_document(**doc) File "build\bdist.win32\egg\whoosh\filedb\filewriting.py", line 369, in add_document

Re: Python Newbie

2013-02-23 Thread Larry Hudson
On 02/23/2013 03:46 PM, piterrr.dolin...@gmail.com wrote: Hi all, ... I have discovered today there is no do...while type loop. [Sigh] No biggie. This is easily simulated with: while True: ... if : break Less easily simulated is the lack of a switch/case structure. This

Re: Basic Listview Example

2013-02-23 Thread Michael Torrie
On 02/23/2013 07:18 PM, Xx7 wrote: > Thanks all! > > I believe C# appears to be a better language for this type of GUI > creation. Better Listview Express has a tonne of options. It's a common misconception that a language has anything to do with a GUI. I know of at least 3 different GUI framew

Re: AttributeError: ' ' object has no attribute ' '

2013-02-23 Thread matt . doolittle33
yeah im not a programmer, i have not wrote anything here that i am trying to use; i am an end user. my only interest in this code is to get the program working. so i have to do what i have to do try to get it working. im just hoping that what im going through here, this error thats coming up

Re: Should Docstrings include RFC citations? - And are non PEP257 syntaxes frowned upon?

2013-02-23 Thread Terry Reedy
On 2/23/2013 1:14 PM, Alec Taylor wrote: PEP257 defines docstring syntax, It suggest a docstring format, which is not religiously followed even in the stdlib. It explicitly disclaims being 'the law'. Do what works for you. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/pytho

Re: Basic Listview Example

2013-02-23 Thread Chris Angelico
On Sun, Feb 24, 2013 at 1:18 PM, Xx7 wrote: > Thanks all! > > I believe C# appears to be a better language for this type of GUI creation. > Better Listview Express has a tonne of options. No probs, glad that's settled. I hope that when you ask the C# people for help, you provide enough informat

Re: Basic Listview Example

2013-02-23 Thread Xx7
Thanks all! I believe C# appears to be a better language for this type of GUI creation. Better Listview Express has a tonne of options. -- http://mail.python.org/mailman/listinfo/python-list

RE: AttributeError: ' ' object has no attribute ' '

2013-02-23 Thread Graham Fielding
> Date: Sat, 23 Feb 2013 10:22:54 -0800 > Subject: AttributeError: ' ' object has no attribute ' ' > From: matt.doolittl...@gmail.com > To: python-list@python.org > > I am using Ubuntu 12.10, and Python 2.7.3, GNU Radio Companion v3.6.3. I get > the this error in terminal: > > in __init_

Re: Python Newbie

2013-02-23 Thread MRAB
On 2013-02-23 23:18, Chris Angelico wrote: On Sun, Feb 24, 2013 at 9:52 AM, Michael Torrie wrote: On 02/23/2013 02:38 PM, Chris Angelico wrote: On Sun, Feb 24, 2013 at 5:29 AM, Dennis Lee Bieber wrote: Error codes under DEC VAX/VMS used odd integers for "success/information" and even

Re: Python Newbie

2013-02-23 Thread Mark Lawrence
On 23/02/2013 21:48, Chris Angelico wrote: On Sun, Feb 24, 2013 at 7:53 AM, jmfauth wrote: On 23 fév, 20:08, Ethan Furman wrote: On 02/23/2013 10:44 AM, jmfauth wrote: [snip various stupidities] jmf Peter, jmfauth is one of our resident trolls. Feel free to ignore him. -- ~Ethan~ Sor

Re: Python Newbie

2013-02-23 Thread piterrr . dolinski
Hi all, (Ethan, I like your "resident troll" statement. Highly exit-aining!) Thanks for all the input. I did not expect to get so much constructive feedback, the more so that my initial attitude towards Python has been less than positive, diplomatically speaking. Yes, it's true that I am tryin

Re: Python Newbie

2013-02-23 Thread Chris Angelico
On Sun, Feb 24, 2013 at 9:52 AM, Michael Torrie wrote: > On 02/23/2013 02:38 PM, Chris Angelico wrote: >> On Sun, Feb 24, 2013 at 5:29 AM, Dennis Lee Bieber >> wrote: >>> Error codes under DEC VAX/VMS used odd integers for >>> "success/information" and even integers for "warning/error" (b

Re: Python Newbie

2013-02-23 Thread Michael Torrie
On 02/21/2013 03:40 PM, piterrr.dolin...@gmail.com wrote: > Chris, you are (almost) spot on with the if blocks indentation. This > is what I do, and it has served me well for 15 years. Most companies, development teams have unified coding style standards that all programmers must adhere to in the

tkinter / gui

2013-02-23 Thread Rex Macey
Here is one general and one specific question about creating GUIs using tkinter from a newbie. I have created a class in which to hold some data. I want to create a GUI to get the data from the user and store it in the object. Browsing the web I see that a lot of examples on GUIs have the for

Re: Python Newbie

2013-02-23 Thread Michael Torrie
On 02/23/2013 02:38 PM, Chris Angelico wrote: > On Sun, Feb 24, 2013 at 5:29 AM, Dennis Lee Bieber > wrote: >> Error codes under DEC VAX/VMS used odd integers for >> "success/information" and even integers for "warning/error" (been too >> many years, I think positive integers were success/

Re: Python Newbie

2013-02-23 Thread Gene Heskett
On Saturday 23 February 2013 17:44:21 Steve Simmons did opine: > On 23/02/2013 18:32, Gene Heskett wrote: > > I am here because I was hoping some knowledge leakage would help me to > > understand python, but at my age I am beginning to have to admit the > > level of abstraction is something I may

Re: Python-list Digest, Vol 113, Issue 192

2013-02-23 Thread Morten Engvoldsen
Hi, Okey i will change the function name :) Do you have any suggestion to generate the weight at run time rather than hard coding it... > > -- Forwarded message -- > From: Dennis Lee Bieber > To: python-list@python.org > Cc: > Date: Sat, 23 Feb 2013 14:03:23 -0500 > Subject: Re: N

Re: AttributeError: ' ' object has no attribute ' '

2013-02-23 Thread Chris Angelico
On Sun, Feb 24, 2013 at 5:22 AM, wrote: > I am using Ubuntu 12.10, and Python 2.7.3, GNU Radio Companion v3.6.3. I get > the this error in terminal: > > in __init__ > self.wxgui_waterfallsink2_0.set_callback(wxgui_waterfallsink2_0_callback) > File "/usr/local/lib/python2.7/dist-packages/

Re: Python Newbie

2013-02-23 Thread Chris Angelico
On Sun, Feb 24, 2013 at 7:53 AM, jmfauth wrote: > On 23 fév, 20:08, Ethan Furman wrote: >> On 02/23/2013 10:44 AM, jmfauth wrote: >> >> [snip various stupidities] >> >> > jmf >> >> Peter, jmfauth is one of our resident trolls. Feel free to ignore him. >> >> -- >> ~Ethan~ > > Sorry, what can say?

Re: Python Newbie

2013-02-23 Thread Chris Angelico
On Sun, Feb 24, 2013 at 5:34 AM, Dennis Lee Bieber wrote: > On Sat, 23 Feb 2013 13:18:56 +1100, Chris Angelico > declaimed the following in gmane.comp.python.general: > >> awesome Fred's Awesome Internet Language is, it's not going to be as > > Pardon, but was that deliberate -> FAIL :)

Re: Python Newbie

2013-02-23 Thread Chris Angelico
On Sun, Feb 24, 2013 at 5:29 AM, Dennis Lee Bieber wrote: > Error codes under DEC VAX/VMS used odd integers for > "success/information" and even integers for "warning/error" (been too > many years, I think positive integers were success/warning, negative > integers were information/error;

Re: Python Newbie

2013-02-23 Thread jmfauth
On 23 fév, 20:08, Ethan Furman wrote: > On 02/23/2013 10:44 AM, jmfauth wrote: > > [snip various stupidities] > > > jmf > > Peter, jmfauth is one of our resident trolls.  Feel free to ignore him. > > -- > ~Ethan~ Sorry, what can say? More memory and slow down! If you see a progress, I'm seeing a

Re: Correct handling of case in unicode and regexps

2013-02-23 Thread MRAB
On 2013-02-23 18:57, Devin Jeanpierre wrote: On Sat, Feb 23, 2013 at 1:12 PM, MRAB wrote: The basic rule is that a series of characters in the regex must match a series of characters in the text, with no partial matches in either. For example, 'ss' can match 'ß', but 's' can't match 'ß' becaus

Re: What happened to 2.7.4 and 3.2.4 ??

2013-02-23 Thread Ned Deily
In article <9d5b3646-2952-49a1-b8ad-3b44d37ea...@googlegroups.com>, Perica Zivkovic wrote: > Any ideas on timelines? I was waiting on this to push out another Portable > Python release. I suggest asking on the python-dev list. There have been no announced new release dates as yet. -- Ned D

Re: Python Newbie

2013-02-23 Thread Michael Torrie
On 02/22/2013 02:37 PM, piterrr.dolin...@gmail.com wrote: > Thanks to everyone for all the posts, some friendly some not. I read > all of them with genuine interest. I just finished reading this entire thread and I don't see any posts that are unfriendly. Perhaps some of them are calling you on y

Re: Python Newbie

2013-02-23 Thread Ethan Furman
On 02/23/2013 10:44 AM, jmfauth wrote: [snip various stupidities] jmf Peter, jmfauth is one of our resident trolls. Feel free to ignore him. -- ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list

Re: Python Newbie

2013-02-23 Thread Michael Torrie
On 02/23/2013 11:10 AM, Steve Simmons wrote: > I'm using Rapid GUI Programming with Python & Qt (Mark Summerfield ISBN > 978-0-13-235418-9) - it fits for me because I needed something that > covered GUI development but also had an intro to the language. Sounds fun. One thing about PyQt is tha

Re: Python Newbie

2013-02-23 Thread Michael Torrie
On 02/23/2013 11:44 AM, jmfauth wrote: > Very easy to explain: wrong, incorrect, naive unicode > handling. You should get together with ranging rick so that his python fork can have unicode done properly then. -- http://mail.python.org/mailman/listinfo/python-list

Re: Python Newbie

2013-02-23 Thread Ian Kelly
On Sat, Feb 23, 2013 at 11:44 AM, jmfauth wrote: > Until you realize this: > > Py32: > timeit.timeit("'abc需'") > 0.032749386495456466 sys.getsizeof('abc需') > 42 > > Py33: > timeit.timeit("'abc需'") > 0.04104208536801017 sys.getsizeof('abc需') > 50 > > Very easy to explain

Re: Good cross-version ASCII serialisation protocol for simple types

2013-02-23 Thread Paul Moore
On Saturday, 23 February 2013 16:06:11 UTC, Jussi Piitulainen wrote: > I don't know much of these things but I've been using Python's > json.dump and json.load for a couple of weeks now and they seem to use > ASCII-friendly escapes automatically, writing a four-character string > as "\u00e4\u00e4n

Re: Python Newbie

2013-02-23 Thread Michael Torrie
On 02/21/2013 04:34 PM, piterrr.dolin...@gmail.com wrote: > Thanks for this. Regarding ambiguity, you will never find me write > ambiguous code. I don't sabotage my own work. But the reality is > that in addition to writing my own code, I have to maintain existing. > I find it incredibly confusing

Re: Correct handling of case in unicode and regexps

2013-02-23 Thread Devin Jeanpierre
On Sat, Feb 23, 2013 at 1:12 PM, MRAB wrote: > The basic rule is that a series of characters in the regex must match a > series of characters in the text, with no partial matches in either. > > For example, 'ss' can match 'ß', but 's' can't match 'ß' because that > would be matching part of 'ß'. >

Re: Python Newbie

2013-02-23 Thread jmfauth
On 23 fév, 16:43, Steve Simmons wrote: > On 22/02/2013 22:37, piterrr.dolin...@gmail.com wrote:> So far I am getting > the impression ... > > My main message to you would be :  don't approach Python with a negative > attitude, give it a chance and I'm sure you'll come to enjoy it. > Until

Re: Escaping list of numbers for Postgres column names

2013-02-23 Thread andydtaylor
In reply to my own question, postgres column names must begin with a letter or an underscore. So this is what I have done: >>> for row in cursor_from: ... if row[8]: ... stn_list_short.append("_" + row[0]) I can now use stn_list_short to create my columns -- http://mail.python.org/m

Re: Python Newbie

2013-02-23 Thread Michael Torrie
On 02/21/2013 02:26 PM, Piterrr wrote: > Hi folks. I am a long time C sharp dev, just learning Python now due > to job requirements. My initial impression is that Python has got to > be the most ambiguous and vague language I have seen to date. I have > major issues with the fact that white space m

AttributeError: ' ' object has no attribute ' '

2013-02-23 Thread matt . doolittle33
I am using Ubuntu 12.10, and Python 2.7.3, GNU Radio Companion v3.6.3. I get the this error in terminal: in __init__ self.wxgui_waterfallsink2_0.set_callback(wxgui_waterfallsink2_0_callback) File "/usr/local/lib/python2.7/dist-packages/gnuradio/gr/hier_block2.py", line 54, in __getattr_

Re: Correct handling of case in unicode and regexps

2013-02-23 Thread MRAB
On 2013-02-23 17:51, Devin Jeanpierre wrote: On Sat, Feb 23, 2013 at 12:41 PM, MRAB wrote: Getting full case folding to work can be tricky. There's always going to be a limit to what's worth doing. There are also areas where it's not clear what the result should be. You've already mentioned ma

Re: Python Newbie

2013-02-23 Thread Steve Simmons
On 23/02/2013 18:32, Gene Heskett wrote: I am here because I was hoping some knowledge leakage would help me to understand python, but at my age I am beginning to have to admit the level of abstraction is something I may never fully grok. If I ever find a python book that literally starts at s

Re: Correct handling of case in unicode and regexps

2013-02-23 Thread Devin Jeanpierre
On Sat, Feb 23, 2013 at 12:41 PM, MRAB wrote: > Getting full case folding to work can be tricky. There's always going to > be a limit to what's worth doing. > > There are also areas where it's not clear what the result should be. > You've already mentioned matching 's' against 'ß' (fails) and matc

Re: Correct handling of case in unicode and regexps

2013-02-23 Thread MRAB
On 2013-02-23 15:30, Devin Jeanpierre wrote: On Sat, Feb 23, 2013 at 10:26 AM, Devin Jeanpierre wrote: However, regex has the same behavior. My apologies, I forgot to set the VERSION1 flag. Interesting. 'ss' matches 'ß', but 's+' does not. Is this desirable behavior? Getting full case fol

Re: Python Newbie

2013-02-23 Thread Steve Simmons
On 23/02/2013 16:51, Chris Angelico wrote: Steve, why do you say you're not a developer? A score of languages under your belt, choosing to write code in your spare time, and speaking competently on the comparative merits of different languages and why you made the decision you made - sounds li

Re: Python Newbie

2013-02-23 Thread Gene Heskett
On Saturday 23 February 2013 12:03:00 Ethan Furman did opine: > On 02/23/2013 07:51 AM, Chris Angelico wrote: > > Steve, why do you say you're not a developer? A score of languages > > under your belt, choosing to write code in your spare time, and > > speaking competently on the comparative merit

Re: Python Newbie

2013-02-23 Thread Ethan Furman
On 02/23/2013 07:51 AM, Chris Angelico wrote: Steve, why do you say you're not a developer? A score of languages under your belt, choosing to write code in your spare time, and speaking competently on the comparative merits of different languages and why you made the decision you made - sounds li

Re: What happened to 2.7.4 and 3.2.4 ??

2013-02-23 Thread Perica Zivkovic
On Saturday, February 23, 2013 10:19:29 AM UTC-6, Mark Lawrence wrote: > On 23/02/2013 16:03, Perica Zivkovic wrote: > > > For quite some time we had 2.7.4 and 3.2.4 planned on Python release > > calendar and both scheduled for Feb 16th (last weekend). However they are > > not released and also

Re: What happened to 2.7.4 and 3.2.4 ??

2013-02-23 Thread Mark Lawrence
On 23/02/2013 16:03, Perica Zivkovic wrote: For quite some time we had 2.7.4 and 3.2.4 planned on Python release calendar and both scheduled for Feb 16th (last weekend). However they are not released and also not scheduled for the future. Are we going to have these releases ? Postponed or canc

Re: Good cross-version ASCII serialisation protocol for simple types

2013-02-23 Thread Jussi Piitulainen
Paul Moore writes: > I need to transfer some data (nothing fancy, some dictionaries, > strings, numbers and lists, basically) between 2 Python > processes. However, the data (string values) is potentially not > ASCII, but the transport is (I'm piping between 2 processes, but > thanks to nasty enc

Re: Good cross-version ASCII serialisation protocol for simple types

2013-02-23 Thread Irmen de Jong
On 23-2-2013 16:45, Paul Moore wrote: > I need to transfer some data (nothing fancy, some dictionaries, strings, > numbers and > lists, basically) between 2 Python processes. However, the data (string > values) is > potentially not ASCII, but the transport is (I'm piping between 2 processes, > b

What happened to 2.7.4 and 3.2.4 ??

2013-02-23 Thread Perica Zivkovic
For quite some time we had 2.7.4 and 3.2.4 planned on Python release calendar and both scheduled for Feb 16th (last weekend). However they are not released and also not scheduled for the future. Are we going to have these releases ? Postponed or cancelled ? -- http://mail.python.org/mailman/li

Re: Good cross-version ASCII serialisation protocol for simple types

2013-02-23 Thread Chris Angelico
On Sun, Feb 24, 2013 at 2:45 AM, Paul Moore wrote: > At the moment, I'm using > > encoded = json.dumps([ord(c) for c in json.dumps(obj)]) > decoded = json.loads(''.join([chr(n) for n in json.loads(encoded)])) > > The double-encoding ensures that non-ASCII characters don't make it into the > resu

Re: Python Newbie

2013-02-23 Thread Chris Angelico
On Sun, Feb 24, 2013 at 2:43 AM, Steve Simmons wrote: > I get the impression that you are a developer of some experience on a single > language. I wouldn't call myself a developer but I have written, modified > and/or debugged software in upwards of 20 languages and, from that > perspective, I wo

Good cross-version ASCII serialisation protocol for simple types

2013-02-23 Thread Paul Moore
I need to transfer some data (nothing fancy, some dictionaries, strings, numbers and lists, basically) between 2 Python processes. However, the data (string values) is potentially not ASCII, but the transport is (I'm piping between 2 processes, but thanks to nasty encoding issues, the only chara

Re: Python Newbie

2013-02-23 Thread Steve Simmons
On 22/02/2013 22:37, piterrr.dolin...@gmail.com wrote: So far I am getting the impression that Python is a toy language of some kind (similar to Basic of the early 80's), not really suitable for serious work. The only difference between these languages (admittedly, a serious one) is the exist

Re: Correct handling of case in unicode and regexps

2013-02-23 Thread Devin Jeanpierre
On Sat, Feb 23, 2013 at 10:26 AM, Devin Jeanpierre wrote: > However, regex has the same behavior. My apologies, I forgot to set the VERSION1 flag. Interesting. 'ss' matches 'ß', but 's+' does not. Is this desirable behavior? -- Devin -- http://mail.python.org/mailman/listinfo/python-list

Re: Correct handling of case in unicode and regexps

2013-02-23 Thread Devin Jeanpierre
On Sat, Feb 23, 2013 at 10:11 AM, Vlastimil Brom wrote: > you may check the new regex implementation > https://pypi.python.org/pypi/regex > which does support casefolding in case insensitive matches (beyond > many other features and improvements comparing to re) Good point, I've been looking only

Re: Correct handling of case in unicode and regexps

2013-02-23 Thread Vlastimil Brom
2013/2/23 Devin Jeanpierre : > Hi folks, > > I'm pretty unsure of myself when it comes to unicode. As I understand > it, you're generally supposed to compare things in a case insensitive > manner by case folding, right? So instead of a.lower() == b.lower() > (the ASCII way), you do a.casefold() ==

RE: Altering sys.stdin

2013-02-23 Thread drekin
> If you're going to replace something, the replacement needs to at least quack like the original... That's for the freezing, even though an exception would be better. But still, even when custon TextIO object is provided, interactive console doesn't read from it (however input() does). -- htt

Re: time as float since Jan 1, 0001?

2013-02-23 Thread Roy Smith
In article , Mark Lawrence wrote: > On 23/02/2013 13:29, Roy Smith wrote: > > I'm working with matplotlib.plot_date(), which represents time as > > "floats starting at January 1st, year 0001". Is there any > > straight-forward way to get that out of a datetime? > > > > datetime.toordinal() give

Re: time as float since Jan 1, 0001?

2013-02-23 Thread Chris Angelico
On Sun, Feb 24, 2013 at 12:29 AM, Roy Smith wrote: > datetime.toordinal() gives me the number of days since that epoch, but > as an integer. I figured it wouldn't be too hard to just do: > > t.toordinal() + t.time().total_seconds() What about t.timestamp()? That's since 1970, but you could add (

Re: time as float since Jan 1, 0001?

2013-02-23 Thread Mark Lawrence
On 23/02/2013 13:29, Roy Smith wrote: I'm working with matplotlib.plot_date(), which represents time as "floats starting at January 1st, year 0001". Is there any straight-forward way to get that out of a datetime? datetime.toordinal() gives me the number of days since that epoch, but as an inte

Re: Altering sys.stdin

2013-02-23 Thread Andrew Berg
On 2013.02.23 07:00, Draic Kin wrote: > Intepreter actually freezes when an object without > encoding attribute is assigned to sys.stdin. Why is that? I that a > correct behavior? Is there any workaround to alter input object for > interactive console? If you're going to replace something, the rep

time as float since Jan 1, 0001?

2013-02-23 Thread Roy Smith
I'm working with matplotlib.plot_date(), which represents time as "floats starting at January 1st, year 0001". Is there any straight-forward way to get that out of a datetime? datetime.toordinal() gives me the number of days since that epoch, but as an integer. I figured it wouldn't be too ha

5 minutes introduction to islam

2013-02-23 Thread BV BV
5 minutes introduction to islam http://www.youtube.com/watch?feature=player_embedded&v=ZHujiWd49l4 thank you -- http://mail.python.org/mailman/listinfo/python-list

Altering sys.stdin

2013-02-23 Thread Draic Kin
Hello, it seems that Python interactive console actually doesn't use sys.stdin to read input (it just affects e.g. input() function). However it uses sys.stdin.encoding. Intepreter actually freezes when an object without encoding attribute is assigned to sys.stdin. Why is that? I that a correct beh

Re: Python Newbie

2013-02-23 Thread Rui Maciel
piterrr.dolin...@gmail.com wrote: > So far I am getting the impression that Python is a toy language of some > kind (similar to Basic of the early 80's), not really suitable for serious > work. The only difference between these languages (admittedly, a serious > one) is the existence of extensive

Escaping list of numbers for Postgres column names

2013-02-23 Thread andydtaylor
Hi I have some convenient short place name IDs which would be handy for column names. Unfortunately, many begin with a number. I can work around this by appending a letter to each one, but should I escape the number in such a way that I can use it directly as my column name, in the same way a

Re: Question about defaultdict

2013-02-23 Thread Frank Millman
On 23/02/2013 13:02, Peter Otten wrote: Frank Millman wrote: On 23/02/2013 12:13, Frank Millman wrote: Hi all I use a dictionary as a cache, and I thought that I could replace it with collections.defaultdict, but it does not work the way I expected (python 3.3.0). > [...] from collection

Re: Question about defaultdict

2013-02-23 Thread Peter Otten
Frank Millman wrote: > On 23/02/2013 12:13, Frank Millman wrote: >> Hi all >> >> I use a dictionary as a cache, and I thought that I could replace it >> with collections.defaultdict, but it does not work the way I expected >> (python 3.3.0). > > > [...] >> >> from collections import defaultdict >

Re: How to write a language parser ?

2013-02-23 Thread Devin Jeanpierre
On Fri, Feb 22, 2013 at 9:14 PM, Mark Lawrence wrote: > http://nedbatchelder.com/text/python-parsers.html Hm, that list is missing information. e.g. ANTLR 4 doesn't support python, and LEPL is dead now. -- Devin -- http://mail.python.org/mailman/listinfo/python-list

Re: Question about defaultdict

2013-02-23 Thread Frank Millman
On 23/02/2013 12:13, Frank Millman wrote: Hi all I use a dictionary as a cache, and I thought that I could replace it with collections.defaultdict, but it does not work the way I expected (python 3.3.0). > [...] from collections import defaultdict my_cache = defaultdict(fetch_object) my_obj =

Re: Question about defaultdict

2013-02-23 Thread Peter Otten
Frank Millman wrote: > I use a dictionary as a cache, and I thought that I could replace it > with collections.defaultdict, but it does not work the way I expected > (python 3.3.0). > > my_cache = {} > def get_object(obj_id): > if obj_id not in my_cache: > my_object = fetch_object(o

Re: Question about defaultdict

2013-02-23 Thread Chris Angelico
On Sat, Feb 23, 2013 at 9:13 PM, Frank Millman wrote: > I thought I could replace this with - > > from collections import defaultdict > my_cache = defaultdict(fetch_object) > my_obj = my_cache['a'] > > It does not work, because fetch_object() is called without any arguments. A reasonable thing to

Re: Unit Test case for complie/test

2013-02-23 Thread Mark Lawrence
On 23/02/2013 06:13, jitendra gupta wrote: Hi, I am working one tool, which will do compile/run the workspace (that code is written on c/c++). on that my requirment is i need to compile subfolder also, i have wrote code for that also. My problem is , i am unable to write the Unit test case for

Question about defaultdict

2013-02-23 Thread Frank Millman
Hi all I use a dictionary as a cache, and I thought that I could replace it with collections.defaultdict, but it does not work the way I expected (python 3.3.0). my_cache = {} def get_object(obj_id): if obj_id not in my_cache: my_object = fetch_object(obj_id) # expensive operatio

Re: Python Newbie

2013-02-23 Thread Serhiy Storchaka
On 23.02.13 06:13, Steven D'Aprano wrote: "def" is short for "define". Actually "def" is short for "DEfine Function". -- http://mail.python.org/mailman/listinfo/python-list

Re: Number validation issue

2013-02-23 Thread Morten Engvoldsen
> > Hi, > Yes true, i need to generate weight at run time rather than hard coding it, following are some solution: Since the max length of thenumber should be 25 and minimum should be 2 so code will be in this way: def is_valid_isbn13(isbn13): if not len(checknum) >= 2 and len(checknum) <=25