Re: frozendict

2012-02-09 Thread anon hung
> I've been trying for a few days (only a little bit at a time) to come up > with a way of implementing a frozendict that doesn't suck. I'm gradually > converging to a solution, but I can't help but think that there's some > subtlety that I'm probably missing which is why it's not already provided.

Re: Common LISP-style closures with Python

2012-02-09 Thread John Nagle
On 2/3/2012 4:27 PM, Antti J Ylikoski wrote: In Python textbooks that I have read, it is usually not mentioned that we can very easily program Common LISP-style closures with Python. It is done as follows: Most dynamic languages have closures. Even Perl and Javascript have closures. Javas

Re: Guide to: Learning Python Decorators

2012-02-09 Thread sajuptpm
Hi, Thanks for replay, I am looking for PDF version of same book. Please share if you can. http://www.amazon.com/gp/product/B006ZHJSIM/ref=as_li_tf_tl?ie=UTF8&tag=8012-20&linkCode=as2&camp=1789&creative=9325&creativeASIN=B006ZHJSIM -- http://mail.python.org/mailman/listinfo/python-list

Re: round down to nearest number

2012-02-09 Thread Ian Kelly
On Thu, Feb 9, 2012 at 8:36 PM, MRAB wrote: > On 10/02/2012 02:25, noydb wrote: >> >> That {>>>  (3219 + 99) // 100} doesnt work if the number is other then >> 4 digits. >> >> >> (for rounding up to nearest 100): > >  (3219 + 99)//100 >> >> 33 > >  (3289 + 99)//100 >> >> 33 > >

Re: round down to nearest number

2012-02-09 Thread MRAB
On 10/02/2012 03:29, Terry Reedy wrote: On 2/9/2012 8:23 PM, noydb wrote: So how would you round UP always? Say the number is 3219, so you want >>> (//100+1)*100 3400 Doing it that way doesn't always work. For example: >>> (3400 // 100 + 1) * 100 3500 However: >>> (3400 + 99) // 1

Re: round down to nearest number

2012-02-09 Thread MRAB
On 10/02/2012 02:25, noydb wrote: That {>>> (3219 + 99) // 100} doesnt work if the number is other then 4 digits. (for rounding up to nearest 100): (3219 + 99)//100 33 (3289 + 99)//100 33 (328678 + 99)//100 3287 (328 + 99)//100 4 >>> (3219 + 99) // 100 * 100 3300 >>> (3289 + 99)

Re: frozendict

2012-02-09 Thread Terry Reedy
On 2/9/2012 9:30 PM, Nathan Rice wrote: That day may be sooner than you think. It is very likely that in Python 3.3, dict order will be randomized on creation as a side-effect of adding a random salt to hashes to prevent a serious vulnerability in dicts. http://securitytracker.com/id/1026478 h

Re: round down to nearest number

2012-02-09 Thread Terry Reedy
On 2/9/2012 8:23 PM, noydb wrote: So how would you round UP always? Say the number is 3219, so you want >>> (//100+1)*100 3400 -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: Read-only attribute in module

2012-02-09 Thread Terry Reedy
On 2/9/2012 8:04 PM, Steven D'Aprano wrote: Python happily violates "consenting adults" all over the place. We have properties, which can easily create read-only and write-once attributes. So propose that propery() work at module level, for module attributes, as well as for class attributes.

Re: Guide to: Learning Python Decorators

2012-02-09 Thread Terry Reedy
On 2/9/2012 5:43 PM, Ian wrote: On 09/02/2012 21:41, Aaron France wrote: How many pages is that? The amazon page conveniently left that off. There is an average of 5.1 chars per word in English, and usually about 350 words an A4 page. The 215K file is a) Compressed - typically by 60% b) Contai

Re: Formate a number with commas

2012-02-09 Thread Terry Reedy
On 2/9/2012 5:12 PM, Chris Rebert wrote: Argh. The 2.7 docs say it was added in 2.7, but the 3.3a0 docs say it was added in 3.1 (Guido's backporting time machine messes with "causality"). Python 2 docs refer to Python 2. Python 3 docs refer to Python 3. So 'it' was in neither 2.6 nor 3.1. Bo

Re: frozendict

2012-02-09 Thread Nathan Rice
On Thu, Feb 9, 2012 at 8:24 PM, Steven D'Aprano wrote: > On Thu, 09 Feb 2012 09:35:52 -0700, Ian Kelly wrote: > >> On Thu, Feb 9, 2012 at 8:19 AM, Nathan Rice >> wrote: >>> As I said, two dictionaries created from the same input will be the >>> same... >> >> That's an implementation detail, not a

Re: round down to nearest number

2012-02-09 Thread noydb
That {>>> (3219 + 99) // 100} doesnt work if the number is other then 4 digits. (for rounding up to nearest 100): >>> (3219 + 99)//100 33 >>> (3289 + 99)//100 33 >>> (328678 + 99)//100 3287 >>> (328 + 99)//100 4 -- http://mail.python.org/mailman/listinfo/python-list

Re: round down to nearest number

2012-02-09 Thread Ian Kelly
On Thu, Feb 9, 2012 at 6:43 PM, Chris Rebert wrote: > On Thu, Feb 9, 2012 at 5:23 PM, noydb wrote: >> hmmm, okay. >> >> So how would you round UP always?  Say the number is 3219, so you want >> 3300 returned. > > http://stackoverflow.com/questions/17944/how-to-round-up-the-result-of-integer-divis

Re: round down to nearest number

2012-02-09 Thread Chris Rebert
On Thu, Feb 9, 2012 at 5:23 PM, noydb wrote: > hmmm, okay. > > So how would you round UP always?  Say the number is 3219, so you want > 3300 returned. http://stackoverflow.com/questions/17944/how-to-round-up-the-result-of-integer-division/96921 Thus: (3219 + 99) // 100 Slight tangent: Beware ne

Re: round down to nearest number

2012-02-09 Thread Chris Kaynor
On Thu, Feb 9, 2012 at 5:40 PM, Chris Kaynor wrote: > On Thu, Feb 9, 2012 at 5:23 PM, noydb wrote: > >> hmmm, okay. >> >> So how would you round UP always? Say the number is 3219, so you want >> 3300 returned. >> > > You may want to look into the mathematical floor and ceiling functions[1]. > Py

Re: round down to nearest number

2012-02-09 Thread Chris Kaynor
On Thu, Feb 9, 2012 at 5:23 PM, noydb wrote: > hmmm, okay. > > So how would you round UP always? Say the number is 3219, so you want > 3300 returned. > You may want to look into the mathematical floor and ceiling functions[1]. Python exposes them in the math module as floor and ceil[2]. [1] ht

Re: round down to nearest number

2012-02-09 Thread noydb
hmmm, okay. So how would you round UP always? Say the number is 3219, so you want 3300 returned. -- http://mail.python.org/mailman/listinfo/python-list

Re: frozendict

2012-02-09 Thread Steven D'Aprano
On Thu, 09 Feb 2012 09:35:52 -0700, Ian Kelly wrote: > On Thu, Feb 9, 2012 at 8:19 AM, Nathan Rice > wrote: >> As I said, two dictionaries created from the same input will be the >> same... > > That's an implementation detail, not a guarantee. It will hold for > current versions of CPython but

Re: Read-only attribute in module

2012-02-09 Thread Steven D'Aprano
On Thu, 09 Feb 2012 23:32:59 +1100, Ben Finney wrote: > Mateusz Loskot writes: > >> I'm wondering, is there any mean to implement attribute in module scope >> which is read-only? > > Python is designed by and for consenting adults. Rather than > restricting, instead use conventions to make your

Re: round down to nearest number

2012-02-09 Thread Ian Kelly
On Thu, Feb 9, 2012 at 5:30 PM, noydb wrote: > How do you round down ALWAYS to nearest 100?  Like, if I have number > 3268, I want that rounded down to 3200.  I'm doing my rounding like round(3268, -2) > But, how to round DOWN? >>> 3268 // 100 * 100 3200 For more complicated cases, Decimal

round down to nearest number

2012-02-09 Thread noydb
How do you round down ALWAYS to nearest 100? Like, if I have number 3268, I want that rounded down to 3200. I'm doing my rounding like >>> round(3268, -2) But, how to round DOWN? -- http://mail.python.org/mailman/listinfo/python-list

Re: Guide to: Learning Python Decorators

2012-02-09 Thread Ian
On 09/02/2012 21:41, Aaron France wrote: How many pages is that? The amazon page conveniently left that off. There is an average of 5.1 chars per word in English, and usually about 350 words an A4 page. The 215K file is a) Compressed - typically by 60% b) Contains simple html and images as its

Re: multiple namespaces within a single module?

2012-02-09 Thread Ethan Furman
Ethan Furman wrote: Hrm -- and functions/classes/etc would have to refer to each other that way as well inside the namespace... not sure I'm in love with that... Not sure I hate it, either. ;) Slightly more sophisticated code: class NameSpace(object): def __init__(self, current_globals

Re: multiple namespaces within a single module?

2012-02-09 Thread jkn
Hi Peter On Feb 9, 7:33 pm, Peter Otten <__pete...@web.de> wrote: > jkn wrote: > >     is it possible to have multiple namespaces within a single python > > module? > > Unless you are abusing classes I don't think so. > > > I have a small app which is in three or four .py files. For various > > re

Re: Formate a number with commas

2012-02-09 Thread John Posner
On 2:59 PM, noydb wrote: > How do you format a number to print with commas? I would readily admit that both the "locale" module and "format" method are preferable to this regular expression, which certainly violates the "readability counts" dictum: r"(?<=\d)(?=(\d\d\d)+$)" # python 2.6.6 imp

Want to improve my code.

2012-02-09 Thread Ian
Hi all, I'm using lxml etree, and have written a routine to remove nodes in the parsed tree. Typically, I load html, and remove tags, so I am moving the font tags children up and moving the text and tail data about. The code of the deleteElem routine is here http://snipt.org/GSoo0 It t

Re: multiple namespaces within a single module?

2012-02-09 Thread Ethan Furman
Peter Otten wrote: Hm, what about with NameSpace(globals()) as a: x = "inside a!" def function(): print(x) with NameSpace(globals()) as b: x = "inside b!" def function(): print(x) x = "inside main!" a.function() b.function() It would have to be `a.x = ...` an

Re: Formate a number with commas

2012-02-09 Thread Chris Rebert
On Thu, Feb 9, 2012 at 1:16 PM, Peter Otten <__pete...@web.de> wrote: > Chris Rebert wrote: >> On Thu, Feb 9, 2012 at 12:39 PM, Peter Otten <__pete...@web.de> wrote: >> import locale >> locale.setlocale(locale.LC_ALL, "") >>> 'de_DE.UTF-8' >> "{:n}".format(1234) # locale-aware >>> '1.23

Re: Apparent "double imports"

2012-02-09 Thread HoneyMonster
On Thu, 09 Feb 2012 15:05:52 -0500, Dave Angel wrote: > On 02/09/2012 02:40 PM, HoneyMonster wrote: >> On Thu, 09 Feb 2012 12:02:03 -0700, Ian Kelly wrote: >> >>> On Thu, Feb 9, 2012 at 11:53 AM, HoneyMonster >>> wrote: One issue I have run into, which may or may not be a problem: I am

Re: multiple namespaces within a single module?

2012-02-09 Thread Peter Otten
Ethan Furman wrote: > Peter Otten wrote: >> jkn wrote: >> >>> is it possible to have multiple namespaces within a single python >>> module? >> >> Unless you are abusing classes I don't think so. > > > Speaking of... > > > class NameSpace(object): > def __init__(self, globals): >

Re: multiple namespaces within a single module?

2012-02-09 Thread Ethan Furman
Peter Otten wrote: jkn wrote: is it possible to have multiple namespaces within a single python module? Unless you are abusing classes I don't think so. Speaking of... class NameSpace(object): def __init__(self, globals): self.globals = globals self.current_keys =

Re: Formate a number with commas

2012-02-09 Thread Peter Otten
Chris Rebert wrote: > On Thu, Feb 9, 2012 at 12:39 PM, Peter Otten <__pete...@web.de> wrote: > import locale > locale.setlocale(locale.LC_ALL, "") >> 'de_DE.UTF-8' > "{:n}".format(1234) # locale-aware >> '1.234' > "{:,d}".format(1234) # always a comma >> '1,234' > > The latter re

Re: Formate a number with commas

2012-02-09 Thread Alain Ketterlin
noydb writes: > How do you format a number to print with commas? import locale locale.setlocale(locale.LC_ALL, "") This sets the locale according to the environment (typically LANG---I'm talking about linux, don't know others). locale.format('%d', 2348721, True) > '2,348,721' T

Re: Reading files in from the proper directory

2012-02-09 Thread Peter Otten
smac2...@comcast.net wrote: > On Feb 7, 3:16 pm, Peter Otten <__pete...@web.de> wrote: >> smac2...@comcast.net wrote: >> > xls_files = glob.glob(in_dir + "*.xls") >> >> Try changing that to >> >> pattern = os.path.join(in_dir, "*.xls") >> xls_files = glob.glob(pattern) >> >> os.path.join() inser

Re: Formate a number with commas

2012-02-09 Thread Chris Rebert
On Thu, Feb 9, 2012 at 12:39 PM, Peter Otten <__pete...@web.de> wrote: > noydb wrote: > >> How do you format a number to print with commas? >> >> Some quick searching, i came up with: >> > import locale > locale.setlocale(locale.LC_ALL, "") > locale.format('%d', 2348721, True) >> '2,348

Re: Reading files in from the proper directory

2012-02-09 Thread SMac2347
On Feb 7, 3:16 pm, Peter Otten <__pete...@web.de> wrote: > smac2...@comcast.net wrote: > > xls_files   = glob.glob(in_dir + "*.xls") > > Try changing that to > > pattern = os.path.join(in_dir, "*.xls") > xls_files = glob.glob(pattern) > > os.path.join() inserts a (back)slash between directory and f

Re: Formate a number with commas

2012-02-09 Thread Peter Otten
noydb wrote: > How do you format a number to print with commas? > > Some quick searching, i came up with: > import locale locale.setlocale(locale.LC_ALL, "") locale.format('%d', 2348721, True) > '2,348,721' > > > I'm a perpetual novice, so just looking for better, slicker, more

Re: Reading files in from the proper directory

2012-02-09 Thread SMac2347
On Feb 7, 3:16 pm, Peter Otten <__pete...@web.de> wrote: > smac2...@comcast.net wrote: > > xls_files   = glob.glob(in_dir + "*.xls") > > Try changing that to > > pattern = os.path.join(in_dir, "*.xls") > xls_files = glob.glob(pattern) > > os.path.join() inserts a (back)slash between directory and f

Re: Formate a number with commas

2012-02-09 Thread Neil Cerutti
On 2012-02-09, noydb wrote: > How do you format a number to print with commas? > > Some quick searching, i came up with: > import locale locale.setlocale(locale.LC_ALL, "") locale.format('%d', 2348721, True) > '2,348,721' > > I'm a perpetual novice, so just looking for better, slick

Formate a number with commas

2012-02-09 Thread noydb
How do you format a number to print with commas? Some quick searching, i came up with: >>> import locale >>> locale.setlocale(locale.LC_ALL, "") >>> locale.format('%d', 2348721, True) '2,348,721' I'm a perpetual novice, so just looking for better, slicker, more proper, pythonic ways to do this.

Re: Apparent "double imports"

2012-02-09 Thread Dave Angel
On 02/09/2012 02:40 PM, HoneyMonster wrote: On Thu, 09 Feb 2012 12:02:03 -0700, Ian Kelly wrote: On Thu, Feb 9, 2012 at 11:53 AM, HoneyMonster wrote: One issue I have run into, which may or may not be a problem: I am finding that modules in the in-house "library" package sometimes have to im

Re: Apparent "double imports" (was: Naming convention for in-house modules (Newbie question))

2012-02-09 Thread HoneyMonster
On Thu, 09 Feb 2012 12:02:03 -0700, Ian Kelly wrote: > On Thu, Feb 9, 2012 at 11:53 AM, HoneyMonster > wrote: >> One issue I have run into, which may or may not be a problem: I am >> finding that modules in the in-house "library" package sometimes have >> to import modules like sys and os, which

Re: Read-only attribute in module

2012-02-09 Thread Mark Lawrence
On 09/02/2012 11:43, Mateusz Loskot wrote: Hi, I'm implementing Python 3 extension using the Python C API. I am familiar with defining new types, implementing get/set for attributes, etc. I'm wondering, is there any mean to implement attribute in module scope which is read-only? So, the follow

Re: multiple namespaces within a single module?

2012-02-09 Thread Peter Otten
jkn wrote: > is it possible to have multiple namespaces within a single python > module? Unless you are abusing classes I don't think so. > I have a small app which is in three or four .py files. For various > reasons I would like to (perhaps optionally) combine these into one > file. Ren

Re: what is the difference between @property and method

2012-02-09 Thread Terry Reedy
On 2/9/2012 10:36 AM, John Posner wrote: On 2:59 PM, Devin Jeanpierre wrote: It is kind of funny that the docs don't ever explicitly say what a property is. http://docs.python.org/library/functions.html#property -- Devin Here's a writeup that does: http://wiki.python.org/moin/AlternativeDesc

Re: Read-only attribute in module

2012-02-09 Thread Terry Reedy
On 2/9/2012 6:43 AM, Mateusz Loskot wrote: Hi, I'm implementing Python 3 extension using the Python C API. I am familiar with defining new types, implementing get/set for attributes, etc. I'm wondering, is there any mean to implement attribute in module scope which is read-only? Not that I kn

Re: Apparent "double imports" (was: Naming convention for in-house modules (Newbie question))

2012-02-09 Thread Ian Kelly
On Thu, Feb 9, 2012 at 11:53 AM, HoneyMonster wrote: > One issue I have run into, which may or may not be a problem: I am > finding that modules in the in-house "library" package sometimes have to > import modules like sys and os, which are also imported by the "calling" > module. Is this a proble

Apparent "double imports" (was: Naming convention for in-house modules (Newbie question))

2012-02-09 Thread HoneyMonster
On Thu, 09 Feb 2012 14:36:52 +, Arnaud Delobelle wrote: > On 9 February 2012 14:00, Laurent Claessens wrote: >> >>> Here is my question: I would like to start an in-house library of >>> small modules to import, for things like error handling/logging. >>> That's easy enough, but is there a rec

Re: frozendict

2012-02-09 Thread Duncan Booth
Nathan Rice wrote: > As I said, two dictionaries created from the same input will be the > same... 'ai' != 'ia'. If I need to hash a dict that I don't know was > created in a deterministic order, I'd frozenset(thedict.items()). > Fair enough, the idea scares me, but it's your code and your ris

multiple namespaces within a single module?

2012-02-09 Thread jkn
Hello there is it possible to have multiple namespaces within a single python module? I have a small app which is in three or four .py files. For various reasons I would like to (perhaps optionally) combine these into one file. I was hoping that there might be a simple mechanism that would le

Re: unicode printing on Windows

2012-02-09 Thread Terry Reedy
On 2/9/2012 5:46 AM, BlueBird wrote: Hi, The question is not totally related to Python but there is a strong connection. Everytime that I try to debug some python programs under Windows, I encounter the issue that things printed on the console simply break the program because : 1. My windows con

Re: Naming convention for in-house modules (Newbie question)

2012-02-09 Thread Laurent Claessens
This is not 100% an answer to the question, but you should read that : http://www.python.org/dev/peps/pep-0008/ The OP mentions PEP 8 in the bit of his message that you *don't* quote. Well... I've to sleep. Sorry :( Laurent -- http://mail.python.org/mailman/listinfo/python-list

Re: frozendict

2012-02-09 Thread Nathan Rice
On Thu, Feb 9, 2012 at 11:35 AM, Ian Kelly wrote: > On Thu, Feb 9, 2012 at 8:19 AM, Nathan Rice > wrote: >> As I said, two dictionaries created from the same input will be the >> same... > > That's an implementation detail, not a guarantee.  It will hold for > current versions of CPython but not

Re: Read-only attribute in module

2012-02-09 Thread mloskot
Ben Finney-10 wrote > > Mateusz Loskot writes: > >> So, the following >> >> import xyz >> print(xyz.flag) # OK >> xyz.flag = 0# error due to no write access > > PEP 8 ; gives the style > guide for Python code (strictly for the standa

Re: frozendict

2012-02-09 Thread Ian Kelly
On Thu, Feb 9, 2012 at 8:19 AM, Nathan Rice wrote: > As I said, two dictionaries created from the same input will be the > same... That's an implementation detail, not a guarantee. It will hold for current versions of CPython but not necessarily for other Python implementations. -- http://mail.

Re: Software tool for stochastic simulation as well as for the stochastic optimization

2012-02-09 Thread Wolfgang Keller
> I plan to work in decision support field in environmental engineering > so I will use both the stochastic simulation as well as the stochastic > optimization. > I would like to select the best for both approaches software tool. > > what you suggest ... Matlab ... python ... something else? I ha

Re: Re: what is the difference between @property and method

2012-02-09 Thread John Posner
On 2:59 PM, Devin Jeanpierre wrote: > It is kind of funny that the docs don't ever explicitly say what a > property is. http://docs.python.org/library/functions.html#property -- > Devin Here's a writeup that does: http://wiki.python.org/moin/AlternativeDescriptionOfProperty -John -- http://m

ANN: eGenix mxODBC Zope Database Adapter 2.0.2

2012-02-09 Thread eGenix Team: M.-A. Lemburg
ANNOUNCEMENT mxODBC Zope Database Adapter Version 2.0.2 for Zope and the Plone CMS Available for Zope 2.10 and later on Windows,

Re: frozendict

2012-02-09 Thread Nathan Rice
>> Two dicts created from the same inputs will return items in the same >> arbitrary order.  As long as you don't insert or delete a key you're >> fine. >> > Two dicts that contain the same keys and values may or may not return them > in the same order: > dict.fromkeys('ia') > {'i': None, 'a':

Re: frozendict

2012-02-09 Thread Duncan Booth
Nathan Rice wrote: > On Thu, Feb 9, 2012 at 5:33 AM, Duncan Booth > wrote: >> Nathan Rice wrote: >> >>> I put dicts in sets all the time.  I just tuple the items, but that >>> means you have to re-dict it on the way out to do anything useful >>> with it.  I am too lazy to write a frozendict or i

Re: Naming convention for in-house modules (Newbie question)

2012-02-09 Thread Arnaud Delobelle
On 9 February 2012 14:00, Laurent Claessens wrote: > >> Here is my question: I would like to start an in-house library of small >> modules to import, for things like error handling/logging. That's easy >> enough, but is there a recommended way of naming such modules? I am >> concerned about avoidi

Re: frozendict

2012-02-09 Thread Nathan Rice
On Thu, Feb 9, 2012 at 5:33 AM, Duncan Booth wrote: > Nathan Rice wrote: > >> I put dicts in sets all the time.  I just tuple the items, but that >> means you have to re-dict it on the way out to do anything useful with >> it.  I am too lazy to write a frozendict or import one, but I would >> use

Re: Naming convention for in-house modules (Newbie question)

2012-02-09 Thread Laurent Claessens
Here is my question: I would like to start an in-house library of small modules to import, for things like error handling/logging. That's easy enough, but is there a recommended way of naming such modules? I am concerned about avoiding name clashes with standard modules and site packages. Thank

Re: turbogears 1

2012-02-09 Thread Roy Smith
In article , anon hung wrote: > >> Hey guys, someone asked me to maintain his old website, trouble is, > >> it's in python, more trouble is it's in turbogears 1. I'm not fluent > >> in python but all right, I can learn, but this turbogears > >> thing.. > >> > >> First of all, is it still

Software tool for stochastic simulation as well as for the stochastic optimization

2012-02-09 Thread John Oksz
Hello Python World, I am starting work on stochastic approach. I plan to work in decision support field in environmental engineering so I will use both the stochastic simulation as well as the stochastic optimization. I would like to select the best for both approaches software tool. what you su

Re: Id of methods

2012-02-09 Thread bruno.desthuilli...@gmail.com
On Feb 9, 5:06 am, Chris Angelico wrote: > On Thu, Feb 9, 2012 at 2:48 PM, Emeka wrote: > > > My question is why is it that the id of Boo.daf  is different from daf's hex > > value in the above dict? > > > daf is not a function, it's a special object for an unbound method. http://wiki.python.org

Re: Komodo 7 release (Python development tools)

2012-02-09 Thread Rod Person
On Wed, 08 Feb 2012 16:52:50 -0500 Terry Reedy wrote: > On 2/8/2012 3:14 PM, Todd Whiteman wrote: > > > My name is Todd. I'm the lead developer for Komodo IDE (Interactive > > Development Environment) and Komodo Edit (a free, open-source > > editor) at ActiveState. I wanted to announce that the

Re: standalone python web server

2012-02-09 Thread Rita
yes, I would like to use a framework. I like the twisted method the user posted. Are there any examples of it using a framework, get/post, etc..? On Thu, Feb 9, 2012 at 6:28 AM, Thomas Bach wrote: > Rita writes: > > > I am building a small intranet website and I would like to use > > Python. I

Re: Can not get the result of query in pymssql module of python...

2012-02-09 Thread Rod Person
On Thu, 9 Feb 2012 12:34:25 +0530 amarjeet yadav wrote: > Hi All, >This is my first post to any mailing group. I am QA engg > and using python for testing automation. I need to connect with Mysql > (2008) and mssql databases for executing some queries. > > I have installed following

Re: Read-only attribute in module

2012-02-09 Thread Ben Finney
Mateusz Loskot writes: > I'm wondering, is there any mean to implement attribute in module > scope which is read-only? Python is designed by and for consenting adults. Rather than restricting, instead use conventions to make your intent clear to the user of your library. > So, the following > >

Read-only attribute in module

2012-02-09 Thread Mateusz Loskot
Hi, I'm implementing Python 3 extension using the Python C API. I am familiar with defining new types, implementing get/set for attributes, etc. I'm wondering, is there any mean to implement attribute in module scope which is read-only? So, the following import xyz print(xyz.flag) # OK xyz.fla

Re: Issue with Scrapping Data from a webpage- Noob Question

2012-02-09 Thread anon hung
> Hi Fellow Pythoners, > > I'm trying to collect table data from an authenticated webpage (Tool) to > which I have access. > > I will have the required data after 'click'ing a submit button on the tool > homepage. > When I inspect the submit button i see > > > Thus the tool's homepage is of the fo

Re: standalone python web server

2012-02-09 Thread Thomas Bach
Rita writes: > I am building a small intranet website and I would like to use > Python. I was wondering if there was a easy and medium performance > python based web server available. Are you going to use a framework? Most of these ship with a light web server implementation… You probably want

Re: unicode printing on Windows

2012-02-09 Thread Andrew Berg
On 2/9/2012 4:46 AM, BlueBird wrote: > Does anybody know how to fix problem 1 ? That way, I could at least > deal with programs that print UTF8 on stdout. I'm pretty sure there isn't a way. cp65001 is supposed to be UTF-8, but it doesn't work in my experience (I fed it some UTF-8 demo text and I go

unicode printing on Windows

2012-02-09 Thread BlueBird
Hi, The question is not totally related to Python but there is a strong connection. Everytime that I try to debug some python programs under Windows, I encounter the issue that things printed on the console simply break the program because : 1. My windows console does not support UTF8 2. Things pr

Re: frozendict

2012-02-09 Thread Duncan Booth
Nathan Rice wrote: > I put dicts in sets all the time. I just tuple the items, but that > means you have to re-dict it on the way out to do anything useful with > it. I am too lazy to write a frozendict or import one, but I would > use it if it was a builtin. > I hope you sort the items before

Re: Cycle around a sequence

2012-02-09 Thread Chris Angelico
On Thu, Feb 9, 2012 at 7:33 PM, Peter Otten <__pete...@web.de> wrote: > Chris Angelico wrote: > >> def cycle(seq,n): >>         seq=iter(seq) >>         lst=[next(seq) for i in range(n)] >>         try: >>                 while True: yield next(seq) >>         except StopIteration: >>              

Re: Cycle around a sequence

2012-02-09 Thread Serhiy Storchaka
08.02.12 22:15, Terry Reedy написав(ла): To make a repeating rotator is only a slight adjustment: k = n - len(seq) while True: i = k while i < n: yield seq[i] i += 1 for i in range(n, len(seq)): yield seq[i] while True: fo

Re: what is the difference between @property and method

2012-02-09 Thread Devin Jeanpierre
On Thu, Feb 9, 2012 at 3:50 AM, Zheng Li wrote: > class A(object): >@properymethod >def value1(self): > return 'value1' > >def value2(self): >return 'value2' > > what is the difference between value1 and value2. There is no such thing as @properymethod After you chang

what is the difference between @property and method

2012-02-09 Thread Zheng Li
class A(object): @properymethod def value1(self): return 'value1' def value2(self): return 'value2' what is the difference between value1 and value2. -- http://mail.python.org/mailman/listinfo/python-list

Re: Cycle around a sequence

2012-02-09 Thread Peter Otten
Mark Lawrence wrote: > I'm looking at a way of cycling around a sequence i.e. starting at some > given location in the middle of a sequence and running to the end before > coming back to the beginning and running to the start place. About the > best I could come up with is the following, any bett

Re: Cycle around a sequence

2012-02-09 Thread Peter Otten
Chris Angelico wrote: > On Thu, Feb 9, 2012 at 2:55 PM, Steven D'Aprano > wrote: >> If your data is humongous but only available lazily, buy more memory :) > > Or if you have a huge iterable and only need a small index into it, > snag those first few entries into a list, then yield everything el