Re: Logic operators with in statement

2009-11-16 Thread Chris Rebert
On Mon, Nov 16, 2009 at 6:02 AM, Mr.SpOOn mr.spoo...@gmail.com wrote: Hi, I'm trying to use logical operators (or, and) with the in statement, but I'm having some problems to understand their behavior. In [1]: l = ['3', 'no3', 'b3'] In [2]: '3' in l Out[2]: True In [3]: '3' and '4' in l

Re: Logic operators with in statement

2009-11-16 Thread Chris Rebert
On Mon, Nov 16, 2009 at 6:08 AM, Mr.SpOOn mr.spoo...@gmail.com wrote: Sorry for replying to myself, but I think I understood why I was wrong. The correct statement should be something like this: In [13]: ('b3' and '5') in l or ('3' and 'b3') in l Out[13]: True No, you've just run into

Re: Logic operators with in statement

2009-11-16 Thread Chris Rebert
On Mon, Nov 16, 2009 at 6:23 AM, Xavier Ho cont...@xavierho.com wrote: snip '3' in l and 'no3' in l True AND operator has a higher precedence, so you don't need any brackets here, I think. But anyway, you have to use it like that. So that's something you'll have to fix first. Er, you mean

Re: Language mavens: Is there a programming with if then else ENDIF syntax?

2009-11-16 Thread Chris Rebert
On Mon, Nov 16, 2009 at 8:54 AM, Steve Ferg steve.ferg.bitbuc...@gmail.com wrote: This is a question for the language mavens that I know hang out here. It is not Python related, except that recent comparisons of Python to Google's new Go language brought it to mind. NOTE that this is *not* a

Re: Web servers

2009-11-16 Thread Chris Rebert
On Mon, Nov 16, 2009 at 11:17 AM, Virgil Stokes v...@it.uu.se wrote: Any suggestions on using Python to connect to Web servers (e.g. to access financial time series data)? In what format? Using what protocol? (*Insert other basic questions that need answering in order to answer your question

Re: Changing the current directory (full post)

2009-11-16 Thread Chris Rebert
On Mon, Nov 16, 2009 at 11:36 AM, vsoler vicente.so...@gmail.com wrote: On Nov 16, 2:35 am, Gabriel Genellina gagsl-...@yahoo.com.ar wrote: En Sun, 15 Nov 2009 09:04:06 -0300, vsoler vicente.so...@gmail.com escribió: Ever since I installed my Python 2.6 interpreter (I use IDLE), I've been

Re: Changing the current directory (full post)

2009-11-16 Thread Chris Rebert
On Mon, Nov 16, 2009 at 11:56 AM, vsoler vicente.so...@gmail.com wrote: On Nov 16, 8:45 pm, Chris Rebert c...@rebertia.com wrote: On Mon, Nov 16, 2009 at 11:36 AM, vsoler vicente.so...@gmail.com wrote: On Nov 16, 2:35 am, Gabriel Genellina gagsl-...@yahoo.com.ar wrote: En Sun, 15 Nov 2009

Re: faster than list.extend()

2009-11-16 Thread Chris Rebert
On Mon, Nov 16, 2009 at 2:30 PM, Hyunchul Kim hyunchul.mail...@gmail.com wrote: Hi, all. I want to improve speed of following simple function. Any suggestion? ** def triple(inputlist):   results = []   for x in inputlist:     results.extend([x,x,x])   return results **

Re: Get attribute this way

2009-11-16 Thread Chris Rebert
On Mon, Nov 16, 2009 at 10:04 PM, King animator...@gmail.com wrote: Python's getattr, setattr and __getattribute__ commands works fine with python types. For example: print o.__getattribute__(name) print getattr(o, name) This is the easiest way to get an attribute using a string. In my

Re: Get attribute this way

2009-11-16 Thread Chris Rebert
On Mon, Nov 16, 2009 at 10:53 PM, King animator...@gmail.com wrote: Writing/Reading data to xml is not a problem. The problem is when I have to write to attributes in xml, where a connections has been established. XML: Connection sourceattribute=node1.gradient.colors[0][1]

Re: Accessing a Web server --- how?

2009-11-17 Thread Chris Rebert
On Mon, Nov 16, 2009 at 2:14 AM, Virgil Stokes v...@it.uu.se wrote: If one goes to the following URL: http://www.nordea.se/Privat/Spara%2boch%2bplacera/Strukturerade%2bprodukter/Aktieobligation%2bNr%2b99%2bEuropa%2bAlfa/973822.html it contains a link (click on Current courses NBD AT99 3113A)

Re: TODO and FIXME tags

2009-11-17 Thread Chris Rebert
2009/11/16 Yasser Almeida Hernández pedro...@fenhi.uh.cu: Hi all.. Sorry if this question sound elemental. How is the sintaxis for set the TODO and FIXME tags...? There is no special syntax for those. Some people use them in comments, but it's just a convention. Cheers, Chris --

Re: Code for finding the 1000th prime

2009-11-17 Thread Chris Rebert
On Tue, Nov 17, 2009 at 9:27 AM, Diez B. Roggisch de...@nospam.web.de wrote: Stefan Behnel wrote: Robert P. J. Day, 15.11.2009 15:44: Now, all that's left to do is write a prime number generator (a random number generator will do, too, but writing a good one isn't easy), run it repeatedly in

Re: python simply not scaleable enough for google?

2009-11-17 Thread Chris Rebert
On Tue, Nov 17, 2009 at 8:41 AM, Rustom Mody rustompm...@gmail.com wrote: Language L is (in)efficient. No! Only implementations are (in)efficient I am reminded of a personal anecdote.  It happened about 20 years ago but is still fresh and this thread reminds me of it. I was attending some

Re: TypeError: unsupported operand types for +: 'NoneType' and 'str'

2009-11-17 Thread Chris Rebert
On Tue, Nov 17, 2009 at 7:25 PM, aurfal...@gmail.com wrote: snip The error I get; File myscript.py, Line 18, in ? projectpath = ourHome+/etc/TEMPLATE TypeError: unsupported operand type(s) for +: 'NoneType' and 'str' Python 2.4.3 I've read were when passing a string to exec may need to

Re: WindowsError is not available on linux?

2009-11-17 Thread Chris Rebert
On Tue, Nov 17, 2009 at 7:37 PM, Peng Yu pengyu...@gmail.com wrote: On Tue, Nov 17, 2009 at 9:18 PM, alex23 wuwe...@gmail.com wrote: Peng Yu pengyu...@gmail.com wrote: But the document doesn't say shutil need to be imported in order to use WindowsError. Shall the document or the code be

Re: Running a python script from interactive mode

2009-11-17 Thread Chris Rebert
On Tue, Nov 17, 2009 at 8:56 PM, ashwini yal ashwini...@gmail.com wrote: Hi, I am trying to run a python script from interactive mode ,but i am not able to know how to run it? Is it possible? if yes please let me how to run the script? execfile(/path/to/the/script.py) or if it's on your

Re: Language mavens: Is there a programming with if then else ENDIF syntax?

2009-11-18 Thread Chris Rebert
On Wed, Nov 18, 2009 at 1:15 AM, Steve Howell showel...@yahoo.com wrote: On the topic of switch statements and even-more-concise-then-we-have- already if/elif/else/end constructs, I have to say that Python does occasionally force you to write code like the code below.  Maybe force is too

Re: break LABEL vs. exceptions + PROPOSAL

2009-11-18 Thread Chris Rebert
On Wed, Nov 18, 2009 at 4:05 AM, Lo'oris loo...@gmail.com wrote: I've found this email, back from 10 years ago: http://mail.python.org/pipermail/python-list/1999-September/009983.html I guess it went unnoticed, because that proposal looks really intresting. • break labels have been refused

Re: Minimally intrusive XML editing using Python

2009-11-18 Thread Chris Rebert
On Wed, Nov 18, 2009 at 4:55 AM, Thomas Lotze tho...@thomas-lotze.de wrote: I wonder what Python XML library is best for writing a program that makes small modifications to an XML file in a minimally intrusive way. By that I mean that information the program doesn't recognize is kept, as are

Re: DOM related question and problem

2009-11-18 Thread Chris Rebert
On Wed, Nov 18, 2009 at 10:04 AM, elca high...@gmail.com wrote: Hello, these day im making python script related with DOM. problem is these day many website structure is very complicate . what is best method to check DOM structure and path.. i mean...following is some example. what is

Re: DeprecationWarning on md5

2009-11-18 Thread Chris Rebert
On Wed, Nov 18, 2009 at 5:23 PM, Zeynel azeyn...@gmail.com wrote: Hello, I am a newbie both in Scrapy and Python. When I create a project with Scrapy I get these errors: C:\Python26\lib\site-packages\twisted\python\filepath.py:12: DeprecationWarning: the sha module is deprecated; use the

Re: combinatorics via __future__ generators

2009-11-18 Thread Chris Rebert
On Wed, Nov 18, 2009 at 4:58 PM, Phlip phlip2...@gmail.com wrote: Python: I have a quaint combinatorics problem. Before I solve it, or find a solution among generators, I thought y'all might like to show off any solutions. Given an array like this...  [0, 4, 3] Produce an array like

Re: What is the naming convention for accessor of a 'private' variable?

2009-11-18 Thread Chris Rebert
On Wed, Nov 18, 2009 at 6:27 PM, Peng Yu pengyu...@gmail.com wrote: http://www.python.org/dev/peps/pep-0008/ The above webpage states the following naming convention. Such a variable can be an internal variable in a class. I'm wondering what is the naming convention for the method that access

Re: Invitation to connect on LinkedIn

2009-11-18 Thread Chris Rebert
On Wed, Nov 18, 2009 at 6:16 PM, Jim Qiu bluefishe...@gmail.com wrote: LinkedIn Jim Qiu requested to add you as a connection on LinkedIn: Jaime, I'd like to add you to my professional network on LinkedIn. - Jim Accept View invitation from Jim Qiu WHY MIGHT CONNECTING WITH JIM QIU

Re: convert a string to a regex?

2009-11-18 Thread Chris Rebert
On Wed, Nov 18, 2009 at 6:51 PM, Peng Yu pengyu...@gmail.com wrote: There are many special characters listed on http://docs.python.org/library/re.html I'm wondering if there is a convenient function that can readily convert a string with the special characters to its corresponding regex. For

Re: What is the naming convention for accessor of a 'private' variable?

2009-11-18 Thread Chris Rebert
On Wed, Nov 18, 2009 at 7:04 PM, Peng Yu pengyu...@gmail.com wrote: On Wed, Nov 18, 2009 at 8:47 PM, Chris Rebert c...@rebertia.com wrote: On Wed, Nov 18, 2009 at 6:27 PM, Peng Yu pengyu...@gmail.com wrote: http://www.python.org/dev/peps/pep-0008/ The above webpage states the following naming

Re: crontab problem

2009-11-21 Thread Chris Rebert
On Sat, Nov 21, 2009 at 5:47 AM, Victor Subervi victorsube...@gmail.com wrote: Hi; I have the following in crontab -eu root: @daily /usr/local/bin/mysql-backup-daily.sh @weekly /usr/local/bin/mysql-backup-weekly.sh @monthly /usr/local/bin/mysql-backup-monthly.sh [r...@13gems

Re: Sorting: too different times. Why?

2009-11-22 Thread Chris Rebert
On Sun, Nov 22, 2009 at 2:56 AM, n00m n...@narod.ru wrote: I was expecting the 1st method would be *slower* than the 2nd one :-) Or at least equal... Just random (intuitive) expectations The second method repeatedly looks up left_item.__class__.__cmp__ (i.e. Vector.__cmp__) when doing the

Re: Why Python allows comparison of a callable and a number?

2009-11-22 Thread Chris Rebert
On Sun, Nov 22, 2009 at 4:03 AM, 一首诗 newpt...@gmail.com wrote: I used python to write an assignment last week, here is a code snippet # def departTime():    '''    Calculate the time to depart a packet.    '''    if(random.random 0.8):        t =

Re: attributes, properties, and accessors -- philosophy

2009-11-23 Thread Chris Rebert
On Mon, Nov 23, 2009 at 10:52 AM, Ethan Furman et...@stoneleaf.us wrote: The problem I have with properties is my typing.  I'll end up assigning to an attribute, but get the spelling slightly wrong (capitalized, or missing an underscore -- non-obvious things when bug-hunting), so now I have an

Re: pointless musings on performance

2009-11-24 Thread Chris Rebert
On Tue, Nov 24, 2009 at 4:31 AM, Rob Williscroft r...@freenet.co.uk wrote: mk wrote in news:mailman.915.1259064240.2873.python-l...@python.org in comp.lang.python: def pythonic(): def unpythonic(): Decidedly counterintuitive: are there special optimizations for if nonevar: type of

Re: attributes, properties, and accessors -- philosophy

2009-11-24 Thread Chris Rebert
On Tue, Nov 24, 2009 at 9:39 AM, Ethan Furman et...@stoneleaf.us wrote: Bruno Desthuilliers wrote: Ethan Furman a écrit : The problem I have with properties is my typing.  I'll end up assigning to an attribute, but get the spelling slightly wrong (capitalized, or missing an underscore --

Re: get line number and filename in a source file

2009-11-24 Thread Chris Rebert
On Tue, Nov 24, 2009 at 9:47 PM, Peng Yu pengyu...@gmail.com wrote: __LINE__ __FILE__ in C++ can give the current line number and filename. Is there a similar thing in python that can give me the current line number and filename? import inspect filename, linenum, funcname =

Re: Can self crush itself?

2009-11-25 Thread Chris Rebert
On Wed, Nov 25, 2009 at 1:46 AM, n00m n...@narod.ru wrote: Then how can we destroy the 3rd instance, right after its creation and from inside class Moo code? Why would you want to do that in the first place? It's strange to say the least. If you want to prevent an instance being created in the

Re: Feature request: String-inferred names

2009-11-25 Thread Chris Rebert
On Wed, Nov 25, 2009 at 6:35 PM, The Music Guy fearsomedragon...@gmail.com wrote: Hello all, I just posted to my blog about a feature that I'd like to see added to Python. Before I go through the trouble of learning how to write a PEP or how to extend the Python interpreter, I want to know

Re: semantics of ** (unexpected/inconsistent?)

2009-11-29 Thread Chris Rebert
On Sun, Nov 29, 2009 at 4:39 PM, Esmail ebo...@hotmail.com wrote: Ok, this is somewhat unexpected: Python 2.6.2 (release26-maint, Apr 19 2009, 01:56:41) [GCC 4.3.3] on linux2 Type help, copyright, credits or license for more information. -3**2 -9 x = -3 x**2 9 I would have

Re: Noobie python shell question

2009-11-29 Thread Chris Rebert
On Sun, Nov 29, 2009 at 7:53 PM, Tim Chase python.l...@tim.thechases.com wrote: snip (as an aside, is there a way to get a local/global variable from a string like one can fetch a variable from a class/object with getattr()?  Something like getattr(magic_namespace_here, hello) used in the above

Re: Unpacking Tuples

2009-11-30 Thread Chris Rebert
On Mon, Nov 30, 2009 at 12:17 AM, Joel Davis callmeclaud...@gmail.com wrote: I hate to post such a simple Q and A here, but I seriously can't find it anywhere. Python (unsure of starting with which version) enables the remainder of the tuple to be placed in a catch-all, for example: myTuple

Re: python and vc numbers

2009-11-30 Thread Chris Rebert
On Mon, Nov 30, 2009 at 2:02 AM, Daniel Dalton d.dal...@iinet.net.au wrote: On Mon, Nov 30, 2009 at 07:20:59PM +1100, Daniel Dalton wrote: That did the trick, thanks, after I append [-2] Further testing under screen says otherwise -- it seems to give me the tty number, not the virtual

Re: semantics of ** (unexpected/inconsistent?)

2009-11-30 Thread Chris Rebert
On Mon, Nov 30, 2009 at 3:46 AM, Gregory Ewing greg.ew...@canterbury.ac.nz wrote: Esmail wrote: Wow .. never heard of Concatenative_languages languages before or the distinction you make. Your distinction explains the behavior, but I find it somewhat counter-intuitive. You shouldn't find

Re: Function parameters list

2009-12-01 Thread Chris Rebert
On Tue, Dec 1, 2009 at 12:15 AM, Nadav Chernin nada...@qualisystems.com wrote: Hello, all I need to know dynamically parameters of any function (prototype). Is there some way to get it? The `inspect` module: http://docs.python.org/library/inspect.html#inspect.getargspec

Re: python bijection

2009-12-01 Thread Chris Rebert
On Tue, Dec 1, 2009 at 5:17 PM, Aahz a...@pythoncraft.com wrote: In article 85100df7-a8b0-47e9-a854-ba8a8a2f3...@r31g2000vbi.googlegroups.com, Joshua Bronson  jabron...@gmail.com wrote: I noticed the phonebook example in your ActiveState recipe and thought you might consider changing it to

Re: commands module for windows

2009-12-01 Thread Chris Rebert
On Tue, Dec 1, 2009 at 10:05 PM, M Kumar tomanis...@gmail.com wrote: Is there any python module for windows which is equivalent to commands module in linux? `subprocess` should work: http://docs.python.org/library/subprocess.html The `commands` docs even say: The subprocess module provides

Re: commands module for windows

2009-12-01 Thread Chris Rebert
On Wed, Dec 2, 2009 at 11:42 AM, Chris Rebert c...@rebertia.com wrote: On Tue, Dec 1, 2009 at 10:05 PM, M Kumar tomanis...@gmail.com wrote: Is there any python module for windows which is equivalent to commands module in linux? `subprocess` should work: http://docs.python.org/library

Re: Don't Understand This Error

2009-12-02 Thread Chris Rebert
On Wed, Dec 2, 2009 at 2:33 AM, Victor Subervi victorsube...@gmail.com wrote: I get the following error:  /var/www/html/angrynates.com/cart/chooseOptions.py     8 from login import login     9 import string    10 import options    11 from particulars import optionsTables, addStore    12

Re: prolog with python

2009-12-02 Thread Chris Rebert
On Wed, Dec 2, 2009 at 6:47 PM, William Heath wghe...@gmail.com wrote: Hi All, I have the following prolog program that I would really like to be able to run in python in some elegant way: From googling: http://pyke.sourceforge.net/ http://code.activestate.com/recipes/303057/ Cheers, Chris

Re: Declaring a class level nested class?

2009-12-02 Thread Chris Rebert
On Wed, Dec 2, 2009 at 8:55 PM, cmckenzie mckenzi...@gmail.com wrote: Hi. I'm new to Python, but I've managed to make some nice progress up to this point. After some code refactoring, I ran into a class design problem and I was wondering what the experts thought. It goes something like this:

Re: Help with function prototype

2009-12-03 Thread Chris Rebert
On Thu, Dec 3, 2009 at 3:02 AM, Nadav Chernin nada...@qualisystems.com wrote: Hi, all In past I asked about module – inspect, that can’t to get me prototype of C-implemented functions ( usually all built-in functions ). But, still I see that all Python Editors ( IDLE for example ) can to

Re: Directly converting Python to C using the C API

2009-12-03 Thread Chris Rebert
On Thu, Dec 3, 2009 at 6:09 PM, Emmanuel Bengio beng...@gmail.com wrote: I'm fairly new to the python world, and I often heard critics about it's speed, and also about it's non-compilability. Then I thought, there is a complete C API that manages Python itself. Would it be feasible to

Re: read from standard input

2009-12-04 Thread Chris Rebert
On Fri, Dec 4, 2009 at 9:37 PM, Siva B sivait...@gmail.com wrote: Hi all, I wrote a program to read some data through standard input and write in a file. the following code works fine in linux. but its giving ArgumentError in windows. There's no such error in Python; you're thinking of

Re: read from standard input

2009-12-04 Thread Chris Rebert
On Sat, Dec 5, 2009 at 11:54 AM, Chris Rebert c...@rebertia.com wrote: On Fri, Dec 4, 2009 at 9:37 PM, Siva B sivait...@gmail.com wrote: Hi all, I wrote a program to read some data through standard input and write in a file. the following code works fine in linux. but its giving

Re: How to create a docstring for a module?

2009-12-06 Thread Chris Rebert
On Sun, Dec 6, 2009 at 12:34 PM, Dr. Phillip M. Feldman pfeld...@verizon.net wrote: OK.  I was able to reproduce the problem.  My difficulty was that the command that I issued initially was from xyz import * rather than just import xyz.  If I say import xyz, then the docstring is defined; if I

Re: dict.fromkeys strange behavior

2009-12-07 Thread Chris Rebert
On Mon, Dec 7, 2009 at 12:42 AM, Tsviki Hirsh tsviki.hi...@gmail.com wrote: Dear list, I'm trying to create a dictionary from set of keys and values using dict.fromkeys When I type: dict.fromkeys('a',50) the output is: {'a': 50} This is fine, but when I try to set the same value to a

Re: hola

2009-12-07 Thread Chris Rebert
2009/12/6 franki fuentes cueto ffrankis...@gmail.com: hola soy un pequeño programador y quiesiera pedirles ayuda para programar en python, no se si me podrian mandar ejemplos para poder empezar, y como terminarlo para que se ejecute, me entiendes , aver sime ayudan gracias Esta lista de

Re: switch

2009-12-08 Thread Chris Rebert
On Tue, Dec 8, 2009 at 5:53 PM, hong zhang henryzhan...@yahoo.com wrote: Python does not have switch statement. Any other option does similar work? Yes, a dictionary with functions as values: http://simonwillison.net/2004/May/7/switch/ Cheers, Chris -- http://blog.rebertia.com --

Re: Generating diagrams from PostgreSQL with Python (Re: postgresql_autodoc in Python?)

2009-12-10 Thread Chris Rebert
On Thu, Dec 10, 2009 at 3:48 AM, Diez B. Roggisch de...@nospam.web.de wrote: Wolfgang Keller wrote: Hello, I will re-precise my question: Has anyone ever implemented a script in Python that generates documentation (especially diagrams, in a format such as e.g. Dia, Inkscape SVG or Tikz)

Re: read text file byte by byte

2009-12-13 Thread Chris Rebert
On Sun, Dec 13, 2009 at 12:20 AM, Michel Claveau - MVP enleverlesx_xx...@xmclavxeaux.com.invalid wrote: Hi! If it's a binary file... OK, but... what is a binary file? http://en.wikipedia.org/wiki/Binary_file Cheers, Chris -- http://blog.rebertia.com --

Re: unable to read the __main__ namespace

2009-12-13 Thread Chris Rebert
On Sun, Dec 13, 2009 at 3:20 AM, vsoler vicente.so...@gmail.com wrote: I'm learning Python, and I am very fond of it. Using Python 2.6 I am able to list all the names in a class namespace: class abc: pass abc.a1=7 abc.a2='Text' print abc.__dict__.keys() That is more simply written as:

Re: insert unique data in a list

2009-12-13 Thread Chris Rebert
On Sun, Dec 13, 2009 at 5:19 PM, knifenomad knifeno...@gmail.com wrote: On 12월14일, 오전2시57분, mattia ger...@gmail.com wrote: Il Sun, 13 Dec 2009 16:37:20 +, mattia ha scritto: How can I insert non-duplicate data in a list? I mean, is there a particular option in the creation of a list that

Re: dictionary with tuple keys

2009-12-14 Thread Chris Rebert
On Mon, Dec 14, 2009 at 9:49 PM, Brandon Devine your.mas...@gmail.com wrote: Hi all, I am probably not thinking straight anymore about this problem.  I have a dictionary with tuple keys in the format (a, b, A, B) and float values.  I want to collect all the keys with identical (a, b...),

Re: csv reader

2009-12-15 Thread Chris Rebert
On Tue, Dec 15, 2009 at 1:24 PM, Emmanuel manou...@gmail.com wrote: I have a problem with csv.reader from the library csv. I'm not able to import accentuated caracters. For example, I'm trying to import a simple file containing a single word equação using the following code: import csv

Re: Odd json encoding erro

2009-12-15 Thread Chris Rebert
On Tue, Dec 15, 2009 at 2:03 PM, Wells thewellsoli...@gmail.com wrote: I get this exception when decoding a certain JSON string: 'ascii' codec can't encode character u'\u2019' in position 8: ordinal not in range(128) The JSON data in question:

Re: Odd json encoding erro

2009-12-15 Thread Chris Rebert
On Tue, Dec 15, 2009 at 3:04 PM, Wells thewellsoli...@gmail.com wrote: Sorry- more detail- the actual problem is an exception thrown when running str() on the value, like so: a = u'St. Paul\u2019s School For Boys (MN) HS' print str(a) Traceback (most recent call last):  File stdin, line 1,

Re: strptime not strict enough

2009-12-15 Thread Chris Rebert
On Tue, Dec 15, 2009 at 9:47 PM, Tim Roberts t...@probo.com wrote: Tobias Weber t...@gmx.net wrote: despite the directives for leading zero stime.strptime('09121', '%y%m%d') returns the first of December. Shouldn't it raise ValueError? Python merely calls the strptime function in your C

Re: Storing a Value in a Cookie

2009-12-16 Thread Chris Rebert
On Wed, Dec 16, 2009 at 1:13 AM, Victor Subervi victorsube...@gmail.com wrote: Hi; From what I've studied and gotten working about cookies, it seems one can store only a certain few pieces of information--expiration, path, comment, domain, max-age, version and last visit--but how is it useful

Re: Can't Iterate

2009-12-16 Thread Chris Rebert
On Wed, Dec 16, 2009 at 11:26 PM, Victor Subervi victorsube...@gmail.com wrote: Hi; I have this line of code: for store in ourStores(): which is called from the statement: from particulars import ourStores The latter file has the following: def ourStores():   return ['prescriptions',

Re: py itertools?

2009-12-19 Thread Chris Rebert
On Sat, Dec 19, 2009 at 2:54 AM, mattia ger...@gmail.com wrote: Hi all, I need to create the permutation of two strings but without repeat the values, e.g. 'ab' for me is equal to 'ba'. Here is my solution, but maybe the python library provides something better: def mcd(a, b): ...     if b

Re: Class variables static by default?

2009-12-19 Thread Chris Rebert
On Sat, Dec 19, 2009 at 8:16 PM, Steven D'Aprano st...@remove-this-cybersource.com.au wrote: On Sun, 20 Dec 2009 11:44:11 +1100, Lie Ryan wrote: In python, 'class variable' is a variable that belongs to a class; not to the instance and is shared by all instance that belong to the class.

Re: Something Like os.environ['HTTP_REFERER']

2009-12-20 Thread Chris Rebert
On Sun, Dec 20, 2009 at 2:06 AM, Victor Subervi victorsube...@gmail.com wrote: Hi; I'm looking for something like os.environ['HTTP_REFERER'] but for python scripts. That is, if I have a script that is imported by another script, how can I have the script that is being imported determine which

Re: Mails encoding

2009-12-20 Thread Chris Rebert
On Sun, Dec 20, 2009 at 2:46 AM, Lord Eldritch lord_eldri...@yahoo.co.uk wrote: snip - When I have: ttext='áá' I get a warning sendinme to this page http://www.python.org/peps/pep-0263.html Should I understand that PEP has been already implemented and follow it? Yes. Cheers,

Re: Import Problem

2009-12-20 Thread Chris Rebert
On Sun, Dec 20, 2009 at 3:34 AM, Victor Subervi victorsube...@gmail.com wrote: snip But I get this error: /var/www/html/angrynates.com/cart/createTables2.py   263 /html   264 '''   265   266 createTables2()   267 createTables2 = function createTables2  

Re: py itertools?

2009-12-20 Thread Chris Rebert
On Dec 19, 12:48 pm, Chris Rebert c...@rebertia.com wrote: On Sat, Dec 19, 2009 at 2:54 AM, mattia ger...@gmail.com wrote: Hi all, I need to create the permutation of two strings but without repeat the values, e.g. 'ab' for me is equal to 'ba'. Here is my solution, but maybe the python

Re: Create attribute from string

2009-12-30 Thread Chris Rebert
On Wed, Dec 30, 2009 at 9:22 PM, AON LAZIO aonla...@gmail.com wrote: Hi,     I would like to know how we could create attribute from string say I want to assign value 0.05 to an object attribute I like to input SIGNIFICANT and 0.05 and get object.SIGFICANT equals to 0.05 setattr(obj,

Re: Exception as the primary error handling mechanism?

2009-12-31 Thread Chris Rebert
On Thu, Dec 31, 2009 at 8:47 PM, Peng Yu pengyu...@gmail.com wrote: I observe that python library primarily use exception for error handling rather than use error code. In the article API Design Matters by Michi Henning Communications of the ACM Vol. 52 No. 5, Pages 46-56

Re: Significant whitespace

2010-01-01 Thread Chris Rebert
On Fri, Jan 1, 2010 at 2:02 PM, Dan Stromberg drsali...@gmail.com wrote: I put together a page about significant whitespace (and the lack thereof). You're invited to check it out: http://stromberg.dnsalias.org/~dstromberg/significant-whitespace.html For those of us who weren't around during

Re: Significant whitespace

2010-01-01 Thread Chris Rebert
On Fri, Jan 1, 2010 at 9:56 PM, Donn donn.in...@gmail.com wrote: On Saturday 02 January 2010 00:02:36 Dan Stromberg wrote: I put together a page about significant whitespace (and the lack thereof). The only thing about Python's style that worries me is that it can't be compressed like

Re: TypeError: can only concatenate list (not tuple) to list

2010-01-04 Thread Chris Rebert
On Sun, Jan 3, 2010 at 11:51 PM, Gabriel Genellina gagsl-...@yahoo.com.ar wrote: This py [1,2,3] + (4,5) Traceback (most recent call last):  File stdin, line 1, in module TypeError: can only concatenate list (not tuple) to list Given that tuples are sometimes used as a poor man's object

Re: Can't Add Variable

2010-01-04 Thread Chris Rebert
On Mon, Jan 4, 2010 at 9:28 AM, Victor Subervi victorsube...@gmail.com wrote: Hi; I have this code snippet:     sql '''create table if not exists %sCustomerData ( You're missing an equal sign there to start with (i.e. sql = '''). Cheers, Chris -- http://blog.rebertia.com --

Re: How to validate the __init__ parameters

2010-01-04 Thread Chris Rebert
On Mon, Jan 4, 2010 at 10:17 AM, Albert van der Horst alb...@spenarnc.xs4all.nl wrote: snip This triggers a question: I can see the traceback, but it would be much more valuable, if I could see the arguments passed to the functions. Is there a tool? print(locals()) #this actually gives the

Re: Newbie help- Can multiple instances with multiple names automatically created.

2010-01-04 Thread Chris Rebert
On Mon, Jan 4, 2010 at 1:32 PM, Shawn Milochik sh...@milochik.com wrote: You could put them in a dictionary with the key being the name, instead of a list. To illustrate that for the OP: name2drink = {} for booze in liquors: for juice in juices: name = juice + +booze # or however

Re: Exception as the primary error handling mechanism?

2010-01-05 Thread Chris Rebert
much snippage On Tue, Jan 5, 2010 at 1:07 AM, r0g aioe@technicalbloke.com wrote: Lie Ryan wrote: I have been looking at Haskell recently and the way the pure functional language handled exceptions and I/O gives me a new distinct insight that exceptions can be thought of as a special return

Re: Exception as the primary error handling mechanism?

2010-01-05 Thread Chris Rebert
On Tue, Jan 5, 2010 at 3:51 PM, Phlip phlip2...@gmail.com wrote: Peng Yu wrote: Otherwise, could some python expert explain to me why exception is widely used for error handling in python? Is it because the efficiency is not the primary goal of python? It's not about efficiency, it's about

Re: Exception as the primary error handling mechanism?

2010-01-05 Thread Chris Rebert
On Tue, Jan 5, 2010 at 5:45 PM, Phlip phlip2...@gmail.com wrote: On Jan 5, 5:01 pm, Chris Rebert c...@rebertia.com wrote: Why can't int('nonnumeric') return None? Errors should never pass silently. You are saying I, as the programmer, cannot decide what is an error and what is a pass-thru

Re: buffer interface problem

2010-01-07 Thread Chris Rebert
On Thu, Jan 7, 2010 at 12:19 AM, Andrew Gillanders andrew.gilland...@uqconnect.edu.au wrote: I have run into a problem running a Python script that is part of the TerraGear suite for building scenery for FlightGear. I am using Mac OS X 10.4, running Python (version 3.0.1) in a Unix terminal.

Re: buffer interface problem

2010-01-07 Thread Chris Rebert
On Thu, Jan 7, 2010 at 4:47 AM, Andrew Gillanders andrew.gilland...@uqconnect.edu.au wrote: On 07/01/2010, at 7:13 PM, Chris Rebert wrote: On Thu, Jan 7, 2010 at 12:19 AM, Andrew Gillanders andrew.gilland...@uqconnect.edu.au wrote: I have run into a problem running a Python script

Re: Recommended new way for config files

2010-01-07 Thread Chris Rebert
On Thu, Jan 7, 2010 at 10:19 AM, Peter vm...@mycircuit.org wrote: snip The .ini file is the simpliest solution, at least from the user point of view, no need to learn any python syntax. I am speaking from the point of view of a python programmer, and I find the .ini restrictions not

Re: Standardized interpreter speed evaluation tool

2010-01-08 Thread Chris Rebert
On Fri, Jan 8, 2010 at 2:25 AM, alexru tara...@gmail.com wrote: Is there any standardized interpreter speed evaluation tool? Say I made few changes in interpreter code and want to know if those changes made python any better, which test should I use? Although apparently undocumented,

Re: integer and string compare, is that correct?

2010-01-10 Thread Chris Rebert
On Sun, Jan 10, 2010 at 4:26 AM, Hellmut Weber m...@hellmutweber.de wrote: Hi, being a causal python user (who likes the language quite a lot) it took me a while to realize the following: l...@sylvester py_count $ python Python 2.6.3 (r263:75183, Oct 26 2009, 12:34:23) [GCC 4.4.1] on

Re: integer and string compare, is that correct?

2010-01-10 Thread Chris Rebert
On Sun, Jan 10, 2010 at 4:46 AM, Chris Rebert c...@rebertia.com wrote: snip The behavior of disparate types being comparable is deprecated and has been removed in Python 3.0+; don't rely upon it. Clarification: Equality testing between disparate types still works unaltered however

Re: how to duplicate array entries

2010-01-10 Thread Chris Rebert
On Sun, Jan 10, 2010 at 10:21 PM, Sebastian sebastian.lan...@gmx.de wrote: Hi there, I have an array  x=[1,2,3] Is there an operator which I can use to get the result [1,1,1,2,2,2,3,3,3] ? I tried x*3, which resulted in [1,2,3,1,2,3,1,2,3] I also tried [[b,b,b] for b in x] which led to

Re: how to duplicate array entries

2010-01-11 Thread Chris Rebert
On Mon, Jan 11, 2010 at 1:03 AM, Alf P. Steinbach al...@start.no wrote: * Steven D'Aprano: On Mon, 11 Jan 2010 08:56:36 +0100, Alf P. Steinbach wrote: * Paul Rudin: Sebastian sebastian.lan...@gmx.de writes: I have an array  x=[1,2,3] In python such an object is called a list. (In

Re: how to duplicate array entries

2010-01-11 Thread Chris Rebert
On Mon, Jan 11, 2010 at 2:20 AM, Alf P. Steinbach al...@start.no wrote: * Chris Rebert: On Mon, Jan 11, 2010 at 1:03 AM, Alf P. Steinbach al...@start.no wrote: * Steven D'Aprano: On Mon, 11 Jan 2010 08:56:36 +0100, Alf P. Steinbach wrote: * Paul Rudin: Sebastian sebastian.lan...@gmx.de

Re: os.system function

2010-01-11 Thread Chris Rebert
On Mon, Jan 11, 2010 at 12:43 PM, Zabin zabin.faris...@gmail.com wrote: Hey everyone! I am a new python programmer. I am trying to get the general file functionality with options of save and save as working. These save functions save a folder with multiple files. Upon using the os.system

Re: What is built-in method sub

2010-01-11 Thread Chris Rebert
On Mon, Jan 11, 2010 at 12:34 PM, Steven D'Aprano st...@remove-this-cybersource.com.au wrote: snip If you can avoid regexes in favour of ordinary string methods, do so. In general, something like: source.replace(target, new) will potentially be much faster than: regex = re.compile(target)

Re: os.system function

2010-01-11 Thread Chris Rebert
On Mon, Jan 11, 2010 at 2:00 PM, Zabin zabin.faris...@gmail.com wrote: snip and just wondering- whats the drawback of using os.system() command Forgetting to properly escape your input. Simple example: filename = foo bar.txt os.system(rm +filename) # uh-oh, we deleted 'foo' and 'bar.txt'

Re: Python File Search

2010-01-11 Thread Chris Rebert
2010/1/11 Eknath Venkataramani eknath.i...@gmail.com: correct.txt snippet: 1 2 1 1 3 3 1 5 21 1 7 19 union_output_TEMP.txt snippet: 1 2 1_NN 1 3 3_VBZ 1 3 5_VBZ 1 3 2_VBZ 1 5 21_VB 1 7 19_NN 1 9 14_VB I need to get the output in categorized.txt as: NN={1 7 19, 1 2 1} VBZ={1 3 3}

Re: A question about Python versions

2010-01-12 Thread Chris Rebert
On Tue, Jan 12, 2010 at 10:09 PM, Gib Bogle g.bo...@auckland.no.spam.ac.nz wrote: I am learning Python, and using PyQt to develop a GUI that will be used to run a Fortran program on Windows, Linux and Mac OS X (I think Python is great, btw). Without thinking about it I downloaded and started

Re: Is python not good enough?

2010-01-13 Thread Chris Rebert
On Wed, Jan 13, 2010 at 1:06 AM, tanix ta...@mongo.net wrote: In article 53ec94c0-dbdd-4901-a46b-d7faee121...@j14g2000yqm.googlegroups.com, johan.san...@gmail.com johan.san...@gmail.com wrote: On Jan 13, 12:55=A0am, a...@pythoncraft.com (Aahz) wrote: In article

Re: Sort list of dictionaries by key (case insensitive)

2010-01-13 Thread Chris Rebert
On Tue, Jan 12, 2010 at 11:45 PM, Nico Grubert nicogrub...@gmail.com wrote: Hi there I have the following list 'mylist' that contains some dictionaries: mylist = [{'title':'the Fog', 'id':1},          {'title':'The Storm', 'id':2},          {'title':'the bible', 'id':3},          

<    2   3   4   5   6   7   8   9   10   11   >