paramiko-expect with Python 2->3 'str' buffer interface issues?

2015-03-23 Thread Nick Ellson
using paramiko-expect? It seems to have the usual 'str' type issue I have seen, and used .decode() for, but can't seem to make it happy with this module. Nick Traceback (most recent call last): File "./ssh-expect.py", line 29, in interact.expect(pr

Generating list of unique search sub-phrases

2015-05-29 Thread Nick Mellor
Hi all, My own solution works but I'm sure it could be simpler or read better. How would you do it? Say you've got a list of companies: Aerosonde Ltd Amcor ANCA Austal Ships Australia Post Australian Air Express Australian Defence Industries Australian Railroad Group Australian Submarine Corpor

Re: Generating list of unique search sub-phrases

2015-06-17 Thread Nick Mellor
On Saturday, 30 May 2015 06:39:44 UTC+10, Nick Mellor wrote: > Hi all, > > My own solution works but I'm sure it could be simpler or read better. How > would you do it? > > Say you've got a list of companies: > > Aerosonde Ltd > Amcor > ANCA > Aus

Re: OFF-TOPIC Ben's sig monster quote [was Re: Parametrized Unit Tests]

2015-08-28 Thread Nick Sarbicki
here is always someone who thinks that it is better than > peace. > > > > -- > Steven > > -- > https://mail.python.org/mailman/listinfo/python-list > -- - Nick -- https://mail.python.org/mailman/listinfo/python-list

Re: packing unpacking depends on order.

2015-09-02 Thread Nick Sarbicki
b = 1 > >>> a[b], b = b, a[b] > >>> a > [1, 1, 3, 4, 5] > > I think I understand how it gets these results > but I'm not really happy with them. I think python > should give the second result in both cases. > > -- > Antoon Pardon > > -- > https://mail.python.org/mailman/listinfo/python-list > -- - Nick -- https://mail.python.org/mailman/listinfo/python-list

Re: error

2015-09-02 Thread Nick Sarbicki
h won't work that way (it will work if you type "import p2"). When you should be using "python p2.py" at the terminal. - Nick On Wed, 2 Sep 2015 19:20 wrote: > Hi, > > > I have a Python version: Python 2.7.8 > > I'm runing it on: Fedora release

Re: Strange location for a comma

2015-09-03 Thread Nick Sarbicki
Tim, Doesn't work for the first column in SQL, but we tend to put the comma and a space before the column name. It makes it easier to move things around and (debateably) more readable. It is also very obvious when you have missed a comma this way. - Nick On Thu, 3 Sep 2015 16:14 Tim

Re: Porting Python Application to a new linux machine

2015-09-03 Thread Nick Sarbicki
distros with > > Python3.x as default (Fedora?) > > Also Ubuntu. If you want to work across multiple Linux distros, the > easiest way is to tell people to install either "python2" or "python3" > using their system package manager, and then use that. > &

Re: Porting Python Application to a new linux machine

2015-09-03 Thread Nick Sarbicki
y. > > Okay. I don't run any current Ubuntu anywhere, so I don't know. And I > can't even find back the page now where the plans were being > discussed; best I can find is this, about a year out of date now: > > https://wiki.ubuntu.com/Python/3 > > ChrisA > -- > https://mail.python.org/mailman/listinfo/python-list > -- - Nick -- https://mail.python.org/mailman/listinfo/python-list

Re: Need Help w. PIP!

2015-09-03 Thread Nick Sarbicki
> Just typing 'pip' as you do does't work because pip.exe is located in Python\Scripts directory which in not included on variable %PATH% Is that new for win10? Just "pip" works fine on my win7 install. Although maybe I had to extend the path and forgot... - Nick

Re: Need Help w. PIP!

2015-09-04 Thread Nick Sarbicki
In the cmd "echo %path%" and send us the output. Also try to run "pip" as opposed to "python -m pip". Nick. On Fri, 4 Sep 2015 17:41 Steve Burrus wrote: > On Thursday, September 3, 2015 at 10:12:23 PM UTC-5, Mark Lawrence wrote: > > On 04/09/2015 02:04

Re: Reply to author, reply to list, reply to all (was: Need Help w. PIP!)

2015-09-08 Thread Nick Sarbicki
l technology, | > `\ calls it proprietary, and then tries to keep others from | > _o__) building on it, is a thief.” —Tim O'Reilly, 2000-01-25 | > Ben Finney > > -- > https://mail.python.org/mailman/listinfo/python-list My question then is do you reply

Re: datetime.datetime.today()

2015-09-16 Thread Nick Sarbicki
sing the today method of the datetime property which inevitably returns a datetime object. Getting today from the date object will return an actual date. Now and today are very, very, similar - but now may be more accurate and gives flexibility with timezones as per https://docs.pyt

Re: Einstein's Riddle

2015-09-18 Thread Nick Sarbicki
notice that it's over fourteen years old. > > Time is relative. Perhaps the poster has been travelling at close to the > speed of light, and for him it is only a few minutes after the original > post was sent. > > > -- > Steven > > -- > https://

Re: Regular expressions

2015-11-03 Thread Nick Sarbicki
t of my job is bringing our legacy Python code into the modern day, and one of the largest roadblocks is the amount of regex used. Some is necessary. Some can be replaced by an `if word in str` or something similarly basic. Some spans hundreds of lines and causes acute alopecia. Just yesterday

Re: Python's re module and genealogy problem

2014-06-11 Thread Nick Cash
On 06/11/2014 10:35 AM, Michael Torrie wrote: > On 06/11/2014 06:23 AM, BrJohan wrote: >> For some genealogical purposes I consider using Python's re module. >> >> Rather many names can be spelled in a number of similar ways, and in >> order to match names even if they are spelled differently, I

Re: Template language for random string generation

2014-08-08 Thread Nick Cash
On 08/08/2014 01:45 PM, cwolf.a...@gmail.com wrote: > On Friday, August 8, 2014 10:35:12 AM UTC-4, Skip Montanaro wrote: >> P.S. Probably a topic for a separate thread, and not actually >> Python-related, but on a related note, I have never found a free password >> keeper which works on all my p

Help with parsing a dict from Vendor's API?

2014-10-15 Thread Nick Ellson
009', 'family': '200', 'url-filtering-version': '4390', 'vpn-disable-mode': False, 'logdb-version': '4.1.2', 'serial': '001606008639', 'hostname': 'bib-int-fw'}, <repeats for 180 firewalls> ]}}, 'status': 'success'}} What I want is to parse through each firewall grabbing the "ip-address" value so that I can dump it to a list: For use in another network management tool so I don't rely on outsourced help to remember to place teh firewalls into the correct tools. But dang if every dict tutorial seems to deal with slightly simpler looking structures than what this puts out. I would be very appreciative with help stepping out of the 6 line "address book/grocery list" example world for a taste of something useful :-) Maybe to a Python coder, it maybe a simple even be able to randomly reference a firewall index number and teh value in this structure so one can easily just pluck any A/V pair at will.. just not for me yet :-D Nick -- https://mail.python.org/mailman/listinfo/python-list

Re: Help with parsing a dict from Vendor's API?

2014-10-15 Thread Nick Ellson
t names running code 4.1.9, or display the serial number of the device with hostname 'foo' That should get me on my way to productive fun :-) Nick Nick Ellson - from iPhone (forgive typos) CCIE #20018 Network Hobbyist "Educating Layer 8, one user at a time." > On Oc

Re: PyWart: Itertools module needs attention

2011-09-12 Thread Nick Stinemates
On Mon, Sep 12, 2011 at 10:04 PM, rantingrick wrote: > > > # Quote # > > # The itertools module is great HOWEVER i believe m

Re: creating a code with two list

2011-10-11 Thread Nick Zarr
build a list of consecutive integers: range(1, n+1) >>> range(1, 1000) [1, 2, ..., 999] -- Nick Zarczynski <http://rentageekit.com> Blog 4 <http://nickzarr.com> -- http://mail.python.org/mailman/listinfo/python-list

Re: How to use shell return value like $? In python?

2011-10-23 Thread Nick Dokos
he exit status (the low byte is the > signal that killed the process). So: > > > > > status = os.system("foo") > > retval, sig = ((status >> 8) & 0xFF), (status & 0xFF) > ... or retval, sig = os.WEXITSTATUS(status), os.WTERMSIG(status) fo

Re: Data acquisition

2011-10-25 Thread Nick Dokos
n-list > Shot in the dark: could it be that you have to add delays to give the instrument time to adjust? When you do it from the python shell, line by line, there is a long delay between one line and the next. Nick -- http://mail.python.org/mailman/listinfo/python-list

Re: String splitting by spaces question

2011-11-23 Thread Nick Dokos
hanks in advance! You can use a list comprehension: l2 = [x.rsplit(...) for x in l] But for the original question, maybe the csv module would be more useful: you can change delimiters and quotechars to match your input: import csv reader = csv.reader(open("foo.txt", "rb&q

Re: Disable readline

2011-12-01 Thread Nick Dokos
66:84292, Dec 27 2010, 00:02:40) > [GCC 4.4.5] on linux2 > Type "help", "copyright", "credits" or "license" for more information. > >>> > > And readline continues to work :/ > Two things: o Is TERM exported? Maybe Roy's is and y

Re: [OT] Book authoring

2011-12-09 Thread Nick Dokos
hich has been used for a few books (http://orgmode.org ). I know it does HTML and PDF (the latter through latex), but I'm not sure about ePub: ISTR somebody actually did ePub for his book but I don't remember details. The indexing is manual: add #+index: foo entries as required. Bu

Re: [OT] Book authoring

2011-12-09 Thread Nick Dokos
Nick Dokos wrote: > There is also orgmode, which has been used for a few books > (http://orgmode.org ). I know it does HTML and PDF (the latter through > latex), but I'm not sure about ePub: ISTR somebody actually did ePub for > his book but I don't remember details. A

Outputting raw MIDI in realtime on Linux

2011-12-11 Thread Nick Irvine
le from the OSS docs, with the same result: http://manuals.opensound.com/developer/midi.c.html (I updated the /dev line.) What do people use to output live MIDI on Linux, assuming it's possible? Thanks, Nick Irvine -- http://mail.python.org/mailman/listinfo/python-list

Re: Verbose and flexible args and kwargs syntax

2011-12-12 Thread Nick Dokos
Terry Reedy wrote: > calculations are helped by the fact that (a+b) % c == a%c + b%c, so As long as we understand that == here does not mean "equal", only "congruent modulo c", e.g try a = 13, b = 12, c = 7. Nick -- http://mail.python.org/mailman/listinfo/python-list

Re: Verbose and flexible args and kwargs syntax

2011-12-12 Thread Nick Dokos
nkingly leads to trouble - duh). It was implementation dependent in old C (whatever the hardware would give you), which predictably - with 20-20 hindsight - turned out to be a Very Bad Idea. Nick PS Z = integers, N = non-negative integers -- http://mail.python.org/mailman/listinfo/python-list

Re: Verbose and flexible args and kwargs syntax

2011-12-12 Thread Nick Dokos
gene heskett wrote: > On Monday, December 12, 2011 12:44:27 PM Chris Angelico did opine: > > > On Tue, Dec 13, 2011 at 2:55 AM, Nick Dokos > wrote: > > > Terry Reedy wrote: > > >> calculations are helped by the fact that (a+b) % c == a%c + b%c, so > &

Re: Need help with really elementary pexpect fragment

2011-12-19 Thread Nick Dokos
ne prompt is "[my machine name here] % " > > Here is the code fragment: > > print "Spawning Expect" > p = pexpect.spawn ('/bin/tcsh',) > If you execute /bin/tcsh by hand, do you get a "%" prompt? Nick > print "Sendi

Re: Text Processing

2011-12-20 Thread Nick Dokos
this task ? > > You could try to do it yourself. > Does it have to be python? If not, I'd go with something similar to sed 1,2d foo.data | awk '{printf("%.2f\n", $2);}' Nick -- http://mail.python.org/mailman/listinfo/python-list

Re: socket.gethostbyaddr( os.environ['REMOTE_ADDR'] error

2012-01-09 Thread Nick Dokos
host name or IP number. ` so socket.gethostbyaddr(os.environ['REMOTE_ADDR'])[0] is the 0th element of the tuple, i.e. the *name* that is returned. So (unless I'm confused which is always a distinct possibility) this has nothing to do with load-balancing or multiple addresses: it's the equivalent of dig +short -x Nick -- http://mail.python.org/mailman/listinfo/python-list

Re: Explanation about for

2012-01-10 Thread Nick Dokos
ve examples and all will become clear. Going back to cursors and databases: you *can* think of 'dataset' as being a list of tuples - a list of all the query results, but with one proviso. The difference when you use a cursor is that `dataset' may be a lazy list (an "iterator

Re: toy list processing problem: collect similar terms

2013-02-06 Thread Nick Mellor
erable(sequence) # use defaultdict to set up the final list and deal with initial empty dictionary key final_list = defaultdict(list) for i in chain: if isinstance(i, int): number = i else: final_list[number].append(i) print (final_list.items()) HTH, Nick On Sunday, Septe

Re: toy list processing problem: collect similar terms

2013-02-06 Thread Nick Mellor
;o','p'),(4,'q','r'),(5,'s','t')) register = defaultdict(list) for number, *letters in data: register[number].extend(letters) final = [] for i in sorted(register.keys()): final.append(register[i]) print (final) NB sorting is "stabl

Re: toy list processing problem: collect similar terms

2013-02-06 Thread Nick Mellor
Oops! Not that sort stability is used in this algorithm. Was thinking of something else :-) N On Thursday, 7 February 2013 10:25:36 UTC+11, Nick Mellor wrote: > Python 3 version: > > > > from collections import defaultdict > > > > data = > ((0,'a'

Re: Curious to see alternate approach on a search/replace via regex

2013-02-07 Thread Nick Mellor
ts.query flattened = unflattened.translate(punct_flatten) print (flattened) Cheers, Nick On Thursday, 7 February 2013 08:41:05 UTC+11, rh wrote: > I am curious to know if others would have done this differently. And if so > > how so? > > > > This converts a url to a mor

Re: Curious to see alternate approach on a search/replace via regex

2013-02-08 Thread Nick Mellor
ay to do things sometimes.) Best, Nick On Friday, 8 February 2013 16:47:03 UTC+11, rh wrote: > On Thu, 7 Feb 2013 04:53:22 -0800 (PST) > > Nick Mellor wrote: > > > > > Hi RH, > > > > > > translate methods might be faster (and a little easier to r

Simulation of human body in movement

2013-02-17 Thread Nick Mellor
Hi all, I'm looking for a fairly undetailed simulation of the human body walking and standing. Has anyone had a go at this in cgkit or similar? Thanks, Nick -- http://mail.python.org/mailman/listinfo/python-list

Re: Python 3.3 vs. MSDOS Basic

2013-02-18 Thread Nick Mellor
at are never needed. Best wishes, Nick And the winner is 837799 with sequence length 524 Time (s): 2.924168109893799 Sequence is: [837799, 2513398, 1256699, 3770098, 1885049, 5655148, 2827574, 1413787, 4241362, 2120681, 6362044, 3181022, 1590511, 4771534, 2385767, 7157302, 3578651, 1073595

Re: Simulation of human body in movement

2013-02-19 Thread Nick Mellor
9 February 2013 06:25:50 UTC+11, Rick Johnson wrote: > Nick Mellor gmail.com> writes: > > > > > I'm looking for a fairly undetailed simulation of the human body walking and > > standing. Has anyone had a go at > > > this in cgkit or similar? > &g

Re: Python Newbie

2013-02-25 Thread Nick Mellor
ne continuation: if (c + 256 * (d + 256 * e)) > 69427: # do something # do something else # then leave the if block This is the preferred method according to the Python style guide. I hope you manage to give Python (and your job) a little longer to charm you :-) Cheers,

del not working for (exhausted) dict iterable value (Python 3.3)

2013-03-11 Thread Nick Mellor
that it won't delete a dict value that's an (exhausted) iterator, or have I found a bug? Thanks for any help, Nick -- http://mail.python.org/mailman/listinfo/python-list

Re: del not working for (exhausted) dict iterable value (Python 3.3)

2013-03-12 Thread Nick Mellor
Thanks Alex! Nick -- http://mail.python.org/mailman/listinfo/python-list

dir() vs print(dir()) in the embedded mode

2013-03-29 Thread Nick Gnedin
silently). Many thanks for your future hints, Nick #include int main() { Py_Initialize(); PyRun_SimpleString("dir()"); printf("-\n"); PyRun_SimpleString("print(dir())"); Py_Finalize(); return 0; } -- http://mail.python.org/mailman/listinfo/python-list

__doc__ string for getset members

2013-04-07 Thread Nick Gnedin
ng for the result of a call to MemGet(...) is printed, not the doc string supplied in the PyGetSetDef structure. Many thanks for the advice, Nick Gnedin -- http://mail.python.org/mailman/listinfo/python-list

standalone vs embedded interpreter

2013-04-09 Thread Nick Gnedin
mpt - does anyone know what I am doing wrong? Many thanks for any hint, Nick -- http://mail.python.org/mailman/listinfo/python-list

distutils and libraries

2013-04-23 Thread Nick Gnedin
to just install it, skipping the build step? Many thanks for any help, Nick Gnedin -- http://mail.python.org/mailman/listinfo/python-list

Reducing import try/except boilerplate

2005-12-21 Thread Nick Coghlan
ogrammer wants Also: from threading or dummy_threading import Thread # No 'as' clause needed since the module name isn't bound Insomnia-induced-random-ideas-are-fun-'ly yours, Nick. -- Nick Coghlan

Retaining Unix EOL when reading/writing in windows

2006-01-18 Thread Nick Wain
dfile = open(filename,'r').readlines() for line in readfile: outfile.write(line) outfile.close() Is there a way I can do this, but retain the UNIX EOL characters? Cheers, Nick _ Are you using the latest version of MSN Me

Re: Sets and Membership Tests

2006-07-12 Thread Nick Vatamaniuc
JK, You are correct to implement __hash__ and __eq__. The problem is how you implemented them. Usually your __eq__ method should compare the necessary attributes of the objects for equality. The __hash__ should return a 32-bit integer. Your best bet is probably to return a hash of hashes of your a

Re: Object Persistence Using a File System

2006-07-12 Thread Nick Vatamaniuc
t, perform computations, persist the wrong results and so on), and you wouldn't even notice it. Hope these comments help, Nick V. Chris Spencer wrote: > Before I get too carried away with something that's probably > unnecessary, please allow me to throw around some ideas. I've

Re: hash() yields different results for different platforms

2006-07-12 Thread Nick Vatamaniuc
, well, just re-implement it in Python such that your version will yield the same hash on any platform. Hope this helps, Nick V. Qiangning Hong wrote: > I'm writing a spider. I have millions of urls in a table (mysql) to > check if a url has already been fetched. To check fast, I am > consi

Re: Object Persistence Using a File System

2006-07-12 Thread Nick Vatamaniuc
Good point about isinstance. Here is a good explanation why: http://www.canonical.org/~kragen/isinstance/ Also the frozenset should be added the list of immutable types. Nick Vatamaniuc Bruno Desthuilliers wrote: > Chris Spencer wrote: > > Before I get too carried away with somethi

Re: Sets and Membership Tests

2006-07-12 Thread Nick Vatamaniuc
nside the __init__ method of your class and perhaps a few others... Nick V. JKPeck wrote: > Thanks for the advice. Once assured that __hash__ etc was the right > route, I found that using hash() instead of object.__hash__() gave me > stable hash valules. (I am hashing strings that I

Re: check type when assignment

2006-07-12 Thread Nick Vatamaniuc
ll raise an exception. A much better explanation about the use and abuse of isinstance() is here: http://www.canonical.org/~kragen/isinstance/ Hope this helps, Nick V. pipehappy wrote: > Hello everyone: > > Is there a way to check the type when do assignment? > > if I write: >

Re: don't need dictionary's keys - hash table?

2006-07-12 Thread Nick Vatamaniuc
It should be enough but it might be a little slower than hash(string). Diez B. Roggisch wrote: > [EMAIL PROTECTED] wrote: > > > Hello, > > I am using some very large dictionaries with keys that are long strings > > (urls). For a large dictionary these keys start to take up a > > significant amoun

Re: don't need dictionary's keys - hash table?

2006-07-12 Thread Nick Vatamaniuc
ng of actual keys are not referenced by the dictionary. Now you couldn't do dic.keys() and see your urls, and every time you want to do dic['abc'] you would get a KeyError exception. Hope this helps, Nick Vatamaniuc [EMAIL PROTECTED] wrote: > [EMAIL PROTECTED] wrote: > > Hello,

Re: PDF with nonLatin-1 characters

2006-07-12 Thread Nick Vatamaniuc
victor, Have you tried Reportlab ( http://www.reportlab.org/rl_toolkit.html )? That sounds like what you might need. -Nick Vatamaniuc victor wrote: > I want to generate a report and the PDF fits perfectly. Though there is > an issue of using different encoding in the doc. I tried PyPS w

Re: How to delete a Python package

2006-07-12 Thread Nick Vatamaniuc
remove all the files of the package. Nick Vatamaniuc Jack wrote: > Installing a Python package is easy, most of time just > "Setup.py install" However, setup.py doesn't seem to support > an uninstall command. If I want to delete a package that I > do not use any more, sh

Re: How to delete a Python package

2006-07-12 Thread Nick Vatamaniuc
suggested Linux. Actually as far as I am concerned, having all your modules, IDEs, and libraries available in a nicely organized repository, available at the touch of an 'agt-get' command is a pretty good reason to switch. Nick V. [EMAIL PROTECTED] wrote: > >> As a rule, if you

Re: Compiling Python using the Portland Group compiler

2006-07-12 Thread Nick Vatamaniuc
w many you can enable before test fail again. If you compiled it as 64bit application, try to compile as a regular 32bit and see what happens. Nick V. Konrad Hinsen wrote: > I am trying to install Python 2.4.3 on an AMD Opteron system using > the Portland Group's compiler (pgcc

Re: How to delete a Python package

2006-07-12 Thread Nick Vatamaniuc
Skip, I agree. Some kind of a manifest or log file would be great and probably not that hard to implement. Nick [EMAIL PROTECTED] wrote: > Nick> Uninstall support is hard, you would turn distutils (setup.py) > Nick> into a package management system, but wait...! there are alread

Re: don't need dictionary's keys - hash table?

2006-07-12 Thread Nick Vatamaniuc
e=dic[hash(urlstring]]. Hopefully this make my point more clear, Nick V. Fredrik Lundh wrote: > Nick Vatamaniuc wrote: > > > If you don't really want to store the keys, just use > > dic[hash(key)]=value, this way the dictionary will have the same shape > > and distrib

Re: don't need dictionary's keys - hash table?

2006-07-12 Thread Nick Vatamaniuc
;>> hash(hash(hash(('abc' -1600925533 >>> - Of course then hash(0)=0, hash(1)=0 and also hash(2**32)=1, all this in standard CPython on IA32. Nick Vatamaniuc Ganesan Rajagopal wrote: > >>>>> "Terry" == Terry Hancock <[EMAI

Re: Determining if an object is a class?

2006-07-13 Thread Nick Vatamaniuc
Clay, Search Google for it. Here is one good explanation with code examples by Michael Fotsch: http://www.geocities.com/foetsch/python/new_style_classes.htm Nick V. placid wrote: > [EMAIL PROTECTED] wrote: > > I need to find out if an object is a class. Using new style classes > &g

{} for set notation

2006-07-14 Thread Nick Vatamaniuc
been secondary in traditional programming languages. For simplicity in implementation arrays and lists have been used to mimic a set. Now that Python has a built in set it only makes sense to give it its own notation and maybe Python 3000 is just the right time for it. - Nick Vatamaniuc [EMAIL

Re: EuroPython 2006 and Py3.0

2006-07-14 Thread Nick Vatamaniuc
3000 this is the time to do it. Rejections do take time but they will just have to happen, out of 10 rejected maybe there will be one good proposal that will make Python a little better. -Nick V. Steve Holden wrote: > [EMAIL PROTECTED] wrote: > > Kay Schluehr: > > > >>th

Re: {} for set notation

2006-07-14 Thread Nick Vatamaniuc
7;d be surprised how many people would more likely to use than if they had to type set([...]). Regards, Nick Vatamaniuc tac-tics wrote: > Nick Vatamaniuc wrote: > > I really like the set notation idea. Now that sets are first class > > "citizens" along with dicts, lists a

Re: EuroPython 2006 and Py3.0

2006-07-14 Thread Nick Vatamaniuc
ate and discussion a reasonable, good middle ground will be reached. Regards, Nick V. A.M. Kuchling wrote: > On Fri, 14 Jul 2006 18:45:07 +0200, > Fredrik Lundh <[EMAIL PROTECTED]> wrote: > > [EMAIL PROTECTED] wrote: > > > >> This attitude may have some downsi

dict = no ordered keys = no slicing

2006-07-14 Thread Nick Vatamaniuc
e-order or post-order so how does slicing fit in there. Hope this helps, Nick Vatamaniuc Antoon Pardon wrote: > On 2006-07-14, Lawrence Oluyede <[EMAIL PROTECTED]> wrote: > > Antoon Pardon <[EMAIL PROTECTED]> wrote: > > > >> These are just some ideas. Whether

Re: instances

2006-07-14 Thread Nick Vatamaniuc
very rare exceptions you don't even need to know about it (I don't even know what its parameters are, because in all these years I have never had to use it). Hope this helps, I assumed you are a new Python user that is why I presented a simplistic example. Please see some Python tutorials an

Re: reading specific lines of a file

2006-07-15 Thread Nick Vatamaniuc
;t be able to jump to line 15000 without reading lines 0-14999. You can either iterate over the rows by yourself or simply use the 'linecache' module like shown above. If I were you I would use the linecache, but of course you don't mention anything about the context of your project

Re: Capturing instant messages

2006-07-18 Thread Nick Vatamaniuc
idea from above won't work too well, you will have to capture all the traffic then decode each stream, for each side, for each protocol. 3) Recording or replay is easy. Save to files or dump to a MySQL table indexed by user id, timestamp, IP etc. Because of buffering issues you will probably

Re: question about what lamda does

2006-07-18 Thread Nick Vatamaniuc
(when_done_call_this=lambda x,y:x*y) Note: because it is an _expression_ you cannot do stuff like 'if..else' inside of lambda. -Nick V. [EMAIL PROTECTED] wrote: > Hey there, > i have been learning python for the past few months, but i can seem to > get what exactly a lamda is for. What woul

Re: Dictionary question

2006-07-18 Thread Nick Vatamaniuc
Brian, You can try the setdefault method of the dictionary. For a dictionary D the setdefault work like this: D.setdefault(k, defvalue). If k not in D then D[k] is set to defvalue and defvalue is returned. For example: In [1]: d={} In [2]: d.setdefault(1,5) Out[2]:5 In [3]: d Out[3]:{1: 5} In y

Re: Cyclic class definations

2006-07-18 Thread Nick Vatamaniuc
r semantics) but regardless, if they make your code hard to understand so try to not introduce them if possible. Hope this helps, Nick V. John Henry wrote: > Hi list, > > I am trying to understand better Python packaging. This might be a > messed up class hierachy but how wo

Re: Dispatch with multiple inheritance

2006-07-18 Thread Nick Vatamaniuc
rmally you don't even need to know about __new__. Hope this helps, Nick V. Michael J. Fromberger wrote: > Consider the following class hierarchy in Python: > > class A (object): > def __init__(self): > print "cons A" > > class B (object): > de

Re: Capturing instant messages

2006-07-18 Thread Nick Vatamaniuc
messages in a cron batch job (at night or weekend). Nick V. Yu-Xi Lim wrote: > Ed Leafe wrote: > > I've been approached by a local business that has been advised that > > they need to start capturing and archiving their instant messaging in > > order to comply with Sarb

Re: No need to close file?

2006-07-18 Thread Nick Vatamaniuc
files (in 'w' mode) might not be able to be opened by another process if they are not closed. In general this is usually a good habit to have (just like washing dishes right after a meal rather than hoping someone will do it later eventually ;) Regards, Nick V. Sybren Stuvel wrote: >

Re: Should this be added to MySQLdb FAQ?

2006-07-18 Thread Nick Vatamaniuc
gmax2006, Yes, perhaps the MySQLdb project should mention that packages are usually available in the popular distributions. I am using Ubuntu and everything I needed for MySQL and Python was in the repositories , 'apt-get' one-lines is all that is needed. In general though, I found that more often

Re: Authentication

2006-07-18 Thread Nick Vatamaniuc
ject print msg.source I tried it before and it didn't work, it said login failed. Perhaps it will work for you. Looking at the source is always a GoodThing (especially if you give your password to a program you just downloaded as an input...). Nick Va

Re: using names before they're defined

2006-07-19 Thread Nick Vatamaniuc
(...) #override some methods ... and so on. Of course I am not familiar with your problem in depth all this might not work for you, just use common sense. Hope this helps, Nick Vatamaniuc [EMAIL PROTECTED] wrote: > I have a problem. I'm writing a simulation program with a n

Re: using names before they're defined

2006-07-19 Thread jordan . nick
Steve Holden wrote: > [EMAIL PROTECTED] wrote: > > I have a problem. I'm writing a simulation program with a number of > > mechanical components represented as objects. When I create instances > > of objects, I need to reference (link) each object to the objects > > upstream and downstream of it,

Re: using names before they're defined

2006-07-19 Thread Nick Vatamaniuc
or me to read. Properties getters and setters are mentioned there too under the "getter and setters are Evil!" section ;) Here is the link: http://dirtsimple.org/2004/12/python-is-not-java.html Nick V. [EMAIL PROTECTED] wrote: > > Even if you need to do something during attachment

Re: Warning when new attributes are added to classes at run time

2006-07-20 Thread Nick Vatamaniuc
cks would make the code itself incomprehnsible over time as half of it would end up being just checks for exceptional situations. So spend 5 minutes to look up http://pyunit.sourceforge.net/ and then in the long run your effort to implement testing will be rewarded. Nick V. Matthew Wilson wrote: > I som

Re: Using python code from Java?

2006-07-20 Thread Nick Vatamaniuc
can always use some help... Nick V. fortepianissimo wrote: > Is there a solution to enable Java programmers to call functions > written in Python? Any wrapper generator that wraps Python code into > some Java-callable form? > > I briefly looked at Jython, but if I understand it r

Re: using names before they're defined

2006-07-22 Thread Nick Vatamaniuc
power="2MW", \ speed="800rpm", \ ... First case is a little shorter but then you have to use a parser for it while in the second case you just execute the file, and besides, you can edit it with any Python editor. Hope this helps, Nick V. [EMAIL PROTECTED] wrote: >

Re: How to test if object is sequence, or iterable?

2006-07-22 Thread Nick Vatamaniuc
than using isinstance to check if it is of a partucular type. You are doing things 'the pythonic way' ;) Nick Vatamaniuc Tim N. van der Leeuw wrote: > Hi, > > I'd like to know if there's a way to check if an object is a sequence, > or an iterable. Something l

Re: httplib, threading, wx app freezing after 4 hours

2006-07-22 Thread Nick Vatamaniuc
and issue a warning. Also check the memory on your machine in case some buffer fills the memory up and the machine gets stuck. To understand what's really happening try to debug the program. Try Winpdb debugger you can find it here: http://www.digitalpeers.com/pythondebugger/ Nick Vatamaniuc

Re: BeautifulSoup to get string inner 'p' and 'a' tags

2006-07-24 Thread Nick Vatamaniuc
be something then you also want it included in the final text. As in 'FOO URLNAME ' ==> 'FOO URLNAME' For the regex start with something simple like <.*?> and see if it works then improve it. Use kiki or kodos - python visual regex helpers. Hope this helps, Nic

Re: dicts vs classes

2006-07-25 Thread Nick Vatamaniuc
Don't optimize prematurely. Write whatever is cleaner, simpler and makes more sense. Such that if someone (or even yourself) looks at it 10 years from now they'll know exactly what is going on. As far as what is slower or what functionality you will use and what you won't -- well, if you won't us

Re: Missing rotor module

2006-07-25 Thread Nick Vatamaniuc
am not sure if it is _exactly_ the same. Good luck, Nick V. rony steelandt wrote: > I'm in the midle of porting a python 1.5 application to 2.4 > > I just discovered that the rotor encryption module isn't part anymore of > the 2.4 distribution. > > Is there a way to a

Re: how best to check a value? (if/else or try/except?)

2006-07-27 Thread Nick Vatamaniuc
tuff because f is callable... except TypeError: pass # ... if f is not callable, then I don't care... But of course it is much shorter to do: if callable(f): #...do stuff because f is callable... Hope this helps, Nick Vatamaniuc John Salerno wrote: > My code is below. The main

Re: Fastest Way To Loop Through Every Pixel

2006-07-27 Thread Nick Vatamaniuc
ou need to run '#Actions here...' you can just use for (i,j) in all_indices: #Actions here ... blah blah In general, if there would be a way to significantly optimize generic for loops, they would probably be already optimized... Nick V. Chaos wrote: > As my first attempt to loop

Re: Threads vs Processes

2006-07-27 Thread Nick Vatamaniuc
in the same number of lines having the same or better performance. I bet you'll end up having a whole bunch of 'locks', 'waits' and 'notify's instead of a bunch of "those 'deferred' things." Debugging all those threads should be a project in an o

Re: War chest for writing web apps in Python?

2006-07-28 Thread Nick Vatamaniuc
, PyGTK, PyQT and so on. In general though, the time spent learning how to design a gui with a designer could probably be used to just write the code yourself in Python (now for Java or C++ it is a different story... -- you can start a war over this ;-) Hope this helps, Nick Vatamaniuc Vi

Re: Comma is not always OK in the argument list?!

2006-07-28 Thread Nick Vatamaniuc
axError: invalid syntax >>> f(*[1,2]) >>> f(*[1,2],) File "", line 1 f(*[1,2],) ^ SyntaxError: invalid syntax >>> f(**{'a':1,'b':2}) >>> f(**{'a':1,'b':2},) File "", line 1 f(**{'a':1,'b':2},)

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