timeit module in IDLE

2013-03-14 Thread Chris Angelico
While putting together some timing stats for the latest Python 3.3
string representation thread, I ran into an oddity in how IDLE handles
timeit. The normal way to profile Python code, according to stuff I've
found on the internet, is timeit.timeit:

>>> import timeit
>>> timeit.timeit("s=s[:-1]+u'\u1234'","s=u'asdf'*1",number=1)
0.57752172412974268

Now I knew that the module I wanted was timeit, but I didn't remember
the full incantation, so I did the obvious thing:

>>> import timeit
>>> timeit.

Only one thing came up: Timer. And help(timeit) doesn't mention
timeit.timeit either. Whereas the documentation:

http://docs.python.org/2/library/timeit.html
http://docs.python.org/3/library/timeit.html

clearly states that timeit.timeit() is the way to do things.

Snooping the source shows that timeit.timeit() is just a tiny
convenience function (alongside timeit.repeat()), but it'd still be
nice to have that come up in the Ctrl-Space list, since it's the
most-normal way to run timing tests.

Would there be a problem with adding timeit (and possibly repeat) to __all__?

-__all__ = ["Timer"]
+__all__ = ["Timer", "timeit"]

ChrisA
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: timeit module in IDLE

2013-03-14 Thread Terry Reedy

On 3/14/2013 2:58 AM, Chris Angelico wrote:

While putting together some timing stats for the latest Python 3.3
string representation thread, I ran into an oddity in how IDLE handles
timeit. The normal way to profile Python code, according to stuff I've
found on the internet, is timeit.timeit:


import timeit
timeit.timeit("s=s[:-1]+u'\u1234'","s=u'asdf'*1",number=1)

0.57752172412974268

Now I knew that the module I wanted was timeit, but I didn't remember
the full incantation, so I did the obvious thing:


import timeit
timeit.


Only one thing came up: Timer. And help(timeit) doesn't mention
timeit.timeit either. Whereas the documentation:

http://docs.python.org/2/library/timeit.html
http://docs.python.org/3/library/timeit.html

clearly states that timeit.timeit() is the way to do things.

Snooping the source shows that timeit.timeit() is just a tiny
convenience function (alongside timeit.repeat()), but it'd still be
nice to have that come up in the Ctrl-Space list, since it's the
most-normal way to run timing tests.

Would there be a problem with adding timeit (and possibly repeat) to __all__?

-__all__ = ["Timer"]
+__all__ = ["Timer", "timeit"]


I believe everything in the doc should be in __all__. Open an issue on 
the tracker and add terry.reedy as nosy.
Note on the issue that timeit.default_timer is not callable, contrary to 
the doc (which should also be fixed).


--
Terry Jan Reedy

--
http://mail.python.org/mailman/listinfo/python-list


Re: timeit module in IDLE

2013-03-14 Thread Chris Angelico
On Thu, Mar 14, 2013 at 6:21 PM, Terry Reedy  wrote:
> I believe everything in the doc should be in __all__. Open an issue on the
> tracker and add terry.reedy as nosy.
> Note on the issue that timeit.default_timer is not callable, contrary to the
> doc (which should also be fixed).

Thanks! Issue 17414 created.

ChrisA
-- 
http://mail.python.org/mailman/listinfo/python-list


Getting a list in user defined selection order

2013-03-14 Thread e . tekinalp
Hello everybody,

I want to select components(vertices) in a particular Order with python.
So when I create a list the main problem is, that maya is not listing the verts 
in the correct selected order as I did. 

Here an example:

I have selected from a polySphere the following vtx

[sphere.vtx400, sphere.vtx250, sphere.vtx260, sphere.vtx500, sphere.vtx100]

so maya is giving me a list like that:

[sphere.vtx100, sphere.vtx250, sphere.vtx260, sphere.vtx400, sphere.vtx500]

I know that there is a flag in the cmds.ls that created a list in ordered 
Selection and that you have to enable the tos flag from the selectPref command

cmds.selectPref(tso = 1)
vtx = cmds.ls(os = 1, flatten = 1)
cmds.select(vtx)

But then he gives me an empty list, I also tried to toggle it in the preference 
window, but to be honest that couldn't be the way.

So how can I get a list in an userdefined selection order.

Thank you guys for any help.

Cheerio
the turkish engineer
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Getting a list in user defined selection order

2013-03-14 Thread e . tekinalp
Ah sorry this is the correct snippet

cmds.selectPref(tso = 1)
vtx = cmds.ls(os = 1, flatten = 1)
print vtx

the other one wouldn't make any sense. :)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Sphinx highlighting

2013-03-14 Thread Jean-Michel Pichavant
- Original Message -
> What controls the yellow highlight bar that Sphinx sometimes puts in
> the
> documentation?
> E.g.:
> .. py:function:: basic_parseStrTest ()
> generates bold-face text, where
> .. py:function:: basicParseStrTest ()
> generates text with a yellow bar highlight.
> 
> I actually rather like the yellow bar highlight, but I can't stand
> having it appear for some of my functions, and not for others, and I
> haven't been able to figure out what turns it on or off.
> 
> --
> Charles Hixson

I think the yellow bar only shows up when you folllow a link to that function.

See for instance the difference between
http://docs.python.org/2/library/multiprocessing.html#multiprocessing.Process.start


and http://docs.python.org/2/library/multiprocessing.html
where you go manually to the start method.

Cheers,

JM


-- IMPORTANT NOTICE: 

The contents of this email and any attachments are confidential and may also be 
privileged. If you are not the intended recipient, please notify the sender 
immediately and do not disclose the contents to any other person, use it for 
any purpose, or store or copy the information in any medium. Thank you.
-- 
http://mail.python.org/mailman/listinfo/python-list


TypeError: 'float' object is not iterable

2013-03-14 Thread Ana Dionísio
Hi!!

I keep having this error and I don't know why: TypeError: 'float' object is not 
iterable.

I have this piece of code, that imports to python some data from Excel and 
saves it in a list:

"
t_amb = []

for i in range(sh2.nrows):
t_amb.append(sh2.cell(i,2).value)

print t_amb

"
Here is everything ok.

But then, I need to pass the data again to exel, so I wrote this:

"
a=8
for b in range (len(t_amb)):
a=8
for d in t_amb[b]:
a=a+1
sheet.write(a,b+1,d)
"

The error appear in "for d in t_amb[b]:" and I don't understand why. Can you 
help me?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: TypeError: 'float' object is not iterable

2013-03-14 Thread Joel Goldstick
On Thu, Mar 14, 2013 at 6:12 AM, Ana Dionísio wrote:

> Hi!!
>
> I keep having this error and I don't know why: TypeError: 'float' object
> is not iterable.
>
> I have this piece of code, that imports to python some data from Excel and
> saves it in a list:
>
> "
> t_amb = []
>
> for i in range(sh2.nrows):
> t_amb.append(sh2.cell(i,2).value)
>
> print t_amb
>
> "
> Here is everything ok.
>
> But then, I need to pass the data again to exel, so I wrote this:
>
> "
> a=8
> for b in range (len(t_amb)):
> a=8
> for d in t_amb[b]:
> a=a+1
> sheet.write(a,b+1,d)
> "
>
> The error appear in "for d in t_amb[b]:" and I don't understand why. Can
> you help me?
>

Most likely the value of t_amb[[b] is a float.  It would have to be a list
or a tuple or some other sequence to be iterable.  I can't tell what you
are trying to do here

> --
> http://mail.python.org/mailman/listinfo/python-list
>



-- 
Joel Goldstick
http://joelgoldstick.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: TypeError: 'float' object is not iterable

2013-03-14 Thread Ana Dionísio
But isn't t_amb a list? I thought that the first piece of script would create a 
list.

I'm trying to create a list named t_amb with some values that are in a Excel 
sheet. And then I need to export that list to another Excel sheet
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: TypeError: 'float' object is not iterable

2013-03-14 Thread MRAB

On 14/03/2013 10:12, Ana Dionísio wrote:

Hi!!

I keep having this error and I don't know why: TypeError: 'float' object is not 
iterable.

I have this piece of code, that imports to python some data from Excel and 
saves it in a list:

"
t_amb = []

for i in range(sh2.nrows):
 t_amb.append(sh2.cell(i,2).value)

print t_amb

"
Here is everything ok.

But then, I need to pass the data again to exel, so I wrote this:

"
a=8
for b in range (len(t_amb)):
 a=8
 for d in t_amb[b]:
 a=a+1
 sheet.write(a,b+1,d)
"

The error appear in "for d in t_amb[b]:" and I don't understand why. Can you 
help me?


t_amb is a list of float, so t_amb[b] is a float, but you can't iterate
over a float.
--
http://mail.python.org/mailman/listinfo/python-list


Re: TypeError: 'float' object is not iterable

2013-03-14 Thread Joel Goldstick
On Thu, Mar 14, 2013 at 6:34 AM, Ana Dionísio wrote:

> But isn't t_amb a list? I thought that the first piece of script would
> create a list.
>
t_amb might be a list, but t_amb[b] is apparently a number of type float
that is in that list

>
> I'm trying to create a list named t_amb with some values that are in a
> Excel sheet. And then I need to export that list to another Excel sheet
> --
> http://mail.python.org/mailman/listinfo/python-list
>



-- 
Joel Goldstick
http://joelgoldstick.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: String performance regression from python 3.2 to 3.3

2013-03-14 Thread rusi
On Mar 14, 11:47 am, Chris Angelico  wrote:

> I expect that Python 3.2 will behave comparably to the 2.6 stats, but
> I don't have 3.2s handy - can someone confirm please?

I have 3.2 but not 3.3. Can run it later today if no one does.
But better if someone with both on the same machine do the comparison.


jmf will you please run Chris' examples on all your pythons?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: TypeError: 'float' object is not iterable

2013-03-14 Thread Chris Rebert
On Thu, Mar 14, 2013 at 3:12 AM, Ana Dionísio  wrote:
> Hi!!
>
> I keep having this error and I don't know why: TypeError: 'float' object is 
> not iterable.

In general, in the future, always include the full exception
Traceback, not just the final error message. The extra details this
provides can greatly aid debugging.

> I have this piece of code, that imports to python some data from Excel and 
> saves it in a list:
>
> "
> t_amb = []
>
> for i in range(sh2.nrows):
> t_amb.append(sh2.cell(i,2).value)

`t_amb` is a list, and you are apparently putting floats (i.e. real
numbers) into it. `t_amb` is a list of floats.
Therefore every item of `t_amb` (i.e. `t_amb[x]`, for any `x` that's
within the bounds of the list's indices) will be a float.
(Also, you may want to rewrite this as a list comprehension;
http://docs.python.org/2/tutorial/datastructures.html#list-comprehensions
)

> print t_amb
>
> "
> Here is everything ok.
>
> But then, I need to pass the data again to exel, so I wrote this:
>
> "
> a=8
This duplicate assignment is pointless.

> for b in range (len(t_amb)):
> a=8
> for d in t_amb[b]:

Given our earlier conclusion, we likewise know that `t_amb[b]` will be
a float (we merely replaced the arbitrary `x` with `b`). A single
float is a scalar, not a collection, so it's nonsensical to try and
iterate over it like you are in "for d in t_amb[b]:"; a number is not
a list. `t_amb[b]` is a lone number, and numbers contain no
items/elements over which to iterate. Perhaps you want just "d =
t_amb[b]" ? Remember that in a `for` loop, the expression after the
`in` (i.e. `t_amb[b]`) is evaluated only once, at the beginning of the
loop, and not repeatedly. In contrast, assuming this were a valid
`for` loop, `d` would take on different values at each iteration of
the loop.

In any case, it's rarely necessary nowadays to manually iterate over
the range of the length of a list; use `enumerate()` instead;
http://docs.python.org/2/library/functions.html#enumerate

> a=a+1
> sheet.write(a,b+1,d)
> "
>
> The error appear in "for d in t_amb[b]:" and I don't understand why. Can you 
> help me?

I hope this explanation has been sufficiently clear. If you haven't
already, you may wish to review the official Python tutorial at
http://docs.python.org/2/tutorial/index.html . You may also find it
helpful to run your program step-by-step in the interactive
interpreter/shell, printing out the values of your variables along the
way so as to understand what your program is doing.

Regards,
Chris
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Finding the Min for positive and negative in python 3.3 list

2013-03-14 Thread 88888 Dihedral
Wolfgang Maier於 2013年3月13日星期三UTC+8下午6時43分38秒寫道:
> Steven D'Aprano  pearwood.info> writes:
> 
> 
> 
> > 
> 
> > On Tue, 12 Mar 2013 17:03:08 +, Norah Jones wrote:
> 
> > 
> 
> > > For example:
> 
> > > a=[-15,-30,-10,1,3,5]
> 
> > > 
> 
> > > I want to find a negative and a positive minimum.
> 
> > > 
> 
> > > example: negative
> 
> > > print(min(a)) = -30
> 
> > >  
> 
> > > positive
> 
> > > print(min(a)) = 1
> 
> > 
> 
> > Thank you for providing examples, but they don't really cover all the 
> 
> > possibilities. For example, if you had:
> 
> > 
> 
> > a = [-1, -2, -3, 100, 200, 300]
> 
> > 
> 
> > I can see that you consider -3 to be the "negative minimum". Do you 
> 
> > consider the "positive minimum" to be 100, or 1?
> 
> > 
> 
> > If you expect it to be 100, then the solution is:
> 
> > 
> 
> > min([item for item in a if item > 0])
> 
> > 
> 
> > If you expect it to be 1, then the solution is:
> 
> > 
> 
> > min([abs(item) for item in a])
> 
> > 
> 
> > which could also be written as:
> 
> > 
> 
> > min(map(abs, a))
> 
> > 
> 
> > A third alternative is in Python 3.3:
> 
> > 
> 
> > min(a, key=abs)
> 
> > 
> 
> > which will return -1.
> 
> > 
> 
> 
> 
> thinking again about the question, then the min() solutions suggested so far
> 
> certainly do the job and they are easy to understand.
> 
> However, if you need to run the function repeatedly on larger lists, using 
> min()
> 
> is suboptimal because its performance is an O(n) one.
> 
> It's faster, though less intuitive, to sort your list first, then use bisect 
> on
> 
> it to find the zero position in it. Two manipulations running at O(log(n)).
> 
> 
> 
> compare these two functions:
> 
> 
> 
> def with_min(x):
> 
> return (min(n for n in a if n<0), min(n for n in a if n>=0))
> 
> 
> 
> def with_bisect(x):
> 
> b=sorted(x)
> 
> return (b[0] if b[0]<0 else None, b[bisect.bisect_left(b,0)])
> 
> 
> 
> then either time them for small lists or try:
> 
> 
> 
> a=range(-1000,1000)
> 
> with_min(a)
> 
> with_bisect(a)
> 
> 
> 
> of course, the disadvantage is that you create a huge sorted list in memory 
> and
> 
> that it's less readable.
> 
> 
> 
> Best,
> 
> Wolfgang

Sorting numbers of such range M in a list of length N by radix sort 
is faster but requires more memory.
-- 
http://mail.python.org/mailman/listinfo/python-list


how to couper contenier of a canvas in an outer canvas???

2013-03-14 Thread olsr . kamal
how to couper all the obejcts in a canvas in an auther canvas? 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What's the easiest Python datagrid GUI (preferably with easy database hooks as well)?

2013-03-14 Thread Wolfgang Keller
> I want to write a fairly trivial database driven application, it will
> basically present a few columns from a database, allow the user to add
> and/or edit rows, recalculate the values in one column and write the
> data back to the database.
> 
> I want to show the data and allow editing of the data in a datagrid as
> being able to see adjacent/previous data will help a huge amount when
> entering data.
> 
> So what toolkits are there out there for doing this sort of thing?  A
> GUI toolkit would be lovely (allowing layout etc.) but isn't
> absolutely necessary.
> 
> I'm a reasonably experienced programmer and know python quite well
> but I'm fairly much a beginner with event driven GUI stuff so I need
> a user friendly framework.

This is becoming an FAQ.

The currently available (non-web) database application development
frameworks for Python are:

using wxPython:
Dabohttp://www.dabodev.com
Defis   http://sourceforge.net/projects/defis/ (Russian only)
GNUehttp://www.gnuenterprise.org/

using PyQt:
Pypapi  https://pypi.python.org/pypi/PyPaPi
Camelot http://www.python-camelot.com/
Qtalchemy   http://www.qtalchemy.org/
Thyme   http://clocksoft.co.uk/downloads/
Kexihttp://www.kexi-project.org/

using PyGTK:
SQLkit  http://sqlkit.argolinux.org/
Kiwihttp://www.async.com.br/projects/kiwi/
Glomhttp://www.glom.org

Openoffice Base
http://www.openoffice.org/product/base.html
Libreoffice Base
http://www.libreoffice.org/features/base/

OpenERP http://www.openerp.org
Tryton  http://www.tryton.org

Dabo (they're about to release 1.0 for Pycon), Pypapi, Camelot, SQLkit
seem to be the most actively developed and best documented ones.

OpenERP and Tryton are ERP systems that can also be used as
frameworks for non-ERP custom applications.

Apparently defunct:

Pythoncard  http://pythoncard.sourceforge.net/
Boa Constructor http://boa-constructor.sourceforge.net/
Knoda   http://www.knoda.org/
Rekall  ?
Gemello http://abu.sourceforge.net/

Sincerely,

Wolfgang
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Pygame mouse cursor load/unload

2013-03-14 Thread Ian Kelly
On Tue, Mar 12, 2013 at 5:33 PM, Alex Gardner  wrote:
> Sorry but im back to square one.  My paddle isn't showing up at all! 
> http://pastebin.com/PB5L8Th0

paddle_rect.center = pygame.mouse.get_pos()

This updates the paddle position.

screen.blit(beeper, paddle_rect)

This draws the paddle at that position.

screen.blit(bpaddle, paddle_rect)

This draws the blank paddle at that same position.  Try to think about
why this results in the paddle not showing up.

If this is for a class, I think you should spend some quality time
with the TA rather than continue to throw non-functional code at this
list, which is clearly getting you nowhere.
-- 
http://mail.python.org/mailman/listinfo/python-list


Generating Filenames from Feeds

2013-03-14 Thread Chuck
HI all,

I am trying to write a podcast catcher for fun, and I am trying to come up with 
a way to generate a destination filename to use in the function 
urlretrieve(url, destination).  I  would like the destination filename to end 
in a .mp3 extension.  

My first attempts were parsing out the  and stripping the whitespace 
characters, and joining with os.path.join.  I haven't been able to make that 
work for some reason.  Whenever I put the .mp3 in the os.path.join I get syntax 
errors.  I am wondering if there is a better way?

I was doing something like os.path.join('C:\\Users\\Me\\Music\\Podcasts\\', 
pubdate.mp3), where pubdate has been parsed and stripped of whitespace.  I keep 
getting an error around the .mp3.

Any ideas?

Thanks!!
Chuck  
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Generating Filenames from Feeds

2013-03-14 Thread Joel Goldstick
On Thu, Mar 14, 2013 at 11:38 AM, Chuck  wrote:

> HI all,
>
> I am trying to write a podcast catcher for fun, and I am trying to come up
> with a way to generate a destination filename to use in the function
> urlretrieve(url, destination).  I  would like the destination filename to
> end in a .mp3 extension.
>
> My first attempts were parsing out the  and stripping the
> whitespace characters, and joining with os.path.join.  I haven't been able
> to make that work for some reason.


The reason is apparently a  syntax error.

Whenever I put the .mp3 in the os.path.join I get syntax errors.  I am
> wondering if there is a better way?
>

Yes, don't write code with syntax errors!

>
> I was doing something like
> os.path.join('C:\\Users\\Me\\Music\\Podcasts\\', pubdate.mp3), where
> pubdate has been parsed and stripped of whitespace.  I keep getting an
> error around the .mp3.
>
> Any ideas?
>

Seriously, if you don't post a minimal code example that shows the problem
and with a full traceback you are asking strangers to do magic tricks for
your pleasure.

>
> Thanks!!
> Chuck
> --
> http://mail.python.org/mailman/listinfo/python-list
>



-- 
Joel Goldstick
http://joelgoldstick.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Generating Filenames from Feeds

2013-03-14 Thread MRAB

On 14/03/2013 15:38, Chuck wrote:

HI all,

I am trying to write a podcast catcher for fun, and I am trying to
come up with a way to generate a destination filename to use in the
function urlretrieve(url, destination).  I  would like the
destination filename to end in a .mp3 extension.

My first attempts were parsing out the  and stripping the
whitespace characters, and joining with os.path.join.  I haven't been
able to make that work for some reason.  Whenever I put the .mp3 in
the os.path.join I get syntax errors.  I am wondering if there is a
better way?

I was doing something like
os.path.join('C:\\Users\\Me\\Music\\Podcasts\\', pubdate.mp3), where
pubdate has been parsed and stripped of whitespace.  I keep getting
an error around the .mp3.

Any ideas?


The filename referred to by pubdate is a string, and you want to append
an extension, also a string, to it. Therefore:

os.path.join('C:\\Users\\Me\\Music\\Podcasts\\', pubdate + '.mp3')
--
http://mail.python.org/mailman/listinfo/python-list


editing a HTML file

2013-03-14 Thread Tracubik

Hi all,

I'would like to make a script that automatically change some text in a 
html file.


I need to make some changes in the text of  tags

My question is: there is a way to just "update/substitute" the text in 
the html  tags or do i have to make a new modified copy of the html file?


To be clear, i'ld like to make something like this:

open html file
for every  tags:
  if "foo" in text:
change "foo" in "bar"
close html file

any sample would be really appreciated
I'm really a beginner as you can see

Thanks
--
http://mail.python.org/mailman/listinfo/python-list


Re: TypeError: 'float' object is not iterable

2013-03-14 Thread John Ladasky
On Thursday, March 14, 2013 3:12:11 AM UTC-7, Ana Dionísio wrote:

> for b in range (len(t_amb)):
> a=8
> for d in t_amb[b]:
> a=a+1
> sheet.write(a,b+1,d)
> 
> The error appear in "for d in t_amb[b]:" and I don't understand why. Can you 
> help me?

It looks to me like you know how to program in some other language, possibly C, 
and your other language's needs are affecting the way that you write Python.  

You are supplying an explicit variable, b to step through... something.  I 
THINK that you want to step through t_amb, and not through the Bth element of 
t_amb.  Python's "in" statement will do this for you automatically, without you 
having to keep track of an index variable.

You didn't show your import statements, but I assume you are using the xlwt 
module.  That's where I find the sheet.write() function.  Now, exactly HOW did 
you want to write the data back to the Excel file?  In a single column?  A 
single row?  Or in a diagonal?  You have two nested loops.  I'm confused by the 
fact that you are incrementing both the row and column indices for 
sheet.write().

Do you know about the enumerate() function?  It's very handy.  It yields a 
tuple, the first element of which is a number counting up from zero, and the 
second element of which is an element from the (iterable) variable that you 
provide.

Does this code accomplish your task?

for column, data in enumerate(t_amb):
sheet.write(8, column+1, data)

Or this?

for row, data in enumerate(t_amb):
sheet.write(row+8, 1, data)

If you have any questions, feel free to ask.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: editing a HTML file

2013-03-14 Thread Jean-Michel Pichavant
- Original Message -
> Hi all,
> 
> I'would like to make a script that automatically change some text in
> a
> html file.
> 
> I need to make some changes in the text of  tags
> 
> My question is: there is a way to just "update/substitute" the text
> in
> the html  tags or do i have to make a new modified copy of the
> html file?
> 
> To be clear, i'ld like to make something like this:
> 
> open html file
> for every  tags:
>if "foo" in text:
>  change "foo" in "bar"
> close html file
> 
> any sample would be really appreciated
> I'm really a beginner as you can see
> 
> Thanks
> --
> http://mail.python.org/mailman/listinfo/python-list
> 

Hi,

You can use
http://www.crummy.com/software/BeautifulSoup/bs4/doc/#modifying-the-tree

Almost all functions have an example.


Cheers,

JM


-- IMPORTANT NOTICE: 

The contents of this email and any attachments are confidential and may also be 
privileged. If you are not the intended recipient, please notify the sender 
immediately and do not disclose the contents to any other person, use it for 
any purpose, or store or copy the information in any medium. Thank you.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Generating Filenames from Feeds

2013-03-14 Thread Chuck

> Seriously, if you don't post a minimal code example that shows the problem 
> and with a full traceback you are asking strangers to do magic tricks for 
> your pleasure. 

I'm asking more for a better way of generating destination filenames, not so 
much debugging questions.  I only put my attempts there to show people that I 
was actually trying something, and not just relying on people to do my thinking 
for me.

I'm trying to take a feed such as this 

http://www.theskepticsguide.org/feed/rss.aspx?feed=SGU

and parse some useful data out of it for a destination filename.  The solution 
should be general, and not just for this particular feed.

Thanks!















-- 
http://mail.python.org/mailman/listinfo/python-list


Re: IOError:[Errno 27] File too large

2013-03-14 Thread ch . valderanis

> Taking a wild guess, I think that you are using a Samba share on a Linux 
> 
> server. A file "FILENAME.xml;" was accidentally creating on this share 
> 
> from the Linux filesystem layer, since Linux will allow you to use 
> 
> semicolons in file names. But samba enforces the same restrictions as 
> 
> Windows, so when you access the file system through sambda, it gives an 
> 
> error when you try to create a new file "FILENAME.sub;".
> 
> This is a wild guess, and could be completely wrong. Please come back and 
> 
> tell us the solution when you have solved it.

So, let me report the solution.
All the files were in an afs filesystem. afs has a limit for the total length 
of  the filenames per directory. for more details take a look at 
http://www.inf.ed.ac.uk/systems/AFS/topten.html#Tip13
In my case 10k files with ~160characters per filename were just hitting the 
limit. The error message is basically misleading.

Makis
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Pygame mouse cursor load/unload

2013-03-14 Thread Alex Gardner
On Saturday, March 2, 2013 7:56:31 PM UTC-6, Alex Gardner wrote:
> I am in the process of making a pong game in python using the pygame library. 
>  My current problem is that when I move the mouse, it turns off as soon as 
> the mouse stops moving.  The way I am doing this is by making the default 
> cursor invisible and using .png files as replacements for the cursor.  
> Perhaps my code would best explain my problem.  I will take help in any way 
> that I can.  Here are the links that contain my code:
> 
> 
> 
> Main class:  http://pastebin.com/HSQzX6h2
> 
> Main file (where the problem lies):  http://pastebin.com/67p97RsJ
> 
> 
> 
> If the links yield nothing, please let me know (agardner...@gmail.com)

It's all working now with one exception.  I just want to arrange the paddle to 
the right side.  I managed to do just that, but it won't move freely 
vertically.  I am not fully aware of the arguments of pygame.Rect().  Here is 
what I am using:


bounds_rect = pygame.Rect(880,200,0,500)


Again, it all works minus the vertcal movement.  The full code (keep in mind it 
works fine now) is http://pastebin.com/xAAda30e

I thank you all (esp. Ian) for this help.  I broke down and remade the code and 
behold it works (with this exception).  Oh, Ian, this isn't a class assignment; 
it's a personal project to help me in the process of learning python.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: 2-D drawing/map with python

2013-03-14 Thread Matteo Boscolo

Il 12/03/2013 16:58, Huseyin Emre Guner ha scritto:

Hello,
I am newbie in Python. I would like to make a project using python.
The main ideo of this project is that a user enters the x,y values to  the Gui(PyQt or 
Gtk) and then a 2-D map is plotted due to the x,y values. First, I use Pygame commands 
"(pygame.draw.line(window, (255, 255, 255), (10, 10), (200, 400))" However  I 
could not establish a gui with pygame. Now I would like to use the PyQt.  Could you 
please give me advice for this project?
have a look at : http://sourceforge.net/projects/pythoncad/ it's also 
integrated with sympy ..


regards,
Matteo

--
http://mail.python.org/mailman/listinfo/python-list


Re: how to couper contenier of a canvas in an outer canvas???

2013-03-14 Thread Rick Johnson
On Thursday, March 14, 2013 7:16:05 AM UTC-5, olsr@gmail.com wrote:
> how to couper all the obejcts in a canvas in an auther canvas?

Hmm, well before i can even start solving your problem, i'll need to spend some 
time figuring out what the hell you're problem is. o_O. "Maybe" you meant to 
say this:

> how to [copy] all the [canvas items] in [one] canvas [into another] canvas?

 "Ahhh, the sweet nectar of articulate communication!"

Why would you want to do that exactly? Hopefully you have a good reason. There 
are quite a few "canvas items" to consider:

* arc objects
* bitmap objects
* image objects
* line objects
* oval objects
* polygon objects
* rectangle objects
* text objects
* window objects

There does not seem to be an easy way to do this via the Tkinter API (feel free 
to dig through the TCL/Tk docs if you like), however, if all you need to do is 
transfer a few simple primitives from one canvas to another, then the following 
(very general and admittedly quite naive) approach might get you there:

for object in canvas1
# create newobject in canvas2
# configure newobject 

But there are quite a few (very important) details that that little sample 
leaves out, for instance: tags, stacking orders, tag bindings, etc. 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Pygame mouse cursor load/unload

2013-03-14 Thread Ian Kelly
On Thu, Mar 14, 2013 at 4:16 PM, Alex Gardner  wrote:
> It's all working now with one exception.  I just want to arrange the paddle 
> to the right side.  I managed to do just that, but it won't move freely 
> vertically.  I am not fully aware of the arguments of pygame.Rect().

I recommend you read the docs, then:

http://www.pygame.org/docs/ref/rect.html

In particular, the clamp method documentation states:

If the rectangle is too large to fit inside, it is centered
inside the argument Rect, but its size is not changed.

This is the case because your bounds_rect has width 0.  I suggest
changing the width of the bounds_rect to be equal to the width of the
paddle.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Getting a list in user defined selection order

2013-03-14 Thread Terry Reedy

On 3/14/2013 5:34 AM, e.tekin...@gmx.de wrote:

Hello everybody,

I want to select components(vertices) in a particular Order with python.
So when I create a list the main problem is, that maya is not listing the verts 
in the correct selected order as I did.

Here an example:

I have selected from a polySphere the following vtx

[sphere.vtx400, sphere.vtx250, sphere.vtx260, sphere.vtx500, sphere.vtx100]

so maya is giving me a list like that:

[sphere.vtx100, sphere.vtx250, sphere.vtx260, sphere.vtx400, sphere.vtx500]


It is sorting by name.


I know that there is a flag in the cmds.ls that created a list in ordered 
Selection and that you have to enable the tos flag from the selectPref command

cmds.selectPref(tso = 1)
vtx = cmds.ls(os = 1, flatten = 1)
cmds.select(vtx)

But then he gives me an empty list, I also tried to toggle it in the preference 
window, but to be honest that couldn't be the way.

So how can I get a list in an userdefined selection order.

Thank you guys for any help.


This is a maya question rather than a python question. Is not there a 
maye list where you can ask? If not, is a a stackovevflow-like site that 
covers maya?


--
Terry Jan Reedy

--
http://mail.python.org/mailman/listinfo/python-list


Re: Pygame mouse cursor load/unload

2013-03-14 Thread Alex Gardner
On Saturday, March 2, 2013 7:56:31 PM UTC-6, Alex Gardner wrote:
> I am in the process of making a pong game in python using the pygame library. 
>  My current problem is that when I move the mouse, it turns off as soon as 
> the mouse stops moving.  The way I am doing this is by making the default 
> cursor invisible and using .png files as replacements for the cursor.  
> Perhaps my code would best explain my problem.  I will take help in any way 
> that I can.  Here are the links that contain my code:
> 
> 
> 
> Main class:  http://pastebin.com/HSQzX6h2
> 
> Main file (where the problem lies):  http://pastebin.com/67p97RsJ
> 
> 
> 
> If the links yield nothing, please let me know (agardner...@gmail.com)

The docs helped (never knew they were there!) and its all safe and sound for 
now.   Thanks :)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Generating Filenames from Feeds

2013-03-14 Thread Steven D'Aprano
On Thu, 14 Mar 2013 11:19:18 -0700, Chuck wrote:

>> Seriously, if you don't post a minimal code example that shows the
>> problem and with a full traceback you are asking strangers to do magic
>> tricks for your pleasure.
> 
> I'm asking more for a better way of generating destination filenames,
> not so much debugging questions.  I only put my attempts there to show
> people that I was actually trying something, and not just relying on
> people to do my thinking for me.
> 
> I'm trying to take a feed such as this
> 
> http://www.theskepticsguide.org/feed/rss.aspx?feed=SGU
> 
> and parse some useful data out of it for a destination filename.  The
> solution should be general, and not just for this particular feed.

There is no such general solution, because "some useful data" will depend 
on what you intend to do with it, what the feed is, and what *you* 
consider "useful".

Your earlier approach is probably fine, once you fix the syntax error.


-- 
Steven
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Getting a list in user defined selection order

2013-03-14 Thread e . tekinalp
Am Donnerstag, 14. März 2013 10:34:31 UTC+1 schrieb e.tek...@gmx.de:
> Hello everybody,
> 
> 
> 
> I want to select components(vertices) in a particular Order with python.
> 
> So when I create a list the main problem is, that maya is not listing the 
> verts in the correct selected order as I did. 
> 
> 
> 
> Here an example:
> 
> 
> 
> I have selected from a polySphere the following vtx
> 
> 
> 
> [sphere.vtx400, sphere.vtx250, sphere.vtx260, sphere.vtx500, sphere.vtx100]
> 
> 
> 
> so maya is giving me a list like that:
> 
> 
> 
> [sphere.vtx100, sphere.vtx250, sphere.vtx260, sphere.vtx400, sphere.vtx500]
> 
> 
> 
> I know that there is a flag in the cmds.ls that created a list in ordered 
> Selection and that you have to enable the tos flag from the selectPref command
> 
> 
> 
> cmds.selectPref(tso = 1)
> 
> vtx = cmds.ls(os = 1, flatten = 1)
> 
> cmds.select(vtx)
> 
> 
> 
> But then he gives me an empty list, I also tried to toggle it in the 
> preference window, but to be honest that couldn't be the way.
> 
> 
> 
> So how can I get a list in an userdefined selection order.
> 
> 
> 
> Thank you guys for any help.
> 
> 
> 
> Cheerio
> 
> the turkish engineer

ah thank you Terry I was in the wrong group.. XD
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: String performance regression from python 3.2 to 3.3

2013-03-14 Thread Terry Reedy

On 3/14/2013 6:48 AM, rusi wrote:

On Mar 14, 11:47 am, Chris Angelico  wrote:


I expect that Python 3.2 will behave comparably to the 2.6 stats, but
I don't have 3.2s handy - can someone confirm please?


I have 3.2 but not 3.3. Can run it later today if no one does.
But better if someone with both on the same machine do the comparison.


The python devs use the microbenchmarks in 
Tools/stringbench/stringbench.py, which covers all string operations, as 
the basis for improving particular string functions. Overall, Unicode is 
nearly as fast as bytes and 3.3 as fast as 3.2. Find/replace is the 
notable exception in stringbench, so it is an anomaly. Other things are 
faster in 3.3.  In selecting the new implementation, the devs also 
considered space and speed gains that do not show up in microbenchmarks.


--
Terry Jan Reedy

--
http://mail.python.org/mailman/listinfo/python-list


Re: String performance regression from python 3.2 to 3.3

2013-03-14 Thread Terry Reedy

On 3/14/2013 7:14 PM, Terry Reedy wrote:

On 3/14/2013 6:48 AM, rusi wrote:

On Mar 14, 11:47 am, Chris Angelico  wrote:


I expect that Python 3.2 will behave comparably to the 2.6 stats, but
I don't have 3.2s handy - can someone confirm please?


I have 3.2 but not 3.3. Can run it later today if no one does.
But better if someone with both on the same machine do the comparison.


The python devs use the microbenchmarks in
Tools/stringbench/stringbench.py, which covers all string operations, as
the basis for improving particular string functions. Overall, Unicode is
nearly as fast as bytes and 3.3 as fast as 3.2. Find/replace is the
notable exception in stringbench, so it is an anomaly. Other things are
faster in 3.3.  In selecting the new implementation, the devs also
considered space and speed gains that do not show up in microbenchmarks.


Links to the readme and code for stringbench can be found here:
http://hg.python.org/cpython/file/c25bc2587c48/Tools/stringbench


--
Terry Jan Reedy

--
http://mail.python.org/mailman/listinfo/python-list


Re: how to couper contenier of a canvas in an outer canvas???

2013-03-14 Thread alex23
On Mar 15, 8:24 am, Rick Johnson  wrote:
> Hmm, well before i can even start solving your problem, i'll need to
> spend some time figuring out what the hell you're problem is. o_O.
> "Maybe" you meant to say this:
>
> > how to [copy] all the [canvas items] in [one] canvas [into another] canvas?
>
>  "Ahhh, the sweet nectar of articulate communication!"

Mocking people for whom English is obviously not their first language
just makes you look petty and racist.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: editing a HTML file

2013-03-14 Thread Dave Angel

On 03/14/2013 02:09 PM, Tracubik wrote:

Hi all,

I'would like to make a script that automatically change some text in a
html file.

I need to make some changes in the text of  tags

My question is: there is a way to just "update/substitute" the text in
the html  tags or do i have to make a new modified copy of the html
file?

To be clear, i'ld like to make something like this:

open html file
for every  tags:
   if "foo" in text:
 change "foo" in "bar"
close html file

any sample would be really appreciated
I'm really a beginner as you can see

Thanks



As JM points out, you can use Beautiful Soup to parse html.  Then you 
can make structural changes, and write it back out.  Beautiful Soup is 
NOT part of the standard library.


But if you haven't already written something that modifies regular text 
files, I'd do that long before I even started messing with html.  You 
cannot in general update things in place, so you have to think about the 
mechanics of updating, and of minimizing or eliminating the likelihood 
of losing data.


For example, suppose you have a text file (created with any text editor) 
that has just one occurrence of the string "Sammy".  You want to replace 
that with the word "Gazelda".  Notice the replacement string is longer 
than the original.  Think about how you'd go about it, and write the 
simplest program that would accomplish it.  Then think about what could 
go wrong.  What about if somebody shuts the machine off just as you're 
starting to rewrite the file, or the program crashes just then, or 
whatever ?  So plan to write the replacement file to a new name, and 
after written, do the appropriate renames and delete of the old one.


Don't forget about closing each file, especially if you're going to 
manipulate it with other functions.




--
DaveA
--
http://mail.python.org/mailman/listinfo/python-list


Re: IOError:[Errno 27] File too large

2013-03-14 Thread Dave Angel

On 03/14/2013 04:12 PM, ch.valdera...@gmail.com wrote:



Taking a wild guess, I think that you are using a Samba share on a Linux

server. A file "FILENAME.xml;" was accidentally creating on this share

from the Linux filesystem layer, since Linux will allow you to use

semicolons in file names. But samba enforces the same restrictions as

Windows, so when you access the file system through sambda, it gives an

error when you try to create a new file "FILENAME.sub;".

This is a wild guess, and could be completely wrong. Please come back and

tell us the solution when you have solved it.


So, let me report the solution.
All the files were in an afs filesystem. afs has a limit for the total length 
of  the filenames per directory. for more details take a look at 
http://www.inf.ed.ac.uk/systems/AFS/topten.html#Tip13
In my case 10k files with ~160characters per filename were just hitting the 
limit. The error message is basically misleading.

Makis



Aha!  So the file that was too large was the directory file.

--
DaveA
--
http://mail.python.org/mailman/listinfo/python-list


Re: Yet another attempt at a safe eval() call

2013-03-14 Thread Ken Seehart
On 1/4/2013 5:33 AM, Steven D'Aprano wrote:
> On Fri, 04 Jan 2013 07:24:04 -0500, Terry Reedy wrote:
>
>> On 1/3/2013 6:25 PM, Grant Edwards wrote:
>>> I've written a small assembler in Python 2.[67], and it needs to
>>> evaluate integer-valued arithmetic expressions in the context of a
>>> symbol table that defines integer values for a set of names.  The
>>> "right" thing is probably an expression parser/evaluator using ast, but
>>> it looked like that would take more code that the rest of the assembler
>>> combined, and I've got other higher-priority tasks to get back to.
>> Will ast.literal_eval do what you want?
> No. Grant needs to support variables, not just literal constants, hence 
> the symbol table.
>
>
Apologies for the delayed response...

Seems like it would be a bit safer and easier to approach this problem
by stretching the capability of ast.literal_eval() rather than
attempting to sandbox eval().

How about ast.literal_eval after performing lexical substitution using
the symbol table?

Assignment into the symbol table, and error handling, are exercises left
to the reader.

Something vaguely like this:

/pseudocode:/

def safe_eval(s, symbols={}):
while search(s, r'\w+'):
replace match with '('+repr(symbols[match])+')' in s
return ast.literal_eval(s)

- Ken

-- 
http://mail.python.org/mailman/listinfo/python-list


changes on windows registry doesn’t take effect immediately

2013-03-14 Thread iMath
changes on windows registry doesn’t take effect immediately

I am trying to change IE’s proxy settings by the following 2 code snippets 

to enable the proxy by this code 

from winreg import *
with 
OpenKey(HKEY_CURRENT_USER,r"Software\Microsoft\Windows\CurrentVersion\Internet 
Settings" ,0, KEY_ALL_ACCESS) as key:
SetValueEx(key,"ProxyServer",0, REG_SZ, "127.0.0.1:8087")
SetValueEx(key,"ProxyEnable",0, REG_DWORD, 1)
SetValueEx(key,"ProxyOverride",0, REG_SZ, "")
FlushKey(key)

to disable the proxy by this code 

from winreg import *
with 
OpenKey(HKEY_CURRENT_USER,r"Software\Microsoft\Windows\CurrentVersion\Internet 
Settings" ,0, KEY_ALL_ACCESS) as key:

DeleteValue(key,"ProxyServer")
SetValueEx(key,"ProxyEnable",0, REG_DWORD, 0)
DeleteValue(key,"ProxyOverride")
FlushKey(key)

but the changes on windows registry doesn’t take effect immediately,so is there 
some way to change the windows registry and let the changes  take effect 
immediately without restarting IE ?

BTW ,I use the code on winxp ,and I am going to embed the 2 code snippets in my 
PyQt application .
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: changes on windows registry doesn’t take effect immediately

2013-03-14 Thread Steven D'Aprano
On Thu, 14 Mar 2013 22:26:50 -0700, iMath wrote:

> changes on windows registry doesn’t take effect immediately
> 
> I am trying to change IE’s proxy settings by the following 2 code
> snippets
[...]
> but the changes on windows registry doesn’t take effect immediately,so
> is there some way to change the windows registry and let the changes 
> take effect immediately without restarting IE ?

That's an IE question, not a Python question. You might be lucky and have 
somebody here happen to know the answer, but you'll probably have more 
luck asking on a group dedicated to Windows and IE.



-- 
Steven
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: changes on windows registry doesn�t take effect immediately

2013-03-14 Thread Tim Roberts
iMath  wrote:
>
>changes on windows registry doesn’t take effect immediately

Well, that's not exactly the issue.  The registry is being changed
immediately.  The issue is that IE doesn't check for proxy settings
continuously.

>but the changes on windows registry doesn’t take effect immediately, so
>is there some way to change the windows registry and let the changes
>take effect immediately without restarting IE ?

No.  This is an IE issue, not a registry issue.  Other browsers might
behave differently.
-- 
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how to couper contenier of a canvas in an outer canvas???

2013-03-14 Thread Chris Angelico
On Fri, Mar 15, 2013 at 12:07 PM, alex23  wrote:
> On Mar 15, 8:24 am, Rick Johnson  wrote:
>> Hmm, well before i can even start solving your problem, i'll need to
>> spend some time figuring out what the hell you're problem is. o_O.
>> "Maybe" you meant to say this:
>>
>> > how to [copy] all the [canvas items] in [one] canvas [into another] canvas?
>>
>>  "Ahhh, the sweet nectar of articulate communication!"
>
> Mocking people for whom English is obviously not their first language
> just makes you look petty and racist.

Yes, but there is legitimate criticism for a post that clearly hasn't
had much work put into it. I'm not 100% convinced that English isn't
the OP's first language (it seems plausible, even likely, but far from
certain), but I'm confident that the OP did not spend a few minutes
polishing the post before hitting Send (or Expedier, or Versenden, or
whatever the button says). Now, that doesn't mean it's polite or
useful to *mock* the person for it, but it is at least a legit
complaint.

ChrisA
-- 
http://mail.python.org/mailman/listinfo/python-list