textfile: copy between 2 keywords

2015-09-10 Thread Gerald
Hey, is there a easy way to copy the content between 2 unique keywords in a .txt file? example.txt 1, 2, 3, 4 #keyword1 3, 4, 5, 6 2, 3, 4, 5 #keyword2 4, 5, 6 ,7 Thank you very much -- https://mail.python.org/mailman/listinfo/python-list

Mastering Python

2007-03-16 Thread Gerald
Hi ,Im a BSc4 Maths/Computer Science student.Unfortunately my curriculum did not include Python programming yet I see many vacancies for Python developers.I studied programming Pascal,C++ and Delphi.So I need to catch up quickly and master Python programming.How do you suggest that I achieve this g

RE: Please critique my script

2011-07-14 Thread Gerald Britton
el + '\n' + "description *** local outbound dialpeer ***" + '\n' + destpatt + '\n' + "port " + p + '\n' "forward-digits 7" if line[0:3] == y and q == "y" else "&

Compile time evaluation of dictionaries

2011-03-10 Thread Gerald Britton
    19 STORE_MAP             20 BINARY_MODULO             21 POP_TOP             22 LOAD_CONST               5 (None)             25 RETURN_VALUE >>> Any idea why Python works this way?  I see that, in 3.2, an optimization was done for sets (See "Optimizations" at http://docs.python.org/py3k/whatsnew/3.2.html) though I do not see anything similar for dictionaries. -- Gerald Britton -- Gerald Britton -- http://mail.python.org/mailman/listinfo/python-list

Compile time evaluation of dictionaries

2011-03-14 Thread Gerald Britton
d obviate any such concern. >3/ it would make the implementation more complex (i.e. more work for our >beloved active community) for no gain See my reply to 1/ above. >4/ you can write C code to speed up things: >http://docs.python.org/extending/extending.html, when really needed. How do you spell red herring? -- Gerald Britton -- http://mail.python.org/mailman/listinfo/python-list

value of pi and 22/7

2011-03-20 Thread Gerald Britton
horsepower and the size of sys.maxint on your machine, this may take a few *days* to run. Note: The sum in the Python expression above runs in reverse to minimize rounding errors. -- Gerald Britton -- http://mail.python.org/mailman/listinfo/python-list

Namespaces in functions vs classes

2011-04-17 Thread Gerald Britton
quot; to my use of "foo" >>> class a(): ... foo = 'foo' ... def g(x): ... return a.foo ... >>> x = a() >>> x.g() 'foo' So, this works and I can use it. However, I would like a deeper understanding of why I cannot use "foo" as an unqualified variable inside the method in the class. If Python allowed such a thing, what problems would that cause? -- Gerald Britton -- http://mail.python.org/mailman/listinfo/python-list

Re: Namespaces in functions vs classes

2011-04-19 Thread Gerald Britton
ses the global definition of "meat". The class attribute "meat" is not seen by the serve method unless it is qualified. I now understand the Python does not consider a class definition as a separate namespace as it does for function definitions. That is a helpful understanding. Anyway, thanks for jumping in to the discussion. -- Gerald Britton -- http://mail.python.org/mailman/listinfo/python-list

Re: Namespaces in functions vs classes

2011-04-19 Thread Gerald Britton
>Gerald Britton wrote: >> I now understand the Python does >> not consider a class definition as a separate namespace as it does for >> function definitions. That is a helpful understanding. >That is not correct. Classes are separate namespaces -- they just >aren

Question about abstract base classes and abstract properties -- Python 2.7

2016-09-04 Thread Gerald Britton
just me? (I've been known to be buggy from time to time!) -- Gerald Britton, MCSE-DP, MVP LinkedIn Profile: http://ca.linkedin.com/in/geraldbritton -- https://mail.python.org/mailman/listinfo/python-list

RE: Any ReST aware editors?

2016-09-22 Thread Gerald Britton
type. (Or at least, updated every thirty seconds or so.) Anybody know > anything like that? Visual Studio Code does an OK job with the reStructuredText Language Support for Visual Studio Code Extension -- Gerald Britton, MCSE-DP, MVP LinkedIn Profile: http://ca.linkedin.com/in/geraldbritton --

RE: How to reduce the DRY violation in this code

2016-09-27 Thread Gerald Britton
ppy=50, sleepy=60, sneezy=70): > # the usual assign arguments to attributes dance... > self.bashful = bashful > self.doc = doc > # etc. This looks like a situation where the GoF Builder pattern might help -- Gerald Britton, MCSE-DP, MVP LinkedIn Profile: http://ca.linkedin.com/in/g

Question about abstract base classes and abstract properties -- Python 2.7

2016-10-22 Thread Gerald Britton
ng write property implementation (otherwise, what's the point of the example?) Is this a doc bug, an ABC bug or just me? (I've been known to be buggy from time to time!) -- Gerald Britton -- https://mail.python.org/mailman/listinfo/python-list

Re: Question about abstract base classes and abstract properties -- Python 2.7

2017-01-10 Thread Gerald Britton
I was rereading the 2.7 docs about abstract base classes the other day. I found this line in the usage section of the abc.abstractproperty function: "This defines a read-only property; you can also define a read-write abstract property using the ‘long’ form of property declaration:" along with

Fwd: What are your opinions on .NET Core vs Python?

2017-01-29 Thread Gerald Britton
> > As you guys might know, .NET Core is up and running, promising a > "cross-platform, unified, fast, lightweight, modern and open source > experience" (source: .NET Core official site). What do you guys think about > it? Do you think it will be able to compete with and overcome Python in the > op

What are your opinions on .NET Core vs Python?

2017-01-30 Thread Gerald Britton
on, which is implemented in .NET, has no GIL and doesn't need it since ir runs on the CLR. That means that, for some things, IronPython can be more performant. No word yet if the IronPython project intends to port to .NET core or enable to run it on OS's other than Windows. Also, it&

Question about imports and packages

2016-05-24 Thread Gerald Britton
t call last): File "testimport.py", line 1, in from testpkg.testimported import A ImportError: No module named testpkg.testimported However, I thought I was doing what the doc describes for intra package imports. What am I missing? Or is the problem simply that I do not have subpackages?

Question about imports and packages

2016-05-24 Thread Gerald Britton
On Wed, 25 May 2016 10:00 am, Steven D'Aprano wrote: >On Wed, 25 May 2016 09:35 am, Gerald Britton wrote: > >For brevity, here's your package setup: > > >testpkg/ >+-- __init__.py >+-- testimport.py which runs "from testpkg.testimported import A" >

Package setup best practice style question

2016-05-28 Thread Gerald Britton
that would indicate to prefer method 1 or method 2? Are there methods 3, 4, 5, ... that I should consider that are even better? -- Gerald Britton, MCSE-DP, MVP LinkedIn Profile: http://ca.linkedin.com/in/geraldbritton -- https://mail.python.org/mailman/listinfo/python-list

re: Operator Precedence/Boolean Logic

2016-07-16 Thread Gerald Britton
<https://mail.python.org/pipermail/python-list/2016-July/thread.html#711777> [ subject ] <https://mail.python.org/pipermail/python-list/2016-July/subject.html#711777> [ author ] <https://mail.python.org/pipermail/python-list/2016-July/author.html#711777> ---

Learning Descriptors

2016-07-31 Thread Gerald Britton
Today, I was reading RH's Descriptor HowTo Guide at https://docs.python.org/3/howto/descriptor.html?highlight=descriptors I just really want to fully "get" this. So I put together a little test from scratch. Looks like this: class The: class Answer: def __get__(self, obj, type=None

Re: Learning Descriptors

2016-07-31 Thread Gerald Britton
>On Sun, Jul 31, 2016 at 6:33 AM, Gerald Britton > wrote: >> Today, I was reading RH's Descriptor HowTo Guide at >> >> https://docs.python.org/3/howto/descriptor.html?highlight=descriptors >> >> I just really want to fully "get" this. >> >

Re: Abstract Methods & Abstract Class

2005-10-20 Thread Gerald Klix
Isn't class AbstractBase: def method(self): raise NotImplementedError( "abstract method called" ) the right thing to do? Gerald - Original Message - From: "Andreas Kostyrka" <[EMAIL PROTECTED]> To: "Iyer, Prasad C" <[EMAIL PROTE

Re: Listen in promiscuous mode (Sniffer) on UDP port 162 and copy packetsto another port

2005-10-26 Thread Gerald Klix
HTH Gerald - Original Message - From: Henko Gouws (H) To: python-list@python.org Sent: Tuesday, October 25, 2005 10:26 AM Subject: Listen in promiscuous mode (Sniffer) on UDP port 162 and copy packetsto another port Dear reader An application A opens UDP port 162 and listens for incoming pa

Re: Is there no compression support for large sized strings in Python?

2005-12-01 Thread Gerald Klix
the OS. HTH, Gerald Claudio Grondi schrieb: > "Fredrik Lundh" <[EMAIL PROTECTED]> schrieb im Newsbeitrag > news:[EMAIL PROTECTED] > >>Claudio Grondi wrote: >> >> >>>What started as a simple test if it is better to load uncompressed data >>

Re: Xah's Edu Corner: Examples of Quality Technical Writing

2005-12-07 Thread Gerald Klix
That's the most accurate description of Xah's behaviour I've read so far. Jon Perez schrieb: > Sherm Pendley wrote: > > >>Xah's a pretty well-known troll in these parts. I suppose he thinks someone >>is going to take the bait and rush to "defend" the other languages or some >>such nonsense. > >

Re: efficient 'tail' implementation

2005-12-08 Thread Gerald Klix
ging logic. HTH, Gerald [EMAIL PROTECTED] schrieb: > Mike Meyer wrote: > >>It would probably be more efficient to read blocks backwards and paste >>them together, but I'm not going to get into that. >> > > That actually is a pretty good idea. just reverse the buffe

Re: Do a "Python beginners e-mail list" exist?

2005-07-07 Thread Gerald Klix
Perhaps irc://irc.freenode.net##python Note the double # This channel is less crowed as the #python channels are. Alessandro Brollo schrieb: > Far from a professional programmer, I'm simply a > newbie Python user. Two basic questions: > > 1. I don't want to post banal questions about Python > to

gmail access

2005-09-03 Thread gerald gillespie
how do I access my new Gmail account [EMAIL PROTECTED] _ Express yourself instantly with MSN Messenger! Download today - it's FREE! http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/ -- http://mail.python.org/mailman/l

Re: Python GUIs

2005-09-21 Thread Gerald Klix
if you write B = '\x12','\x32' you get an immutable tuple. To get a mutable list use: B = [ '\x12','\x32' ] HTH, Gerald Tuvas schrieb: > As a bit more of an update, I have decided to create a list of strings, > but am having a problem. To illistrat

Re: Making a DLL with python?

2005-03-31 Thread Gerald Klix
://starship.python.net/crew/theller/ctypes/ Pyrex: http://www.cosc.canterbury.ac.nz/~greg/python/Pyrex/ Feel free to ask, if you need a more complex example, than the one, that comes with pyrex. HTH, Gerald Larry Bates schrieb: I don't think you can make a .DLL (but someone else might). Why can&

Re: Python backend binding to PAM, NSS or pppd

2005-04-07 Thread Gerald Klix
Hi Heiko, Hi all, I have a PAM-library available that embedds Python. Just tell me if you need it and I will publish it. HTH, Gerald Heiko Wundram schrieb: Hey all! Before I start hacking away, I'm looking for a Python backend binding for libpam or libnss, or a python binding for the pppd p

Re: Python backend binding to PAM, NSS or pppd

2005-04-07 Thread Gerald Klix
home directory utilising Loop-AES and the certficate on the floppy * and it opens an openvpn connection using the same certificate * and, of course, unmounts the loopback file and terminates the vpn on logout. Perhaps this is somewhat more than playing :) cya, Gerald Diez B. Roggisch schrieb: I&#x

Re: variables exist

2005-04-11 Thread Gerald Klix
try: myVariable except NameError: print "Not bound" else: print "Bound" If you want to distinguish between the local an the global environment: if globals().has_key( "myVariable" ): ... versus if locals().has_key( ". HTH, Gerald fabian schrieb: how testin

Problem with import "from omniORB import CORBA, PortableServer"

2005-04-11 Thread gerald . maher
Hi, I am trying to excuate the follwong code: [ import sys from omniORB import CORBA, PortableServer ] I get the following error: [ Traceback (most recent call last): File "C:\omniORBpy-2.5-win32-python2.3\omniORBpy-2.5\examples\echoMyTest\example_echo_coloc.py", line 9, in ? from omniORB

Re: Problem with import "from omniORB import CORBA, PortableServer"

2005-04-11 Thread gerald . maher
\omniORBpy-2.5\examples\echo\example_echo_coloc.py Ciao Gerald -- http://mail.python.org/mailman/listinfo/python-list

Correct Versions to execute Corba calls using omniORBpy and omniORB.

2005-04-11 Thread gerald . maher
Hi, I just want to execute a script that used omniORB, omniORBpy Python, Here are the version that I Tried, is this correct ? omniORBpy 2.5 omniORB 4.0.5 Python 2.4.1 The script is below: #!/usr/bin/env python import sys from omniORB import CORBA, PortableServer # Import the stubs and skeleto

Missing Module when calling 'Import' _omnipy

2005-04-11 Thread gerald . maher
I am trying to run an Corba example using Python and i get the follwing error: import _omnipy ImportError: No module named _omnipy Where can i find this Module ? -- http://mail.python.org/mailman/listinfo/python-list

Re: Programming Language for Systems Administrator

2005-04-12 Thread Gerald Klix
g. No it's rather slow, but widley used. There is a mod_python for Apache which is used be some of the web application frameworks mentioned above. Sorry if these questions are out of this group , but answers to these ? will help me a lot. The are perfectly valid. HTH, Gerald -- GPG

Re: Missing Module when calling 'Import' _omnipy

2005-04-12 Thread gerald . maher
*_omnipy is Missing* I have searched my C drive can not find any file called *_omnipy.so or .dll where do I get it from ? I found the fike _omnipy.pyd is that what you mean? Here is my Lib Path: >>> ['C:\\omniORBpy-2.5-win32-python2.3\\omniORBpy-2.5\\examples\\echoMyTest', 'C:\\WINNT\\system32\

Re: pythonic use of properties?

2005-04-14 Thread Gerald Klix
The python rationale is "We are all consenting adults.". You shoukd change "tens" to "_tens" and "ones" to "_ones", in order to syntacticly mark these attributes as internal. If someone not consenting, wants to mess with your internal representa

Re: eval function not working how i want it dag namn

2005-04-15 Thread Gerald Klix
How about using the vars builtin? Michael Hoffman schrieb: robcarlton wrote: I've written this function to make a list of all of an objects attributes and methods (not for any reason, I'm just learning) def list_members(obj) l = dir(obj) return map(lambda x : eval('obj.'+x), l) That works

Re: regex over files

2005-04-25 Thread Gerald Klix
Map the file into RAM by using the mmap module. The file's contents than is availabel as a seachable string. HTH, Gerald Robin Becker schrieb: Is there any way to get regexes to work on non-string/unicode objects. I would like to split large files by regex and it seems relatively hard to

AW: Calling foreign functions from Python? ctypes?

2006-01-10 Thread Gerald Klix
I read the whol email thread carefully and could not find any sentence by Guido, which states that he does not accept ctypes for the standard library. He just declined to rewrite winreg. Did I miss something? Cya, Gerald -Ursprüngliche Nachricht- Von: [EMAIL PROTECTED] [mailto:[EMAIL

AW: Python Embedding Questions

2006-08-01 Thread Gerald Klix
/) discovered with their static analysis tools, were fixed.   Some answers: ad 1) I don't know, I did it twice and had similar problems as you. ad 2) AFAIK some games embed python, perhaps someone with more experience can proviode more explanation.   HTH, Gerald Von: [EMAIL PROTECTED] [m

Re: does anybody earn a living programming in python?

2006-09-26 Thread Gerald Klix
AOL^H^H^H, me too. And it's paid better than C++ programming. HTH, Gerald Gabriel Genellina schrieb: > At Monday 25/9/2006 20:09, walterbyrd wrote: > > I do. > >> If so, I doubt there are many. > > > That's why they get well paid :) > (uhm, not rea

Re: What's going on here?

2006-11-22 Thread Gerald Klix
a' object behaves like having an implict __slots__ attribute. HTH, Gerald Dale Strickland-Clark schrieb: > Python 2.4.2 (#1, Oct 13 2006, 17:11:24) > [GCC 4.1.0 (SUSE Linux)] on linux2 > Type "help", "copyright", "credits" or "license" for

[no subject]

2005-05-15 Thread gerald hereford
__ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com -- http://mail.python.org/mailman/listinfo/python-list

Re: open file in dir independently of operating system

2005-05-25 Thread Gerald Klix
Hi, it`s import os f = open( os.path.join( dir , 'configuration.smo' ), 'r' ) HTH, Gerald Joerg Schuster schrieb: > Hello, > > > I want to open the file 'configuration.smo' that is in directory dir. > Yet, I don't know on which os my program

Re: Knowing the signature of a function

2005-06-08 Thread Gerald Klix
Use the inspect module like: >>> def tf( a, b, c, *arguments, **keywordArguments ): ... print "tf" ... >>> import inspect >>> inspect.getargspec( tf ) (['a', 'b', 'c'], 'arguments', 'keywordArguments', None) >>> Xavier Décoret schrieb: > Hello, > > I have the following code: > > def foo(x,

Re: [OT ?] (Pythonic) detection word protected files

2005-06-13 Thread Gerald Klix
Perhaps you can use OpenOffice and it's python UNO Bindings? I only know about their existence, but perhaps this will be a starting point: http://udk.openoffice.org/ HTH, Gerald Gilles Lenfant schrieb: > Hi, > > This is certainly off topic, but as my problem must have a p

Re: strxfrm works with unicode string ?

2005-06-17 Thread Gerald Klix
How about: import locale s=u'\u00e9' print s locale.setlocale(locale.LC_ALL, '') locale.strxfrm( s.encode( "latin-1" ) ) --- HTH, Gerald [EMAIL PROTECTED] schrieb: > I am trying to use strxfm with unicode strings, but it does not work. > This is what I

Re: strxfrm works with unicode string ?

2005-06-17 Thread Gerald Klix
Sali Nicolas :)), please see below for my answers. [EMAIL PROTECTED] schrieb: > Gruëzi, Gerald ;-) > > Well, ok, but I don't understand why I should first convert a pure > unicode string into a byte string. > The encoding ( here, latin-1) seems an arbitrary choice. We

Re: Is there a way to hook into module destruction?

2007-06-16 Thread Gerald Kaszuba
On Jun 17, 6:16 am, Neal Becker <[EMAIL PROTECTED]> wrote: > Code at global scope in a module is run at module construction (init). Is > it possible to hook into module destruction (unloading)? Try the __del__ method. See http://docs.python.org/ref/customization.html for the docs

Re: Is there a way to hook into module destruction?

2007-06-16 Thread Gerald Kaszuba
> I doubt python calls __del__ when unloading module... and plus, I > don't really think python does module unloading though. del module Ah! Apologies... I mis-read the question. Unloading or at least destroying the reference to a loaded module, you could go for "del module_n

Re: Setting thread priorities

2007-05-13 Thread Gerald Kaszuba
dows. I'm not sure why this hasn't been implemented in Python. Gerald http://geraldkaszuba.com/ -- http://mail.python.org/mailman/listinfo/python-list

Re: Wanted: a python24 package for Python 2.3

2007-03-20 Thread Gerald Klix
ux)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import subprocess >>> --- snip --- HTH, Gerald [EMAIL PROTECTED] schrieb: > On Mar 20, 10:33 am, Jonathan Fine <[EMAIL PROTECTED]> wrote: &g

pycallgraph 0.1.0

2007-02-09 Thread Gerald Kaszuba
led and in your path and a few lines of code changes. More details at http://pycallgraph.slowchop.com/ If you have any problems, don't hesitate to ask here or email me directly. Enjoy! Gerald -- http://mail.python.org/mailman/listinfo/python-list

Re: pycallgraph 0.1.0

2007-02-09 Thread Gerald Kaszuba
On 2/10/07, Stef Mientki <[EMAIL PROTECTED]> wrote: > ... but isn't "__main__." non-information ? Good point -- I'll consider removing it in the next version. Gerald -- http://mail.python.org/mailman/listinfo/python-list

pycallgraph 0.2.0

2007-02-09 Thread Gerald Kaszuba
an exception if there is an error from dot/neato * removed obvious use of __main__ as the module name * added some examples There is no documentation yet but if you browse the source you'll be able to figure out a lot. Enjoy! Gerald -- http://mail.python.org/mailman/listinfo/python-list

Re: pycallgraph 0.1.0

2007-02-10 Thread Gerald Kaszuba
callgraph/wiki/RegExpExample Gerald -- http://mail.python.org/mailman/listinfo/python-list

Re: pycallgraph 0.2.0

2007-02-10 Thread Gerald Kaszuba
;: [], 'exclude_specific': ['stop_trace', 'make_graph'], 'include_module': [], 'include_class': [], 'include_func': [], 'include_specific': [], "specific" means the whole name of a node, e.g. "foo.MyBarClass.__init__" Gerald -- http://mail.python.org/mailman/listinfo/python-list

Re: pycallgraph 0.2.0

2007-02-10 Thread Gerald Kaszuba
has so many dependencies of its own (and many of them are > GTK-related) that the chance of me satisfying them is very small. (I'm on > Solaris and Mac, not Linux, so I don't have the benefit of a Linux distro to > solve those particular headaches for me.) It's easy enough.

ANN: Python Call Graph 0.3.0

2007-02-14 Thread Gerald Kaszuba
of formats like ASCII and HTML output. Have fun. Gerald -- http://mail.python.org/mailman/listinfo/python-list

ANN: pyraknet 0.1.4

2007-02-20 Thread Gerald Kaszuba
tell you what's wrong when you don't have Pyrex installed Gerald -- http://mail.python.org/mailman/listinfo/python-list

ANN: Python Google Chart (pygooglechart) 0.1.2

2007-12-15 Thread Gerald Kaszuba
Python Google Chart is a complete wrapper to the Google Chart API. http://pygooglechart.slowchop.com/ * Added more examples * Fixed pie labels encoding * Fixed MANIFEST.in to allow examples and COPYING in the source distribution * Added more metadata in setup.py -- Gerald Kaszuba http

Re: Function Overloading and Python

2008-02-25 Thread Gerald Klix
ould dispatch based on type /names/: > >class B(object): >def func(self, x,y,z): >func = getattr(self, "_%s_func" % type(x).__name__, self._func) > func(x,y,z) > >def _A_func(self, x,y,z): ># ... > > class B1(B): >def _A1_func(self, x,y,z): ># ... > > Stefan The BDFL came across that problem, too. You will find his thoughts here: <http://www.artima.com/weblogs/viewpost.jsp?thread=101605> The reference implementation for his solution is here: <http://svn.python.org/view/sandbox/trunk/overload/> HTH, Gerald -- http://mail.python.org/mailman/listinfo/python-list

Re: detect current timezone set by kde

2008-03-18 Thread Gerald Klix
I suggest to change /etc/timezone by invoking sudo tzselect. HTH, Gerald Pradnyesh Sawant schrieb: > Hello, > can someone please tell me how can I programatically detect the timezone > information that has been set through kde? > > basically, I have a small pyqt4 app which sh

Re: Lazy List Generator Problem

2009-01-16 Thread Gerald Britton
For those interested in the Sieve of Eratosthenes, have a look at: http://www.cs.hmc.edu/~oneill/papers/Sieve-JFP.pdf The examples in the paper are in Haskell, but I have been corresponding with the author who provided this Python version: def sieve(): innersieve = sieve() prevsquare = 1

is None vs. == None

2009-01-23 Thread Gerald Britton
Hi -- Some time ago I ran across a comment recommending using is None instead of == None (also is not None, etc.) My own testing indicates that the former beats the latter by about 30% on average. Not a log for a single instruction but it can add up in large projects. I'm looking for a (semi)

Python Google Chart 0.2.1 released

2008-08-25 Thread Gerald Kaszuba
* Better clipping checks I've also updated the home page with more examples. Gerald -- Gerald Kaszuba http://geraldkaszuba.com/ -- http://mail.python.org/mailman/listinfo/python-list

Performance of lists vs. list comprehensions

2010-01-19 Thread Gerald Britton
on would prove more efficient. There doesn't appear to be one. I scaled the length of the input list up to 1 million items and got more or less the same relative performance. Now I'm really curious and I'd like to know: 1. Can anyone else confirm this observation? 2. Why should the "pure" list comprehension be slower than the same comprehension enclosed in '[...]' ? -- Gerald Britton -- http://mail.python.org/mailman/listinfo/python-list

Re: Performance of lists vs. list comprehensions

2010-01-19 Thread Gerald Britton
Thanks! Good explanation. On Tue, Jan 19, 2010 at 10:57 AM, Alf P. Steinbach wrote: > * Gerald Britton: >> >> Yesterday I stumbled across some old code in a project I was working >> on.  It does something like this: >> >> mystring = '\n'.join( [ li

Re: Performance of lists vs. list comprehensions

2010-01-19 Thread Gerald Britton
em in the generator expression. That in itself probably accounts for the differences since function calls are somewhat expensive IIRC. On Tue, Jan 19, 2010 at 11:18 AM, Stephen Hansen wrote: > On Tue, Jan 19, 2010 at 7:30 AM, Gerald Britton > wrote: > [snip] >> >> mystring = &

Re: Create list/dict from string

2010-01-19 Thread Gerald Britton
_name": "action_1", "val": "asdf", "val2": > "asdf"}] > > And have this create a list/dict.  I'm aware of pickle, but it won't > work as far as I can tell. > > Thanks. > -- > http://mail.python.org/mailman/listinfo/python-list > -- Gerald Britton -- http://mail.python.org/mailman/listinfo/python-list

Re: Performance of lists vs. list comprehensions

2010-01-19 Thread Gerald Britton
s as you say then join would have to copy the iterable on the first pass, effectively turning it into a list. Though I didn't read through it, I would suppose that join could use a dynamic-table approach to hold the result, starting with some guesstimate then expanding the result buffer

Re: Performance of lists vs. list comprehensions

2010-01-19 Thread Gerald Britton
n Tue, Jan 19, 2010 at 4:01 PM, Arnaud Delobelle wrote: > Gerald Britton writes: > >> [snip] >> >>> >>> Yes, list building from a generator expression *is* expensive. And >>> join has to do it, because it has to iterate twice over the iterable >>&

Re: MySQLdb

2009-11-22 Thread Gerald Walker
Kill Joy wrote: > Hi all. > > I have a mod_python script with two query: > > cursor = db.cursor() > > sql = 'SELECT * FROM users where username=\'' + username +'\'' > cursor.execute(sql) > result = cursor.fetchall() > num = int(cursor.rowcount) > > if num ==

Re: Waiting for receiving data

2009-11-23 Thread Gerald Walker
Anjanesh Lekshminarayanan wrote: > fp = urllib.urlopen(url) > data = fp.read() > > Retrieving XML data via an XML service API. > Very often network gets stuck in between. No errors / exceptions. > > CTRL+C > > File "get-xml.py", line 32, in > fp = urllib.urlopen(url) > File "/usr/lib/py

Re: Waiting for receiving data

2009-11-23 Thread Gerald Walker
> > import socket > from urllib2 import urlopen > > # A one-hundredths of a second (0.01) timeout before socket throws > # an exception to demonstrate catching the timeout. > # Obviously, this you will set this greater than 0.01 in real life. > socket.setdefaulttimeout(0.01) > > # example xml f

Re: Waiting for receiving data

2009-11-23 Thread Gerald Walker
> > Also, if you are using multiple threads to retrieve the xml source(s) > and any thread blocks due to network problems, the thread can go way by > itself after the default timeout expires. > > Typo, edited for clarity: That is: "..the thread can go *away* by itself after the default timeout

Re: Waiting for receiving data

2009-11-23 Thread Gerald Walker
> > import socket > from urllib2 import urlopen > > # A one-hundredths of a second (0.01) timeout before socket throws > # an exception to demonstrate catching the timeout. > # Obviously, this you will set this greater than 0.01 in real life. > socket.setdefaulttimeout(0.01) > > # example xml f

Iterating over a function call

2010-02-01 Thread Gerald Britton
any interest in an apply() built-in function that would work like map() does in 2.x (calls the function with each value returned by the iterator) but return nothing. Maybe "apply" isn't the best name; it's just the first one that occurred to me. Or is this just silly and should

Re: Iterating over a function call

2010-02-01 Thread Gerald Britton
st calls deque anyway when you want to eat up the rest of the iterable. It also solves the iterator-variable leakage problem and is only a wee bit slower than a conventional for-loop. > > -- > Arnaud > -- > http://mail.python.org/mailman/listinfo/python-list > -- Gerald Bri

Re: Adding methods from one class to another, dynamically

2010-02-01 Thread Gerald Britton
med by the string in the variable > `name`. > You want setattr(): http://docs.python.org/library/functions.html#setattr > Assuming the rest of your code chunk is correct: > > setattr(tee, name, new.instancemethod(func,None,tee)) > > Cheers, > Chris > -- > http://blog.rebertia.com > -- > http://mail.python.org/mailman/listinfo/python-list > -- Gerald Britton -- http://mail.python.org/mailman/listinfo/python-list

Re: Iterating over a function call

2010-02-02 Thread Gerald Britton
it > buggy. Quite so. I just like to eliminate the possibility up front. If 'value' is never bound, the the bug will show up sooner. -- Gerald Britton -- http://mail.python.org/mailman/listinfo/python-list

Re: lists as an efficient implementation of large two-dimensional arrays(!)

2010-02-02 Thread Gerald Britton
d > many factors affecting it, including patterns of use. I just wanted to > demonstrate the basics for a situation that I just encountered. In > particular, if the array was sparse, rather than completely full, the > two-level dictionary implementation would be the natural representation. > -- > http://mail.python.org/mailman/listinfo/python-list > -- Gerald Britton -- http://mail.python.org/mailman/listinfo/python-list

Re: Trouble with os.system

2010-02-03 Thread Gerald Britton
cted some kind of escaping issue, but it won't even work with > files such as : foo.txt, bar.txt. > > Any idea ? > Thanks, > Cpa > -- > http://mail.python.org/mailman/listinfo/python-list > -- Gerald Britton -- http://mail.python.org/mailman/listinfo/python-list

Re: Trouble with os.system

2010-02-03 Thread Gerald Britton
,re,os > files2create = sys.argv[1:] > os.system('mkdir tmp') > > # Some code to create the .tex > > # Compile tex files > os.system('for file in tmp/*; do pdflatex "$file"; done') > > Pretty simple, alas. > > -- > Cpa > > > O

Re: exec within function

2010-02-03 Thread Gerald Britton
tracebacks** when asking a > question like this. (The only exception would be if it is v e r y long, as > with hitting the recursion depth limit of 1000.) > > -- > http://mail.python.org/mailman/listinfo/python-list > -- Gerald Britton -- http://mail.python.org/mailman/listinfo/python-list

Re: which

2010-02-05 Thread Gerald Britton
hough I might consider removing the outer parentheses. -- Gerald Britton -- http://mail.python.org/mailman/listinfo/python-list

Re: list.extend([]) Question

2010-02-05 Thread Gerald Britton
t in ['a'], not None. > > http://www.python.org/doc/faq/general/#why-doesn-t-list-sort-return-the-sorted-list > -- > Aahz (a...@pythoncraft.com)           <*>         http://www.pythoncraft.com/ > > import antigravity > -- > http://mail.python.org/mailman/listinfo/python-list > -- Gerald Britton -- http://mail.python.org/mailman/listinfo/python-list

Re: which

2010-02-05 Thread Gerald Britton
if-then-else machinery, making it easier (for me) > to read. But there was considerable resistance to spending so much vertical > space in the source code. Weird! It's three lines and the original was four lines was it not>? -- Gerald Britton -- http://mail.python.org/mailman/listinfo/python-list

Re: Editor for Python

2010-02-05 Thread Gerald Britton
ecker or pylint though I believe that its not too difficult. Who knows? Perhaps someone already has such a plugin that you can use. -- Gerald Britton -- http://mail.python.org/mailman/listinfo/python-list

Re: Exception class documentation

2010-02-05 Thread Gerald Britton
'd','e') Exception('a', 'b', 'c', 'd', 'e') >>> Exception(Exception(1)) Exception(Exception(1,),) -- Gerald Britton -- http://mail.python.org/mailman/listinfo/python-list

Re: method names nounVerb or verbNoun

2010-02-05 Thread Gerald Britton
names should be lowercase, with words separated by underscores as necessary to improve readability. mixedCase is allowed only in contexts where that's already the prevailing style (e.g. threading.py), to retain backwards compatibility. -- Gerald Britton -- http://mail.python.org/mailman/listinfo/python-list

Re: Last M digits of expression A^N

2010-02-05 Thread Gerald Britton
;    return ret > -- > http://mail.python.org/mailman/listinfo/python-list > http://docs.python.org/3.1/library/decimal.html#decimal.Context.power -- Gerald Britton -- http://mail.python.org/mailman/listinfo/python-list

Re: Exception class documentation

2010-02-06 Thread Gerald Britton
If you browse the Python source tree, you should be able to find it. http://svn.python.org/view/python/trunk/Objects/exceptions.c?revision=77045&view=markup On Fri, Feb 5, 2010 at 7:27 PM, Charles Yeomans wrote: > > On Feb 5, 2010, at 2:13 PM, Gerald Britton wrote: > >> On

Re: Checking the coding style

2010-02-07 Thread Gerald Britton
tandards > > -- > Pablo Recio Quijano > > Estudiante de Ingeniería Informática (UCA) > Alumno colaborador del Departamento de Lenguajes y Sistemas Informáticos > Participante del IV Concurso Universitario de Software Libre > > -- > http://mail.python.org/mailman/listin

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

2010-02-10 Thread Gerald Britton
> http://mail.python.org/mailman/listinfo/python-list > Something similar in a for-loop: for x in y: if not should_process(x): continue # process x -- Gerald Britton -- http://mail.python.org/mailman/listinfo/python-list

  1   2   >