Hi Miki,
On 2012-04-05 00:34, Miki Tebeka wrote:
> I'm going to give a "Python Gotcha's" talk at work.
> If you have an interesting/common "Gotcha" (warts/dark corners ...) please
> share.
>
> (Note that I want over http://wiki.python.org/moin/PythonWarts already).
I gave a somewhat similar tal
Hello,
I wrote a `Connection` class that can be found at [1]. A
`Connection` object has a method `put_bytes(data)` which
returns a "future" [2]. The data will be sent asynchronously
by a thread attached to the connection object.
The future object returned by `put_bytes` has a `was_sent`
method wh
ut in my reader I
only saw one answer in the newsgroup.)
Stefan Schwarzer wrote:
> I wrote a `Connection` class that can be found at [1]. A
> `Connection` object has a method `put_bytes(data)` which
> returns a "future" [2]. The data will be sent asynchronously
> by a thread
snacktime wrote:
> I am consistantly getting seg faults and bus errors when running a
> multi threaded python application under 5.3-release-p2. Python was
> built from the port(python 2.4) with threading enabled.
I had similar problems some time ago. The solution/workaround was to remove
the thre
Hi,
Recently, I got a request [1] to support pickling of
`FTPHost` instances in my `ftplib` library.
I explained in the ticket why I think it's a bad idea and
now want to make explicit that `FTPHost` objects can't be
pickled. The usual way to do this seems to be defining a
`__getstate__` method a
ftputil 3.0a1 is now available from
http://ftputil.sschwarzer.net/download .
Changes since version 2.8
-
Note: This version of ftputil is _not_ backward-compatible
with earlier versions.See the links below for information
on adapting existing client code.
- This version a
Hello,
I'm currently changing the FTP client library ftputil [1]
so that the same code of the library works with Python
2 (2.6 and up) and Python 3. (At the moment the code is for
Python 2 only.) I've run into a API design issue where I
don't know which API I should offer ftputil users under
Pytho
Terry, Ethan:
Thanks a lot for your excellent advice. :-)
On 2013-04-13 19:32, Terry Jan Reedy wrote:
> Approach 2 matches (or should match) io.open, which became
> builtin open in Python 3. I would simply document that
> ftp_host.open mimics io.open in the same way that
> ftp_host.chdir, etceter
Hi Chris,
On 2013-04-14 23:50, Chris Angelico wrote:
> Quirky question time!
>
> When you read out a qualified name, eg collections.OrderedDict, do you
> read the qualifier ("collections dot ordered dict"), or do you elide
> it ("ordered dict")? I ask because it makes a difference to talking
> ab
Hi placid:
On 2006-08-03 14:56, placid wrote:
> this site is contains code snippets for various languages and python
> does not have many code snippet posters.
Probably that's because there's a Python "snippet repository" at
http://aspn.activestate.com/ASPN/Python/Cookbook/ :-) It wouldn't
make
On 2006-10-20 15:50, Tor Erik Soenvisen wrote:
> Anyone know about existing code supporting FTP over SSL?
> I guess pycurl http://pycurl.sourceforge.net/ could be used, but that
> requires knowledge of libcurl, which I haven't.
Possibly you could use M2Crypto [1]. It has a FTP_TLS class
in module
Hi Bruno :)
On 2006-06-27 10:30, Bruno Desthuilliers wrote:
> FWIW, a good part of the canonical design patterns are mostly workaround
> the lack of flexibility in languages like C++ and Java.
May be, but that doesn't exclude that some patterns are also
useful in Python. :-)
> The Strategy
> pat
Hello Matimus,
On 2006-09-07 00:07, Matimus wrote:
> Someone correct me if I'm wrong (sometimes I get the terms mixed up)
> but I believe that what you are seeing is due to 'number' being an
> immutable type. This means that its value cannot be changed and thus
> each assignment is effectively cre
Source software, released under the revised BSD
license (see http://www.opensource.org/licenses/bsd-license.php ).
Stefan
--
Dr.-Ing. Stefan Schwarzer
SSchwarzer.com - Softwareentwicklung f??r Technik und Wissenschaft
http://sschwarzer.com
--
http://mail.python.org/mailman/listinfo/python-list
Hi Luis,
Luis Armendariz wrote:
> There's no need for savestdout. There's a backup copy in sys.__stdout__
Depending on the code that ran before the call to the
function run_without_stdout, sys.stdout may not be
the same as sys.__stdout__ . Of course, you also have
to be careful regarding threads
se M2Crypto, try to make sure that you have a class
which is compatible with ftplib.FTP. You can pass such a class as
session_factory to ftputil.FTPHost's constructor. If you don't
have such a class, you might be able to write it yourself.
Stefan
--
Dr.-Ing. Stefan Schwarzer
SSchwarzer.c
ython2006.pdf
Stefan
--
Dr.-Ing. Stefan Schwarzer
SSchwarzer.com - Softwareentwicklung für Technik und Wissenschaft
http://sschwarzer.com
--
http://mail.python.org/mailman/listinfo/python-list
>>> file_names
['wanted_filename']
>>> file_name = file_names[0]
>>> host.download(file_name, file_name, "b")
>>> host.close()
Ok, I admit this isn't a pure-ftplib solution. :-)
Stefan
--
Dr.-Ing. Stefan Schwarzer
SSchwarzer.com - Softwareentwicklung für Technik und Wissenschaft
http://sschwarzer.com
--
http://mail.python.org/mailman/listinfo/python-list
On 2007-01-07 01:54, BJörn Lindqvist wrote:
> Google for "python for consenting adults"
>
> Or ask yourself the opposite question. Why does C++ and C# prefer more
> private data? It is given that emphasizing private data
> (encapsulation) leads to more internal complexity and more lines of
> code b
On 2007-01-05 03:46, tubby wrote:
> Is this the safest, most portable way to open files on any platform:
>
> fp = open(file_name, 'rb')
> fp.close()
>
> I understand that doing the following on Windows to a binary file (a
> jpeg or exe files for example) can cause file corruption, is that correct?
Hi all!
For my FTP library module ftputil [1], some users have asked
for a way to avoid server timeouts (FTP status code 421). But I
haven't found out yet how I can do this in all cases.
I try to explain the problem in more detail. The following is
rather special and probably not so easy to under
Hello Ian,
On 2007-06-10 10:01, IanC wrote:
> Does anyone know of a function or script to upload an entire
> subdirectory tree from a local file space to an FTP server?
>
> The Python distribution comes with "ftpmirror.py", which performs
> a mirror download of a directory tree, but I need the "U
d BSD
license (see http://www.opensource.org/licenses/bsd-license.php ).
Stefan
--
Dr.-Ing. Stefan Schwarzer
SSchwarzer.com - Softwareentwicklung für Technik und Wissenschaft
http://sschwarzer.com
--
http://mail.python.org/mailman/listinfo/python-list
revised BSD
license (see http://www.opensource.org/licenses/bsd-license.php ).
Stefan
--
Dr.-Ing. Stefan Schwarzer
SSchwarzer.com - Softwareentwicklung für Technik und Wissenschaft
http://sschwarzer.com
http://ftputil.sschwarzer.net
--
http://mail.python.org/mailman/listinfo/python-list
Hello nazarianin,
On 2006-03-30 09:35, 5>=>2 ;5:A59 wrote:
> from ftplib import FTP
> def handleDownload(block):
> file.write(block)
> print "."
>
> file = open('1', 'wb')
> ftp = FTP('ftp.utk.ru')
> ftp.set_pasv(1)
> ftp.login()
> ftp.retrlines('LIST')
> [...]
> and have this error mes
Hello,
from time to time I want to inspect the source code of projects
on remote computers.(*) I've googled for one or two hours but
didn't find anything helpful. :-/ I'm looking for something like
IDLE's path browser - i. e. a tree view and file view
side-by-side - but with the following differen
ftputil 2.1 is now available from
http://ftputil.sschwarzer.net/download .
Changes since version 2.0
-
- Added new methods to the FTPHost class, namely makedirs, walk,
rmtree.
- The FTP server directory format ("Unix" vs. "Windows") is now set
automatically (thanks to
Hi Arne,
On 2006-04-08 12:44, Arne wrote:
> I am looking for a way to put ftp returns in a variable.
>
> My OS is XP and I want to get the owner of a file. So I have to
>
> connect to ftp. But I am stacked with how I can receive this
> information and put it in a variable.
you can use a library t
Hi Arne
On 2006-04-12 18:05, Arne wrote:
> I am working on Windows XP and I want to do the following:
>
> 1. Connecting to a server using ftp
> 2. Getting the directory structure and the size of each directory in the
> root
> 3. Getting the owner of a file
>
> All these steps I want to do with
Hello Matt,
On 2010-12-23 01:03, Matt Funk wrote:
> i was wondering whether someone can point me whether the following
> already exists.
>
> I want to connect to a server , download various files (for whose name i
> want to be able to use a wildcard), and store those files in a given
> location o
Hello,
I'm happy to announce the release of Websourcebrowser 0.4a.
Websourcebrowser is a program intended to get a quick overview of a
project's source code. The program is controlled from a web browser
which displays a directory tree and a source code file side by side.
The homepage of the proj
Hi Eric,
On 2010-08-04 21:58, Eric J. Van der Velden wrote:
> class C:
> def __init__(self,name):self.name=name
>
> I was wondering if I could make the __init__ a lambda function, but
>
> class C:
> __init__=lambda self,self.name:None
>
> and then later,
>
> C('Hello')
>
> does not work; th
Hi Andreas,
On 2010-08-03 12:15, Andreas Pfrengle wrote:
> On 3 Aug., 03:22, Carl Banks wrote:>
> Thinking about it, it might really be dangerous to coerce always to
> int1, since sometimes I might want a normal int as result (I can't
> tell yet for sure).
Yes, that way your problem may shift fr
Hi DG,
On 2010-08-06 14:28, DG wrote:
> I've always thought of it as you don't compare strings with "is", you
> *should* use == The reasoning is that you don't know if that string
> instance is the only one in memory. I've heard as an implementation
> detail, since strings are immutable, that Py
Hello Peter,
On 2010-08-06 19:20, Peter Pearson wrote:
> On Fri, 06 Aug 2010 15:37:04 +0200, Stefan Schwarzer wrote:
> [snip]
>> I can imagine a case where you might want to compare a
>> string with `is`:
>>
>> FORWARD = "forward"
>> BACKWARD
Hi Steven,
On 2010-08-07 00:28, Steven D'Aprano wrote:
> On Fri, 06 Aug 2010 15:37:04 +0200, Stefan Schwarzer wrote:
>>> Plus, I believe the
>>> "==" operator will check if the variables point to the same object.
>>
>> No, that's what `is` is
On 2010-07-31 05:47, Steven D'Aprano wrote:
> On Fri, 30 Jul 2010 08:34:52 -0400, wheres pythonmonks wrote:
> It does re-use the same underlying data.
>
> >>> from collections import defaultdict as dd
> >>> x = dd(list)
> >>> x[1].append(1)
> >>> x
> defaultdict(, {1: [1]})
> >>> y = dict(x)
> >>>
Hi Ben,
On 2010-08-08 01:16, Ben Finney wrote:
> Don't use strings for such values. The data isn't going to be used, so
> there's no sense using a semantically rich data type like a string.
>
> Instead, use an ‘object’ instance; then, the only way to get a binding
> that will compare equal is to
Hi Steven,
On 2010-08-09 10:21, Steven D'Aprano wrote:
> And that it's quite finicky about blank lines between methods and inside
> functions. Makes it hard to paste code directly into the interpreter.
>
> And that pasting doesn't strip out any leading prompts. It needs a good
> doctest mode.
Hi Robert,
On 2010-08-09 22:23, Robert Kern wrote:
> On 2010-08-09 06:42 , Stefan Schwarzer wrote:
>> Unfortunatey, when I enter
>>
>>In [2]: %paste
>>
>> at the prompt it gives me (before I pasted
On 2010-08-09 23:43, Stefan Schwarzer wrote:
> I got that traceback as soon as I typed in "%paste" and
> pressed enter, without pasting anything in the terminal.
> I had assumed it works like :paste in Vim, activating a
I meant ":set paste" of course.
Stefan
--
h
Hi,
On 2010-08-10 17:01, Francesco Bochicchio wrote:
> There used to be a very nice (also graphic) explanationor this
> somewhere on the web, but my googling skills failed me this time,
> so instead I'll show you the concept using your own code:
Probably this isn't the page you're referring to, b
Hello Jean-Michel,
On 2010-08-12 16:06, Jean-Michel Pichavant wrote:
> Eric J. Van der Velden wrote:
> Should be
>
> class C:
> n = 0
> def __init__(self):
>self.__class__.n+=1
>C.n+=1 # equivalent to this line (I prefer this one, more
> readable, less refactor-friendly)
On 2010-08-13 11:18, blur959 wrote:
> import os
>
> directory = raw_input("Please input file directory. \n\n")
> s = raw_input("Please input a name to replace. \n\n")
> ext = raw_input("input file ext")
>
> for files in os.listdir(directory):
> if ext in files:
> file_number = len(fil
Hi Vamsi,
On 2010-08-13 22:50, Vamsi wrote:
> I am trying to count the number of lines in a file and insert into
> the file but getting the error message "TypeError: must be string or
> read-only character buffer, not int", Could you please help me how to
> correct this?
Which Python version do
Hi Alex,
On 2010-08-16 18:44, Alex van der Spek wrote:
> Anybody catches any other ways to improve my program (attached), you are
> most welcome. Help me learn, that is one of the objectives of this
> newsgroup, right? Or is it all about exchanging the next to impossible
> solution to the never
Hi Neil,
On 2010-08-17 14:42, Neil Cerutti wrote:
> On 2010-08-17, Michael Torrie wrote:
>> In general if I find myself consistently going longer than 75
>> or 80 characters, I need to refactor my code to make it more
>> manageable. If I have to scroll up five pages to find the
>> beginning of a
On 2010-08-17 17:44, AK wrote:
> On 08/17/2010 10:28 AM, Stefan Schwarzer wrote:
>> I'd probably reformat this to
>>
>>self.expiration_date = translate_date(
>> find(response, 'MPNExpirationDate').text,
>>
Hi Andrei,
On 2010-08-17 18:43, AK wrote:
> But let me ask you, would you really prefer to have:
>
self.expiration_date = translate_date(
find(response, 'MPNExpirationDate').text,
'%Y-%m-%d', '%m%d%Y')
>
> (or the 4-line version of this abov
Hi Bidda,
On 2010-08-18 09:19, Bidda Gowda wrote:
> I have a project coming up where i have to integrate our existing
> Python based web application with Java Programs. Basically i should be
> able to call Java programs which comes in the form of jars. Whats the
> best way to call these jars from
Hi Lie,
On 2010-08-18 12:02, Lie Ryan wrote:
> On 08/17/10 12:59, AK wrote:
>> On 08/16/2010 10:42 PM, James Mills wrote:
>>> My personal opinion (despite monitors being wider) is
>>> the horizontal scrolling isn't worth it. Stick to a 80-char width.
>>
>> But.. why horizontal scrolling, isn't aut
Hi Νίκος,
On 2010-08-19 09:10, Νίκος wrote:
> On 18 Αύγ, 12:50, Cameron Simpson wrote:
>>
>> ("nikos",) is a single element tuple.
>> ["nikos"] is a single element list.
>> ["nikos",] is also a single element list, just written like the tuple.
>
> It makes more sense if i:
>
> "nikos" is just a
Hi Lawrence,
On 2010-08-20 13:11, Lawrence D'Oliveiro wrote:
> In message
> <8d1b76b7-1ba3-49c5-97cf-dc3837050...@y11g2000yqm.googlegroups.com>, Rony
> wrote:
>
>> The manager of the development has been fired, main reason (what they
>> told me) is that they have big big troubles in keeping deadli
Hi Rony,
On 2010-08-20 10:16, Rony wrote:
> Here's the story :
> I've been hired by a company as a consultant to reorganise there
> development department.
> The actual situation is :
> The manager of the development has been fired, main reason (what they
> told me) is that they have big big troub
Hi Rodrick,
On 2010-08-17 18:40, Rodrick Brown wrote:
> I have a fairly large file 1-2GB in size that I need to
> process line by line but I first need to convert the file
> to text using a 3rd party tool that prints the records
> also line by line.
>
> I've tried using Popen to do this with no l
Hi durumdara,
On 2010-08-24 11:21, durumdara wrote:
> def CallBack(Data):
> d['size'] = d['size'] + len(Data)
> d['buffer'].append(Data)
> percent = (d['size'] / float(fsize)) * 100
> percentp10 = int(percent/10)
> if percentp10 > d['lastpercentp10']:
>
Hi Astan,
On 2010-08-24 21:18, Astan Chee wrote:
> I'm trying to convert my tcsh script to python and am stuck at one part,
> particularly the part of the script that looks like this:
>
> #!/bin/tcsh
> setenv LSFLOG /var/tmp/lsf_log
> source /etc/setup
> unalias cp
> umask 0
> env >> ${AFLOG}
>
Hi durumdara,
On 2010-08-24 16:29, Stefan Schwarzer wrote:
>> I experienced some problem.
>> The server is Windows and FileZilla, the client is Win7 and Python2.6.
>> When I got a file with size 1 303 318 662 byte, python is halt on
>> "retrbinary" line
Hi durumdara,
On 2010-08-25 09:43, durumdara wrote:
>> I can imagine the error message (a full traceback if
>> possible) would help to say a bit more about the cause of
>> the problem and maybe what to do about it.
>
> This was:
>
> Filename: "Repositories 20100824_101805 (Teljes).zip" Size: 153
Hi durumdara,
On 2010-08-25 11:18, durumdara wrote:
> On aug. 25, 08:07, Stefan Schwarzer wrote:
>>
>> The file is 2 GB in size and is fully transferred, without
>> blocking or an error message. The status message from the
>> server is '226-File successfully tr
Hi Navkirat,
On 2010-08-26 19:22, Navkirat Singh wrote:
> I am programming a webserver, I receive a jpeg file with
> the POST method.The file (.jpeg) is encoded in bytes, I
> parse the bytes by decoding them to a string. I wanted to
> know how i could write the file (now a string) as a jpeg
> imag
Hi Lawrence,
On 2010-08-28 01:49, Lawrence D'Oliveiro wrote:
>> Now it may be that the data connection, after having started
>> the transfer, works as it should, but the control connection
>> times out because the duration of the transfer is too long.
>
> It might not be the fault of the FTP serv
Hi Pinku,
On 2010-08-11 21:35, Pinku Surana wrote:
> Even though I used the same name "x" for a local and global variable,
> they are actually completely different. When I call "fun(x)" it COPIES
> the global value of "x" into the local variable "x" in "fun". [...]
The global value isn't copied w
Hi,
On 2010-08-31 02:05, Bradley Hintze wrote:
> I may be having a brain fart, but is it at all possible to have a
> function first return a value then continue its calculation. Like this
> simple example:
>
> my_var = 5
> def my_function():
> return my_var
> my_var +=1
>
> This obviousl
Hi Grant,
On 2010-08-31 20:49, Grant Edwards wrote:
> How many filenames contain ","?
CVS repository files end with ,v . However, just let's agree
that nobody uses CVS anymore. :-)
> Not many, but the OP wants his
> program to be bulletproof. Can't fault him for that.
What about using the csv
Hi John,
On 2010-08-11 20:24, John Nagle wrote:
>Perl has a function which will take a remote directory page, in
> the form that most web sites return for a file directory, and
> parse it into a useful form:
>
> http://www.xav.com/perl/site/lib/File/Listing.html
>
> This is especially
Hi Steven,
On 2010-09-05 17:30, Steven D'Aprano wrote:
> I run the doctests with:
>
> python2.6 -m doctest examples.txt
>
> and the first example passes, but the second fails with NameError:
> make_spam not defined.
I run my doctests by calling
doctest.testfile(filename)
for each file in
Hi Ian,
On 2010-09-07 12:18, Ian Hobson wrote:
> f = open('d:\logfile.txt','a')
Just a note: Using a backslash in a non-raw string will get
you in trouble as soon as the backslash is followed by a
character which makes a special character sequence, like "\n".
For example,
f = open('d:\nice_
Hi Neal,
On 2010-09-10 20:23, Neal Becker wrote:
> IN [3]: bool('False')
> Out[3]: True
If you consider strings, only an empty string has a false
value. So the string 'False' which is non-empty, results in
a true boolean value.
For example, you can use
if my_string:
...
to execute
Hello,
I maintain ftputil [1], an FTP client library.
Users of the library may use it like this:
| import ftputil
|
| with ftputil.FTPHost(server, userid, password) as ftp_host:
| # for example, make a remote file and read its content
| with ftp_host.open("remote_name", "rb") as remote_f
Hi,
On 2010-09-25 14:11, Yingjie Lan wrote:
> Having more than one way of doing things sometimes is good.
In my opinion this _isn't_ a situation where it's good. :)
L[::-1]
is only marginally longer than
-1 * L
I think this small gain doesn't justify "violating" this
"Python Zen" rule
Hi,
On 2010-09-25 15:54, Yingjie Lan wrote:
> The first one is simpler (4 chars v.s. 9 chars).
One thing is whether a certain form is shorter, another
thing to take into account is how often you need the
functionality.
> I thought it was also intuitive because if you multiply
> a vector by -1, y
Hi Terry,
On 2010-09-25 19:24, Terry Reedy wrote:
> On 9/25/2010 4:22 AM, Yingjie Lan wrote:
> There is already a builtin reversed() function whose output can be
> multiplied.
Seemingly, it can't:
$ python
Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56)
[GCC 4.4.3] on linux2
Type "help
Hi Daniel,
On 2010-09-23 07:30, vineet daniel wrote:
> On Sep 22, 2:20 pm, de...@web.de (Diez B. Roggisch) wrote:
>> vineet daniel writes:
>>> On Sep 21, 9:47 pm, de...@web.de (Diez B. Roggisch) wrote:
vineet daniel writes:
> code that I am using is as follows :
>>
> #! /usr/bin/env
Hello Alex,
On 2010-09-28 11:27, AlexWalk wrote:
> In python 3.1.2(I'm using windows edition, 32bit),
> accessing __class__ of an int literal will raise a
> SyntaxException, while other literals will not. For
> example. 1.__class__ is an error, while 1.1.__class__ runs
> ok.
>
> I searched the p
Hello,
I'm looking for a tool which can read Python files and write
a corresponding XMI file for import into UML tools.
Ideally, the conversion tool should:
- be open source or freeware
- be available for Linux
- be a command line tool
- allow to specify exactly the Python files that should t
Hi Sebastian,
On 2010-10-21 00:27, Sebastian wrote:
> Is there a simpler way to yield all elements of a sequence than this?
> for x in xs:
> yield x
Can you give an example where you would need this? Can't
you just iterate over the sequence? If you really need an
iterator, you can use `iter(s
Hi Cameron,
On 2010-10-25 01:08, Cameron Simpson wrote:
> On 24Oct2010 20:58, Stefan Schwarzer wrote:
> | On 2010-10-21 00:27, Sebastian wrote:
> | > Is there a simpler way to yield all elements of a sequence than this?
> | > for x in xs:
> | > yield x
> |
> |
Hi Steve and others,
On 2010-10-25 06:08, Steve Holden wrote:
> On 10/24/2010 11:42 PM, Chris Rebert wrote:
>> On Sun, Oct 24, 2010 at 4:11 PM, James Mills
>> wrote:
>>> I don't agree but anyway... I've just not seen it commonly used
>>> amongst python programmers.
>>
>> If Python wanted to encou
Hi Lawrence,
I missed your answer because I didn't expect someone to
respond after all this time. :-)
On 2010-10-30 04:07, Lawrence D'Oliveiro wrote:
>> I'm looking for a tool which can read Python files and write
>> a corresponding XMI file for import into UML tools.
>
> UML ... isn’t that some
80 matches
Mail list logo