Re: ANN: obfuscate

2010-02-10 Thread Gregory Ewing
Christian Heimes wrote: A much, much stronger version of the principles behind Vigenère was used in the German Enigma machine. Because the algorithm was still not good enought some clever guy called Turing and his team was able to crack the enigma. Actually I gather it had a lot to do with the

Re: Modifying Class Object

2010-02-10 Thread I V
On Thu, 11 Feb 2010 07:37:35 +0100, Alf P. Steinbach wrote: > * Steven D'Aprano: >> s = [1] >> t = s # Binds the name t to the object bound to the name s. >> t[0] = 2 # Changes the object bound to the name t print(s) # >> Checks the object via the original name. >> >> Notice that

Re: Modifying Class Object

2010-02-10 Thread Alf P. Steinbach
* alex23: "Alf P. Steinbach" wrote: Telling someone to "learn to read" is a Steve Holden'sk way to imply that the person is an ignoramus who hasn't bothered to learn to read. Ad hominem. So, you are misrepresenting -- again -- and in a quite revealing way, sorry. Ad hominem. Yes, in

Re: Modifying Class Object

2010-02-10 Thread Alf P. Steinbach
* Steven D'Aprano: On Wed, 10 Feb 2010 23:56:36 +0100, Alf P. Steinbach wrote: * Steven D'Aprano: On Wed, 10 Feb 2010 21:02:14 +0100, Alf P. Steinbach wrote: "pointer" refers to a copyable reference value as seen from the Python level, in the same way as "pointer" is used by e.g. the Java la

Re: regex to match python string literal syntax

2010-02-10 Thread Ken Seehart
Found this in pypy! # Match any flavor of string; /*the terminating quote is optional*/ # so that we're robust in the face of incomplete program text. _match_stringre = re.compile(r""" \""" [^"\\]* (?: (?: \\. | "(?!"") ) [^"\\]* )* (

Re: Modifying Class Object

2010-02-10 Thread alex23
"Alf P. Steinbach" wrote: > Telling someone to "learn to read" is a Steve Holden'sk way to imply that the > person is an ignoramus who hasn't bothered to learn to read. Ad hominem. > So, you > are misrepresenting  --  again  --  and in a quite revealing way, sorry. Ad hominem. > Yes, in this g

Re: Modifying Class Object

2010-02-10 Thread Steven D'Aprano
On Wed, 10 Feb 2010 23:56:36 +0100, Alf P. Steinbach wrote: > * Steven D'Aprano: >> On Wed, 10 Feb 2010 21:02:14 +0100, Alf P. Steinbach wrote: >> >>> "pointer" refers to a copyable reference value as seen from the Python >>> level, in the same way as "pointer" is used by e.g. the Java language >

Re: SimpleXMLRPCServer and client address

2010-02-10 Thread Gabriel Genellina
En Wed, 10 Feb 2010 19:19:50 -0300, Jordan Apgar escribió: I'm trying to right a server that needs specific information for each client accessing it. The easiest way I could think of doing this is keeping this information based on ip address (the information is only valid for a short time).

Re: SocketServer error: AttributeError: instance has no __call__ method

2010-02-10 Thread Gabriel Genellina
En Wed, 10 Feb 2010 17:13:58 -0300, Jordan Apgar escribió: I'm having some issues connecting to my Socket Server, I get this traceback on the sever side: Exception happened during processing of request from ('127.0.0.1', 56404) Traceback (most recent

regex to match python string literal syntax

2010-02-10 Thread Ken Seehart
I found this: http://code.activestate.com/recipes/475109/ But it is incorrect in some cases, such as: * "foo \" bar"* / (incorrectly matches "foo \")/ * '''* /(incorrectly matches the second two single quotes)/ *" foo bar "* / (incorrectly matches quote containing newline/) Anyone kno

Re: I've built Python, but can't figure out how to package it for windows

2010-02-10 Thread Mark Jones
Turns out there is an tools/msi directory and in there is python code to help build the MSI from the tree you built. Only problem is you can't use it without having python and PythonWin installed. So I grabbed 2.6.4 python and pythonwin and installed them. It uses COM objects and the CabSDK from M

Re: Modifying Class Object

2010-02-10 Thread Alf P. Steinbach
* Steve Holden: Alf P. Steinbach wrote: * Steve Holden: So now the whole thing boils down to "Alf against the world"? The reminds me of the story about the woman who went to see her son qualify from his basic army training. When asked what she thought of the parade she said it was very nice, bu

RE: Modifying Class Object

2010-02-10 Thread Dino Viehland
Steve wrote: > id() simply returns a unique value identifying a particular object. In > CPython, where objects do not migrate in memory once created, the > memory > address of the object is used. In IronPython each object is assigned an > id when it is created, and that value is stored as an attrib

Re: Modifying Class Object

2010-02-10 Thread Alf P. Steinbach
* Steve Holden: Alf P. Steinbach wrote: * Steve Holden: Alf P. Steinbach wrote: [snip] Since in the quoting above no reference to definition of "pointer" remains: "pointer" refers to a copyable reference value as seen from the Python level, in the same way as "pointer" is used by e.g. the Jav

Re: Is a merge interval function available?

2010-02-10 Thread Daniel Stutzbach
On Wed, Feb 10, 2010 at 5:23 PM, Peng Yu wrote: > I'm wondering there is already a function in python library that can > merge intervals. > Not in the standard library, but this package may help: http://pypi.python.org/pypi/interval -- Daniel Stutzbach, Ph.D. President, Stutzbach Enterprises,

Re: Modifying Class Object

2010-02-10 Thread Steve Holden
Stephen Hansen wrote: > On Wed, Feb 10, 2010 at 7:49 PM, Steve Holden > wrote: > > *The* standard general language independent definition? As > defined where? > > > Wait, what happened here? > > This thread started a couple days ago; you pointed out its fu

Re: Modifying Class Object

2010-02-10 Thread Steve Holden
Alf P. Steinbach wrote: > * Steve Holden: >> >> So now the whole thing boils down to "Alf against the world"? The >> reminds me of the story about the woman who went to see her son qualify >> from his basic army training. When asked what she thought of the parade >> she said it was very nice, but t

Re: Modifying Class Object

2010-02-10 Thread Stephen Hansen
On Wed, Feb 10, 2010 at 7:49 PM, Steve Holden wrote: > *The* standard general language independent definition? As defined where? > Wait, what happened here? This thread started a couple days ago; you pointed out its futility, and even knowing better, I jumped in the deep end. When I realized th

Re: Is a merge interval function available?

2010-02-10 Thread Steve Holden
Nobody wrote: > On Wed, 10 Feb 2010 15:23:42 -0800, Peng Yu wrote: > >> I'm wondering there is already a function in python library that can >> merge intervals. For example, if I have the following intervals ('[' >> and ']' means closed interval as in >> http://en.wikipedia.org/wiki/Interval_(math

Re: SimpleXMLRPCServer and client address

2010-02-10 Thread Stephen Hansen
On Wed, Feb 10, 2010 at 5:36 PM, Jean-Michel Pichavant < jeanmic...@sequans.com> wrote: > I don't know exactly what you are trying to do, but if your server requires > informations from the client, it would be better to ask explicitly the > client for those informations. > For instance, if a metho

Re: Modifying Class Object

2010-02-10 Thread Steve Holden
Alf P. Steinbach wrote: > * Steve Holden: >> Alf P. Steinbach wrote: > [snip] >>> >>> Since in the quoting above no reference to definition of "pointer" >>> remains: "pointer" refers to a copyable reference value as seen from the >>> Python level, in the same way as "pointer" is used by e.g. the Ja

Re: Is a merge interval function available?

2010-02-10 Thread Nobody
On Wed, 10 Feb 2010 15:23:42 -0800, Peng Yu wrote: > I'm wondering there is already a function in python library that can > merge intervals. For example, if I have the following intervals ('[' > and ']' means closed interval as in > http://en.wikipedia.org/wiki/Interval_(mathematics)#Excluding_the

expy 0.6 released

2010-02-10 Thread Yingjie Lan
Hi: EXPY (http://expy.sourceforge.net/) is an express way to extend Python. Why consider expy? Here are some good reasons: (I). WYSIWYG. The expy project enables you to write your module in Python the way your extension would be (WYSIWYG), and meanwhile write your implementation in pure C. Yo

Re: A silly question on file opening

2010-02-10 Thread Nobody
On Wed, 10 Feb 2010 21:23:08 +, Steven D'Aprano wrote: > The solution to this is to remember that Windows accepts forward slashes > as well as backslashes, and always use the forward slash. So try: > > open("D:/file") > > and see if that works. The solution is not to hard-code pathnames i

Re: Modifying Class Object

2010-02-10 Thread Alf P. Steinbach
* Steve Holden: So now the whole thing boils down to "Alf against the world"? The reminds me of the story about the woman who went to see her son qualify from his basic army training. When asked what she thought of the parade she said it was very nice, but that "everyone but our Alf was out of s

Re: Function attributes

2010-02-10 Thread Terry Reedy
On 2/10/2010 4:49 PM, Gabriel Genellina wrote: I've written a decorator for "injecting" a __function__ name into the function namespace, but I can't find it anywhere. I think I implemented it by adding a fake additional argument and replacing LOAD_GLOBAL with LOAD_NAME in the bytecode. The dec

Re: Dreaming of new generation IDE

2010-02-10 Thread alex23
catonano wrote: > You know what I'm doing now ? I'm drawing the map of > twisted.web.client on a paper with a pencil :-( You're a programmer. Why are you complaining about the problem instead of endeavouring to solve it? -- http://mail.python.org/mailman/listinfo/python-list

FWD: Lore about Division

2010-02-10 Thread kirby.ur...@gmail.com
Alan: 2^(1/2) Kirby: Also pow(2, 0.5) in Python. Alan: Gee, I wonder if pow(2, (1/2)) also works in Python? Kirby: It does if you remember integer division in earlier versions, such that one needed: from __future__ import division or, simply made it 1./2 or 1/2. or something, to force a floa

Re: Modifying Class Object

2010-02-10 Thread Steve Holden
Alf P. Steinbach wrote: > * Ethan Furman: >> Steven D'Aprano wrote: >>> >>> Believe me Alf, the fact that people are taking the time to try to >>> argue with you instead of just kill-filing you is a compliment. >> >> It's a compliment I am not paying, although I am grateful to those who >> are atte

Re: ignoring some placeholders in string formatting

2010-02-10 Thread MRAB
Michal Ludvig wrote: Hi all, when I've got a string, say: URL="http://xyz/blah?session=%(session)s&message=%(message)s" is it possible to fill in only 'session' and leave "%(message)s" as is when it isn't present in the values dict? For example: URL % { 'session' : 123 } raises KeyError becau

Re: Get __doc__ from main module in imported module.

2010-02-10 Thread David
> > How can I access the top level module's doc string from toolkit? > > Like > >      import __main__ >      print_usage( __main__ ) > > with suitable definition of 'usage'. > > Cheers & hth., > > - Alf Problem solved! Thanks for the other tips too. -- http://mail.python.org/mailman/listinfo/pyt

Re: ignoring some placeholders in string formatting

2010-02-10 Thread Steven D'Aprano
On Thu, 11 Feb 2010 14:25:10 +1300, Michal Ludvig wrote: > Hi all, > > when I've got a string, say: > > URL="http://xyz/blah?session=%(session)s&message=%(message)s" > > is it possible to fill in only 'session' and leave "%(message)s" as is > when it isn't present in the values dict? No, but i

Re: ignoring some placeholders in string formatting

2010-02-10 Thread Tim Chase
Michal Ludvig wrote: URL="http://xyz/blah?session=%(session)s&message=%(message)s" is it possible to fill in only 'session' and leave "%(message)s" as is when it isn't present in the values dict? For example: URL % { 'session' : 123 } raises KeyError because of missing 'message' in the dict. I

ignoring some placeholders in string formatting

2010-02-10 Thread Michal Ludvig
Hi all, when I've got a string, say: URL="http://xyz/blah?session=%(session)s&message=%(message)s" is it possible to fill in only 'session' and leave "%(message)s" as is when it isn't present in the values dict? For example: URL % { 'session' : 123 } raises KeyError because of missing 'message'

Re: question on storing dates in a tuple

2010-02-10 Thread Rhodri James
On Thu, 11 Feb 2010 01:17:17 -, m_ahlenius wrote: Hi, I have a weird question about tuples. I am getting some dates from a mysql db, using the mysqldb interface. I am doing a standard query with several of the fields are "datetime" format in mysql. When I retrieve and print them in pytho

Re: SimpleXMLRPCServer and client address

2010-02-10 Thread Jean-Michel Pichavant
Jordan Apgar wrote: I'm trying to right a server that needs specific information for each client accessing it. The easiest way I could think of doing this is keeping this information based on ip address (the information is only valid for a short time). I know there is no was to get the client's

Re: question on storing dates in a tuple

2010-02-10 Thread Chris Rebert
On Wed, Feb 10, 2010 at 5:17 PM, m_ahlenius wrote: > Hi, > > I have a weird question about tuples.  I am getting some dates from a > mysql db, using the mysqldb interface.  I am doing a standard query > with several of the fields are "datetime" format in mysql. > When I retrieve and print them in

Re: Get __doc__ from main module in imported module.

2010-02-10 Thread Alf P. Steinbach
* David: I have a module toolkit.py with some functions I use often. One of these functions displays a usage message (__doc__). def usage(messages=[], exit=-1): """Print the doc string as wells as any useful messages.""" print(__doc__) for message in messages: print("\033[91

Re: strange issue with C extension using Py_BuildValue

2010-02-10 Thread Mark Hammond
On 11/02/2010 9:19 AM, bobicanprogram wrote: I'm am having "strange" problems with the code snip below. When this code is built on a 64bit Linux, it would appear to work flawlessly.When the source is rebuilt on a 32bit Linux it begins to crack in strange ways. The issue seems to be associ

question on storing dates in a tuple

2010-02-10 Thread m_ahlenius
Hi, I have a weird question about tuples. I am getting some dates from a mysql db, using the mysqldb interface. I am doing a standard query with several of the fields are "datetime" format in mysql. When I retrieve and print them in python, they look fine. eg. storeddate = 2010-02-07 12:03:41

Re: Need debugging knowhow for my creeping Unicodephobia

2010-02-10 Thread kj
In Duncan Booth writes: >kj wrote: >> But to ground >> the problem a bit I'll say that the exception above happens during >> the execution of a statement of the form: >> >> x = '%s %s' % (y, z) >> >> Also, I found that, with the exact same values y and z as above, >> all of the following

Get __doc__ from main module in imported module.

2010-02-10 Thread David
I have a module toolkit.py with some functions I use often. One of these functions displays a usage message (__doc__). def usage(messages=[], exit=-1): """Print the doc string as wells as any useful messages.""" print(__doc__) for message in messages: print("\033[91m{}\033[0m"

Re: sqlite3 bug?

2010-02-10 Thread Tim Chase
dads wrote: When the method below is run it raises 'sqlite3.OperationalError: no such table: dave'. the arguments are ds = a datestamp and w = a string of digits. The path of the db is C:\sv_zip_test\2006\2006.db and the table is definitely named dave. I've run the sql in sql manager and it works

Re: Is a merge interval function available?

2010-02-10 Thread Steven D'Aprano
On Wed, 10 Feb 2010 15:23:42 -0800, Peng Yu wrote: > I'm wondering there is already a function in python library that can > merge intervals. For example, if I have the following intervals ('[' and > ']' means closed interval as in > http://en.wikipedia.org/wiki/Interval_(mathematics) #Excluding_th

sqlite3 bug?

2010-02-10 Thread dads
When the method below is run it raises 'sqlite3.OperationalError: no such table: dave'. the arguments are ds = a datestamp and w = a string of digits. The path of the db is C:\sv_zip_test\2006\2006.db and the table is definitely named dave. I've run the sql in sql manager and it works. Is this a bu

Re: Python Logic Map/Logic Flow Chart. (Example Provided)

2010-02-10 Thread Rhodri James
On Tue, 09 Feb 2010 07:35:51 -, Gary Herron wrote: spike wrote: On Feb 8, 1:35 pm, Gary Herron wrote: spike wrote: Has anyone been able to come across a Python logic map or Python logic flow chart? An example can be seen on the right under History: http://en.wikipedia.org/wiki

Re: Modifying Class Object

2010-02-10 Thread Alf P. Steinbach
* Steven D'Aprano: On Wed, 10 Feb 2010 23:02:27 +0100, Alf P. Steinbach wrote: For a less likely more technical interpretation, as far as I know in Python there's just one case of a pointer that does not point to anything, namely as exemplified by def foo(): print( x ) x =

Is a merge interval function available?

2010-02-10 Thread Peng Yu
I'm wondering there is already a function in python library that can merge intervals. For example, if I have the following intervals ('[' and ']' means closed interval as in http://en.wikipedia.org/wiki/Interval_(mathematics)#Excluding_the_endpoints) [1, 3] [2, 9] [10,13] [11,12] I want to get th

Re: Modifying Class Object

2010-02-10 Thread Steven D'Aprano
On Wed, 10 Feb 2010 23:02:27 +0100, Alf P. Steinbach wrote: > For a less likely more technical interpretation, as far as I know in > Python there's just one case of a pointer that does not point to > anything, namely as exemplified by > > def foo(): > print( x ) > x = "whateve

Re: Need debugging knowhow for my creeping Unicodephobia

2010-02-10 Thread David Malcolm
On Wed, 2010-02-10 at 12:17 -0800, Anthony Tolle wrote: > On Feb 10, 2:09 pm, kj wrote: > > Some people have mathphobia. I'm developing a wicked case of > > Unicodephobia. > > [snip] > > Some general advice (Looks like I am reiterating what MRAB said -- I > type slower :): > > 1. If possible, u

Re: Executing Commands From Windows Service

2010-02-10 Thread T
On Feb 9, 4:25 pm, David Bolen wrote: > David Bolen writes: > > Not from my past experience - the system account (LocalSystem for > > services) can be surprising, in that it's pretty much unlimited access > > to all local resources, but severely limited in a handful of cases, > > one of which is

Re: Modifying Class Object

2010-02-10 Thread Alf P. Steinbach
* Steven D'Aprano: On Wed, 10 Feb 2010 21:02:14 +0100, Alf P. Steinbach wrote: "pointer" refers to a copyable reference value as seen from the Python level, in the same way as "pointer" is used by e.g. the Java language spec. Python doesn't have "copyable reference values" in the Python level

Re: How to measure elapsed time under Windows?

2010-02-10 Thread Grant Edwards
On 2010-02-09, Gabriel Genellina wrote: > In code, using SetProcessAffinityMask and related functions: > http://msdn.microsoft.com/en-us/library/ms686223(VS.85).aspx That solves the problem. If I don't set the process affinity mask, I regularly get measurements that are off by 6ms. I presume 6

Re: How to measure elapsed time under Windows?

2010-02-10 Thread Gabriel Genellina
En Wed, 10 Feb 2010 13:15:22 -0300, Grant Edwards escribió: On 2010-02-09, Gabriel Genellina wrote: En Tue, 09 Feb 2010 13:10:56 -0300, Grant Edwards escribi?: What's the correct way to measure small periods of elapsed time. I've always used time.clock() in the past: However on multi-proc

Re: intolerant HTML parser

2010-02-10 Thread Lawrence D'Oliveiro
In message <4b712919$0$6584$9b4e6...@newsspool3.arcor-online.net>, Stefan Behnel wrote: > Usually PyPI. Where do you think these tools come from? They don’t write themselves, you know. -- http://mail.python.org/mailman/listinfo/python-list

strange issue with C extension using Py_BuildValue

2010-02-10 Thread bobicanprogram
I'm am having "strange" problems with the code snip below. When this code is built on a 64bit Linux, it would appear to work flawlessly.When the source is rebuilt on a 32bit Linux it begins to crack in strange ways. The issue seems to be associated with the sender field in the Py_BuildValue

SimpleXMLRPCServer and client address

2010-02-10 Thread Jordan Apgar
I'm trying to right a server that needs specific information for each client accessing it. The easiest way I could think of doing this is keeping this information based on ip address (the information is only valid for a short time). I know there is no was to get the client's address directly and

Re: Modifying Class Object

2010-02-10 Thread John Posner
On 2/10/2010 1:38 PM, Ethan Furman wrote: After all is said and done - if you had a truly good grasp of Python, I might buy your book even if you still had -- ummm -- a less than winning presence on the mailing list; but right now your understanding is not worth paying for. Alf, here's my sug

Re: Modifying Class Object

2010-02-10 Thread Alf P. Steinbach
* Ethan Furman: Steven D'Aprano wrote: Believe me Alf, the fact that people are taking the time to try to argue with you instead of just kill-filing you is a compliment. It's a compliment I am not paying, although I am grateful to those who are attempting to teach him. At the rate it's goi

Re: Modifying Class Object

2010-02-10 Thread Alf P. Steinbach
* Steve Holden: Alf P. Steinbach wrote: [snip] Since in the quoting above no reference to definition of "pointer" remains: "pointer" refers to a copyable reference value as seen from the Python level, in the same way as "pointer" is used by e.g. the Java language spec. [snip] If so, then t

Re: New to Python

2010-02-10 Thread J. Cliff Dyer
On Wed, 2010-02-10 at 13:18 -0800, Stephen Hansen wrote: > > The original code: > > > s = f.readline() > if 'mystring' in s: print 'foundit' > if 'mystring' not in s: print 'not found' > if 'mystring' in s: > print 'processing' > > > ... will only work on Python 2.x, as print is being used

Re: Creating formatted output using picture strings

2010-02-10 Thread John Posner
On 2/10/2010 2:57 PM, Grant Edwards wrote: On 2010-02-10, pyt...@bdurham.com wrote: [regardning "picture" output format specifiers] I was thinking that there was a built-in function for this common(?) use case I haven't seen that paradigm since my one-and-only exposure to COBOL in a class I

Re: "if {negative}" vs. "if {positive}" style (was: New to Python)

2010-02-10 Thread Carl Banks
On Feb 9, 7:36 pm, Tim Chase wrote: > Larry Hudson wrote: > > But a minor rearrangement is simpler, and IMHO clearer: > > > if 'mystring' not in s: > >      print 'not found' > > else: > >      print 'foundit' > >      print 'processing' > > I've always vacillated on whether that would better be w

Re: Function attributes

2010-02-10 Thread Arnaud Delobelle
MRAB writes: > Does this mean that Python needs, say, __function__ (and perhaps also > __module__)? See PEP 3130 "Access to Current Module/Class/Function" (rejected) (http://www.python.org/dev/peps/pep-3130/) -- Arnaud -- http://mail.python.org/mailman/listinfo/python-list

Re: Modifying Class Object

2010-02-10 Thread Steven D'Aprano
On Wed, 10 Feb 2010 21:02:14 +0100, Alf P. Steinbach wrote: > "pointer" refers to a copyable reference value as seen from the Python > level, in the same way as "pointer" is used by e.g. the Java language > spec. Python doesn't have "copyable reference values" in the Python level. It has objects

Re: Function attributes

2010-02-10 Thread Gabriel Genellina
En Wed, 10 Feb 2010 10:59:41 -0300, Muhammad Alkarouri escribió: What is the simplest way to access the attributes of a function from inside it, other than using its explicit name? In a function like f below: def f(*args): f.args = args print args is there any other way? See this:

Re: Need debugging knowhow for my creeping Unicodephobia

2010-02-10 Thread Chris Rebert
On Wed, Feb 10, 2010 at 1:03 PM, kj wrote: > In <402ac982-0750-4977-adb2-602b19149...@m24g2000prn.googlegroups.com> Jonathan Gardner writes: >>It sounds like someone, probably beautiful soup, is trying to turn >>your strings into unicode. A full stacktrace would be useful to see >>who did what w

Re: Function attributes

2010-02-10 Thread Arnaud Delobelle
Steven D'Aprano writes: > On Wed, 10 Feb 2010 18:31:23 +, Arnaud Delobelle wrote: > >> It's not ideal, but you can use a decorator like this to solve this >> problem: >> >> def bindfunction(f): >> def bound_f(*args, **kwargs): >> return f(bound_f, *args, **kwargs) >> bound_f.

Re: Need debugging knowhow for my creeping Unicodephobia

2010-02-10 Thread Stephen Hansen
On Wed, Feb 10, 2010 at 1:03 PM, kj wrote: > >What are y and z? > > x = "%s %s" % (table['id'], table.tr.renderContents()) > > where the variable table represents a BeautifulSoup.Tag instance. > > >Are they unicode or strings? > > The first item (table['id']) is unicode, and the second is str.

Re: "if {negative}" vs. "if {positive}" style

2010-02-10 Thread Gerald Britton
On Wed, Feb 10, 2010 at 3:56 PM, Ethan Furman wrote: > Tim Chase wrote: >> >> Any thoughts on how others make the choice? >> >> -tkc > > If one branch is only a few lines, it comes first.  As often as not, that > tiny branch is checking for errors, and the "else" branch doesn't need to be > indent

Re: A silly question on file opening

2010-02-10 Thread Steven D'Aprano
On Wed, 10 Feb 2010 12:42:17 -0800, joy99 wrote: > I tried to change the location to D:\file and as I saw in Python Docs > the file reading option is now "r+" so I changed the statement to >file_open=open("D:\file","r+") > but it is still giving error. You should copy and paste (do not re-ty

Re: Creating formatted output using picture strings

2010-02-10 Thread Chris Rebert
On Wed, Feb 10, 2010 at 12:19 PM, sstein...@gmail.com wrote: > On Feb 10, 2010, at 2:57 PM, Grant Edwards wrote: >> On 2010-02-10, pyt...@bdurham.com wrote: >> >> [regardning "picture" output format specifiers] >> >>> I was thinking that there was a built-in function for this >>> common(?) use ca

Re: New to Python

2010-02-10 Thread Stephen Hansen
On Wed, Feb 10, 2010 at 2:21 AM, Quin wrote: > Well, PyScripter works find with that code. Furthermore, the > un-intellisense in IronPython was problematic, inserting the wrong things, > which I had to erase. > I think you're confused and are comparing apples to oranges. To define a couple term

Re: Modifying Class Object

2010-02-10 Thread Steve Holden
Alf P. Steinbach wrote: > * Duncan Booth: >> "Alf P. Steinbach" wrote: >> In CPython objects once created remain in the same memory location (and their id is their address). Compare that to IronPython where the objects themselves can move around in memory so they have no fixed

Re: Modifying Class Object

2010-02-10 Thread Ethan Furman
Steven D'Aprano wrote: Believe me Alf, the fact that people are taking the time to try to argue with you instead of just kill-filing you is a compliment. It's a compliment I am not paying, although I am grateful to those who are attempting to teach him. At the rate it's going, though, I don

Re: Need debugging knowhow for my creeping Unicodephobia

2010-02-10 Thread kj
In <402ac982-0750-4977-adb2-602b19149...@m24g2000prn.googlegroups.com> Jonathan Gardner writes: >On Feb 10, 11:09=A0am, kj wrote: >> FWIW, I'm using Python 2.6. =A0The example above happens to come from >> a script that extracts data from HTML files, which are all in >> English, but they are a

Re: A silly question on file opening

2010-02-10 Thread Anthony Tolle
On Feb 10, 3:42 pm, joy99 wrote: > Dear Group, > [snip] > I tried to change the location to D:\file and as I saw in Python Docs > the file reading option is now "r+" so I changed the statement to >    file_open=open("D:\file","r+") > but it is still giving error. Only use "r+" if you need to also

Re: Creating formatted output using picture strings

2010-02-10 Thread sstein...@gmail.com
On Feb 10, 2010, at 3:40 PM, Grant Edwards wrote: > On 2010-02-10, sstein...@gmail.com wrote: >> On Feb 10, 2010, at 2:57 PM, Grant Edwards wrote: >> >>> On 2010-02-10, pyt...@bdurham.com wrote: >>> >>> [regardning "picture" output format specifiers] >>> I was thinking that there was a

Re: "if {negative}" vs. "if {positive}" style

2010-02-10 Thread Ethan Furman
Tim Chase wrote: Any thoughts on how others make the choice? -tkc If one branch is only a few lines, it comes first. As often as not, that tiny branch is checking for errors, and the "else" branch doesn't need to be indented. def func(arg1): if arg1 is 'stupid': raise ValueErr

A silly question on file opening

2010-02-10 Thread joy99
Dear Group, I was using Python with IDLE as GUI for quite some time. My Operating System was Windows XP with Service Pack2. Recently I changed the Operating System to Windows XP with Service Pack3. I had to reinstall Python for which I downloaded "python-2.6.4.msi"and loaded it in my D drive. Her

Re: Creating formatted output using picture strings

2010-02-10 Thread Grant Edwards
On 2010-02-10, sstein...@gmail.com wrote: > On Feb 10, 2010, at 2:57 PM, Grant Edwards wrote: > >> On 2010-02-10, pyt...@bdurham.com wrote: >> >> [regardning "picture" output format specifiers] >> >>> I was thinking that there was a built-in function for this >>> common(?) use case >> >> I hav

Re: Creating formatted output using picture strings

2010-02-10 Thread Tim Chase
Grant Edwards wrote: [regardning "picture" output format specifiers] I was thinking that there was a built-in function for this common(?) use case I haven't seen that paradigm since my one-and-only exposure to COBOL in a class I took back in 1979. Is the "picture" thing commonly used in other

Re: New to Python

2010-02-10 Thread Terry Reedy
On 2/10/2010 5:21 AM, Quin wrote: Well, PyScripter works find with that code. Furthermore, the un-intellisense in IronPython was problematic, inserting the wrong things, which I had to erase. Also, there were some code constructs IronPython let pass that PyScripter didn't, namely, print(), PySc

Re: Need debugging knowhow for my creeping Unicodephobia

2010-02-10 Thread Anthony Tolle
On Feb 10, 2:09 pm, kj wrote: > Some people have mathphobia.  I'm developing a wicked case of > Unicodephobia. > [snip] Some general advice (Looks like I am reiterating what MRAB said -- I type slower :): 1. If possible, use unicode strings for everything. That is, don't use both str and unicod

Re: Creating formatted output using picture strings

2010-02-10 Thread sstein...@gmail.com
On Feb 10, 2010, at 2:57 PM, Grant Edwards wrote: > On 2010-02-10, pyt...@bdurham.com wrote: > > [regardning "picture" output format specifiers] > >> I was thinking that there was a built-in function for this >> common(?) use case > > I haven't seen that paradigm since my one-and-only exposure

SocketServer error: AttributeError: instance has no __call__ method

2010-02-10 Thread Jordan Apgar
Hey guys, I'm having some issues connecting to my Socket Server, I get this traceback on the sever side: Exception happened during processing of request from ('127.0.0.1', 56404) Traceback (most recent call last): File "/usr/lib/python2.6/SocketServer.py"

Re: Modifying Class Object

2010-02-10 Thread Alf P. Steinbach
* Steven D'Aprano: On Wed, 10 Feb 2010 09:13:22 +0100, Alf P. Steinbach wrote: You've dismissed at least one of my arguments with a simple hand-waving of, "That's invalid, cuz." That is not a quote of me. It is a lie. Alf, although your English in this forum has been excellent so far, I und

Re: Need debugging knowhow for my creeping Unicodephobia

2010-02-10 Thread MRAB
kj wrote: Some people have mathphobia. I'm developing a wicked case of Unicodephobia. I have read a *ton* of stuff on Unicode. It doesn't even seem all that hard. Or so I think. Then I start writing code, and WHAM: UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 0: ord

Re: Modifying Class Object

2010-02-10 Thread Alf P. Steinbach
* Duncan Booth: "Alf P. Steinbach" wrote: In CPython objects once created remain in the same memory location (and their id is their address). Compare that to IronPython where the objects themselves can move around in memory so they have no fixed address. Try comparing the IronPython implementa

Re: Creating formatted output using picture strings

2010-02-10 Thread Grant Edwards
On 2010-02-10, pyt...@bdurham.com wrote: [regardning "picture" output format specifiers] > I was thinking that there was a built-in function for this > common(?) use case I haven't seen that paradigm since my one-and-only exposure to COBOL in a class I took back in 1979. Is the "picture" thing

Re: Need debugging knowhow for my creeping Unicodephobia

2010-02-10 Thread Duncan Booth
kj wrote: > But to ground > the problem a bit I'll say that the exception above happens during > the execution of a statement of the form: > > x = '%s %s' % (y, z) > > Also, I found that, with the exact same values y and z as above, > all of the following statements work perfectly fine: > >

Re: Creating formatted output using picture strings

2010-02-10 Thread MRAB
Tim Chase wrote: pyt...@bdurham.com wrote: Original poster here. Thank you all for your ideas. I certainly learned some great techniques by studying everyone's solutions!! Thanks for the positive feedback -- it's something most folks like to hear when they try to assist and such thanks appea

Re: Need debugging knowhow for my creeping Unicodephobia

2010-02-10 Thread Jonathan Gardner
On Feb 10, 11:09 am, kj wrote: > > UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 0: > ordinal not in range(128) > You'll have to understand some terminology first. "codec" is a description of how to encode and decode unicode data to a stream of bytes. "decode" means you

Need debugging knowhow for my creeping Unicodephobia

2010-02-10 Thread kj
Some people have mathphobia. I'm developing a wicked case of Unicodephobia. I have read a *ton* of stuff on Unicode. It doesn't even seem all that hard. Or so I think. Then I start writing code, and WHAM: UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 0: ordinal not i

Re: Function attributes

2010-02-10 Thread Steven D'Aprano
On Wed, 10 Feb 2010 18:31:23 +, Arnaud Delobelle wrote: > It's not ideal, but you can use a decorator like this to solve this > problem: > > def bindfunction(f): > def bound_f(*args, **kwargs): > return f(bound_f, *args, **kwargs) > bound_f.__name__ = f.__name__ > return b

Re: Creating formatted output using picture strings

2010-02-10 Thread donn
On 10/02/2010 20:36, pyt...@bdurham.com wrote: def picture(s, pic, placeholder='@'): nextchar=iter(s).next return ''.join(nextchar() if i == placeholder else i for i in pic) Hell's teeth - even I understood that! Amazing solution. \d -- Fonty Python and Things! -- http://otherwise.re

Re: Function attributes

2010-02-10 Thread Steven D'Aprano
On Wed, 10 Feb 2010 17:23:36 +, MRAB wrote: > Stephen Hansen wrote: >> On Wed, Feb 10, 2010 at 6:36 AM, Steven D'Aprano >> > > wrote: >> >> On Wed, 10 Feb 2010 05:59:41 -0800, Muhammad Alkarouri wrote: >> > What is the simplest way to acce

Re: Creating formatted output using picture strings

2010-02-10 Thread python
Arnaud, Very cool!! Just when I thought the problem couldn't be made simpler ... WOW!!! Again, a big thank you to everyone who posted solutions!!! I'm humbled at how clever and different everyone's techniques have been. I have to say, I learned much more than I thought I needed to learn :) Tha

Re: Function attributes

2010-02-10 Thread Arnaud Delobelle
Steven D'Aprano writes: > On Wed, 10 Feb 2010 10:08:47 -0500, John Posner wrote: > >>> This won't work correctly, because old_f still tries to refer to itself >>> under the name "f", and things break very quickly. >> >> They didn't break immediately for me -- what am I missing?: > > The original

Re: Python and Ruby

2010-02-10 Thread Andreas Waldenburger
On Wed, 10 Feb 2010 09:51:11 -0500 Steve Holden wrote: > [snip] > It's as sensible to complain about people being "*forced* to keep > perfect indentation" as it is to complain about people being *forced* > to use braces to delimit code blocks. > > This is called "syntax", and it's a part of the

  1   2   >