On Tue, Sep 6, 2011 at 5:25 PM, Jabba Laci wrote:
> Hi,
>
> If I want to use the 'os.path' module, it's enought to import 'os':
>
> import os
> if os.path.isfile('/usr/bin/bash'):
> print 'got it'
>
> In other source codes I noticed that people write 'import os.path' in
> this case. Which is be
On Wed, Mar 23, 2011 at 10:10 AM, T wrote:
> For a Python script with multiple command line options, what is the
> best way to go about validating that only certain options are used
> together? For example, say -s, -t, and -v are all valid options, but
> should never be used together (i.e. -s -t
On Fri, Nov 4, 2011 at 8:28 AM, John Roth wrote:
> The first is that if you use TDD (Test Driven Development) and
> refactor relentlessly to remove duplication, most of the basic design
> patterns will emerge naturally from the code as you work.
I agree, and there is a pretty good series of artic
This seems like a pretty good resource, although I didn't read it all yet:
http://www.ibm.com/developerworks/edu/l-dw-linux-pythonscript-i.html
--
http://mail.python.org/mailman/listinfo/python-list
I use vim on both Windows and UNIX/Linux, and found this vimrc file.
http://darksmile.net/software/.vimrc.html
It's pretty good and has good comments. You might want to take a look
at that and customize it.
Plus this is great:
http://www.usf.uni-osnabrueck.de/infoservice/doc/localhtml/vim/if_pyth
How about this one for recursion and control flow:
>>> def hcd(m,n):
... r = m % n
... if( r > 0 ):
... hcd(n, r)
... else:
... print "hcd = %d" % (n,)
...
>>> hcd(119, 544)
hcd = 17
>>>
It calculates the highest common denominator for m and n. Plus it's E1
in
I am still learning and this is a great resource:
http://diveintopython.org/index.html
You can buy it or read it online for free.
--
http://mail.python.org/mailman/listinfo/python-list
> Precisely what? You complained that the OP didn't provide the location
> of the event, which he did.
Well, where is DFW?
--
http://mail.python.org/mailman/listinfo/python-list
On 6/26/07, kaens <[EMAIL PROTECTED]> wrote:
> It was like being slapped with the mid-90s
That was awesome.
> On 6/26/07, Stefan Behnel <[EMAIL PROTECTED]> wrote:
> > Brandon wrote:
> > > Check it out: www.BrandonsMansion.com
That is horrible.
--
http://mail.python.org/mailman/listinfo/python-lis
On 7/11/07, Shafik <[EMAIL PROTECTED]> wrote:
> I am an experienced programmer, but very new to python (2 days). I
> wanted to ask: what exactly is the difference between a tuple and a
> list? I'm sure there are some, but I can't seem to find a situation
> where I can use one but not the other.
Th
On 7/18/07, Robert Rawlins - Think Blue
<[EMAIL PROTECTED]> wrote:
> What's the best way to create a copy of a list?
I am pretty new to python but this works:
>>> list_one = [0,1,2,3,4,5,6,7,8,9]
>>> list_two = [i for i in list_one]
>>> print list_two
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
>>>
--
http:/
I forgot to mention that you can go here for a little more of an explanation:
http://diveintopython.org/native_data_types/mapping_lists.html
--
http://mail.python.org/mailman/listinfo/python-list
Sorry, I don't understand why this is still on the python mailing list.
:wq
--
http://mail.python.org/mailman/listinfo/python-list
Using camel case instead of the under_score means less typing. I am lazy.
fooBar
foo_bar
--
http://mail.python.org/mailman/listinfo/python-list
I am new to Python but these 2 have been great resources, so far:
http://diveintopython.org/toc/index.html
http://docs.python.org/tut/
--
http://mail.python.org/mailman/listinfo/python-list
> Each requires exactly the same number of key strokes when I do the
> math. (Too lazy to explain further...)
foo_bar
f, o, o, shift + underscore, b, a, r = 8
fooBar
f, o, o, shift + b, a, r = 7
--
http://mail.python.org/mailman/listinfo/python-list
On 9/12/07, Evan <[EMAIL PROTECTED]> wrote:
> Hi, guys ~~
>
> How can i work on VIM for python code? I use cscope plugin on VIM for
> C code before, it helps me to different function and search C
> variable where it is defined.
Change to the top level directory that contains your python source
f
On 10/10/07, Kevin <[EMAIL PROTECTED]> wrote:
> Am I missing something, or am I the only one who explicitly declares
> structs in python?
> For example:
> FileObject = {
> "filename" : None,
> "path" : None,
> }
>
> fobj = FileObject.copy()
> fobj["filename"] = "passwd"
> fobj["path"] =
On 10/17/07, Anthony Perkins <[EMAIL PROTECTED]> wrote:
> Hi everyone,
>
> What is the best GNU/Linux distribution (or the most preferred) for
> developing Python applications? Ideally I would like one with both
> Python *and* IDLE included on the install media (neither Ubuntu nor SUSE
> have IDLE
On 10/17/07, Joe Riopel <[EMAIL PROTECTED]> wrote:
> IDLE and Python came installed on Slackware 12, I am not 100% sure
> about previous versions.
Also, I am sure a lot of it (with most distributions) depends on the
packages you select during the installation.
--
http://mai
On 10/19/07, Robert Dailey <[EMAIL PROTECTED]> wrote:
> Is there a C++ version of the C Python API packaged with python 2.5?
> It would be nice to have a OOP approach to embedding python in C++. It
> would also be a bonus if this C++ Python API cleaned up a lot of the
> messy code involved in embed
This might be worth a look: http://www.sqlalchemy.org/docs/04/ormtutorial.html
--
http://mail.python.org/mailman/listinfo/python-list
On Nov 8, 2007 11:02 AM, steven depret <[EMAIL PROTECTED]> wrote:
> I get a lot of stuff in my output, but simply NOT the a=xx and the b = yy.
> What the heck am I doing wrong ?
What kind of stuff are you getting? Are you getting all the contents
of the HTTP response and/or HTML?
--
http://mail
On Nov 3, 2007 10:28 AM, BartlebyScrivener <[EMAIL PROTECTED]> wrote:
> Try the free trial of Komodo
>
> http://www.activestate.com/Products/komodo_ide/
Komodo Edit is free
http://www.activestate.com/Products/komodo_edit/
Open Komodo is free and open source:
http://www.openkomodo.com/
--
http://
On Nov 20, 2007 7:19 AM, joe jacob <[EMAIL PROTECTED]> wrote:
> There are a lot of web frameworks for python like django, mod_python,
> spyce, turbo gears, Zope, Cherrypy etc. Which one is the best in terms
> of performance and ease of study.
I wouldn't classify mod_python as a web framework: "Mod
On Nov 20, 2007 8:46 AM, BartlebyScrivener <[EMAIL PROTECTED]> wrote:
> Django comes with its own little server so that you don't have
> to set up Apache on your desktop to play with it.
Pylons too, it's good for development but using the bundled web server
is not recommended for production.
--
On Nov 21, 2007 5:42 AM, joe jacob <[EMAIL PROTECTED]> wrote:
> Thanks everyone for the response. From the posts I understand that
> Django and pylons are the best. By searching the net earlier I got the
> same information that Django is best among the frameworks so I
> downloaded it and I found it
On Nov 21, 2007 10:15 AM, Gilles Ganault <[EMAIL PROTECTED]> wrote:
> I know about socket.gethostbyname, but this relies on what's in
> /etc/hosts, and I'd rather have a more independent solution.
I might be missing something in your question, but on a Windows XP
machine, I can get the IP address
On Dec 10, 2007 9:03 PM, Whizzer <[EMAIL PROTECTED]> wrote:
> Is OReilly's Learning Python a good place to start learning to program?
> I've been told Python is a good first language.
I think this is a great place to start, there is a free version right
there online.
http://diveintopython.org/
--
On Jan 7, 2008 8:09 AM, <[EMAIL PROTECTED]> wrote:
> The best thing about Python is ___.
it's mailing list.
--
http://mail.python.org/mailman/listinfo/python-list
On Jan 12, 2008 2:00 PM, radiosrfun <[EMAIL PROTECTED]> wrote:
> Whether we agree on "tactics" or not - if it come to a battlefield with the
> two of us - or any Americans there - we're still going to fight the same
> enemy - not each other.
This is a good resource for starting Python
http://divei
On Jan 12, 2008 10:13 AM, Jorgen Bodde <[EMAIL PROTECTED]> wrote:
> I thought about that too. I just wonder why /usr/local/bin is always
> empty and every .deb I install from a source (if it's from Ubuntu or
> not) installs files in /usr/bin .. So I looked further and noticed
> that most python fil
On Jan 29, 2008 12:11 PM, walterbyrd <[EMAIL PROTECTED]> wrote:
> I am not really sure about what wsgi is supposed to accomplish.
This will explain WSGI: http://www.python.org/dev/peps/pep-0333/
--
http://mail.python.org/mailman/listinfo/python-list
On Jan 29, 2008 1:35 PM, Hannah Drayson <[EMAIL PROTECTED]> wrote:
> It imports as a string of rubbish...
> i.e.
>
>
> >>> text = f.read()
> >>> print text
> ?F?C??y??>?
> @[EMAIL PROTECTED]@???/???8[EMAIL PROTECTED]/[EMAIL
> PROTECTED]@?Q???Q???Q???Q???Q??ǑR[???Q?
On Jan 29, 2008 1:59 PM, Joe Riopel <[EMAIL PROTECTED]> wrote:
> When reading the file, try using
> file = open('data.bin', 'rb')
> file.seek(0)
> raw = file.read()
>
> Do the unpack on "raw".
Ignore this, sorry for the confusion.
--
http://mail.python.org/mailman/listinfo/python-list
Since you're unpacking it with the 'd' format character I am assuming
a "doubleword" field is a double. You said you had 113 of them in the
binary file. You should be doing something like this:
file = open('data.bin', 'rb')
file.seek(0)
raw = file.re
On Jan 29, 2008 9:23 AM, [EMAIL PROTECTED]
<[EMAIL PROTECTED]> wrote:
> If you're going to delete elements from
> a list while iterating over it, then do
> it in reverse order:
how about
>>> li = [1,2,3,4,5]
>>> filter(lambda x: x != 3, li)
[1, 2, 4, 5]
>>>
--
http://mail.python.org/mailman/listi
On Mon, Mar 10, 2008 at 6:58 PM, Mark M Manning <[EMAIL PROTECTED]> wrote:
> I need your expertise with a sockets question.
>
> Let me preface this by saying I don't have much experience with
> sockets in general so this question may be simple.
I would suggest taking a quick look at this tutori
On Mon, Mar 10, 2008 at 1:08 AM, Nathan Pinno <[EMAIL PROTECTED]> wrote:
> How do I factor a number? I mean how do I translate x! into proper
> Python code, so that it will always do the correct math?
This should work to do x! (factorial of x).
reduce(lambda x,y: x*y, range(1, x+1))
--
http://m
On Tue, Mar 11, 2008 at 10:38 AM, Joe Riopel <[EMAIL PROTECTED]> wrote:
> On Mon, Mar 10, 2008 at 1:08 AM, Nathan Pinno <[EMAIL PROTECTED]> wrote:
> > How do I factor a number? I mean how do I translate x! into proper
> > Python code, so that it will always do the cor
On Tue, Mar 11, 2008 at 10:58 AM, davidj411 <[EMAIL PROTECTED]> wrote:
> Thanks, that makes sense. Are there any local relational databases
> available to python that don't require a server backend?
sqlite
http://www.sqlite.org/
--
http://mail.python.org/mailman/listinfo/python-list
On Fri, Jan 23, 2009 at 6:16 PM, Xah Lee wrote:
> The haskell tutorials you can find online are the most mothefucking
> stupid unreadable fuck. The Haskll community is almost stupid. What
> they talk all day is about monads, currying, linder myer fuck type.
> That's what they talk about all day. A
I typically use vim/vi, because it's usually already installed on the
OS's I work with and vim for Windows works the same. Also, using the
same editor across these different OS's, I don't have to worry too
much soft/hard tabs. The contents of rc files on both Windows and
UNIX/Linux are the same too
On Tue, Feb 10, 2009 at 11:48 AM, Qian Xu wrote:
> self.assertEquals(testMethod1(), expected_value1);
> self.assertEquals(testMethod2(), expected_value2);
>
> However, if the first test item is failed, no more tests will be executed.
> Can I tell Python,
> 1. go ahead, if a failure is occurred.
On Fri, Feb 13, 2009 at 9:04 AM, News123 wrote:
> Hi,
> I'd like to do some web automation with python 2.5
> - https:
> - a cookiejar
> - some forms to be filled in
> what is the best set of modules.
I have automated some testing of our product, using it's web UI with
Python with urllib2 and urrl
On Fri, Feb 13, 2009 at 12:03 PM, David wrote:
> Hi everyone,
>
> I copied a program from C to track multiple log files. I would like to be
> able to print a label when a log file is updated. Here is the program;
Since you're calling tail itself, why not just use tail's ability to
tail multiple f
On Sat, Nov 29, 2008 at 3:44 PM, Josh <[EMAIL PROTECTED]> wrote:
> Thanks in advance,
There is no right, or wrong, answer to this question. Try one for a
few weeks, force yourself to use it as exclusively as possible for all
your text editing needs. After that, repeat that process with the
other e
On Sat, Nov 29, 2008 at 3:44 PM, Josh <[EMAIL PROTECTED]> wrote:
> Thanks in advance,
There is no right, or wrong, answer to this question. Try one for a
few weeks, force yourself to use it as exclusively as possible for all
your text editing needs. After that, repeat that process with the
other e
On Wed, Oct 8, 2008 at 1:55 PM, Joe Python <[EMAIL PROTECTED]> wrote:
> I want to find the top '100' hosts (sorted in descending order of total
> requests) like follows:
> Is there a fast way to this without scanning the log file many times?
As you encounter a new "host" add it to a dict (or anoth
On Thu, Mar 5, 2009 at 7:26 AM, Evan wrote:
> Hello ~
>
> I'm new with python, what my problem is, I have a binary file, I want
> to read first 2 bytes and convert it to host byte order, then write it
> to another file.
Have you checked out socket.htons, socket.ntohs, etc ?
--
http://mail.python
On Thu, Mar 5, 2009 at 5:40 PM, SpamMePlease PleasePlease
wrote:
> Python can do that and a lot more! For this purpose I would go to
> http://djangoproject.com/
Django is neat, but there are more choices for you:
http://wiki.python.org/moin/WebFrameworks
--
http://mail.python.org/mailman/listinfo
On Sat, Mar 21, 2009 at 9:26 AM, Esmail wrote:
> In any case, the scripts are starting to look pretty hairy and I was
> wondering if it would make sense to re-write them in Python. I am not
> sure how suitable it would be for this.
Are these scripts run on computers that are guaranteed to have Py
On Wed, Apr 1, 2009 at 10:43 AM, wrote:
> If anyone can give me some guidance what should be the best way to
> generate html/xhtml page using python would be great. I am open to
> other options like xsl or anything else that can make things simple.
Since you're open to other options, I would tak
On Sat, Apr 18, 2009 at 12:56 PM, karlos barlos wrote:
> LDAP://CN=bessy,OU=sales,DC=shay,DC=com
> LDAP://CN=ron,OU=legal,DC=shay,DC=com
>
> to a text \ csv file ...
>
> can any one help ??
Have a look at this:
http://docs.python.org/tutorial/inputoutput.html#reading-and-writing-files
and this:
Hi,
I am using Distutils to build and distribute some packages. I do write
unit tests, but I am confused as to where to put them and how to run
them prior to the package being installed (The modules being tested
would not be in my sys.path). I would rather not put the test cases in
the same files
On Mon, Jun 23, 2008 at 9:59 AM, Cédric Lucantis <[EMAIL PROTECTED]> wrote:
> Yes a checksuite should be kept separate from the 'real' code. You can run it
> locally by setting the PYTHONPATH environment variable :
>
> PYTHONPATH=/path/to/your/modules python checksuite.py
So I could also just appe
On Tue, Apr 22, 2008 at 4:55 PM, DataSmash <[EMAIL PROTECTED]> wrote:
> Hello,
>
> I have a list that looks like this:
> roadList = ["Motorways","Local","Arterial"]
>
> I want to apply some code so that the output looks like this:
> "Motorways;Local;Arterial"
> How can this be done with the LE
On Tue, Apr 29, 2008 at 10:33 AM, Victor Subervi
<[EMAIL PROTECTED]> wrote:
> Hi;
>
>
> why doesn't this work?
> It never increments z! Yet, if I print z, it will increment and change the
> bgcolor! Why?!
Are you only trying to "print '\n' % bg" once, or
for each iteration of the loop?
It might
On Tue, Sep 2, 2008 at 12:55 PM, Steven D'Aprano
<[EMAIL PROTECTED]> wrote:
> Is there a better way of doing this than the way I am going about it?
Would the logging module help, and just print the output to the stdout
(or a file) instead?
--
http://mail.python.org/mailman/listinfo/python-list
On Tue, Sep 23, 2008 at 8:37 AM, Bobby Roberts <[EMAIL PROTECTED]> wrote:
> hi group. I'm new to python and need some help and hope you can
> answer this question. I have a situation in my code where i need to
> create a file on the server and write to it. That's not a problem if
> i hard code t
On Mon, Dec 7, 2009 at 12:12 PM, dpapathanasiou
wrote:
> I have two methods for writing binaries files: the first works with
> data received by a server corresponding to a file upload, and the
> second works with data sent as email attachments.
>
> The odd thing is, they're not interchangeable: if
On Mon, Jan 4, 2010 at 12:28 PM, Victor Subervi wrote:
> Hi;
> I have this code snippet:
>
> sql '''create table if not exists %sCustomerData (
I think you may have forgotten the "=" after sql.
--
http://mail.python.org/mailman/listinfo/python-list
On Wed, Oct 14, 2009 at 8:39 AM, Benedict Verheyen
wrote:
> This kind of problems seems to happen sometimes: i need to fix something
> quickly,
> build a script for it, and then i realise that the code i've written is not
> the best in
> terms of reusability and has some "not so great" functions
On Wed, Oct 14, 2009 at 8:53 PM, Peng Yu wrote:
> I have the following python code snippet. I'm wondering what command I
> should use to terminate the program if the arguments are not right.
I usually use sys.exit.
--
http://mail.python.org/mailman/listinfo/python-list
On Tue, Nov 3, 2009 at 11:02 PM, Jonathan Haddad wrote:
> I've got a class, in the constructor it loads a CSV file from disc. I'd
> like only 1 instance of the class to be instantiated. However, when running
> multiple unit tests, multiple instances of the class are created. What's
> the best w
On Fri, Feb 19, 2010 at 3:54 AM, Schedule wrote:
> Hello everyone
>
> I haeve tried to understand the capabilities of python in web development.
> Have gone throuhg forums and online tutorials. Nevertheless I am not able to
> find any topic which can give me some insite along with basic examples o
On Thu, Apr 29, 2010 at 11:43 AM, Wolfnoliir wrote:
> I would like to add a method to the gtk.TextBuffer class to save a text
> buffer to a file, but I get an error:
I don't know gtk, but can you inherit from the TextBuffer class create
your own TexBuffer subclass with the save_to_file method?
--
On Wed, May 5, 2010 at 8:56 AM, Massi wrote:
> but this does not work, since the two threads share the same pid. Can
> anyone give me a suggestion?
Have you looked at os.fork ?
http://docs.python.org/library/os.html#os.fork
--
http://mail.python.org/mailman/listinfo/python-list
On Mon, May 10, 2010 at 8:38 AM, John Maclean wrote:
> hi,
>
> can some one explain why the __first__ test is not being run?
It looks like you defined test_T1 inside of the tearDown method.
--
http://mail.python.org/mailman/listinfo/python-list
On Mon, May 10, 2010 at 5:17 PM, cjw wrote:
> PyScripter and PythonWin permit the user to choose the equivalence of tabs
> and spaces. I like two spaces = on tab, it's a matter of taste. I feel
> that eight spaces is too much.
While it is a matter of taste, PEP 8 recommends 4 spaces per indent
On Thu, Jul 29, 2010 at 8:34 AM, Mahmood Naderan wrote:
> the output should be 7600 (s) for example. What is the best and easiest way
> to do that?
Take a look at time.clock()
http://docs.python.org/library/time.html#time.clock
"this is the function to use for benchmarking Python or timing algo
On Wed, Sep 23, 2009 at 10:49 AM, D'Arcy J.M. Cain wrote:
> Of course you can get around this by specifying every field and using
> "AS" to change the names to manager_id and employee_firstname, etc. but
> if you are going to do that anyway, why not just do it once in the
> database instead of lit
On Wed, Sep 23, 2009 at 4:21 PM, D'Arcy J.M. Cain wrote:
> In any case, I have a strong philosophical objection to using the same
> name to refer to two different things regardless of any operational
> issues. The manager.firstname and employee.firstname are not the same
> thing and should have d
73 matches
Mail list logo